diff --git a/src/ChangeLog b/src/ChangeLog index 65de4190cc..feac458abe 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2003-05-28 André Pönitz + + * metricsinfo.[Ch]: remove 'fullredraw' member + 2003-05-28 Lars Gullik Bjřnnes * lyxtextclass.C (operator): remove caching. diff --git a/src/dimension.h b/src/dimension.h index 2b732584ff..67d63b9e21 100644 --- a/src/dimension.h +++ b/src/dimension.h @@ -40,6 +40,11 @@ public: /// get width int width() const { return wid; } + /// add space for a frame + //void addFrame(int frame) const; + /// add space for bottom part of a frame + //void addFrameBottom(int frame) const; + public: /// these are intentionally public as things like /// diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 71ffdd4742..9092e1304f 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,5 +1,9 @@ -2003-05-23 André Pönitz +2003-05-28 André Pönitz + + * *.[Ch]: prepare unified two-stage drawing + +2003-05-27 André Pönitz * *.C: dim.w -> dim.wid etc diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index a490bbdc81..4bae5b7ccc 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -151,10 +151,6 @@ libmathed_la_SOURCES = \ math_undersetinset.h \ math_xarrowinset.C \ math_xarrowinset.h \ - math_xyarrowinset.C \ - math_xyarrowinset.h \ - math_xymatrixinset.C \ - math_xymatrixinset.h \ button_inset.C \ button_inset.h \ command_inset.h \ diff --git a/src/mathed/button_inset.C b/src/mathed/button_inset.C index e7d81e14a0..0784850ac1 100644 --- a/src/mathed/button_inset.C +++ b/src/mathed/button_inset.C @@ -16,7 +16,7 @@ ButtonInset::ButtonInset() {} -void ButtonInset::metrics(MetricsInfo & mi) const +Dimension ButtonInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy(mi.base, "textnormal"); if (editing()) { @@ -28,6 +28,7 @@ void ButtonInset::metrics(MetricsInfo & mi) const mathed_string_dim(mi.base.font, screenLabel(), dim_); dim_.wid += 10; } + return dim_; } @@ -37,7 +38,9 @@ void ButtonInset::draw(PainterInfo & pi, int x, int y) const if (editing()) { cell(0).draw(pi, x, y); cell(1).draw(pi, x + cell(0).width() + 2, y); - mathed_draw_framebox(pi, x, y, this); + //if (mathcursor && mathcursor->isInside(p)) + pi.pain.rectangle(x, y - dim_.ascent(), dim_.width(), dim_.height(), + LColor::mathframe); } else { pi.pain.buttonText(x + 2, y, screenLabel(), pi.base.font); } diff --git a/src/mathed/button_inset.h b/src/mathed/button_inset.h index 0b1160b66e..31e534450a 100644 --- a/src/mathed/button_inset.h +++ b/src/mathed/button_inset.h @@ -23,7 +23,7 @@ public: /// ButtonInset(); /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 0065c5d257..5b1c8cc997 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -13,7 +13,6 @@ * the GNU General Public Licence version 2 or later. */ - #include #include "formula.h" @@ -146,10 +145,11 @@ int InsetFormula::latex(Buffer const *, ostream & os, int InsetFormula::ascii(Buffer const *, ostream & os, int) const { if (0 && display()) { + Dimension dim; TextMetricsInfo mi; - par()->metricsT(mi); - TextPainter tpain(par()->width(), par()->height()); - par()->drawT(tpain, 0, par()->ascent()); + par()->metricsT(mi, dim); + TextPainter tpain(dim.width(), dim.height()); + par()->drawT(tpain, 0, dim.ascent()); tpain.show(os, 3); // reset metrics cache to "real" values metrics(); @@ -226,7 +226,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font, int const a = ascent(bv, font); int const h = a + d; - PainterInfo pi(bv->painter()); + PainterInfo pi(bv); if (use_preview) { pi.pain.image(x + 1, y - a, w, h, // one pixel gap in front @@ -287,7 +287,7 @@ bool InsetFormula::insetAllowed(Inset::Code code) const void InsetFormula::dimension(BufferView * bv, LyXFont const & font, Dimension & dim) const { - metrics(bv, font); + metrics(bv, font, dim); if (preview_->previewReady()) { dim.asc = preview_->pimage()->ascent(); int const descent = preview_->pimage()->descent(); @@ -295,7 +295,9 @@ void InsetFormula::dimension(BufferView * bv, LyXFont const & font, // insert a one pixel gap in front of the formula dim.wid = 1 + preview_->pimage()->width(); } else { - dim = par_->dimensions(); + MetricsInfo mi; + mi.base.bv = bv; + dim = par()->metrics(mi); dim.asc += 1; dim.des += 1; } diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 42c6f32aae..04713ba293 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -141,7 +141,8 @@ void InsetFormulaBase::validate(LaTeXFeatures &) const {} -void InsetFormulaBase::metrics(BufferView * bv, LyXFont const & f) const +void InsetFormulaBase::metrics(BufferView * bv, LyXFont const & f, + Dimension & dim) const { font_ = f; metrics(bv); @@ -153,6 +154,7 @@ void InsetFormulaBase::metrics(BufferView * bv) const if (bv) view_ = bv->owner()->view(); MetricsInfo mi; + mi.base.bv = bv; mi.base.style = LM_ST_TEXT; mi.base.font = font_; mi.base.font.setColor(LColor::math); @@ -348,6 +350,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) switch (cmd.action) { case LFUN_INSET_EDIT: + lyxerr << "Called EDIT with '" << cmd.argument << "'\n"; if (!bv->lockInset(this)) lyxerr << "Cannot lock math inset in edit call!\n"; releaseMathCursor(bv); diff --git a/src/mathed/formulabase.h b/src/mathed/formulabase.h index 399811b963..e6826e34be 100644 --- a/src/mathed/formulabase.h +++ b/src/mathed/formulabase.h @@ -118,7 +118,7 @@ protected: protected: /// - void metrics(BufferView * bv, LyXFont const & font) const; + void metrics(BufferView * bv, LyXFont const & font, Dimension & dim) const; /// void metrics(BufferView * bv = 0) const; /// diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index c8b96229f7..d75a398617 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -13,7 +13,6 @@ #include - #include "formulamacro.h" #include "lfuns.h" #include "math_cursor.h" @@ -144,8 +143,10 @@ string InsetFormulaMacro::prefix() const void InsetFormulaMacro::dimension(BufferView * bv, LyXFont const & font, Dimension & dim) const { - metrics(bv, font); - dim = par()->dimensions(); + MetricsInfo mi; + mi.base.bv = bv; + mi.base.font = font; + dim = par()->metrics(mi); dim.asc += 5; dim.des += 5; dim.wid += 10 + font_metrics::width(prefix(), font); @@ -177,7 +178,7 @@ void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f, LyXFont font(f); font.setColor(LColor::math); - PainterInfo pi = PainterInfo(bv->painter()); + PainterInfo pi(bv); pi.base.style = LM_ST_TEXT; pi.base.font = font; diff --git a/src/mathed/math_amsarrayinset.C b/src/mathed/math_amsarrayinset.C index 16ab3802e7..bfb6f2032c 100644 --- a/src/mathed/math_amsarrayinset.C +++ b/src/mathed/math_amsarrayinset.C @@ -57,22 +57,23 @@ char const * MathAMSArrayInset::name_right() const } -void MathAMSArrayInset::metrics(MetricsInfo & mi) const +Dimension MathAMSArrayInset::metrics(MetricsInfo & mi) const { MetricsInfo m = mi; if (m.base.style == LM_ST_DISPLAY) m.base.style = LM_ST_TEXT; MathGridInset::metrics(m); dim_.wid += 12; + return dim_; } void MathAMSArrayInset::draw(PainterInfo & pi, int x, int y) const { MathGridInset::draw(pi, x + 6, y); - int const yy = y - ascent(); - mathed_draw_deco(pi, x + 1, yy, 5, height(), name_left()); - mathed_draw_deco(pi, x + width() - 6, yy, 5, height(), name_right()); + int const yy = y - dim_.ascent(); + mathed_draw_deco(pi, x + 1, yy, 5, dim_.height(), name_left()); + mathed_draw_deco(pi, x + dim_.width() - 6, yy, 5, dim_.height(), name_right()); } diff --git a/src/mathed/math_amsarrayinset.h b/src/mathed/math_amsarrayinset.h index aac377e508..47332517e6 100644 --- a/src/mathed/math_amsarrayinset.h +++ b/src/mathed/math_amsarrayinset.h @@ -22,7 +22,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pain, int x, int y) const; /// diff --git a/src/mathed/math_arrayinset.C b/src/mathed/math_arrayinset.C index e130f43d17..9ccd154006 100644 --- a/src/mathed/math_arrayinset.C +++ b/src/mathed/math_arrayinset.C @@ -37,10 +37,10 @@ MathArrayInset::MathArrayInset(string const & name, string const & str) : MathGridInset(1, 1), name_(name) { vector< vector > dat; - istringstream is(str.c_str()); + istringstream is(STRCONV(str)); string line; while (getline(is, line)) { - istringstream ls(line.c_str()); + istringstream ls(STRCONV(line)); typedef istream_iterator iter; vector v = vector(iter(ls), iter()); if (v.size()) @@ -63,18 +63,19 @@ MathInset * MathArrayInset::clone() const } -void MathArrayInset::metrics(MetricsInfo & mi) const +Dimension MathArrayInset::metrics(MetricsInfo & mi) const { ArrayChanger dummy(mi.base); MathGridInset::metrics(mi); metricsMarkers2(); + return dim_; } void MathArrayInset::draw(PainterInfo & pi, int x, int y) const { ArrayChanger dummy(pi.base); - MathGridInset::draw(pi, x, y); + MathGridInset::draw(pi, x + 1, y); drawMarkers2(pi, x, y); } diff --git a/src/mathed/math_arrayinset.h b/src/mathed/math_arrayinset.h index 3ddc83cfda..05e77e9139 100644 --- a/src/mathed/math_arrayinset.h +++ b/src/mathed/math_arrayinset.h @@ -27,7 +27,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_atom.h b/src/mathed/math_atom.h index 215f102f0f..c251cdc1a2 100644 --- a/src/mathed/math_atom.h +++ b/src/mathed/math_atom.h @@ -55,6 +55,9 @@ public: /// access to the inset MathInset const * operator->() const { return nucleus_; } + /// width cache. Not nice... + mutable int width_; + private: /// MathInset * nucleus_; diff --git a/src/mathed/math_biginset.C b/src/mathed/math_biginset.C index 5c02ff8207..0824bfbb66 100644 --- a/src/mathed/math_biginset.C +++ b/src/mathed/math_biginset.C @@ -32,23 +32,23 @@ double MathBigInset::increase() const case 3: return 0.7; default: return 0.0; } - return 0.0; } -void MathBigInset::metrics(MetricsInfo & mi) const +Dimension MathBigInset::metrics(MetricsInfo & mi) const { double const h = mathed_char_ascent(mi.base.font, 'I'); double const f = increase(); dim_.wid = 6; dim_.asc = int(h + f * h); dim_.des = int(f * h); + return dim_; } void MathBigInset::draw(PainterInfo & pi, int x, int y) const { - mathed_draw_deco(pi, x + 1, y - ascent(), 4, height(), delim_); + mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 4, dim_.height(), delim_); } diff --git a/src/mathed/math_biginset.h b/src/mathed/math_biginset.h index 554429e453..fb5e99bcb8 100644 --- a/src/mathed/math_biginset.h +++ b/src/mathed/math_biginset.h @@ -14,10 +14,10 @@ #ifndef MATH_BIGINSET_H #define MATH_BIGINSET_H - #include "math_diminset.h" #include "LString.h" + /// Inset for \bigl & Co. class MathBigInset : public MathDimInset { public: @@ -26,12 +26,12 @@ public: /// MathInset * clone() const; /// + Dimension metrics(MetricsInfo & mi) const; + /// void draw(PainterInfo & pi, int x, int y) const; /// void write(WriteStream & os) const; /// - void metrics(MetricsInfo & st) const; - /// void normalize(NormalStream & os) const; private: diff --git a/src/mathed/math_binaryopinset.C b/src/mathed/math_binaryopinset.C index 20966ce96e..e09edf5731 100644 --- a/src/mathed/math_binaryopinset.C +++ b/src/mathed/math_binaryopinset.C @@ -28,7 +28,7 @@ int MathBinaryOpInset::opwidth() const } -void MathBinaryOpInset::metrics(MetricsInfo & mi) const +Dimension MathBinaryOpInset::metrics(MetricsInfo & mi) const { mi_ = mi; cell(0).metrics(mi); diff --git a/src/mathed/math_binominset.C b/src/mathed/math_binominset.C index 9bb1e8de15..a240adb6c6 100644 --- a/src/mathed/math_binominset.C +++ b/src/mathed/math_binominset.C @@ -1,6 +1,5 @@ #include - #include "math_binominset.h" #include "math_support.h" #include "support/LOstream.h" @@ -23,7 +22,7 @@ MathInset * MathBinomInset::clone() const int MathBinomInset::dw() const { - int w = height()/5; + int w = dim_.height() / 5; if (w > 15) w = 15; if (w < 6) @@ -32,7 +31,7 @@ int MathBinomInset::dw() const } -void MathBinomInset::metrics(MetricsInfo & mi) const +Dimension MathBinomInset::metrics(MetricsInfo & mi) const { ScriptChanger dummy(mi.base); cell(0).metrics(mi); @@ -40,17 +39,19 @@ void MathBinomInset::metrics(MetricsInfo & mi) const dim_.asc = cell(0).height() + 4 + 5; dim_.des = cell(1).height() + 4 - 5; dim_.wid = max(cell(0).width(), cell(1).width()) + 2 * dw() + 4; + return dim_; } void MathBinomInset::draw(PainterInfo & pi, int x, int y) const { - int m = x + width() / 2; + int m = x + dim_.width() / 2; ScriptChanger dummy(pi.base); cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 3 - 5); cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 3 - 5); - mathed_draw_deco(pi, x, y - ascent(), dw(), height(), "("); - mathed_draw_deco(pi, x + width() - dw(), y - ascent(), dw(), height(), ")"); + mathed_draw_deco(pi, x, y - dim_.ascent(), dw(), dim_.height(), "("); + mathed_draw_deco(pi, x + dim_.width() - dw(), y - dim_.ascent(), + dw(), dim_.height(), ")"); } diff --git a/src/mathed/math_binominset.h b/src/mathed/math_binominset.h index 9894862a40..58f1534c36 100644 --- a/src/mathed/math_binominset.h +++ b/src/mathed/math_binominset.h @@ -19,7 +19,7 @@ public: /// void normalize(NormalStream &) const; /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; private: diff --git a/src/mathed/math_boxinset.C b/src/mathed/math_boxinset.C index f479ae2470..e57a151e54 100644 --- a/src/mathed/math_boxinset.C +++ b/src/mathed/math_boxinset.C @@ -1,6 +1,5 @@ #include - #include "math_boxinset.h" #include "math_support.h" #include "math_mathmlstream.h" @@ -33,12 +32,12 @@ void MathBoxInset::normalize(NormalStream & os) const } -void MathBoxInset::metrics(MetricsInfo & mi) const +Dimension MathBoxInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy(mi.base, "textnormal"); - cell(0).metrics(mi); - dim_ = cell(0).dim(); - metricsMarkers2(); + cell(0).metrics(mi, dim_); + metricsMarkers(); + return dim_; } @@ -46,7 +45,7 @@ void MathBoxInset::draw(PainterInfo & pi, int x, int y) const { FontSetChanger dummy(pi.base, "textnormal"); cell(0).draw(pi, x, y); - drawMarkers2(pi, x, y); + drawMarkers(pi, x, y); } diff --git a/src/mathed/math_boxinset.h b/src/mathed/math_boxinset.h index 37553b1af6..754d9fd7d2 100644 --- a/src/mathed/math_boxinset.h +++ b/src/mathed/math_boxinset.h @@ -19,7 +19,7 @@ public: /// mode_type currentMode() const { return TEXT_MODE; } /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_braceinset.C b/src/mathed/math_braceinset.C index 69bea7dfcf..524fe4e673 100644 --- a/src/mathed/math_braceinset.C +++ b/src/mathed/math_braceinset.C @@ -1,6 +1,5 @@ #include - #include "math_braceinset.h" #include "math_parser.h" #include "math_support.h" @@ -28,7 +27,7 @@ MathInset * MathBraceInset::clone() const } -void MathBraceInset::metrics(MetricsInfo & mi) const +Dimension MathBraceInset::metrics(MetricsInfo & mi) const { cell(0).metrics(mi); Dimension t; @@ -37,6 +36,7 @@ void MathBraceInset::metrics(MetricsInfo & mi) const dim_.asc = max(cell(0).ascent(), t.asc); dim_.des = max(cell(0).descent(), t.des); dim_.wid = cell(0).width() + 2 * wid_; + return dim_; } @@ -46,7 +46,7 @@ void MathBraceInset::draw(PainterInfo & pi, int x, int y) const font.setColor(LColor::latex); drawChar(pi, font, x, y, '{'); cell(0).draw(pi, x + wid_, y); - drawChar(pi, font, x + width() - wid_, y, '}'); + drawChar(pi, font, x + dim_.width() - wid_, y, '}'); } diff --git a/src/mathed/math_braceinset.h b/src/mathed/math_braceinset.h index 7ba25f3d6a..abc67b1f5b 100644 --- a/src/mathed/math_braceinset.h +++ b/src/mathed/math_braceinset.h @@ -22,7 +22,7 @@ public: /// we write extra braces in any case... bool extraBraces() const { return true; } /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/math_casesinset.C b/src/mathed/math_casesinset.C index bc0f7d370e..ae04d38444 100644 --- a/src/mathed/math_casesinset.C +++ b/src/mathed/math_casesinset.C @@ -20,16 +20,17 @@ MathInset * MathCasesInset::clone() const } -void MathCasesInset::metrics(MetricsInfo & mi) const +Dimension MathCasesInset::metrics(MetricsInfo & mi) const { MathGridInset::metrics(mi); dim_.wid += 8; + return dim_; } void MathCasesInset::draw(PainterInfo & pain, int x, int y) const { - mathed_draw_deco(pain, x + 1, y - ascent(), 6, height(), "{"); + mathed_draw_deco(pain, x + 1, y - dim_.ascent(), 6, dim_.height(), "{"); MathGridInset::draw(pain, x + 8, y); } diff --git a/src/mathed/math_casesinset.h b/src/mathed/math_casesinset.h index 93398d104b..6349656fea 100644 --- a/src/mathed/math_casesinset.h +++ b/src/mathed/math_casesinset.h @@ -14,7 +14,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pain, int x, int y) const; diff --git a/src/mathed/math_charinset.C b/src/mathed/math_charinset.C index f5192cb4a9..827aa7f7ad 100644 --- a/src/mathed/math_charinset.C +++ b/src/mathed/math_charinset.C @@ -1,6 +1,5 @@ #include - #include "math_charinset.h" #include "LColor.h" #include "frontends/Painter.h" @@ -55,33 +54,35 @@ MathInset * MathCharInset::clone() const } -void MathCharInset::metrics(MetricsInfo & mi) const +Dimension MathCharInset::metrics(MetricsInfo & mi) const { + Dimension dim; #if 1 if (char_ == '=' && has_math_fonts) { FontSetChanger dummy(mi.base, "cmr"); - mathed_char_dim(mi.base.font, char_, dim_); + mathed_char_dim(mi.base.font, char_, dim); } else if ((char_ == '>' || char_ == '<') && has_math_fonts) { FontSetChanger dummy(mi.base, "cmm"); - mathed_char_dim(mi.base.font, char_, dim_); + mathed_char_dim(mi.base.font, char_, dim); } else if (slanted(char_) && mi.base.fontname == "mathnormal") { ShapeChanger dummy(mi.base.font, LyXFont::ITALIC_SHAPE); - mathed_char_dim(mi.base.font, char_, dim_); + mathed_char_dim(mi.base.font, char_, dim); } else { - mathed_char_dim(mi.base.font, char_, dim_); + mathed_char_dim(mi.base.font, char_, dim); } int const em = mathed_char_width(mi.base.font, 'M'); if (isBinaryOp(char_)) - dim_.wid += static_cast(0.5*em+0.5); + dim.wid += static_cast(0.5*em+0.5); else if (char_ == '\'') - dim_.wid += static_cast(0.1667*em+0.5); + dim.wid += static_cast(0.1667*em+0.5); #else whichFont(font_, code_, mi); mathed_char_dim(font_, char_, dim_); if (isBinaryOp(char_, code_)) width_ += 2 * font_metrics::width(' ', font_); - lyxerr << "MathCharInset::metrics: " << dim_ << "\n"; + lyxerr << "MathCharInset::metrics: " << dim << "\n"; #endif + return dim; } @@ -112,11 +113,11 @@ void MathCharInset::draw(PainterInfo & pi, int x, int y) const } -void MathCharInset::metricsT(TextMetricsInfo const &) const +void MathCharInset::metricsT(TextMetricsInfo const &, Dimension & dim) const { - dim_.wid = 1; - dim_.asc = 1; - dim_.des = 0; + dim.wid = 1; + dim.asc = 1; + dim.des = 0; } diff --git a/src/mathed/math_charinset.h b/src/mathed/math_charinset.h index 1f9fa26ccf..a98044cff2 100644 --- a/src/mathed/math_charinset.h +++ b/src/mathed/math_charinset.h @@ -2,7 +2,7 @@ #ifndef MATH_CHARINSET_H #define MATH_CHARINSET_H -#include "math_diminset.h" +#include "math_inset.h" /** The base character inset. @@ -11,18 +11,18 @@ * Full author contact details are available in file CREDITS */ -class MathCharInset : public MathDimInset { +class MathCharInset : public MathInset { public: /// explicit MathCharInset(char c); /// MathInset * clone() const; /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// - void draw(PainterInfo &, int x, int y) const; + void draw(PainterInfo & pi, int x, int y) const; /// - void metricsT(TextMetricsInfo const & st) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// void drawT(TextPainter &, int x, int y) const; /// diff --git a/src/mathed/math_commentinset.C b/src/mathed/math_commentinset.C index 047b6ea166..7c7400e3a1 100644 --- a/src/mathed/math_commentinset.C +++ b/src/mathed/math_commentinset.C @@ -27,10 +27,11 @@ MathInset * MathCommentInset::clone() const } -void MathCommentInset::metrics(MetricsInfo & mi) const +Dimension MathCommentInset::metrics(MetricsInfo & mi) const { - dim_ = cell(0).metrics(mi); + cell(0).metrics(mi); metricsMarkers(); + return dim_; } @@ -41,9 +42,9 @@ void MathCommentInset::draw(PainterInfo & pi, int x, int y) const } -void MathCommentInset::metricsT(TextMetricsInfo const & mi) const +void MathCommentInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const { - dim_ = cell(0).metricsT(mi); + cell(0).metricsT(mi, dim); } diff --git a/src/mathed/math_commentinset.h b/src/mathed/math_commentinset.h index bb2619dd7c..04b117ea95 100644 --- a/src/mathed/math_commentinset.h +++ b/src/mathed/math_commentinset.h @@ -22,11 +22,11 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// - void metricsT(TextMetricsInfo const & mi) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// void drawT(TextPainter & pi, int x, int y) const; diff --git a/src/mathed/math_data.C b/src/mathed/math_data.C index 119313692e..de0588783a 100644 --- a/src/mathed/math_data.C +++ b/src/mathed/math_data.C @@ -1,6 +1,5 @@ #include - #include "math_data.h" #include "math_inset.h" #include "math_cursor.h" @@ -22,7 +21,6 @@ using std::min; using std::abs; - MathArray::MathArray() : xo_(0), yo_(0), clean_(false), drawn_(false) {} @@ -204,7 +202,14 @@ void MathArray::touch() const } -Dimension const & MathArray::metrics(MetricsInfo & mi) const +void MathArray::metrics(MetricsInfo & mi, Dimension & dim) const +{ + metrics(mi); + dim = dim_; +} + + +void MathArray::metrics(MetricsInfo & mi) const { //if (clean_) // return; @@ -212,15 +217,15 @@ Dimension const & MathArray::metrics(MetricsInfo & mi) const drawn_ = false; mathed_char_dim(mi.base.font, 'I', dim_); - if (empty()) - return dim_; - dim_.wid = 0; - for (const_iterator it = begin(), et = end(); it != et; ++it) { - (*it)->metrics(mi); - dim_ += (*it)->dimensions(); + if (!empty()) { + dim_.wid = 0; + for (const_iterator it = begin(), et = end(); it != et; ++it) { + Dimension d = (*it)->metrics(mi); + dim_ += d; + it->width_ = d.wid; + } } - return dim_; } @@ -249,22 +254,23 @@ void MathArray::draw(PainterInfo & pi, int x, int y) const } for (const_iterator it = begin(), et = end(); it != et; ++it) { + pi.width = it->width_; (*it)->draw(pi, x, y); - x += (*it)->width(); + x += it->width_; } } -Dimension const & MathArray::metricsT(TextMetricsInfo const & mi) const +void MathArray::metricsT(TextMetricsInfo const & mi, Dimension & dim) const { //if (clean_) // return; - dim_.clear(); + dim.clear(); + Dimension d; for (const_iterator it = begin(); it != end(); ++it) { - (*it)->metricsT(mi); - dim_ += (*it)->dimensions(); + (*it)->metricsT(mi, d); + dim += d; } - return dim_; } @@ -279,7 +285,7 @@ void MathArray::drawT(TextPainter & pain, int x, int y) const for (const_iterator it = begin(), et = end(); it != et; ++it) { (*it)->drawT(pain, x, y); - x += (*it)->width(); + x += it->width_; } } @@ -298,7 +304,7 @@ int MathArray::pos2x(size_type pos, int glue) const const_iterator it = begin() + i; if ((*it)->getChar() == ' ') x += glue; - x += (*it)->width(); + x += it->width_; } return x; } @@ -319,7 +325,7 @@ MathArray::size_type MathArray::x2pos(int targetx, int glue) const lastx = currx; if ((*it)->getChar() == ' ') currx += glue; - currx += (*it)->width(); + currx += it->width_; } if (abs(lastx - targetx) < abs(currx - targetx) && it != begin()) --it; diff --git a/src/mathed/math_data.h b/src/mathed/math_data.h index 1d6728126a..6d166f23c4 100644 --- a/src/mathed/math_data.h +++ b/src/mathed/math_data.h @@ -32,8 +32,6 @@ class TextMetricsInfo; class TextPainter; - - class MathArray : private std::vector { public: /// re-use inhertited stuff @@ -105,11 +103,13 @@ public: /// checked read access MathAtom const & operator[](pos_type) const; /// rebuild cached metrics information - Dimension const & metrics(MetricsInfo & mi) const; + void metrics(MetricsInfo & mi) const; + /// rebuild cached metrics information + void metrics(MetricsInfo & mi, Dimension & dim) const; /// redraw cell using cache metrics information void draw(PainterInfo & pi, int x, int y) const; /// rebuild cached metrics information - Dimension const & metricsT(TextMetricsInfo const & mi) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// redraw cell using cache metrics information void drawT(TextPainter & pi, int x, int y) const; /// mark cell for re-drawing @@ -146,7 +146,7 @@ public: /// width of this cell int width() const { return dim_.wid; } /// dimensions of cell - Dimension const & dim() const { return dim_; } + Dimension const & dim() const { return dim_; } /// dimensions of cell void setDim(Dimension const & d) const { dim_ = d; } /// bounding box of this cell diff --git a/src/mathed/math_decorationinset.C b/src/mathed/math_decorationinset.C index 64078471aa..f685706e34 100644 --- a/src/mathed/math_decorationinset.C +++ b/src/mathed/math_decorationinset.C @@ -72,10 +72,11 @@ bool MathDecorationInset::wide() const } -void MathDecorationInset::metrics(MetricsInfo & mi) const +Dimension MathDecorationInset::metrics(MetricsInfo & mi) const { cell(0).metrics(mi); dim_ = cell(0).dim(); + dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_); dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x'); @@ -88,6 +89,7 @@ void MathDecorationInset::metrics(MetricsInfo & mi) const } metricsMarkers(); + return dim_; } @@ -95,9 +97,10 @@ void MathDecorationInset::draw(PainterInfo & pi, int x, int y) const { cell(0).draw(pi, x + 1, y); if (wide()) - mathed_draw_deco(pi, x + 1, y + dy_, width(), dh_, key_->name); + mathed_draw_deco(pi, x + 1, y + dy_, pi.width, dh_, key_->name); else - mathed_draw_deco(pi, x + 1 + (width() - dw_) / 2, y + dy_, dw_, dh_, key_->name); + mathed_draw_deco(pi, x + 1 + (pi.width - dw_) / 2, + y + dy_, dw_, dh_, key_->name); drawMarkers(pi, x, y); } diff --git a/src/mathed/math_decorationinset.h b/src/mathed/math_decorationinset.h index 09c50d58d3..d6783e7c56 100644 --- a/src/mathed/math_decorationinset.h +++ b/src/mathed/math_decorationinset.h @@ -25,7 +25,7 @@ public: /// void write(WriteStream & os) const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void normalize(NormalStream & os) const; /// diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index 82b58813cf..53f10ff11b 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -1,6 +1,5 @@ #include - #include "math_deliminset.h" #include "math_parser.h" #include "math_support.h" @@ -73,18 +72,7 @@ void MathDelimInset::normalize(NormalStream & os) const } -int MathDelimInset::dw() const -{ - int w = height() / 5; - if (w > 8) - w = 8; - if (w < 4) - w = 4; - return w; -} - - -void MathDelimInset::metrics(MetricsInfo & mi) const +Dimension MathDelimInset::metrics(MetricsInfo & mi) const { cell(0).metrics(mi); Dimension t; @@ -92,19 +80,25 @@ void MathDelimInset::metrics(MetricsInfo & mi) const int h0 = (t.asc + t.des) / 2; int a0 = max(cell(0).ascent(), t.asc) - h0; int d0 = max(cell(0).descent(), t.des) + h0; + dw_ = cell(0).height() / 5; + if (dw_ > 8) + dw_ = 8; + if (dw_ < 4) + dw_ = 4; + dim_.wid = cell(0).width() + 2 * dw_ + 8; dim_.asc = max(a0, d0) + h0; dim_.des = max(a0, d0) - h0; - dim_.wid = cell(0).width() + 2 * dw() + 8; + return dim_; } void MathDelimInset::draw(PainterInfo & pi, int x, int y) const { - int const w = dw(); - int const b = y - ascent(); - cell(0).draw(pi, x + w + 4, y); - mathed_draw_deco(pi, x + 4, b, w, height(), left_); - mathed_draw_deco(pi, x + width() - w - 4, b, w, height(), right_); + int const b = y - dim_.asc; + cell(0).draw(pi, x + dw_ + 4, y); + mathed_draw_deco(pi, x + 4, b, dw_, dim_.height(), left_); + mathed_draw_deco(pi, x + dim_.width() - dw_ - 4, + b, dw_, dim_.height(), right_); } diff --git a/src/mathed/math_deliminset.h b/src/mathed/math_deliminset.h index 54ec58cab9..09731c8df8 100644 --- a/src/mathed/math_deliminset.h +++ b/src/mathed/math_deliminset.h @@ -31,7 +31,7 @@ public: /// is it |...|? bool isAbs() const; /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; @@ -55,6 +55,6 @@ public: string right_; private: /// - int dw() const; + mutable int dw_; }; #endif diff --git a/src/mathed/math_diffinset.C b/src/mathed/math_diffinset.C index de162b5b6e..d6f739aacd 100644 --- a/src/mathed/math_diffinset.C +++ b/src/mathed/math_diffinset.C @@ -32,9 +32,10 @@ void MathDiffInset::normalize(NormalStream & os) const } -void MathDiffInset::metrics(MetricsInfo &) const +Dimension MathDiffInset::metrics(MetricsInfo &) const { lyxerr << "should not happen\n"; + return Dimension(); } diff --git a/src/mathed/math_diffinset.h b/src/mathed/math_diffinset.h index 16e67642cf..ceb00f853f 100644 --- a/src/mathed/math_diffinset.h +++ b/src/mathed/math_diffinset.h @@ -17,7 +17,7 @@ public: /// void addDer(MathArray const & der); /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/math_diminset.h b/src/mathed/math_diminset.h index 801aa9952b..1fb5a18af1 100644 --- a/src/mathed/math_diminset.h +++ b/src/mathed/math_diminset.h @@ -2,22 +2,16 @@ #ifndef MATH_DIMINSET_H #define MATH_DIMINSET_H - #include "math_inset.h" #include "dimension.h" + /// things that need the dimension cache class MathDimInset : public MathInset { public: /// not sure whether the initialization is really necessary MathDimInset() {} - /// read ascent value (should be inline according to gprof) - int ascent() const { return dim_.ascent(); } - /// read descent - int descent() const { return dim_.descent(); } - /// read width - int width() const { return dim_.width(); } /// Dimension dimensions() const { return dim_; } /// diff --git a/src/mathed/math_dotsinset.C b/src/mathed/math_dotsinset.C index 821ad4c70c..a1ba4d2133 100644 --- a/src/mathed/math_dotsinset.C +++ b/src/mathed/math_dotsinset.C @@ -1,6 +1,5 @@ #include - #include "math_dotsinset.h" #include "math_mathmlstream.h" #include "math_streamstr.h" @@ -19,32 +18,35 @@ MathInset * MathDotsInset::clone() const } -void MathDotsInset::metrics(MetricsInfo & mi) const +Dimension MathDotsInset::metrics(MetricsInfo & mi) const { mathed_char_dim(mi.base.font, 'M', dim_); dh_ = 0; if (key_->name == "cdots" || key_->name == "dotsb" || key_->name == "dotsm" || key_->name == "dotsi") - dh_ = ascent() / 2; + dh_ = dim_.asc / 2; else if (key_->name == "dotsc") - dh_ = ascent() / 4; + dh_ = dim_.asc / 4; else if (key_->name == "vdots") { dim_.wid = (dim_.wid / 2) + 1; - dh_ = ascent(); + dh_ = dim_.asc; } else if (key_->name == "ddots") - dh_ = ascent(); + dh_ = dim_.asc; + return dim_; } void MathDotsInset::draw(PainterInfo & pain, int x, int y) const { - mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), key_->name); + mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(), + key_->name); if (key_->name == "vdots" || key_->name == "ddots") ++x; if (key_->name != "vdots") --y; - mathed_draw_deco(pain, x + 2, y - dh_, width() - 2, ascent(), key_->name); + mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(), + key_->name); } diff --git a/src/mathed/math_dotsinset.h b/src/mathed/math_dotsinset.h index 0eb9b3b1a7..b1b28a3294 100644 --- a/src/mathed/math_dotsinset.h +++ b/src/mathed/math_dotsinset.h @@ -15,13 +15,13 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// string name() const; protected: - /// cache for the thing's heigth + /// cache for the thing's height mutable int dh_; /// latexkeys const * key_; diff --git a/src/mathed/math_envinset.C b/src/mathed/math_envinset.C index 1fe6093ee6..04e7433dff 100644 --- a/src/mathed/math_envinset.C +++ b/src/mathed/math_envinset.C @@ -18,17 +18,18 @@ MathInset * MathEnvInset::clone() const } -void MathEnvInset::metrics(MetricsInfo & mi) const +Dimension MathEnvInset::metrics(MetricsInfo & mi) const { - dim_ = cell(0).metrics(mi); - metricsMarkers2(); + cell(0).metrics(mi, dim_); + metricsMarkers(); + return dim_; } void MathEnvInset::draw(PainterInfo & pi, int x, int y) const { cell(0).draw(pi, x + 1, y); - drawMarkers2(pi, x, y); + drawMarkers(pi, x, y); } diff --git a/src/mathed/math_envinset.h b/src/mathed/math_envinset.h index f56622f28b..270d6a70a1 100644 --- a/src/mathed/math_envinset.h +++ b/src/mathed/math_envinset.h @@ -25,7 +25,7 @@ public: /// write normalized content void normalize(NormalStream & ns) const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void infoize(std::ostream & os) const; diff --git a/src/mathed/math_ertinset.C b/src/mathed/math_ertinset.C index eeeca0c9e4..10f5f595c5 100644 --- a/src/mathed/math_ertinset.C +++ b/src/mathed/math_ertinset.C @@ -12,12 +12,13 @@ MathInset * MathErtInset::clone() const } -void MathErtInset::metrics(MetricsInfo & mi) const +Dimension MathErtInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy(mi.base, "lyxert"); MathTextInset::metrics(mi); cache_.colinfo_[0].align_ = 'l'; - metricsMarkers2(); + metricsMarkers(); + return dim_; } @@ -25,7 +26,7 @@ void MathErtInset::draw(PainterInfo & pi, int x, int y) const { FontSetChanger dummy(pi.base, "lyxert"); MathTextInset::draw(pi, x + 1, y); - drawMarkers2(pi, x, y); + drawMarkers(pi, x, y); } diff --git a/src/mathed/math_ertinset.h b/src/mathed/math_ertinset.h index 77680bfb1e..37c35fdcda 100644 --- a/src/mathed/math_ertinset.h +++ b/src/mathed/math_ertinset.h @@ -15,7 +15,7 @@ public: /// mode_type currentMode() const { return TEXT_MODE; } /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_exfuncinset.C b/src/mathed/math_exfuncinset.C index e81c032fb7..9c693b3b6b 100644 --- a/src/mathed/math_exfuncinset.C +++ b/src/mathed/math_exfuncinset.C @@ -25,7 +25,7 @@ MathInset * MathExFuncInset::clone() const } -void MathExFuncInset::metrics(MetricsInfo & mi) const +Dimension MathExFuncInset::metrics(MetricsInfo & mi) const { mathed_string_dim(mi.base.font, name_, dim_); } diff --git a/src/mathed/math_exfuncinset.h b/src/mathed/math_exfuncinset.h index a123101951..5417754779 100644 --- a/src/mathed/math_exfuncinset.h +++ b/src/mathed/math_exfuncinset.h @@ -17,7 +17,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_exintinset.C b/src/mathed/math_exintinset.C index 2f9d07ca19..096c996471 100644 --- a/src/mathed/math_exintinset.C +++ b/src/mathed/math_exintinset.C @@ -48,9 +48,10 @@ void MathExIntInset::normalize(NormalStream & os) const } -void MathExIntInset::metrics(MetricsInfo &) const +Dimension MathExIntInset::metrics(MetricsInfo &) const { lyxerr << "should not happen\n"; + return Dimension(); } diff --git a/src/mathed/math_exintinset.h b/src/mathed/math_exintinset.h index 9681b31b59..4623bd0247 100644 --- a/src/mathed/math_exintinset.h +++ b/src/mathed/math_exintinset.h @@ -18,7 +18,7 @@ public: /// void symbol(string const &); /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index 1ccb5829dc..f2fa0b4396 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -36,8 +36,6 @@ #include "math_undersetinset.h" #include "math_unknowninset.h" #include "math_xarrowinset.h" -#include "math_xymatrixinset.h" -#include "math_xyarrowinset.h" //#include "insets/insetref.h" #include "ref_inset.h" @@ -264,8 +262,6 @@ MathAtom createMathInset(string const & s) return MathAtom(new MathMakeboxInset); if (s == "kern") return MathAtom(new MathKernInset); - if (s == "xymatrix") - return MathAtom(new MathXYMatrixInset); if (s == "xrightarrow" || s == "xleftarrow") return MathAtom(new MathXArrowInset(s)); if (s == "split" || s == "gathered" || s == "aligned") diff --git a/src/mathed/math_fboxinset.C b/src/mathed/math_fboxinset.C index 6e36ae4d22..afef0c6837 100644 --- a/src/mathed/math_fboxinset.C +++ b/src/mathed/math_fboxinset.C @@ -1,6 +1,5 @@ #include - #include "math_fboxinset.h" #include "math_support.h" #include "math_mathmlstream.h" @@ -29,23 +28,23 @@ MathInset::mode_type MathFboxInset::currentMode() const } -void MathFboxInset::metrics(MetricsInfo & mi) const +Dimension MathFboxInset::metrics(MetricsInfo & mi) const { if (key_->name == "fbox") { FontSetChanger dummy(mi.base, "textnormal"); - dim_ = cell(0).metrics(mi); - metricsMarkers2(5); // 5 pixels margin + cell(0).metrics(mi, dim_); } else { - dim_ = cell(0).metrics(mi); - metricsMarkers2(5); // 5 pixels margin + cell(0).metrics(mi, dim_); } + metricsMarkers(5); // 5 pixels margin + return dim_; } void MathFboxInset::draw(PainterInfo & pi, int x, int y) const { - pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2, - LColor::foreground); + pi.pain.rectangle(x + 1, y - dim_.ascent() + 1, + dim_.width() - 2, dim_.height() - 2, LColor::foreground); if (key_->name == "fbox") { FontSetChanger dummy(pi.base, "textnormal"); cell(0).draw(pi, x + 5, y); diff --git a/src/mathed/math_fboxinset.h b/src/mathed/math_fboxinset.h index 549dab00ea..b9b54e1e54 100644 --- a/src/mathed/math_fboxinset.h +++ b/src/mathed/math_fboxinset.h @@ -23,7 +23,7 @@ public: /// mode_type currentMode() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_fontinset.C b/src/mathed/math_fontinset.C index a73dbb78ff..a1c2e3824d 100644 --- a/src/mathed/math_fontinset.C +++ b/src/mathed/math_fontinset.C @@ -1,6 +1,5 @@ #include - #include "math_fontinset.h" #include "math_mathmlstream.h" #include "math_streamstr.h" @@ -33,11 +32,12 @@ MathInset::mode_type MathFontInset::currentMode() const } -void MathFontInset::metrics(MetricsInfo & mi) const +Dimension MathFontInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy(mi.base, key_->name.c_str()); - dim_ = cell(0).metrics(mi); - metricsMarkers(); + cell(0).metrics(mi, dim_); + metricsMarkers(1); + return dim_; } @@ -49,9 +49,9 @@ void MathFontInset::draw(PainterInfo & pi, int x, int y) const } -void MathFontInset::metricsT(TextMetricsInfo const & mi) const +void MathFontInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const { - dim_ = cell(0).metricsT(mi); + cell(0).metricsT(mi, dim_); } diff --git a/src/mathed/math_fontinset.h b/src/mathed/math_fontinset.h index 7673b07422..d0b8f33e72 100644 --- a/src/mathed/math_fontinset.h +++ b/src/mathed/math_fontinset.h @@ -28,11 +28,11 @@ public: /// string name() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// - void metricsT(TextMetricsInfo const & mi) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// void drawT(TextPainter & pi, int x, int y) const; /// diff --git a/src/mathed/math_fontoldinset.C b/src/mathed/math_fontoldinset.C index 11bf5f153c..86661d0159 100644 --- a/src/mathed/math_fontoldinset.C +++ b/src/mathed/math_fontoldinset.C @@ -25,11 +25,12 @@ MathInset * MathFontOldInset::clone() const } -void MathFontOldInset::metrics(MetricsInfo & mi) const +Dimension MathFontOldInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy(mi.base, key_->name.c_str()); - dim_ = cell(0).metrics(mi); - metricsMarkers(); + cell(0).metrics(mi, dim_); + metricsMarkers(1); + return dim_; } @@ -41,9 +42,9 @@ void MathFontOldInset::draw(PainterInfo & pi, int x, int y) const } -void MathFontOldInset::metricsT(TextMetricsInfo const & mi) const +void MathFontOldInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const { - dim_ = cell(0).metricsT(mi); + cell(0).metricsT(mi, dim); } diff --git a/src/mathed/math_fontoldinset.h b/src/mathed/math_fontoldinset.h index 8d68e3064e..62621ac08c 100644 --- a/src/mathed/math_fontoldinset.h +++ b/src/mathed/math_fontoldinset.h @@ -24,11 +24,11 @@ public: /// we write extra braces in any case... bool extraBraces() const { return true; } /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// - void metricsT(TextMetricsInfo const & mi) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// void drawT(TextPainter & pi, int x, int y) const; /// diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index ea05d41c66..776265656c 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -32,7 +32,7 @@ MathFracInset const * MathFracInset::asFracInset() const } -void MathFracInset::metrics(MetricsInfo & mi) const +Dimension MathFracInset::metrics(MetricsInfo & mi) const { FracChanger dummy(mi.base); cell(0).metrics(mi); @@ -40,37 +40,39 @@ void MathFracInset::metrics(MetricsInfo & mi) const dim_.wid = max(cell(0).width(), cell(1).width()) + 2; dim_.asc = cell(0).height() + 2 + 5; dim_.des = cell(1).height() + 2 - 5; + return dim_; } void MathFracInset::draw(PainterInfo & pi, int x, int y) const { - int m = x + width() / 2; + int m = x + dim_.wid / 2; FracChanger dummy(pi.base); cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5); cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 2 - 5); if (!atop_) - pi.pain.line(x + 1, y - 5, x + width() - 2, y - 5, LColor::math); + pi.pain.line(x + 1, y - 5, x + dim_.wid - 2, y - 5, LColor::math); } -void MathFracInset::metricsT(TextMetricsInfo const & mi) const +void MathFracInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const { - cell(0).metricsT(mi); - cell(1).metricsT(mi); - dim_.wid = max(cell(0).width(), cell(1).width()); - dim_.asc = cell(0).height() + 1; - dim_.des = cell(1).height(); + cell(0).metricsT(mi, dim); + cell(1).metricsT(mi, dim); + dim.wid = max(cell(0).width(), cell(1).width()); + dim.asc = cell(0).height() + 1; + dim.des = cell(1).height(); + //return dim_; } void MathFracInset::drawT(TextPainter & pain, int x, int y) const { - int m = x + width() / 2; + int m = x + dim_.width() / 2; cell(0).drawT(pain, m - cell(0).width() / 2, y - cell(0).descent() - 1); cell(1).drawT(pain, m - cell(1).width() / 2, y + cell(1).ascent()); if (!atop_) - pain.horizontalLine(x, y, width()); + pain.horizontalLine(x, y, dim_.width()); } diff --git a/src/mathed/math_fracinset.h b/src/mathed/math_fracinset.h index a720ed93a8..14ca4d4c40 100644 --- a/src/mathed/math_fracinset.h +++ b/src/mathed/math_fracinset.h @@ -17,11 +17,11 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; /// - void metricsT(TextMetricsInfo const & mi) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// void drawT(TextPainter &, int x, int y) const; /// identifies FracInsets diff --git a/src/mathed/math_frameboxinset.C b/src/mathed/math_frameboxinset.C index a8381fb386..4e51af0c41 100644 --- a/src/mathed/math_frameboxinset.C +++ b/src/mathed/math_frameboxinset.C @@ -1,6 +1,5 @@ #include - #include "math_frameboxinset.h" #include "math_support.h" #include "math_mathmlstream.h" @@ -8,7 +7,6 @@ #include "frontends/Painter.h" - MathFrameboxInset::MathFrameboxInset() : MathNestInset(3) {} @@ -20,24 +18,24 @@ MathInset * MathFrameboxInset::clone() const } -void MathFrameboxInset::metrics(MetricsInfo & mi) const +Dimension MathFrameboxInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy(mi.base, "textnormal"); w_ = mathed_char_width(mi.base.font, '['); MathNestInset::metrics(mi); - dim_ = cell(0).dim(); - dim_ += cell(1).dim(); - dim_ += cell(2).dim(); - dim_.wid += 4 * w_ + 4; - metricsMarkers2(5); // 5 pixels margin + dim_ = cell(0).dim(); + dim_ += cell(1).dim(); + dim_ += cell(2).dim(); + metricsMarkers(); + return dim_; } void MathFrameboxInset::draw(PainterInfo & pi, int x, int y) const { FontSetChanger dummy(pi.base, "textnormal"); - pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2, - LColor::foreground); + pi.pain.rectangle(x + 1, y - dim_.ascent() + 1, + dim_.width() - 2, dim_.height() - 2, LColor::foreground); x += 5; drawStrBlack(pi, x, y, "["); diff --git a/src/mathed/math_frameboxinset.h b/src/mathed/math_frameboxinset.h index a102afddaa..7dd13ba711 100644 --- a/src/mathed/math_frameboxinset.h +++ b/src/mathed/math_frameboxinset.h @@ -18,7 +18,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index c6310c7cb2..d42d4927aa 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -298,7 +298,7 @@ LyXLength MathGridInset::vcrskip(row_type row) const } -void MathGridInset::metrics(MetricsInfo & mi) const +Dimension MathGridInset::metrics(MetricsInfo & mi) const { // let the cells adjust themselves MathNestInset::metrics(mi); @@ -370,17 +370,17 @@ void MathGridInset::metrics(MetricsInfo & mi) const dim_.wid = colinfo_[ncols() - 1].offset_ + colinfo_[ncols() - 1].width_ - + vlinesep() * colinfo_[ncols()].lines_ + + vlinesep() * colinfo_[ncols()].lines_ + border(); dim_.asc = - rowinfo_[0].offset_ + rowinfo_[0].ascent_ - + hlinesep() * rowinfo_[0].lines_ + + hlinesep() * rowinfo_[0].lines_ + border(); dim_.des = rowinfo_[nrows() - 1].offset_ + rowinfo_[nrows() - 1].descent_ - + hlinesep() * rowinfo_[nrows()].lines_ + + hlinesep() * rowinfo_[nrows()].lines_ + border(); @@ -434,6 +434,7 @@ void MathGridInset::metrics(MetricsInfo & mi) const cxrow->setBaseline(cxrow->getBaseline() - ascent); } */ + return dim_; } @@ -446,24 +447,24 @@ void MathGridInset::draw(PainterInfo & pi, int x, int y) const for (int i = 0; i < rowinfo_[row].lines_; ++i) { int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_ - i * hlinesep() - hlinesep()/2 - rowsep()/2; - pi.pain.line(x + 1, yy, x + width() - 1, yy); + pi.pain.line(x + 1, yy, x + dim_.width() - 1, yy); } for (col_type col = 0; col <= ncols(); ++col) for (int i = 0; i < colinfo_[col].lines_; ++i) { int xx = x + colinfo_[col].offset_ - i * vlinesep() - vlinesep()/2 - colsep()/2; - pi.pain.line(xx, y - ascent() + 1, xx, y + descent() - 1); + pi.pain.line(xx, y - dim_.ascent() + 1, xx, y + dim_.descent() - 1); } } -void MathGridInset::metricsT(TextMetricsInfo const & mi) const +void MathGridInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const { // let the cells adjust themselves //MathNestInset::metrics(mi); for (idx_type i = 0; i < nargs(); ++i) - cell(i).metricsT(mi); + cell(i).metricsT(mi, dim); // compute absolute sizes of vertical structure for (row_type row = 0; row < nrows(); ++row) { @@ -530,21 +531,20 @@ void MathGridInset::metricsT(TextMetricsInfo const & mi) const } - dim_.wid = colinfo_[ncols() - 1].offset_ + dim.wid = colinfo_[ncols() - 1].offset_ + colinfo_[ncols() - 1].width_ //+ vlinesep() * colinfo_[ncols()].lines_ + 2; - dim_.asc = -rowinfo_[0].offset_ + dim.asc = -rowinfo_[0].offset_ + rowinfo_[0].ascent_ //+ hlinesep() * rowinfo_[0].lines_ + 1; - dim_.des = rowinfo_[nrows() - 1].offset_ + dim.des = rowinfo_[nrows() - 1].offset_ + rowinfo_[nrows() - 1].descent_ //+ hlinesep() * rowinfo_[nrows()].lines_ + 1; - } diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index 1beffcb7c1..5d5af40d86 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -92,11 +92,11 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// - void metricsT(TextMetricsInfo const & mi) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// void drawT(TextPainter & pi, int x, int y) const; /// diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 4712712de2..78f3549e58 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -1,6 +1,5 @@ #include - #include "math_hullinset.h" #include "math_mathmlstream.h" #include "math_streamstr.h" @@ -166,7 +165,7 @@ char const * MathHullInset::standardFont() const } -void MathHullInset::metrics(MetricsInfo & mi) const +Dimension MathHullInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy1(mi.base, standardFont()); StyleChanger dummy2(mi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT); @@ -198,6 +197,7 @@ void MathHullInset::metrics(MetricsInfo & mi) const // for markers metricsMarkers2(); + return dim_; } @@ -220,17 +220,17 @@ void MathHullInset::draw(PainterInfo & pi, int x, int y) const } -void MathHullInset::metricsT(TextMetricsInfo const & mi) const +void MathHullInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const { if (display()) { - MathGridInset::metricsT(mi); + MathGridInset::metricsT(mi, dim); } else { ostringstream os; WriteStream wi(os, false, true); write(wi); - dim_.wid = os.str().size(); - dim_.asc = 1; - dim_.des = 0; + dim.wid = os.str().size(); + dim.asc = 1; + dim.des = 0; } } diff --git a/src/mathed/math_hullinset.h b/src/mathed/math_hullinset.h index 7b3e407e42..0ef8679a6c 100644 --- a/src/mathed/math_hullinset.h +++ b/src/mathed/math_hullinset.h @@ -24,11 +24,11 @@ public: /// mode_type currentMode() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; /// - void metricsT(TextMetricsInfo const & mi) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// void drawT(TextPainter &, int x, int y) const; /// diff --git a/src/mathed/math_inferinset.C b/src/mathed/math_inferinset.C index 930fec7a82..0cc5246a69 100644 --- a/src/mathed/math_inferinset.C +++ b/src/mathed/math_inferinset.C @@ -17,8 +17,9 @@ MathInset * MathInferInset::clone() const } -void MathInferInset::metrics(MetricsInfo &) const +Dimension MathInferInset::metrics(MetricsInfo &) const { + return Dimension(); } diff --git a/src/mathed/math_inferinset.h b/src/mathed/math_inferinset.h index ca74627bc5..4385b7a232 100644 --- a/src/mathed/math_inferinset.h +++ b/src/mathed/math_inferinset.h @@ -17,7 +17,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index aa4493987b..d5d6af8653 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -17,7 +17,6 @@ #include - #include "math_inset.h" #include "Lsstream.h" #include "math_scriptinset.h" @@ -42,25 +41,12 @@ BufferView * MathInset::view() const } -int MathInset::height() const -{ - return ascent() + descent(); -} - - MathInset::size_type MathInset::nargs() const { return 0; } -Dimension MathInset::dimensions() const -{ - lyxerr << "call MathInset::dimensions()\n"; - return Dimension(width(), ascent(), descent()); -} - - MathArray dummyCell; MathArray & MathInset::cell(idx_type) @@ -172,12 +158,6 @@ bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const } -void MathInset::metrics(MetricsInfo &) const -{ - lyxerr << "MathInset::metrics() called directly!\n"; -} - - void MathInset::draw(PainterInfo &, int, int) const { lyxerr << "MathInset::draw() called directly!\n"; @@ -191,7 +171,7 @@ void MathInset::drawSelection(PainterInfo &, } -void MathInset::metricsT(TextMetricsInfo const &) const +void MathInset::metricsT(TextMetricsInfo const &, Dimension &) const { #ifdef WITH_WARNINGS lyxerr << "MathInset::metricsT(Text) called directly!\n"; diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 611d4fd75b..d3cb73333a 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -103,29 +103,19 @@ public: virtual MathInset * clone() const = 0; /// substitutes macro arguments if necessary virtual void substitute(MathMacro const & macro); - /// compute the size of the object, sets ascend_, descend_ and width_ - // updates the (xo,yo)-caches of all contained cells - virtual void metrics(MetricsInfo & mi) const; + /// compute the size of the object returned in dim + virtual Dimension metrics(MetricsInfo & mi) const = 0; /// draw the object + // updates the (xo,yo)-caches of all contained cells virtual void draw(PainterInfo & pi, int x, int y) const; /// draw selection between two positions virtual void drawSelection(PainterInfo & pi, idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const; /// the ascent of the inset above the baseline /// compute the size of the object for text based drawing - virtual void metricsT(TextMetricsInfo const & st) const; + virtual void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// draw the object as text virtual void drawT(TextPainter &, int x, int y) const; - /// the ascent of the inset above the baseline - virtual int ascent() const { return 1; } - /// the descent of the inset below the baseline - virtual int descent() const { return 1; } - /// total width - virtual int width() const { return 2; } - /// all in one batch - virtual Dimension dimensions() const; - /// total height (== ascent + descent) - virtual int height() const; /// Where should we go when we press the up or down cursor key? virtual bool idxUpDown(idx_type & idx, pos_type & pos, bool up, diff --git a/src/mathed/math_kerninset.C b/src/mathed/math_kerninset.C index 19658fa516..cf7cb75611 100644 --- a/src/mathed/math_kerninset.C +++ b/src/mathed/math_kerninset.C @@ -28,11 +28,13 @@ MathInset * MathKernInset::clone() const } -void MathKernInset::metrics(MetricsInfo & mi) const +Dimension MathKernInset::metrics(MetricsInfo & mi) const { - dim_.wid = wid_.inPixels(0, mathed_char_width(mi.base.font, 'M')); - dim_.asc = 0; - dim_.des = 0; + Dimension dim; + dim.wid = wid_.inPixels(0, mathed_char_width(mi.base.font, 'M')); + dim.asc = 0; + dim.des = 0; + return dim; } diff --git a/src/mathed/math_kerninset.h b/src/mathed/math_kerninset.h index 480486cdb6..53a03b9656 100644 --- a/src/mathed/math_kerninset.h +++ b/src/mathed/math_kerninset.h @@ -2,7 +2,7 @@ #ifndef MATH_CHEATINSET_H #define MATH_CHEATINSET_H -#include "math_diminset.h" +#include "math_inset.h" #include "vspace.h" #include "LString.h" #include "math_nestinset.h" @@ -11,7 +11,7 @@ /// The \kern primitive /// Some hack for visual effects -class MathKernInset : public MathDimInset { +class MathKernInset : public MathInset { public: /// MathKernInset(); @@ -22,13 +22,13 @@ public: /// MathInset * clone() const; /// - void draw(PainterInfo &, int x, int y) const; + Dimension metrics(MetricsInfo & mi) const; + /// + void draw(PainterInfo & pi, int x, int y) const; /// void write(WriteStream & os) const; /// void normalize(NormalStream & ns) const; - /// - void metrics(MetricsInfo & st) const; private: /// width in em LyXLength wid_; diff --git a/src/mathed/math_lefteqninset.C b/src/mathed/math_lefteqninset.C index 5d8a2e67e3..d560e1237a 100644 --- a/src/mathed/math_lefteqninset.C +++ b/src/mathed/math_lefteqninset.C @@ -15,20 +15,21 @@ MathInset * MathLefteqnInset::clone() const } -void MathLefteqnInset::metrics(MetricsInfo & mi) const +Dimension MathLefteqnInset::metrics(MetricsInfo & mi) const { cell(0).metrics(mi); dim_.asc = cell(0).ascent() + 2; dim_.des = cell(0).descent() + 2; dim_.wid = 4; - metricsMarkers2(); + metricsMarkers(); + return dim_; } void MathLefteqnInset::draw(PainterInfo & pi, int x, int y) const { cell(0).draw(pi, x + 2, y); - drawMarkers2(pi, x, y); + drawMarkers(pi, x, y); } diff --git a/src/mathed/math_lefteqninset.h b/src/mathed/math_lefteqninset.h index 6a82a59502..7a7f74df90 100644 --- a/src/mathed/math_lefteqninset.h +++ b/src/mathed/math_lefteqninset.h @@ -16,7 +16,7 @@ public: /// string name() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_liminset.C b/src/mathed/math_liminset.C index 8608db0edf..3dd05b6997 100644 --- a/src/mathed/math_liminset.C +++ b/src/mathed/math_liminset.C @@ -28,9 +28,10 @@ void MathLimInset::normalize(NormalStream & os) const } -void MathLimInset::metrics(MetricsInfo &) const +Dimension MathLimInset::metrics(MetricsInfo &) const { lyxerr << "should not happen\n"; + return Dimension(); } diff --git a/src/mathed/math_liminset.h b/src/mathed/math_liminset.h index ee914d85a1..71a97e6ac1 100644 --- a/src/mathed/math_liminset.h +++ b/src/mathed/math_liminset.h @@ -15,7 +15,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 13aab1ae9b..0291e37c15 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -69,40 +69,42 @@ void MathMacro::expand() const } -void MathMacro::metrics(MetricsInfo & mi) const +Dimension MathMacro::metrics(MetricsInfo & mi) const { augmentFont(font_, "lyxtex"); mi_ = mi; if (defining()) { - mathed_string_dim(font_, name(), dim_); - return; - } - if (editing()) { + mathed_string_dim(font_, name(), dim_); + + } else if (editing()) { + expand(); - dim_ = expanded_.metrics(mi_); - metricsMarkers2(2); + expanded_.metrics(mi_, dim_); + metricsMarkers(); dim_.wid += mathed_string_width(font_, name()) + 10; - Dimension dim; - mathed_string_dim(font_, "#1: ", dim); + int ww = mathed_string_width(font_, "#1: "); for (idx_type i = 0; i < nargs(); ++i) { MathArray const & c = cell(i); c.metrics(mi_); - dim_.wid = max(dim_.wid, c.width() + dim.wid); - dim_.des += max(c.ascent(), dim.asc) + 5; - dim_.des += max(c.descent(), dim.des) + 5; + dim_.wid = max(dim_.wid, c.width() + ww); + dim_.des += max(c.ascent(), dim_.asc) + 5; + dim_.des += max(c.descent(), dim_.des) + 5; } - return; + + } else { + + expand(); + expanded_.substitute(*this); + expanded_.metrics(mi_, dim_); + } - expand(); - expanded_.substitute(*this); - expanded_.metrics(mi_); - dim_ = expanded_.dim(); + return dim_; } @@ -119,7 +121,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const } if (editing()) { - int h = y - ascent() + 2 + expanded_.ascent(); + int h = y - dim_.ascent() + 2 + expanded_.ascent(); drawStr(pi, font_, x + 3, h, name()); int const w = mathed_string_width(font_, name()); diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index 39bda1ccf0..d233b6a773 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -41,7 +41,7 @@ public: /// void draw(PainterInfo & pi, int x, int y) const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// MathInset * clone() const; /// diff --git a/src/mathed/math_macroarg.C b/src/mathed/math_macroarg.C index 8de0f3af41..ce318085a2 100644 --- a/src/mathed/math_macroarg.C +++ b/src/mathed/math_macroarg.C @@ -1,4 +1,3 @@ - #include "math_macroarg.h" #include "math_macro.h" #include "math_mathmlstream.h" @@ -34,12 +33,13 @@ void MathMacroArgument::write(WriteStream & os) const } -void MathMacroArgument::metrics(MetricsInfo & mi) const +Dimension MathMacroArgument::metrics(MetricsInfo & mi) const { if (expanded_) - dim_ = cell(0).metrics(mi); + cell(0).metrics(mi, dim_); else mathed_string_dim(mi.base.font, str_, dim_); + return dim_; } diff --git a/src/mathed/math_macroarg.h b/src/mathed/math_macroarg.h index d6bb6f919d..22a42f7542 100644 --- a/src/mathed/math_macroarg.h +++ b/src/mathed/math_macroarg.h @@ -19,7 +19,7 @@ public: /// bool isActive() const { return false; } /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index 1342198e05..ce4481526b 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -62,13 +62,14 @@ string MathMacroTemplate::name() const } -void MathMacroTemplate::metrics(MetricsInfo & mi) const +Dimension MathMacroTemplate::metrics(MetricsInfo & mi) const { cell(0).metrics(mi); cell(1).metrics(mi); dim_.wid = cell(0).width() + cell(1).width() + 10; dim_.asc = std::max(cell(0).ascent(), cell(1).ascent()) + 2; dim_.des = std::max(cell(0).descent(), cell(1).descent()) + 2; + return dim_; } @@ -77,11 +78,11 @@ void MathMacroTemplate::draw(PainterInfo & pi, int x, int y) const int const w0 = cell(0).width(); int const w1 = cell(1).width(); cell(0).draw(pi, x + 2, y + 1); - pi.pain.rectangle(x, y - ascent() + 1, w0 + 4, height(), + pi.pain.rectangle(x, y - dim_.ascent() + 1, w0 + 4, dim_.height(), LColor::mathline); cell(1).draw(pi, x + 8 + w0, y + 1); - pi.pain.rectangle(x + w0 + 6 , y - ascent() + 1, w1 + 4, - height(), LColor::mathline); + pi.pain.rectangle(x + w0 + 6 , y - dim_.ascent() + 1, w1 + 4, + dim_.height(), LColor::mathline); } diff --git a/src/mathed/math_macrotemplate.h b/src/mathed/math_macrotemplate.h index dc90d9c977..d0b10c075e 100644 --- a/src/mathed/math_macrotemplate.h +++ b/src/mathed/math_macrotemplate.h @@ -37,7 +37,7 @@ public: /// void draw(PainterInfo &, int x, int y) const; /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// identifies macro templates MathMacroTemplate * asMacroTemplate() { return this; } /// identifies macro templates diff --git a/src/mathed/math_makeboxinset.C b/src/mathed/math_makeboxinset.C index c2b6264da3..f2d5ea80cb 100644 --- a/src/mathed/math_makeboxinset.C +++ b/src/mathed/math_makeboxinset.C @@ -23,23 +23,24 @@ MathInset * MathMakeboxInset::clone() const } -void MathMakeboxInset::metrics(MetricsInfo & mi) const +Dimension MathMakeboxInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy(mi.base, "textnormal"); w_ = mathed_char_width(mi.base.font, '['); MathNestInset::metrics(mi); - dim_ = cell(0).dim(); - dim_ += cell(1).dim(); - dim_ += cell(2).dim(); + dim_ = cell(0).dim(); + dim_ += cell(1).dim(); + dim_ += cell(2).dim(); dim_.wid += 4 * w_ + 4; - metricsMarkers2(); + metricsMarkers(); + return dim_; } void MathMakeboxInset::draw(PainterInfo & pi, int x, int y) const { FontSetChanger dummy(pi.base, "textnormal"); - drawMarkers2(pi, x, y); + drawMarkers(pi, x, y); drawStrBlack(pi, x, y, "["); x += w_; diff --git a/src/mathed/math_makeboxinset.h b/src/mathed/math_makeboxinset.h index f93de06c11..95e8db12d0 100644 --- a/src/mathed/math_makeboxinset.h +++ b/src/mathed/math_makeboxinset.h @@ -23,7 +23,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index e77b8253a9..30ba7b5f9d 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -15,8 +15,6 @@ public: MathMatrixInset(string const & str); /// MathInset * clone() const; - /// - void metrics(MetricsInfo &) const {} /// identifies MatrixInsets MathMatrixInset const * asMatrixInset() const { return this; } diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index d3954a3b49..ddb730fd8c 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -10,7 +10,7 @@ MathNestInset::MathNestInset(idx_type nargs) - : MathDimInset(), cells_(nargs), lock_(false) + : cells_(nargs), lock_(false) {} @@ -58,21 +58,6 @@ void MathNestInset::metrics(MetricsInfo const & mi) const } -void MathNestInset::metricsMarkers(int frame) const -{ - dim_.des += frame; - dim_.wid += 2 * frame; -} - - -void MathNestInset::metricsMarkers2(int frame) const -{ - dim_.asc += frame; - dim_.des += frame; - dim_.wid += 2 * frame; -} - - bool MathNestInset::idxNext(idx_type & idx, pos_type & pos) const { if (idx + 1 >= nargs()) @@ -192,33 +177,6 @@ void MathNestInset::drawSelection(PainterInfo & pi, } -void MathNestInset::drawMarkers(PainterInfo & pi, int x, int y) const -{ - if (!editing()) - return; - int t = x + width() - 1; - int d = y + descent(); - pi.pain.line(x, d - 3, x, d, LColor::mathframe); - pi.pain.line(t, d - 3, t, d, LColor::mathframe); - pi.pain.line(x, d, x + 3, d, LColor::mathframe); - pi.pain.line(t - 3, d, t, d, LColor::mathframe); -} - - -void MathNestInset::drawMarkers2(PainterInfo & pi, int x, int y) const -{ - if (!editing()) - return; - drawMarkers(pi, x, y); - int t = x + width() - 1; - int a = y - ascent(); - pi.pain.line(x, a + 3, x, a, LColor::mathframe); - pi.pain.line(t, a + 3, t, a, LColor::mathframe); - pi.pain.line(x, a, x + 3, a, LColor::mathframe); - pi.pain.line(t - 3, a, t, a, LColor::mathframe); -} - - void MathNestInset::validate(LaTeXFeatures & features) const { for (idx_type i = 0; i < nargs(); ++i) @@ -343,5 +301,47 @@ dispatch_result MathNestInset::dispatch default: return MathInset::dispatch(cmd, idx, pos); } - return UNDISPATCHED; } + + +void MathNestInset::metricsMarkers(int) const +{ + dim_.wid += 2; + dim_.asc += 1; +} + + +void MathNestInset::metricsMarkers2(int) const +{ + dim_.wid += 2; + dim_.asc += 1; + dim_.des += 1; +} + +void MathNestInset::drawMarkers(PainterInfo & pi, int x, int y) const +{ + if (!editing()) + return; + int t = x + dim_.width() - 1; + int d = y + dim_.descent(); + pi.pain.line(x, d - 3, x, d, LColor::mathframe); + pi.pain.line(t, d - 3, t, d, LColor::mathframe); + pi.pain.line(x, d, x + 3, d, LColor::mathframe); + pi.pain.line(t - 3, d, t, d, LColor::mathframe); +} + + +void MathNestInset::drawMarkers2(PainterInfo & pi, int x, int y) const +{ + if (!editing()) + return; + drawMarkers(pi, x, y); + int t = x + dim_.width() - 1; + int a = y - dim_.ascent(); + pi.pain.line(x, a + 3, x, a, LColor::mathframe); + pi.pain.line(t, a + 3, t, a, LColor::mathframe); + pi.pain.line(x, a, x + 3, a, LColor::mathframe); + pi.pain.line(t - 3, a, t, a, LColor::mathframe); +} + + diff --git a/src/mathed/math_nestinset.h b/src/mathed/math_nestinset.h index e44bb6516a..401e3091e8 100644 --- a/src/mathed/math_nestinset.h +++ b/src/mathed/math_nestinset.h @@ -1,7 +1,6 @@ #ifndef MATH_NESTINSET_H #define MATH_NESTINSET_H - #include "math_diminset.h" /** Abstract base class for all math objects that contain nested items. @@ -10,27 +9,19 @@ */ -class LaTeXFeatures; - class MathNestInset : public MathDimInset { public: /// nestinsets have a fixed size to start with explicit MathNestInset(idx_type ncells); /// the size is usuall some sort of convex hull of the cells + /// hides inset::metrics() intentionally! void metrics(MetricsInfo const & mi) const; - /// add space for markers - void metricsMarkers(int frame = 1) const; - /// add space for markers - void metricsMarkers2(int frame = 1) const; /// draw background if locked void draw(PainterInfo & pi, int x, int y) const; /// draw selection background void drawSelection(PainterInfo & pi, idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const; - void drawMarkers(PainterInfo & pi, int x, int y) const; - /// draw four angular markers - void drawMarkers2(PainterInfo & pi, int x, int y) const; /// appends itself with macro arguments substituted void substitute(MathMacro const & macro); /// identifies NestInsets @@ -109,6 +100,17 @@ protected: cells_type cells_; /// if the inset is locked, it can't be entered with the cursor bool lock_; + + /// draw four angular markers + void drawMarkers(PainterInfo & pi, int x, int y) const; + /// draw two angular markers + void drawMarkers2(PainterInfo & pi, int x, int y) const; + + /// add space for markers + void metricsMarkers(int frame = 1) const; + /// add space for markers + void metricsMarkers2(int frame = 1) const; + }; #endif diff --git a/src/mathed/math_numberinset.C b/src/mathed/math_numberinset.C index d14b183fc8..d53409630d 100644 --- a/src/mathed/math_numberinset.C +++ b/src/mathed/math_numberinset.C @@ -19,9 +19,11 @@ MathInset * MathNumberInset::clone() const } -void MathNumberInset::metrics(MetricsInfo & mi) const +Dimension MathNumberInset::metrics(MetricsInfo & mi) const { - mathed_string_dim(mi.base.font, str_, dim_); + Dimension dim; + mathed_string_dim(mi.base.font, str_, dim); + return dim; } diff --git a/src/mathed/math_numberinset.h b/src/mathed/math_numberinset.h index 5f6d54a699..30ca051734 100644 --- a/src/mathed/math_numberinset.h +++ b/src/mathed/math_numberinset.h @@ -2,7 +2,7 @@ #ifndef MATH_NUMBERINSET_H #define MATH_NUMBERINSET_H -#include "math_diminset.h" +#include "math_inset.h" /** Some inset that "is" a number @@ -12,14 +12,14 @@ * Full author contact details are available in file CREDITS */ -class MathNumberInset : public MathDimInset { +class MathNumberInset : public MathInset { public: /// explicit MathNumberInset(string const & s); /// MathInset * clone() const; /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/math_parboxinset.C b/src/mathed/math_parboxinset.C index f8a3254e0e..d40efc594f 100644 --- a/src/mathed/math_parboxinset.C +++ b/src/mathed/math_parboxinset.C @@ -33,12 +33,13 @@ void MathParboxInset::setWidth(string const & w) } -void MathParboxInset::metrics(MetricsInfo & mi) const +Dimension MathParboxInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy1(mi.base, "textnormal"); WidthChanger dummy2(mi.base, lyx_width_); MathTextInset::metrics(mi); - metricsMarkers2(); + metricsMarkers(); + return dim_; } @@ -46,7 +47,7 @@ void MathParboxInset::draw(PainterInfo & pi, int x, int y) const { FontSetChanger dummy(pi.base, "textnormal"); MathTextInset::draw(pi, x + 1, y); - drawMarkers2(pi, x, y); + drawMarkers(pi, x, y); } diff --git a/src/mathed/math_parboxinset.h b/src/mathed/math_parboxinset.h index 1b56b32f74..9aae3c1450 100644 --- a/src/mathed/math_parboxinset.h +++ b/src/mathed/math_parboxinset.h @@ -17,7 +17,7 @@ public: /// mode_type currentMode() const { return TEXT_MODE; } /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/math_parinset.C b/src/mathed/math_parinset.C index 03bb1d6c32..9d50bfdca7 100644 --- a/src/mathed/math_parinset.C +++ b/src/mathed/math_parinset.C @@ -12,10 +12,11 @@ MathParInset::MathParInset(MathArray const & ar) } -void MathParInset::metrics(MetricsInfo & mi) const +Dimension MathParInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy1(mi.base, "textnormal"); MathGridInset::metrics(mi); + return dim_; } diff --git a/src/mathed/math_parinset.h b/src/mathed/math_parinset.h index aa3f40ffbc..1465d0739d 100644 --- a/src/mathed/math_parinset.h +++ b/src/mathed/math_parinset.h @@ -13,7 +13,7 @@ public: /// mode_type currentMode() const { return TEXT_MODE; } /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 56b89b58f1..54bc695110 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -56,7 +56,6 @@ following hack as starting point to write some macros: #include "math_stringinset.h" #include "math_support.h" #include "math_tabularinset.h" -#include "math_xyarrowinset.h" //#include "insets/insetref.h" #include "ref_inset.h" @@ -1132,11 +1131,6 @@ void Parser::parse1(MathGridInset & grid, unsigned flags, parse2(cell->back(), FLAG_ITEM, mode, false); } - else if (t.cs() == "xymatrix") { - cell->push_back(createMathInset(t.cs())); - parse2(cell->back(), FLAG_ITEM, mode, false); - } - else if (t.cs() == "framebox" || t.cs() == "makebox") { cell->push_back(createMathInset(t.cs())); parse(cell->back().nucleus()->cell(0), FLAG_OPTION, MathInset::TEXT_MODE); diff --git a/src/mathed/math_rootinset.C b/src/mathed/math_rootinset.C index cd56b6b0db..48fc1375f8 100644 --- a/src/mathed/math_rootinset.C +++ b/src/mathed/math_rootinset.C @@ -31,13 +31,14 @@ MathInset * MathRootInset::clone() const } -void MathRootInset::metrics(MetricsInfo & mi) const +Dimension MathRootInset::metrics(MetricsInfo & mi) const { MathNestInset::metrics(mi); dim_.asc = max(cell(0).ascent() + 5, cell(1).ascent()) + 2; dim_.des = max(cell(1).descent() + 5, cell(0).descent()) + 2; dim_.wid = cell(0).width() + cell(1).width() + 10; - metricsMarkers(); + metricsMarkers(1); + return dim_; } @@ -48,16 +49,16 @@ void MathRootInset::draw(PainterInfo & pi, int x, int y) const cell(0).draw(pi, x, y - 5 - cell(0).descent()); // the "base" cell(1).draw(pi, x + w + 8, y); - int const a = ascent(); - int const d = descent(); + int const a = dim_.ascent(); + int const d = dim_.descent(); int xp[5]; int yp[5]; - xp[0] = x + width(); yp[0] = y - a + 1; - xp[1] = x + w + 4; yp[1] = y - a + 1; - xp[2] = x + w; yp[2] = y + d; - xp[3] = x + w - 2; yp[3] = y + (d - a)/2 + 2; - //xp[4] = x; yp[4] = y + (d - a)/2 + 2; - xp[4] = x + w - 5; yp[4] = y + (d - a)/2 + 4; + xp[0] = x + dim_.width(); yp[0] = y - a + 1; + xp[1] = x + w + 4; yp[1] = y - a + 1; + xp[2] = x + w; yp[2] = y + d; + xp[3] = x + w - 2; yp[3] = y + (d - a)/2 + 2; + //xp[4] = x; yp[4] = y + (d - a)/2 + 2; + xp[4] = x + w - 5; yp[4] = y + (d - a)/2 + 4; pi.pain.lines(xp, yp, 5, LColor::math); drawMarkers(pi, x, y); } diff --git a/src/mathed/math_rootinset.h b/src/mathed/math_rootinset.h index d483027fcf..e1293e287b 100644 --- a/src/mathed/math_rootinset.h +++ b/src/mathed/math_rootinset.h @@ -33,7 +33,7 @@ public: /// bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index ea01864bad..c59bf351e4 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -180,7 +180,7 @@ int MathScriptInset::ndes() const } -void MathScriptInset::metrics(MetricsInfo & mi) const +Dimension MathScriptInset::metrics(MetricsInfo & mi) const { cell(2).metrics(mi); ScriptChanger dummy(mi.base); @@ -202,7 +202,8 @@ void MathScriptInset::metrics(MetricsInfo & mi) const } dim_.asc = dy1() + (hasUp() ? up().ascent() : 0); dim_.des = dy0() + (hasDown() ? down().descent() : 0); - metricsMarkers2(); + metricsMarkers(); + return dim_; } @@ -220,17 +221,17 @@ void MathScriptInset::draw(PainterInfo & pi, int x, int y) const up().draw(pi, x + dx1(), y - dy1()); if (hasDown()) down().draw(pi, x + dx0(), y + dy0()); - drawMarkers2(pi, x, y); + drawMarkers(pi, x, y); } -void MathScriptInset::metricsT(TextMetricsInfo const & mi) const +void MathScriptInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const { if (hasUp()) - up().metricsT(mi); + up().metricsT(mi, dim); if (hasDown()) - down().metricsT(mi); - nuc().metricsT(mi); + down().metricsT(mi, dim); + nuc().metricsT(mi, dim); } diff --git a/src/mathed/math_scriptinset.h b/src/mathed/math_scriptinset.h index 38bdebb1f4..50a409b799 100644 --- a/src/mathed/math_scriptinset.h +++ b/src/mathed/math_scriptinset.h @@ -22,11 +22,11 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// - void metricsT(TextMetricsInfo const & mi) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// void drawT(TextPainter & pi, int x, int y) const; diff --git a/src/mathed/math_sizeinset.C b/src/mathed/math_sizeinset.C index cf9a261f09..409993b270 100644 --- a/src/mathed/math_sizeinset.C +++ b/src/mathed/math_sizeinset.C @@ -21,11 +21,12 @@ MathInset * MathSizeInset::clone() const } -void MathSizeInset::metrics(MetricsInfo & mi) const +Dimension MathSizeInset::metrics(MetricsInfo & mi) const { StyleChanger dummy(mi.base, style_); - dim_ = cell(0).metrics(mi); - metricsMarkers2(); + cell(0).metrics(mi, dim_); + metricsMarkers(); + return dim_; } @@ -33,7 +34,7 @@ void MathSizeInset::draw(PainterInfo & pi, int x, int y) const { StyleChanger dummy(pi.base, style_); cell(0).draw(pi, x + 1, y); - drawMarkers2(pi, x, y); + drawMarkers(pi, x, y); } diff --git a/src/mathed/math_sizeinset.h b/src/mathed/math_sizeinset.h index 70c56c3641..1b14135d01 100644 --- a/src/mathed/math_sizeinset.h +++ b/src/mathed/math_sizeinset.h @@ -23,7 +23,7 @@ public: /// we write extra braces in any case... bool extraBraces() const { return true; } /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index 1dda4d5352..c346e45a25 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -38,23 +38,25 @@ MathInset * MathSpaceInset::clone() const } -void MathSpaceInset::metrics(MetricsInfo &) const +Dimension MathSpaceInset::metrics(MetricsInfo &) const { + Dimension dim; switch (space_) { - case 0: dim_.wid = 6; break; - case 1: dim_.wid = 8; break; - case 2: dim_.wid = 10; break; - case 3: dim_.wid = 6; break; - case 4: dim_.wid = 8; break; - case 5: dim_.wid = 10; break; - case 6: dim_.wid = 20; break; - case 7: dim_.wid = 40; break; - case 8: dim_.wid = -2; break; - case 9: dim_.wid = 2; break; - default: dim_.wid = 6; + case 0: dim.wid = 6; break; + case 1: dim.wid = 8; break; + case 2: dim.wid = 10; break; + case 3: dim.wid = 6; break; + case 4: dim.wid = 8; break; + case 5: dim.wid = 10; break; + case 6: dim.wid = 20; break; + case 7: dim.wid = 40; break; + case 8: dim.wid = -2; break; + case 9: dim.wid = 2; break; + default: dim.wid = 6; } - dim_.asc = 4; - dim_.des = 0; + dim.asc = 4; + dim.des = 0; + return dim; } @@ -69,10 +71,10 @@ void MathSpaceInset::draw(PainterInfo & pi, int x, int y) const int xp[4]; int yp[4]; - xp[0] = ++x; yp[0] = y - 3; - xp[1] = x; yp[1] = y; - xp[2] = x + width() - 2; yp[2] = y; - xp[3] = x + width() - 2; yp[3] = y - 3; + xp[0] = ++x; yp[0] = y - 3; + xp[1] = x; yp[1] = y; + xp[2] = x + pi.width - 2; yp[2] = y; + xp[3] = x + pi.width - 2; yp[3] = y - 3; pi.pain.lines(xp, yp, 4, (space_ < 3) ? LColor::latex : LColor::math); } diff --git a/src/mathed/math_spaceinset.h b/src/mathed/math_spaceinset.h index c22c05fc53..e3e14900fb 100644 --- a/src/mathed/math_spaceinset.h +++ b/src/mathed/math_spaceinset.h @@ -2,11 +2,11 @@ #ifndef MATH_SPACEINSET_H #define MATH_SPACEINSET_H -#include "math_diminset.h" +#include "math_inset.h" /// Smart spaces -class MathSpaceInset : public MathDimInset { +class MathSpaceInset : public MathInset { public: /// explicit MathSpaceInset(int sp); @@ -21,7 +21,7 @@ public: /// void incSpace(); /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/math_sqrtinset.C b/src/mathed/math_sqrtinset.C index de320a9c5d..2969c6b21d 100644 --- a/src/mathed/math_sqrtinset.C +++ b/src/mathed/math_sqrtinset.C @@ -17,38 +17,38 @@ MathInset * MathSqrtInset::clone() const } -void MathSqrtInset::metrics(MetricsInfo & mi) const +Dimension MathSqrtInset::metrics(MetricsInfo & mi) const { - cell(0).metrics(mi); - dim_.asc = cell(0).ascent() + 4; - dim_.des = cell(0).descent() + 2; - dim_.wid = cell(0).width() + 12; - metricsMarkers(); + cell(0).metrics(mi, dim_); + dim_.asc += 4; + dim_.des += 2; + dim_.wid += 12; + metricsMarkers(1); + return dim_; } void MathSqrtInset::draw(PainterInfo & pi, int x, int y) const { cell(0).draw(pi, x + 10, y); - int const a = ascent(); - int const d = descent(); + int const a = dim_.ascent(); + int const d = dim_.descent(); int xp[4]; int yp[4]; - xp[0] = x + width(); yp[0] = y - a + 1; - xp[1] = x + 8; yp[1] = y - a + 1; - xp[2] = x + 5; yp[2] = y + d - 1; - xp[3] = x; yp[3] = y + (d - a)/2; + xp[0] = x + dim_.width(); yp[0] = y - a + 1; + xp[1] = x + 8; yp[1] = y - a + 1; + xp[2] = x + 5; yp[2] = y + d - 1; + xp[3] = x; yp[3] = y + (d - a)/2; pi.pain.lines(xp, yp, 4, LColor::math); drawMarkers(pi, x, y); } -void MathSqrtInset::metricsT(TextMetricsInfo const & mi) const +void MathSqrtInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const { - cell(0).metricsT(mi); - dim_.asc = cell(0).ascent() + 1; - dim_.des = cell(0).descent(); - dim_.wid = cell(0).width() + 2; + cell(0).metricsT(mi, dim); + dim.asc += 1; + dim.wid += 2; } diff --git a/src/mathed/math_sqrtinset.h b/src/mathed/math_sqrtinset.h index d9cdcfd261..68c490925b 100644 --- a/src/mathed/math_sqrtinset.h +++ b/src/mathed/math_sqrtinset.h @@ -19,11 +19,11 @@ public: /// void draw(PainterInfo &, int x, int y) const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void drawT(TextPainter &, int x, int y) const; /// - void metricsT(TextMetricsInfo const & mi) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// void write(WriteStream & os) const; diff --git a/src/mathed/math_stackrelinset.C b/src/mathed/math_stackrelinset.C index 760903a3a7..621f07fd0e 100644 --- a/src/mathed/math_stackrelinset.C +++ b/src/mathed/math_stackrelinset.C @@ -17,7 +17,7 @@ MathInset * MathStackrelInset::clone() const } -void MathStackrelInset::metrics(MetricsInfo & mi) const +Dimension MathStackrelInset::metrics(MetricsInfo & mi) const { cell(1).metrics(mi); FracChanger dummy(mi.base); @@ -25,16 +25,19 @@ void MathStackrelInset::metrics(MetricsInfo & mi) const dim_.wid = max(cell(0).width(), cell(1).width()) + 4; dim_.asc = cell(1).ascent() + cell(0).height() + 4; dim_.des = cell(1).descent(); + metricsMarkers(); + return dim_; } void MathStackrelInset::draw(PainterInfo & pi, int x, int y) const { - int m = x + width() / 2; + int m = x + dim_.width() / 2; int yo = y - cell(1).ascent() - cell(0).descent() - 1; cell(1).draw(pi, m - cell(1).width() / 2, y); FracChanger dummy(pi.base); cell(0).draw(pi, m - cell(0).width() / 2, yo); + drawMarkers(pi, x, y); } diff --git a/src/mathed/math_stackrelinset.h b/src/mathed/math_stackrelinset.h index 96755245da..0050a224ab 100644 --- a/src/mathed/math_stackrelinset.h +++ b/src/mathed/math_stackrelinset.h @@ -17,7 +17,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/math_stringinset.C b/src/mathed/math_stringinset.C index d8a37291bb..0dc71e7bb6 100644 --- a/src/mathed/math_stringinset.C +++ b/src/mathed/math_stringinset.C @@ -19,9 +19,11 @@ MathInset * MathStringInset::clone() const } -void MathStringInset::metrics(MetricsInfo & mi) const +Dimension MathStringInset::metrics(MetricsInfo & mi) const { - mathed_string_dim(mi.base.font, str_, dim_); + Dimension dim; + mathed_string_dim(mi.base.font, str_, dim); + return dim; } diff --git a/src/mathed/math_stringinset.h b/src/mathed/math_stringinset.h index 47d0613c36..1345a5acde 100644 --- a/src/mathed/math_stringinset.h +++ b/src/mathed/math_stringinset.h @@ -2,7 +2,7 @@ #ifndef MATH_STRINGINSET_H #define MATH_STRINGINSET_H -#include "math_diminset.h" +#include "math_inset.h" /** Some collection of chars with similar properties @@ -12,14 +12,14 @@ * Full author contact details are available in file CREDITS */ -class MathStringInset : public MathDimInset { +class MathStringInset : public MathInset { public: /// explicit MathStringInset(string const & s); /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_substackinset.C b/src/mathed/math_substackinset.C index 81099479df..bd4cf9eaf2 100644 --- a/src/mathed/math_substackinset.C +++ b/src/mathed/math_substackinset.C @@ -17,7 +17,7 @@ MathInset * MathSubstackInset::clone() const } -void MathSubstackInset::metrics(MetricsInfo & mi) const +Dimension MathSubstackInset::metrics(MetricsInfo & mi) const { if (mi.base.style == LM_ST_DISPLAY) { StyleChanger dummy(mi.base, LM_ST_TEXT); @@ -25,14 +25,15 @@ void MathSubstackInset::metrics(MetricsInfo & mi) const } else { MathGridInset::metrics(mi); } - metricsMarkers2(); + metricsMarkers(); + return dim_; } void MathSubstackInset::draw(PainterInfo & pi, int x, int y) const { MathGridInset::draw(pi, x + 1, y); - drawMarkers2(pi, x, y); + drawMarkers(pi, x, y); } diff --git a/src/mathed/math_substackinset.h b/src/mathed/math_substackinset.h index ad2c3a26e6..1e152c1567 100644 --- a/src/mathed/math_substackinset.h +++ b/src/mathed/math_substackinset.h @@ -14,7 +14,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_support.C b/src/mathed/math_support.C index f85f7f62b5..804e38b554 100644 --- a/src/mathed/math_support.C +++ b/src/mathed/math_support.C @@ -3,7 +3,6 @@ #include "math_support.h" #include "lyxfont.h" -#include "math_cursor.h" #include "math_inset.h" #include "math_parser.h" #include "metricsinfo.h" @@ -465,14 +464,6 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h, } -void mathed_draw_framebox(PainterInfo & pi, int x, int y, MathInset const * p) -{ - if (mathcursor && mathcursor->isInside(p)) - pi.pain.rectangle(x, y - p->ascent(), p->width(), p->height(), - LColor::mathframe); -} - - // In the future maybe we use a better fonts renderer void drawStr(PainterInfo & pi, LyXFont const & font, int x, int y, string const & str) diff --git a/src/mathed/math_support.h b/src/mathed/math_support.h index 722f983328..b6a275dcb9 100644 --- a/src/mathed/math_support.h +++ b/src/mathed/math_support.h @@ -7,7 +7,6 @@ #include "LString.h" class PainterInfo; -class MathInset; class LyXFont; class Dimension; @@ -19,8 +18,6 @@ int mathed_char_descent(LyXFont const &, unsigned char c); void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h, string const & name); -void mathed_draw_framebox(PainterInfo & pi, int x, int y, MathInset const *); - void mathed_string_dim(LyXFont const & font, string const & s, Dimension & dim); int mathed_string_width(LyXFont const &, string const & s); diff --git a/src/mathed/math_symbolinset.C b/src/mathed/math_symbolinset.C index 6e4d71b7ff..99b823ad49 100644 --- a/src/mathed/math_symbolinset.C +++ b/src/mathed/math_symbolinset.C @@ -9,6 +9,7 @@ #include "LaTeXFeatures.h" #include "debug.h" + MathSymbolInset::MathSymbolInset(const latexkeys * l) : sym_(l), h_(0) {} @@ -37,32 +38,35 @@ string MathSymbolInset::name() const } -void MathSymbolInset::metrics(MetricsInfo & mi) const +Dimension MathSymbolInset::metrics(MetricsInfo & mi) const { //lyxerr << "metrics: symbol: '" << sym_->name // << "' in font: '" << sym_->inset // << "' drawn as: '" << sym_->draw // << "'\n"; + Dimension dim; int const em = mathed_char_width(mi.base.font, 'M'); FontSetChanger dummy(mi.base, sym_->inset.c_str()); - mathed_string_dim(mi.base.font, sym_->draw, dim_); + mathed_string_dim(mi.base.font, sym_->draw, dim); // correct height for broken cmex and wasy font if (sym_->inset == "cmex" || sym_->inset == "wasy") { - h_ = 4 * dim_.des / 5; - dim_.asc += h_; - dim_.des -= h_; + h_ = 4 * dim.des / 5; + dim.asc += h_; + dim.des -= h_; } // seperate things a bit if (isRelOp()) - dim_.wid += static_cast(0.5*em+0.5); + dim.wid += static_cast(0.5 * em + 0.5); else - dim_.wid += static_cast(0.1667*em+0.5); + dim.wid += static_cast(0.1667 * em + 0.5); scriptable_ = false; if (mi.base.style == LM_ST_DISPLAY) if (sym_->inset == "cmex" || sym_->extra == "funclim") scriptable_ = true; + + return dim; } diff --git a/src/mathed/math_symbolinset.h b/src/mathed/math_symbolinset.h index a26f54d030..4fbe359f86 100644 --- a/src/mathed/math_symbolinset.h +++ b/src/mathed/math_symbolinset.h @@ -2,15 +2,15 @@ #ifndef MATH_SYMBOLINSET_H #define MATH_SYMBOLINSET_H - -#include "math_diminset.h" +#include "math_inset.h" struct latexkeys; + // "normal" symbols that don't take limits and don't grow in displayed // formulae -class MathSymbolInset : public MathDimInset { +class MathSymbolInset : public MathInset { public: /// explicit MathSymbolInset(latexkeys const *); @@ -21,7 +21,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/math_tabularinset.C b/src/mathed/math_tabularinset.C index 2e8282ec03..95be73efcb 100644 --- a/src/mathed/math_tabularinset.C +++ b/src/mathed/math_tabularinset.C @@ -39,10 +39,10 @@ MathInset * MathTabularInset::clone() const } -void MathTabularInset::metrics(MetricsInfo & mi) const +Dimension MathTabularInset::metrics(MetricsInfo & mi) const { FontSetChanger dummy(mi.base, "textnormal"); - MathGridInset::metrics(mi); + return MathGridInset::metrics(mi); } diff --git a/src/mathed/math_tabularinset.h b/src/mathed/math_tabularinset.h index bf530309ba..35426e2dc7 100644 --- a/src/mathed/math_tabularinset.h +++ b/src/mathed/math_tabularinset.h @@ -25,7 +25,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_textinset.C b/src/mathed/math_textinset.C index d67dbb19d7..965cdb087a 100644 --- a/src/mathed/math_textinset.C +++ b/src/mathed/math_textinset.C @@ -57,7 +57,7 @@ bool MathTextInset::idxUpDown2(idx_type &, pos_type & pos, bool up, } -void MathTextInset::metrics(MetricsInfo & mi) const +Dimension MathTextInset::metrics(MetricsInfo & mi) const { cell(0).metrics(mi); @@ -95,14 +95,14 @@ void MathTextInset::metrics(MetricsInfo & mi) const safepos = i; ++spaces; // restart chunk with size of the space - curr = cell(0)[i]->width(); + curr = cell(0)[i].width_; continue; } if (c != '\n') { // This is a regular char. Go on if we either don't care for // the width limit or have not reached that limit. - curr += cell(0)[i]->width(); + curr += cell(0)[i].width_; if (!mi.base.restrictwidth || curr + safe <= mi.base.textwidth) continue; } @@ -151,14 +151,14 @@ void MathTextInset::metrics(MetricsInfo & mi) const //lyxerr << "last line: " << ar.data() << "\n"; // what to report? - cache_.metrics(mi); - dim_ = cache_.dimensions(); + dim_ = cache_.metrics(mi); //lyxerr << "outer dim: " << dim_ << endl; // reset position cache for (idx_type i = 0; i < cache_.nargs(); ++i) cache_.cell(i).setXY(old_xo, old_yo); + return dim_; } diff --git a/src/mathed/math_textinset.h b/src/mathed/math_textinset.h index c5fb02531f..d44144d402 100644 --- a/src/mathed/math_textinset.h +++ b/src/mathed/math_textinset.h @@ -15,7 +15,7 @@ public: /// get cursor position void getPos(idx_type idx, pos_type pos, int & x, int & y) const; /// this stores metrics information in cache_ - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// draw according to cached metrics void draw(PainterInfo &, int x, int y) const; /// draw selection background diff --git a/src/mathed/math_undersetinset.C b/src/mathed/math_undersetinset.C index 07968726b5..f04e2dfeec 100644 --- a/src/mathed/math_undersetinset.C +++ b/src/mathed/math_undersetinset.C @@ -17,7 +17,7 @@ MathInset * MathUndersetInset::clone() const } -void MathUndersetInset::metrics(MetricsInfo & mi) const +Dimension MathUndersetInset::metrics(MetricsInfo & mi) const { cell(1).metrics(mi); FracChanger dummy(mi.base); @@ -25,12 +25,13 @@ void MathUndersetInset::metrics(MetricsInfo & mi) const dim_.wid = max(cell(0).width(), cell(1).width()) + 4; dim_.asc = cell(1).ascent(); dim_.des = cell(1).descent() + cell(0).height() + 4; + return dim_; } void MathUndersetInset::draw(PainterInfo & pi, int x, int y) const { - int m = x + width() / 2; + int m = x + pi.width / 2; int yo = y + cell(1).descent() + cell(0).ascent() + 1; cell(1).draw(pi, m - cell(1).width() / 2, y); FracChanger dummy(pi.base); diff --git a/src/mathed/math_undersetinset.h b/src/mathed/math_undersetinset.h index 8c24e47701..95b68921a2 100644 --- a/src/mathed/math_undersetinset.h +++ b/src/mathed/math_undersetinset.h @@ -20,9 +20,9 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & st) const; + Dimension metrics(MetricsInfo & mi) const; /// - void draw(PainterInfo &, int x, int y) const; + void draw(PainterInfo & pi, int x, int y) const; /// void write(WriteStream & os) const; diff --git a/src/mathed/math_unknowninset.C b/src/mathed/math_unknowninset.C index c350985a73..6d5e446a13 100644 --- a/src/mathed/math_unknowninset.C +++ b/src/mathed/math_unknowninset.C @@ -1,6 +1,5 @@ #include - #include "math_unknowninset.h" #include "math_support.h" #include "math_mathmlstream.h" @@ -43,9 +42,11 @@ void MathUnknownInset::normalize(NormalStream & os) const } -void MathUnknownInset::metrics(MetricsInfo & mi) const +Dimension MathUnknownInset::metrics(MetricsInfo & mi) const { - mathed_string_dim(mi.base.font, name_, dim_); + Dimension dim; + mathed_string_dim(mi.base.font, name_, dim); + return dim; } diff --git a/src/mathed/math_unknowninset.h b/src/mathed/math_unknowninset.h index 99df75a64f..eff59df80f 100644 --- a/src/mathed/math_unknowninset.h +++ b/src/mathed/math_unknowninset.h @@ -4,7 +4,6 @@ #include "math_diminset.h" - /** Unknowntions or LaTeX names for objects that we really don't know */ @@ -16,7 +15,7 @@ public: /// MathInset * clone() const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/math_xarrowinset.C b/src/mathed/math_xarrowinset.C index 84951c97de..8bbf0497e2 100644 --- a/src/mathed/math_xarrowinset.C +++ b/src/mathed/math_xarrowinset.C @@ -1,6 +1,5 @@ #include - #include "math_xarrowinset.h" #include "math_support.h" #include "math_parser.h" @@ -19,7 +18,7 @@ MathInset * MathXArrowInset::clone() const } -void MathXArrowInset::metrics(MetricsInfo & mi) const +Dimension MathXArrowInset::metrics(MetricsInfo & mi) const { ScriptChanger dummy(mi.base); cell(0).metrics(mi); @@ -27,6 +26,7 @@ void MathXArrowInset::metrics(MetricsInfo & mi) const dim_.wid = std::max(cell(0).width(), cell(1).width()) + 10; dim_.asc = cell(0).height() + 10; dim_.des = cell(1).height(); + return dim_; } @@ -35,7 +35,7 @@ void MathXArrowInset::draw(PainterInfo & pi, int x, int y) const ScriptChanger dummy(pi.base); cell(0).draw(pi, x + 5, y - 10); cell(1).draw(pi, x + 5, y + cell(1).height()); - mathed_draw_deco(pi, x + 1, y - 7, width() - 2, 5, name_); + mathed_draw_deco(pi, x + 1, y - 7, pi.width - 2, 5, name_); } diff --git a/src/mathed/math_xarrowinset.h b/src/mathed/math_xarrowinset.h index be7d4efa8f..302ba78cfe 100644 --- a/src/mathed/math_xarrowinset.h +++ b/src/mathed/math_xarrowinset.h @@ -23,7 +23,7 @@ public: /// void write(WriteStream & os) const; /// - void metrics(MetricsInfo & mi) const; + Dimension metrics(MetricsInfo & mi) const; /// void normalize(NormalStream & os) const; diff --git a/src/mathed/math_xymatrixinset.C b/src/mathed/math_xymatrixinset.C deleted file mode 100644 index 46da10ee96..0000000000 --- a/src/mathed/math_xymatrixinset.C +++ /dev/null @@ -1,62 +0,0 @@ -#include - - -#include "math_xymatrixinset.h" -#include "math_mathmlstream.h" -#include "math_streamstr.h" - - -MathXYMatrixInset::MathXYMatrixInset() - : MathGridInset(1, 1) -{} - - -MathInset * MathXYMatrixInset::clone() const -{ - return new MathXYMatrixInset(*this); -} - - -int MathXYMatrixInset::colsep() const -{ - return 40; -} - - -int MathXYMatrixInset::rowsep() const -{ - return 40; -} - - -void MathXYMatrixInset::metrics(MetricsInfo & st) const -{ - MetricsInfo mi = st; - if (mi.base.style == LM_ST_DISPLAY) - mi.base.style = LM_ST_TEXT; - MathGridInset::metrics(mi); -} - - -void MathXYMatrixInset::write(WriteStream & os) const -{ - os << "\\xymatrix{"; - MathGridInset::write(os); - os << "}\n"; -} - - -void MathXYMatrixInset::normalize(NormalStream & os) const -{ - os << "[xymatrix "; - MathGridInset::normalize(os); - os << ']'; -} - - -void MathXYMatrixInset::maple(MapleStream & os) const -{ - os << "xymatrix("; - MathGridInset::maple(os); - os << ')'; -} diff --git a/src/mathed/math_xymatrixinset.h b/src/mathed/math_xymatrixinset.h deleted file mode 100644 index 0311047bc1..0000000000 --- a/src/mathed/math_xymatrixinset.h +++ /dev/null @@ -1,34 +0,0 @@ -// -*- C++ -*- -#ifndef MATH_XYMATRIX_H -#define MATH_XYMATRIX_H - -#include "math_gridinset.h" - - - -class MathXYMatrixInset : public MathGridInset { -public: - /// - MathXYMatrixInset(); - /// - MathInset * clone() const; - /// - void metrics(MetricsInfo & st) const; - /// - MathXYMatrixInset const * asXYMatrixInset() const { return this; } - /// - virtual int colsep() const; - /// - virtual int rowsep() const; - - /// - void normalize(); - /// - void write(WriteStream & os) const; - /// - void normalize(NormalStream &) const; - /// - void maple(MapleStream &) const; -}; - -#endif diff --git a/src/metricsinfo.C b/src/metricsinfo.C index 34b504fd3d..1a66b53eb0 100644 --- a/src/metricsinfo.C +++ b/src/metricsinfo.C @@ -5,11 +5,12 @@ #include "mathed/math_support.h" #include "frontends/Painter.h" #include "debug.h" +#include "BufferView.h" MetricsBase::MetricsBase() - : font(), style(LM_ST_TEXT), fontname("mathnormal"), + : bv(0), font(), style(LM_ST_TEXT), fontname("mathnormal"), restrictwidth(false), textwidth(0) {} @@ -17,15 +18,16 @@ MetricsBase::MetricsBase() MetricsInfo::MetricsInfo() - : fullredraw(false) {} -PainterInfo::PainterInfo(Painter & p) - : pain(p) -{} +PainterInfo::PainterInfo(BufferView * bv) + : pain(bv->painter()) +{ + base.bv = bv; +} void PainterInfo::draw(int x, int y, char c) @@ -42,11 +44,9 @@ Styles smallerScriptStyle(Styles st) return LM_ST_SCRIPT; case LM_ST_SCRIPT: case LM_ST_SCRIPTSCRIPT: + default: // shut up compiler return LM_ST_SCRIPTSCRIPT; } - // shut up compiler - lyxerr << "should not happen\n"; - return LM_ST_DISPLAY; } ScriptChanger::ScriptChanger(MetricsBase & mb) @@ -64,13 +64,12 @@ Styles smallerFracStyle(Styles st) return LM_ST_SCRIPT; case LM_ST_SCRIPT: case LM_ST_SCRIPTSCRIPT: + default: // shut up compiler return LM_ST_SCRIPTSCRIPT; } - // shut up compiler - lyxerr << "should not happen\n"; - return LM_ST_DISPLAY; } + FracChanger::FracChanger(MetricsBase & mb) : StyleChanger(mb, smallerFracStyle(mb.style)) {} diff --git a/src/metricsinfo.h b/src/metricsinfo.h index c1acab6a67..c626956491 100644 --- a/src/metricsinfo.h +++ b/src/metricsinfo.h @@ -1,11 +1,11 @@ #ifndef METRICSINFO_H #define METRICSINFO_H - #include "lyxfont.h" #include "LString.h" class Painter; +class BufferView; /// Standard Sizes (mode styles) @@ -28,11 +28,13 @@ struct MetricsBase { /// MetricsBase(); - /// + /// the current view + BufferView * bv; + /// current font LyXFont font; - /// + /// current math style (display/text/script/..) Styles style; - /// + /// name of current font string fontname; /// if this is set... bool restrictwidth; @@ -51,8 +53,6 @@ struct MetricsInfo { /// MetricsBase base; - /// - bool fullredraw; }; @@ -62,7 +62,7 @@ struct MetricsInfo { // struct PainterInfo { /// - PainterInfo(Painter & pain); + explicit PainterInfo(BufferView * bv); /// void draw(int x, int y, char c); @@ -70,6 +70,8 @@ struct PainterInfo { MetricsBase base; /// Painter & pain; + /// width of current item + int width; }; diff --git a/src/text3.C b/src/text3.C index 98998c59ad..6da72b34b1 100644 --- a/src/text3.C +++ b/src/text3.C @@ -608,7 +608,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) && isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) { Inset * tmpinset = cursor.par()->getInset(cursor.pos()); cmd.message(tmpinset->editMessage()); - FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "left" : "right"); + FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "right" : "left"); tmpinset->localDispatch(cmd1); break; } @@ -634,7 +634,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) { Inset * tmpinset = cursor.par()->getInset(cursor.pos()); cmd.message(tmpinset->editMessage()); - FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "right" : "left"); + FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "left" : "right"); tmpinset->localDispatch(cmd1); break; }