// Display-style insets should always be on a centered row
if (Inset const * inset = par.getInset(row.pos())) {
- if (inset->display() & Inset::Display) {
- if (inset->display() & Inset::AlignLeft)
- align = LYX_ALIGN_BLOCK;
- else if (inset->display() & Inset::AlignRight)
- align = LYX_ALIGN_RIGHT;
- else
- align = LYX_ALIGN_CENTER;
+ switch (inset->display()) {
+ case Inset::AlignLeft:
+ align = LYX_ALIGN_BLOCK;
+ break;
+ case Inset::AlignCenter:
+ align = LYX_ALIGN_CENTER;
+ break;
+ case Inset::Inline:
+ // unchanged (use align)
+ break;
+ case Inset::AlignRight:
+ align = LYX_ALIGN_RIGHT;
+ break;
}
}
}
// Handle some situations that abruptly terminate the row
- // - Before an inset with BreakBefore
- // - After an inset with BreakAfter
- Inset const * prevInset = !row.empty() ? row.back().inset : 0;
- Inset const * nextInset = (i + 1 < end) ? par.getInset(i + 1) : 0;
- if ((nextInset && nextInset->display() & Inset::BreakBefore)
- || (prevInset && prevInset->display() & Inset::BreakAfter)) {
+ // - A newline inset
+ // - Before a display inset
+ // - After a display inset
+ Inset const * inset = 0;
+ if (par.isNewline(i) || par.isEnvSeparator(i)
+ || (i + 1 < end && (inset = par.getInset(i + 1))
+ && inset->display())
+ || (!row.empty() && row.back().inset
+ && row.back().inset->display())) {
row.flushed(true);
need_new_row = par.isNewline(i);
++i;
// display style insets are always centered, omit indentation
&& !(!par.empty()
&& par.isInset(pos)
- && par.getInset(pos)->display() & Inset::Display)
+ && par.getInset(pos)->display())
&& (!(tclass.isDefaultLayout(par.layout())
|| tclass.isPlainLayout(par.layout()))
|| buffer.params().paragraph_separation
/// does this inset try to use all available space (like \\hfill does)?
virtual bool isHfill() const { return false; }
- // Describe how the inset should be typeset
enum DisplayType {
Inline = 0,
- // break row before this inset
- BreakBefore = 1,
- // break row after this inset
- BreakAfter = 2,
- // optionally break row after this inset (not used yet)
- CanBreakAfter = 4,
- // specify an alignment (left, right) for a display inset (default is center)
- AlignLeft = 8,
- AlignRight = 16,
- // do not allow cursor to go at the end of the row before
- // a display inset (not used yet)
- NoBoundary = 32,
- // A display inset breaks row at both ends
- Display = BreakBefore | BreakAfter
+ AlignLeft,
+ AlignCenter,
+ AlignRight
};
- /// How should this inset be typeset?
+ /// should we have a non-filled line before this inset?
virtual DisplayType display() const { return Inline; }
/// indentation before this inset (only needed for displayed hull insets with fleqn option)
virtual int indent(BufferView const &) const { return 0; }
Buffer * buffer_;
};
-
-inline Inset::DisplayType operator|(Inset::DisplayType const d1,
- Inset::DisplayType const d2)
-{
- return static_cast<Inset::DisplayType>(int(d1) | int(d2));
-}
-
-
-inline Inset::DisplayType operator&(Inset::DisplayType const d1,
- Inset::DisplayType const d2)
-{
- return static_cast<Inset::DisplayType>(int(d1) & int(d2));
-}
-
-
} // namespace lyx
#endif
///
InsetCode lyxCode() const { return BIBTEX_CODE; }
///
- DisplayType display() const { return Display; }
+ DisplayType display() const { return AlignCenter; }
///
void latex(otexstream &, OutputParams const &) const;
///
///
void metrics(MetricsInfo &, Dimension &) const;
///
+ DisplayType display() const { return Inline; }
+ ///
ColorCode backgroundColor(PainterInfo const &) const;
///
LyXAlignment contentAlignment() const;
///
void write(std::ostream & os) const;
///
- DisplayType display() const { return Display; }
+ DisplayType display() const { return AlignCenter; }
///
bool neverIndent() const { return true; }
///
///
InsetCode lyxCode() const { return FLOAT_LIST_CODE; }
///
- DisplayType display() const { return Display; }
+ DisplayType display() const { return AlignCenter; }
///
void write(std::ostream &) const;
///
Inset::DisplayType InsetInclude::display() const
{
- return type(params()) == INPUT ? Inline : Display;
+ return type(params()) == INPUT ? Inline : AlignCenter;
}
///
bool hasSettings() const;
///
- DisplayType display() const { return Display; }
+ DisplayType display() const { return AlignCenter; }
//@}
/// \name Static public methods obligated for InsetCommand derived classes
Inset::DisplayType InsetListings::display() const
{
- return params().isInline() || params().isFloat() ? Inline : Display | AlignLeft;
+ return params().isInline() || params().isFloat() ? Inline : AlignLeft;
}
InsetNewline(InsetNewlineParams par) : Inset(0)
{ params_.kind = par.kind; }
///
- DisplayType display() const { return BreakAfter | NoBoundary; }
- ///
static void string2params(std::string const &, InsetNewlineParams &);
///
static std::string params2string(InsetNewlineParams const &);
///
void write(std::ostream & os) const;
///
- DisplayType display() const { return Display; }
+ DisplayType display() const { return AlignCenter; }
///
docstring insetLabel() const;
///
///
bool hasSettings() const { return true; }
///
- DisplayType display() const { return Display; }
+ DisplayType display() const { return AlignCenter; }
///
void latex(otexstream &, OutputParams const &) const;
///
}
+Inset::DisplayType InsetNote::display() const
+{
+ return Inline;
+}
+
+
void InsetNote::write(ostream & os) const
{
params_.write(os);
InsetCode lyxCode() const { return NOTE_CODE; }
///
docstring layoutName() const;
+ ///
+ DisplayType display() const;
/** returns false if, when outputing LaTeX, font changes should
be closed before generating this inset. This is needed for
insets that may contain several paragraphs */
docstring toolTip(BufferView const &, int, int) const
{ return tooltip_; }
///
- docstring getTOCString() const;
+ docstring getTOCString() const;
///
bool hasSettings() const { return true; }
///
InsetCode lyxCode() const { return REF_CODE; }
///
+ DisplayType display() const { return Inline; }
+ ///
void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstringstream & ods, OutputParams const & op,
}
+Inset::DisplayType InsetScript::display() const
+{
+ return Inline;
+}
+
+
void InsetScript::metrics(MetricsInfo & mi, Dimension & dim) const
{
int const shift = params_.shift(mi.base.font);
///
docstring layoutName() const;
///
+ DisplayType display() const;
+ ///
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
// remove warning
return docstring();
}
- ///
- DisplayType display() const { return BreakAfter | NoBoundary; }
private:
///
InsetSeparatorParams params() const { return params_; }
///
docstring layoutName() const;
///
- DisplayType display() const { return Display; }
+ DisplayType display() const { return AlignCenter; }
///
virtual void validate(LaTeXFeatures &) const;
///
if (tabular.is_long_tabular) {
switch (tabular.longtabular_alignment) {
case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
- return Display | AlignLeft;
+ return AlignLeft;
case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
- return Display;
+ return AlignCenter;
case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
- return Display | AlignRight;
+ return AlignRight;
default:
- return Display;
+ return AlignCenter;
}
} else
return Inline;
///
void write(std::ostream & os) const;
///
- DisplayType display() const { return Display; }
+ DisplayType display() const { return AlignCenter; }
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///
// insert a gap in front of the formula
// value was hardcoded to 1 pixel
dim.wid += mi.base.bv->zoomedPixels(1) ;
- if (display() != Inline) {
+ if (display()) {
dim.asc += display_margin;
dim.des += display_margin;
}
}
Changer dummy1 = mi.base.changeFontSet(standardFont());
- Changer dummy2 = mi.base.font.changeStyle(display() != Inline ? LM_ST_DISPLAY
+ Changer dummy2 = mi.base.font.changeStyle(display() ? LM_ST_DISPLAY
: LM_ST_TEXT);
// let the cells adjust themselves
InsetMathGrid::metrics(mi, dim);
- if (display() != Inline) {
+ if (display()) {
dim.asc += display_margin;
dim.des += display_margin;
}
Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
: Changer();
Changer dummy1 = pi.base.changeFontSet(standardFont());
- Changer dummy2 = pi.base.font.changeStyle(display() != Inline ? LM_ST_DISPLAY
+ Changer dummy2 = pi.base.font.changeStyle(display() ? LM_ST_DISPLAY
: LM_ST_TEXT);
int xmath = x;
void InsetMathHull::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
{
- if (display() != Inline) {
+ if (display()) {
InsetMathGrid::metricsT(mi, dim);
} else {
odocstringstream os;
void InsetMathHull::drawT(TextPainter & pain, int x, int y) const
{
- if (display() != Inline) {
+ if (display()) {
InsetMathGrid::drawT(pain, x, y);
} else {
odocstringstream os;
case hullMultline:
case hullGather:
if (buffer().params().is_math_indent)
- return Display | AlignLeft;
+ return AlignLeft;
else
- return Display;
+ return AlignCenter;
}
// avoid warning
- return Display;
+ return AlignCenter;
}
OutputParams const & op, size_t max_length) const
{
// Try enabling this now that there is a flag as requested at #2275.
- if (buffer().isExporting() && display() != Inline) {
+ if (buffer().isExporting() && display()) {
Dimension dim;
TextMetricsInfo mi;
metricsT(mi, dim);