InsetListings: change the interface of diaplay function and allow AlignLeft. Applied to InsetListings. Fixes bug 3617, 3618

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18404 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bo Peng 2007-05-18 14:32:29 +00:00
parent 4bf2660863
commit 73849af5df
21 changed files with 44 additions and 28 deletions

View File

@ -323,10 +323,17 @@ RowMetrics TextMetrics::computeRowMetrics(pit_type const pit,
// would trigger the assert in Paragraph::getInset().
//inset = par.size() ? par.getInset(row.pos()) : 0;
if (!par.empty()
&& par.isInset(row.pos())
&& par.getInset(row.pos())->display())
&& par.isInset(row.pos()))
{
align = LYX_ALIGN_CENTER;
switch(par.getInset(row.pos())->display()) {
case Inset::AlignLeft:
align = LYX_ALIGN_BLOCK;
break;
case Inset::AlignCenter:
align = LYX_ALIGN_CENTER;
break;
// other types unchanged (use align)
}
}
switch (align) {

View File

@ -377,8 +377,16 @@ public:
/// is this equivalent to a space (which is BTW different from
/// a line separator)?
virtual bool isSpace() const { return false; }
enum DisplayType {
Inline = 0,
AlignLeft,
AlignCenter,
AlignRight
};
/// should we have a non-filled line before this inset?
virtual bool display() const { return false; }
virtual DisplayType display() const { return Inline; }
/// should we break lines after this inset?
virtual bool isLineSeparator() const { return false; }
/// should paragraph indendation be ommitted in any case?

View File

@ -34,7 +34,7 @@ public:
///
Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; }
///
bool display() const { return true; }
DisplayType display() const { return AlignCenter; }
///
int latex(Buffer const &, odocstream &, OutputParams const &) const;
///

View File

@ -76,7 +76,7 @@ public:
/// show the Box dialog
bool showInsetDialog(BufferView * bv) const;
///
bool display() const { return false; }
DisplayType display() const { return Inline; }
///
bool forceDefaultParagraphs(idx_type) const;
///

View File

@ -32,7 +32,7 @@ public:
///
void read(Buffer const & buf, Lexer & lex);
///
virtual bool display() const;
virtual DisplayType display() const;
///
virtual bool neverIndent(Buffer const &) const { return true; }
///
@ -109,9 +109,9 @@ private:
inline
bool InsetCaption::display() const
Inset::DisplayType InsetCaption::display() const
{
return true;
return AlignCenter;
}

View File

@ -33,7 +33,7 @@ public:
///
Inset::Code lyxCode() const;
///
bool display() const { return true; }
DisplayType display() const { return AlignCenter; }
///
void write(Buffer const &, std::ostream &) const;
///

View File

@ -729,9 +729,10 @@ void InsetInclude::draw(PainterInfo & pi, int x, int y) const
button_.draw(pi, x, y);
}
bool InsetInclude::display() const
Inset::DisplayType InsetInclude::display() const
{
return type(params_) != INPUT;
return type(params_) == INPUT ? Inline : AlignCenter;
}

View File

@ -41,7 +41,7 @@ public:
///
void draw(PainterInfo & pi, int x, int y) const;
///
virtual bool display() const;
virtual DisplayType display() const;
/// get the parameters
InsetCommandParams const & params() const;

View File

@ -53,7 +53,7 @@ public:
///
Inset::Code lyxCode() const;
///
bool display() const { return true; }
DisplayType display() const { return AlignCenter; }
///
docstring const getScreenLabel(Buffer const &) const;
private:

View File

@ -44,7 +44,7 @@ public:
/// We don't need \begin_inset and \end_inset
bool directWrite() const { return true; }
bool display() const { return true; }
DisplayType display() const { return AlignCenter; }
///
void validate(LaTeXFeatures & features) const;
private:

View File

@ -79,9 +79,9 @@ InsetListings::~InsetListings()
}
bool InsetListings::display() const
Inset::DisplayType InsetListings::display() const
{
return !params().isInline();
return params().isInline() ? Inline : AlignLeft;
}

View File

@ -33,7 +33,7 @@ public:
///
Inset::Code lyxCode() const { return Inset::LISTINGS_CODE; }
/// lstinline is inlined, normal listing is displayed
virtual bool display() const;
virtual DisplayType display() const;
///
docstring name() const { return from_ascii("Listings"); }
///

View File

@ -67,7 +67,7 @@ public:
///
Inset::Code lyxCode() const;
///
bool display() const { return true; }
DisplayType display() const { return AlignCenter; }
///
docstring const getScreenLabel(Buffer const &) const;
private:

View File

@ -44,7 +44,7 @@ public:
/// We don't need \begin_inset and \end_inset
bool directWrite() const { return true; }
bool display() const { return true; }
DisplayType display() const { return AlignCenter; }
virtual docstring insetLabel() const { return _("Page Break"); }

View File

@ -45,7 +45,7 @@ public:
///
Code lyxCode() const { return REF_CODE; }
///
bool display() const { return false; }
DisplayType display() const { return Inline; }
///
int latex(Buffer const &, odocstream &, OutputParams const &) const;
///

View File

@ -30,7 +30,7 @@ public:
///
Inset::Code lyxCode() const;
///
bool display() const { return true; }
DisplayType display() const { return AlignCenter; }
///
int plaintext(Buffer const &, odocstream &,
OutputParams const &) const;

View File

@ -697,7 +697,7 @@ public:
insets that may contain several paragraphs */
bool noFontChange() const { return true; }
///
bool display() const { return tabular.isLongTabular(); }
DisplayType display() const { return tabular.isLongTabular() ? AlignCenter : Inline; }
///
int latex(Buffer const &, odocstream &,
OutputParams const &) const;

View File

@ -36,7 +36,7 @@ public:
///
EDITABLE editable() const { return IS_EDITABLE; }
///
bool display() const { return false; }
DisplayType display() const { return Inline; }
///
int latex(Buffer const &, odocstream &,
OutputParams const &) const;

View File

@ -46,7 +46,7 @@ public:
///
void write(Buffer const & buf, std::ostream & os) const;
///
bool display() const { return true; }
DisplayType display() const { return AlignCenter; }
/// How much?
VSpace const & space() const { return space_; }

View File

@ -471,9 +471,9 @@ bool InsetMathHull::ams() const
}
bool InsetMathHull::display() const
Inset::DisplayType InsetMathHull::display() const
{
return type_ != hullSimple && type_ != hullNone;
return (type_ != hullSimple && type_ != hullNone) ? AlignCenter : Inline;
}

View File

@ -200,7 +200,7 @@ public:
///
Inset * editXY(Cursor & cur, int x, int y);
///
bool display() const;
DisplayType display() const;
///
Code lyxCode() const;