]> git.lyx.org Git - lyx.git/commitdiff
IU for second phase of two-phase drawing
authorAndré Pönitz <poenitz@gmx.net>
Fri, 30 May 2003 06:48:24 +0000 (06:48 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 30 May 2003 06:48:24 +0000 (06:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7067 a592a061-630c-0410-9148-cb99ea01b6c8

40 files changed:
src/ChangeLog
src/insets/ChangeLog
src/insets/inset.h
src/insets/insetbase.h
src/insets/insetbutton.C
src/insets/insetbutton.h
src/insets/insetcaption.C
src/insets/insetcaption.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/insets/insetnewline.C
src/insets/insetnewline.h
src/insets/insetquotes.C
src/insets/insetquotes.h
src/insets/insetspace.C
src/insets/insetspace.h
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/updatableinset.C
src/insets/updatableinset.h
src/mathed/formula.C
src/mathed/formula.h
src/mathed/formulabase.h
src/mathed/formulamacro.C
src/mathed/formulamacro.h
src/rowpainter.C

index 805793496ec0a4a99cc42f44b11def918c97d715..c69e281f37c72a3a8cfb3c0e6377bc1819b69fc0 100644 (file)
@@ -1,3 +1,7 @@
+2003-05-30  André Pönitz  <poenitz@gmx.net>
+
+       * rowpainter.C: unify second drawing phase
+
 2003-05-29  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * trans_mgr.C: remove one case of current_view
index cf73cf8d448c52030634223cf2bef07b195d7dbc..c09097b85c05220c9f77f42600319a291f8f9aeb 100644 (file)
@@ -1,3 +1,24 @@
+
+2003-05-30  André Pönitz  <poenitz@gmx.net>
+
+       * inset.h:
+       * insetbase.h:
+       * insetbutton.[Ch]:
+       * insetcaption.[Ch]:
+       * insetcollapsable.[Ch]:
+       * inseterror.[Ch]:
+       * insetert.[Ch]:
+       * insetgraphics.[Ch]:
+       * insetinclude.[Ch]:
+       * insetlatexaccent.[Ch]:
+       * insetnewline.[Ch]:
+       * insetquotes.[Ch]:
+       * insetspace.[Ch]:
+       * insetspecialchar.[Ch]:
+       * insettabular.[Ch]:
+       * insettext.[Ch]:
+       * updatableinset.[Ch]: unify second drawing phase
+
 2003-05-30  John Levon  <levon@movementarian.org>
 
        * insetgraphics.C: fix a bformat
index 4cbf3e471938bb963e15c011cb5b945dbd11526e..b4f82328bb042be6add25f667bc54afca1a55549 100644 (file)
@@ -167,8 +167,6 @@ public:
        int descent(BufferView *, LyXFont const &) const;
        ///
        int width(BufferView *, LyXFont const &) const;
-       ///
-       virtual void draw(BufferView *, LyXFont const &, int baseline, float & x) const = 0;
        /// update the inset representation
        virtual void update(BufferView *, bool = false)
                {}
index c6dc34894ee7e0b175c478e42ec093160104a512..52b5ec824b281fa5c9d613a7ac5407296fde4ba8 100644 (file)
@@ -16,6 +16,8 @@
 
 class BufferView;
 class FuncRequest;
+class MetricsInfo;
+class PainterInfo;
 
 /** Dispatch result codes
                DISPATCHED          = the inset catched the action
@@ -62,6 +64,8 @@ public:
 
        /// small wrapper for the time being
        virtual dispatch_result localDispatch(FuncRequest const & cmd);
+       ///
+       virtual void draw(PainterInfo & pi, int x, int y) const = 0;
 
        ///
        virtual ~InsetBase() {}
index bac1e65c343a954e8621fdf1cce931cb0675de69..5310940d6c17daefa3f21396d2fa274b91192796 100644 (file)
@@ -21,6 +21,7 @@
 #include "frontends/Painter.h"
 #include "support/LAssert.h"
 #include "lyxfont.h"
+#include "metricsinfo.h"
 #include "frontends/font_metrics.h"
 
 using std::ostream;
@@ -46,27 +47,23 @@ void InsetButton::dimension(BufferView * bv, LyXFont const &,
 }
 
 
-void InsetButton::draw(BufferView * bv, LyXFont const &,
-                       int baseline, float & x) const
+void InsetButton::draw(PainterInfo & pi, int x, int y) const
 {
-       lyx::Assert(bv);
-       cache(bv);
+       lyx::Assert(pi.base.bv);
+       cache(pi.base.bv);
 
-       Painter & pain = bv->painter();
        // Draw it as a box with the LaTeX text
        LyXFont font(LyXFont::ALL_SANE);
        font.setColor(LColor::command).decSize();
 
-       string const s = getScreenLabel(bv->buffer());
+       string const s = getScreenLabel(pi.base.bv->buffer());
 
        if (editable()) {
-               pain.buttonText(int(x) + 2, baseline, s, font);
+               pi.pain.buttonText(x + 2, y, s, font);
        } else {
-               pain.rectText(int(x) + 2, baseline, s, font,
+               pi.pain.rectText(x + 2, y, s, font,
                              LColor::commandbg, LColor::commandframe);
        }
-
-       x += width(bv, font);
 }
 
 
index 821d8683776183a21c4041a807300728940c654b..beb127761c9dd657386433907ba51783c6ac847d 100644 (file)
@@ -25,7 +25,7 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
        dispatch_result localDispatch(FuncRequest const & cmd);
 
index da5afffce716705b8a31ece1ea912644194283db..0da530552d4b4ed79b684e04792a88849dedbe45 100644 (file)
@@ -21,6 +21,7 @@
 #include "debug.h"
 #include "gettext.h"
 #include "Lsstream.h"
+#include "metricsinfo.h"
 #include "support/lstrings.h"
 #include "support/LAssert.h"
 #include "support/BoostFormat.h"
@@ -66,8 +67,7 @@ string const InsetCaption::editMessage() const
 }
 
 
-void InsetCaption::draw(BufferView * bv, LyXFont const & f,
-                       int baseline, float & x) const
+void InsetCaption::draw(PainterInfo & pi, int x, int y) const
 {
        // We must draw the label, we should get the label string
        // from the enclosing float inset.
@@ -88,7 +88,7 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
                lyx::Assert(0);
 
        FloatList const & floats =
-               bv->buffer()->params.getLyXTextClass().floats();
+               pi.base.bv->buffer()->params.getLyXTextClass().floats();
        string const fl = i2 ? floats.getType(type).name() : N_("Float");
 
        // Discover the number...
@@ -96,12 +96,9 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
 
        // Generate the label
        string const label = bformat("%1$s %2$s:", _(fl), num);
-       Painter & pain = bv->painter();
-       int const w = font_metrics::width(label, f);
-       pain.text(int(x), baseline, label, f);
-       x += w;
-
-       InsetText::draw(bv, f, baseline, x);
+       int const w = font_metrics::width(label, pi.base.font);
+       pi.pain.text(x, y, label, pi.base.font);
+       InsetText::draw(pi, x + w, y);
 }
 
 
index af616f662894dff6327f7d40419527b7e5dd440c..83da8b22b10c4b99866bf843c07ef8a818ad842a 100644 (file)
@@ -34,8 +34,7 @@ public:
        ///
        virtual string const editMessage() const;
        ///
-       virtual void draw(BufferView * bv, LyXFont const & f,
-                         int baseline, float & x) const;
+       virtual void draw(PainterInfo & pi, int x, int y) const;
        ///
        virtual int latex(Buffer const * buf, std::ostream & os,
                          LatexRunParams const &) const;
index 8d62008e0807f4ce8155fea707dbfde051771a25..b6cae4d6e26d3d0d24a0cfa05542b80d99f04bcd 100644 (file)
@@ -25,6 +25,7 @@
 #include "WordLangTuple.h"
 #include "funcrequest.h"
 #include "buffer.h"
+#include "metricsinfo.h"
 
 #include "frontends/font_metrics.h"
 #include "frontends/Painter.h"
@@ -136,22 +137,16 @@ void InsetCollapsable::dimension(BufferView * bv, LyXFont const & font,
 }
 
 
-void InsetCollapsable::draw_collapsed(Painter & pain,
-                                     int baseline, float & x) const
+void InsetCollapsable::draw_collapsed(PainterInfo & pi, int x, int y) const
 {
-       pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET,
-                       baseline, label, labelfont);
-       Dimension dim;
-       dimension_collapsed(dim);
-       x += dim.wid;
+       pi.pain.buttonText(x + TEXT_TO_INSET_OFFSET, y, label, labelfont);
 }
 
 
-void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
-                            int baseline, float & x, bool inlined) const
+void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
 {
-       lyx::Assert(bv);
-       cache(bv);
+       lyx::Assert(pi.base.bv);
+       cache(pi.base.bv);
 
        if (nodraw())
                return;
@@ -159,45 +154,41 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
        Dimension dim_collapsed;
        dimension_collapsed(dim_collapsed);
 
-       Painter & pain = bv->painter();
-
+       int const aa    = ascent(pi.base.bv, pi.base.font);
        button_length   = dim_collapsed.width();
-       button_top_y    = -ascent(bv, f);
-       button_bottom_y = -ascent(bv, f) + dim_collapsed.height();
+       button_top_y    = -aa;
+       button_bottom_y = -aa + dim_collapsed.height();
 
        if (!isOpen()) {
-               draw_collapsed(pain, baseline, x);
+               draw_collapsed(pi, x, y);
                return;
        }
 
-       float old_x = x;
+       int old_x = x;
 
        if (!owner())
                x += scroll();
 
-       top_x = int(x);
-       top_baseline = baseline;
+       top_x = x;
+       top_baseline = y;
 
-       int const bl = baseline - ascent(bv, f) + dim_collapsed.ascent();
+       int const bl = y - aa + dim_collapsed.ascent();
 
        if (inlined) {
-               inset.draw(bv, f, baseline, x);
+               inset.draw(pi, x, y);
        } else {
-               draw_collapsed(pain, bl, old_x);
-               int const yy = bl + dim_collapsed.descent() + inset.ascent(bv, f);
-               inset.draw(bv, f, yy, x);
-               // contained inset may be shorter than the button
-               if (x < top_x + button_length + TEXT_TO_INSET_OFFSET)
-                       x = top_x + button_length + TEXT_TO_INSET_OFFSET;
+               draw_collapsed(pi, old_x, bl);
+               int const yy = bl + dim_collapsed.descent()
+                       + inset.ascent(pi.base.bv, pi.base.font);
+               inset.draw(pi, x, yy);
        }
 }
 
 
-void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
-                           int baseline, float & x) const
+void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
 {
        // by default, we are not inlined-drawing
-       draw(bv, f, baseline, x, false);
+       draw(pi, x, y, false);
 }
 
 
index b733d9ec6dfd74eecb6a30a659fcbf56b520be14..e7dc0cbaa70da9337a8de76b87b7a9fdf55b2f38 100644 (file)
@@ -47,10 +47,9 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, const LyXFont &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
        /// draw, either inlined (no button) or collapsed/open
-       void draw(BufferView * bv, LyXFont const & f,
-                 int baseline, float & x, bool inlined) const;
+       void draw(PainterInfo & pi, int x, int y, bool inlined) const;
        ///
        void update(BufferView *, bool = false);
        ///
@@ -181,7 +180,7 @@ protected:
        ///
        int height_collapsed() const;
        ///
-       void draw_collapsed(Painter & pain, int, float &) const;
+       void draw_collapsed(PainterInfo & pi, int x, int y) const;
        ///
        int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
 
index a0dd7e9a64fde0de457bab2dc8b19c9905a03a1f..8bc8a7e5bbd1587e513a2dab6a33e993693b2dc3 100644 (file)
@@ -17,6 +17,7 @@
 #include "funcrequest.h"
 #include "gettext.h"
 #include "lyxfont.h"
+#include "metricsinfo.h"
 
 #include "frontends/Dialogs.h"
 #include "frontends/font_metrics.h"
@@ -71,30 +72,24 @@ void InsetError::dimension(BufferView *, LyXFont const & font,
 }
 
 
-void InsetError::draw(BufferView * bv, LyXFont const & font,
-                     int baseline, float & x) const
+void InsetError::draw(PainterInfo & pi, int x, int y) const
 {
-       lyx::Assert(bv);
-       cache(bv);
+       lyx::Assert(pi.base.bv);
+       cache(pi.base.bv);
 
-       Painter & pain = bv->painter();
        LyXFont efont;
-       efont.setSize(font.size()).decSize();
+       efont.setSize(pi.base.font.size()).decSize();
        efont.setColor(LColor::error);
 
        // Draw as "Error" in a framed box
        x += 1;
-       pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
-                         width(bv, font) - 2,
-                         ascent(bv, font) + descent(bv, font) - 2,
-                          LColor::insetbg);
-       pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
-                      width(bv, font) - 2,
-                      ascent(bv, font) + descent(bv, font) - 2,
-                      LColor::error);
-       pain.text(int(x + 2), baseline, _("Error"), efont);
-
-       x +=  width(bv, font) - 1;
+       Dimension dim;
+       dimension(pi.base.bv, pi.base.font, dim);
+       pi.pain.fillRectangle(x, y - dim.asc + 1,
+             dim.wid - 2, dim.asc + dim.des - 2, LColor::insetbg);
+       pi.pain.rectangle(x, y - dim.asc + 1,
+             dim.wid - 2, dim.asc + dim.des - 2, LColor::error);
+       pi.pain.text(x + 2, y, _("Error"), efont);
 }
 
 
index 9dadbee3a3ebd856a176c95fd1a5dcc696c86944..919f6b0cd6e23e501d393f4877fa44f30902994d 100644 (file)
@@ -32,7 +32,7 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
        void write(Buffer const *, std::ostream &) const {}
        ///
index c0fa754a42d0ed946fd4361fc67084bae61de08d..c4141894f0ee4cf834d8dd49ac4a1c46a886f314 100644 (file)
@@ -562,10 +562,9 @@ void InsetERT::dimension(BufferView * bv, LyXFont const & font,
 }
 
 
-void InsetERT::draw(BufferView * bv, LyXFont const & f,
-                   int baseline, float & x) const
+void InsetERT::draw(PainterInfo & pi, int x, int y) const
 {
-       InsetCollapsable::draw(bv, f, baseline, x, inlined());
+       InsetCollapsable::draw(pi, x, y, inlined());
 }
 
 
index 786c6aacb34252011b5f8f89ae9acc463bc6d031..3483cbd2e0f8383c8133e255f3c82489cb03537a 100644 (file)
@@ -101,7 +101,7 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, const LyXFont &, int , float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
        /// set the status of the inset
        void status(BufferView *, ERTStatus const st) const;
        ///
index b250a80fc1bf93ec23653369a5019b7bf257f9e9..c92b5b12ff7770da5723e99a193ef5b6a38b3c98 100644 (file)
@@ -73,7 +73,7 @@ TODO
 #include "Lsstream.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
-#include "Lsstream.h"
+#include "metricsinfo.h"
 
 #include "frontends/lyx_gui.h"
 #include "frontends/Alert.h"
@@ -324,9 +324,9 @@ BufferView * InsetGraphics::view() const
 }
 
 
-void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
-                        int baseline, float & x) const
+void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
 {
+       BufferView * bv = pi.base.bv;
        // MakeAbsPath returns params().filename unchanged if it absolute
        // already.
        string const file_with_path =
@@ -342,22 +342,18 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
        cache_->view = bv->owner()->view();
        int oasc = cache_->old_ascent;
 
-       int ldescent = descent(bv, font);
-       int lascent  = ascent(bv, font);
-       int lwidth   = width(bv, font);
+       Dimension dim;
+       dimension(bv, pi.base.font, dim);
 
        // we may have changed while someone other was drawing us so better
        // to not draw anything as we surely call to redraw ourself soon.
        // This is not a nice thing to do and should be fixed properly somehow.
        // But I still don't know the best way to go. So let's do this like this
        // for now (Jug 20020311)
-       if (lascent != oasc)
+       if (dim.asc != oasc)
                return;
 
        // Make sure now that x is updated upon exit from this routine
-       int old_x = int(x);
-       x += lwidth;
-
        grfx::Params const & gparams = params().as_grfxParams();
 
        if (gparams.display != grfx::NoDisplay &&
@@ -369,26 +365,25 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
 
        // This will draw the graphics. If the graphics has not been loaded yet,
        // we draw just a rectangle.
-       Painter & paint = bv->painter();
 
        if (imageIsDrawable()) {
-               paint.image(old_x + TEXT_TO_INSET_OFFSET, baseline - lascent,
-                           lwidth - 2 * TEXT_TO_INSET_OFFSET, lascent + ldescent,
+               pi.pain.image(x + TEXT_TO_INSET_OFFSET, y - dim.asc,
+                           dim.wid - 2 * TEXT_TO_INSET_OFFSET, dim.asc + dim.des,
                            *cache_->loader.image());
 
        } else {
 
-               paint.rectangle(old_x + TEXT_TO_INSET_OFFSET, baseline - lascent,
-                               lwidth - 2 * TEXT_TO_INSET_OFFSET, lascent + ldescent);
+               pi.pain.rectangle(x + TEXT_TO_INSET_OFFSET, y - dim.asc,
+                               dim.wid - 2 * TEXT_TO_INSET_OFFSET, dim.asc + dim.des);
 
                // Print the file name.
-               LyXFont msgFont(font);
+               LyXFont msgFont = pi.base.font;
                msgFont.setFamily(LyXFont::SANS_FAMILY);
                string const justname = OnlyFilename (params().filename);
                if (!justname.empty()) {
                        msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
-                       paint.text(old_x + TEXT_TO_INSET_OFFSET + 6,
-                                  baseline - font_metrics::maxAscent(msgFont) - 4,
+                       pi.pain.text(x + TEXT_TO_INSET_OFFSET + 6,
+                                  y - font_metrics::maxAscent(msgFont) - 4,
                                   justname, msgFont);
                }
 
@@ -396,7 +391,7 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
                string const msg = statusMessage();
                if (!msg.empty()) {
                        msgFont.setSize(LyXFont::SIZE_TINY);
-                       paint.text(old_x + TEXT_TO_INSET_OFFSET + 6, baseline - 4, msg, msgFont);
+                       pi.pain.text(x + TEXT_TO_INSET_OFFSET + 6, y - 4, msg, msgFont);
                }
        }
 }
index 7a070d1ca9d36193cc611826b02cc6e1f5cef2cb..958dbc64b09db42b2dd50f194940fbc8d6cdf110 100644 (file)
@@ -36,7 +36,7 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
        EDITABLE editable() const;
        ///
index 75a1ca5b43355814aa2e07f18378431daa0bd0f0..5f492c074536dc36dd0bea5d909fea2cd8c5a4d0 100644 (file)
@@ -22,7 +22,8 @@
 #include "Lsstream.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
-#include "Lsstream.h"
+#include "metricsinfo.h"
+#include "dimension.h"
 
 #include "frontends/Dialogs.h"
 #include "frontends/LyXView.h"
@@ -532,28 +533,22 @@ int InsetInclude::width(BufferView * bv, LyXFont const & font) const
 }
 
 
-void InsetInclude::draw(BufferView * bv, LyXFont const & font, int y,
-                       float & xx) const
+void InsetInclude::draw(PainterInfo & pi, int x, int y) const
 {
-       cache(bv);
+       cache(pi.base.bv);
        if (!preview_->previewReady()) {
-               InsetButton::draw(bv, font, y, xx);
+               InsetButton::draw(pi, x, y);
                return;
        }
 
        if (!preview_->monitoring())
                preview_->startMonitoring();
 
-       int const x = int(xx);
-       int const w = width(bv, font);
-       int const d = descent(bv, font);
-       int const a = ascent(bv, font);
-       int const h = a + d;
+       Dimension dim;
+       dimension(pi.base.bv, pi.base.font, dim);
 
-       bv->painter().image(x, y - a, w, h,
+       pi.pain.image(x, y - dim.asc, dim.wid, dim.height(),
                            *(preview_->pimage()->image()));
-
-       xx += w;
 }
 
 
index a6d197952b159c7944e83dad43f50918728f5ff2..b81e9df26ca544db35b4e68a6445eda7533d7e49 100644 (file)
@@ -66,7 +66,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
 
        /// get the parameters
        Params const & params(void) const;
index b5e51eb57b180b57edb9317c04530ed682415c8b..791269e73e1ab936428e73567396b98d84d8e21e 100644 (file)
@@ -21,6 +21,7 @@
 #include "frontends/font_metrics.h"
 #include "language.h"
 #include "lyxlex.h"
+#include "metricsinfo.h"
 
 using std::ostream;
 using std::endl;
@@ -306,9 +307,7 @@ int InsetLatexAccent::rbearing(LyXFont const & font) const
 }
 
 
-bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
-                                       int baseline,
-                                       float & x) const
+bool InsetLatexAccent::displayISO8859_9(PainterInfo & pi, int x, int y) const
 {
        unsigned char tmpic = ic;
 
@@ -339,9 +338,7 @@ bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
        default:         return false;
        }
        if (tmpic != ic) {
-               char ch = char(tmpic);
-               bv->painter().text(int(x), baseline, ch, font);
-               x += width(bv, font);
+               pi.pain.text(x, y, char(tmpic), pi.base.font);
                return true;
        }
        else
@@ -349,13 +346,10 @@ bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
 }
 
 
-void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
-                           int baseline, float & x) const
+void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
 {
-       Painter & pain = bv->painter();
-
        if (lyxrc.font_norm_type == LyXRC::ISO_8859_9)
-               if (displayISO8859_9(bv, font0, baseline, x))
+               if (displayISO8859_9(pi, x, baseline))
                        return;
 
        /* draw it! */
@@ -363,27 +357,28 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
        // overhaul. Different ways of drawing (what metrics to use)
        // should also be considered.
 
-       LyXFont font(font0);
+       BufferView * bv = pi.base.bv;
+       LyXFont font = pi.base.font;
        if (lyxrc.font_norm_type == LyXRC::ISO_10646_1)
                font.setLanguage(english_language);
 
+       Dimension dim;
+       dimension(bv, font, dim);
+
        if (candisp) {
-               int asc = ascent(bv, font);
-               int desc = descent(bv, font);
-               int wid = width(bv, font);
                float x2 = x + (rbearing(font) - lbearing(font)) / 2.0;
                float hg;
                int y;
                if (plusasc) {
                        // mark at the top
                        hg = font_metrics::maxDescent(font);
-                       y = baseline - asc;
+                       y = baseline - dim.asc;
 
                        if (font.shape() == LyXFont::ITALIC_SHAPE)
                                x2 += (4.0 * hg) / 5.0; // italic
                } else {
                        // at the bottom
-                       hg = desc;
+                       hg = dim.des;
                        y = baseline;
                }
 
@@ -391,18 +386,18 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
 
                // display with proper accent mark
                // first the letter
-               pain.text(int(x), baseline, ic, font);
+               pi.pain.text(x, baseline, ic, font);
 
                if (remdot) {
                        int tmpvar = baseline - font_metrics::ascent('i', font);
-                       float tmpx = 0;
+                       int tmpx = 0;
                        if (font.shape() == LyXFont::ITALIC_SHAPE)
-                               tmpx += (8.0 * hg) / 10.0; // italic
+                               tmpx += int(0.8 * hg); // italic
                        lyxerr[Debug::KEY] << "Removing dot." << endl;
                        // remove the dot first
-                       pain.fillRectangle(int(x + tmpx), tmpvar, wid,
-                                          font_metrics::ascent('i', font) -
-                                          font_metrics::ascent('x', font) - 1,
+                       pi.pain.fillRectangle(x + tmpx, tmpvar, dim.wid,
+                                          font_metrics::ascent('i', pi.base.font) -
+                                          font_metrics::ascent('x', pi.base.font) - 1,
                                           backgroundColor());
                        // the five lines below is a simple hack to
                        // make the display of accent 'i' and 'j'
@@ -410,7 +405,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
                        // closer to the top of the dot-less 'i' or 'j'.
                        char tmpic = ic; // store the ic when we
                        ic = 'x';        // calculates the ascent of
-                       asc = ascent(bv, font); // the dot-less version (here: 'x')
+                       int asc = ascent(bv, font); // the dot-less version (here: 'x')
                        ic = tmpic;      // set the orig ic back
                        y = baseline - asc; // update to new y coord.
                }
@@ -418,48 +413,52 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
                switch (modtype) {
                case ACUTE:     // acute 0xB4
                {
-                       pain.text(int(x2 - (font_metrics::rbearing(0xB4, font) - font_metrics::lbearing(0xB4, font)) / 2),
-                                 baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB4, font) - (font_metrics::ascent(0xB4, font) + font_metrics::descent(0xB4, font)) / 2,
+                       pi.pain.text(int(x2 - (font_metrics::rbearing(0xB4, font)
+                                     - font_metrics::lbearing(0xB4, font)) / 2),
+                                 baseline - font_metrics::ascent(ic, font)
+                                                - font_metrics::descent(0xB4, font)
+                                                - (font_metrics::ascent(0xB4, font)
+                                                 + font_metrics::descent(0xB4, font)) / 2,
                                  char(0xB4), font);
                        break;
                }
                case GRAVE:     // grave 0x60
                {
-                       pain.text(int(x2 - (font_metrics::rbearing(0x60, font) - font_metrics::lbearing(0x60, font)) / 2),
+                       pi.pain.text(int(x2 - (font_metrics::rbearing(0x60, font) - font_metrics::lbearing(0x60, font)) / 2),
                                  int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x60, font) - (font_metrics::ascent(0x60, font) + font_metrics::descent(0x60, font)) / 2.0),
                                  char(0x60), font);
                        break;
                }
                case MACRON:     // macron
                {
-                       pain.text(int(x2 - (font_metrics::rbearing(0xAF, font) - font_metrics::lbearing(0xAF, font)) / 2),
+                       pi.pain.text(int(x2 - (font_metrics::rbearing(0xAF, font) - font_metrics::lbearing(0xAF, font)) / 2),
                                  baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xAF, font) - (font_metrics::ascent(0xAF, font) + font_metrics::descent(0xAF, font)),
                                  char(0xAF), font);
                        break;
                }
                case TILDE:     // tilde
                {
-                       pain.text(int(x2 - (font_metrics::rbearing('~', font) - font_metrics::lbearing('~', font)) / 2),
+                       pi.pain.text(int(x2 - (font_metrics::rbearing('~', font) - font_metrics::lbearing('~', font)) / 2),
                                  baseline - font_metrics::ascent(ic, font) - font_metrics::descent('~', font) - (font_metrics::ascent('~', font) + font_metrics::descent('~', font)) / 2,
                                  '~', font);
                        break;
                }
                case UNDERBAR:     // underbar 0x5F
                {
-                       pain.text(int(x2 - (font_metrics::rbearing(0x5F, font) - font_metrics::lbearing(0x5F, font)) / 2), baseline,
+                       pi.pain.text(int(x2 - (font_metrics::rbearing(0x5F, font) - font_metrics::lbearing(0x5F, font)) / 2), baseline,
                                  char(0x5F), font);
                        break;
                }
                case CEDILLA:     // cedilla
                {
-                       pain.text(int(x2 - (font_metrics::rbearing(0xB8, font) - font_metrics::lbearing(0xB8, font)) / 2), baseline,
+                       pi.pain.text(int(x2 - (font_metrics::rbearing(0xB8, font) - font_metrics::lbearing(0xB8, font)) / 2), baseline,
                                  char(0xB8), font);
 
                        break;
                }
                case UNDERDOT:     // underdot
                {
-                       pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
+                       pi.pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
                                  int(baseline + 3.0 / 2.0 * (font_metrics::ascent('.', font) + font_metrics::descent('.', font))),
                                  '.', font);
                        break;
@@ -467,7 +466,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
 
                case DOT:    // dot
                {
-                       pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
+                       pi.pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0),
                                  baseline - font_metrics::ascent(ic, font) - font_metrics::descent('.', font) - (font_metrics::ascent('.', font) + font_metrics::descent('.', font)) / 2,
                                  '.', font);
                        break;
@@ -477,20 +476,20 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
                {
                        LyXFont tmpf(font);
                        tmpf.decSize().decSize();
-                       pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0),
+                       pi.pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0),
                                  int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB0, tmpf) - (font_metrics::ascent(0xB0, tmpf) + font_metrics::descent(0xB0, tmpf)) / 3.0),
                                  char(0xB0), tmpf);
                        break;
                }
                case TIE:     // tie
                {
-                       pain.arc(int(x2 + hg35), int(y + hg / 2.0),
+                       pi.pain.arc(int(x2 + hg35), int(y + hg / 2.0),
                                 int(2 * hg), int(hg), 0, 360 * 32);
                        break;
                }
                case BREVE:     // breve
                {
-                       pain.arc(int(x2 - (hg / 2.0)), y,
+                       pi.pain.arc(int(x2 - (hg / 2.0)), y,
                                 int(hg), int(hg), 0, -360*32);
                        break;
                }
@@ -501,41 +500,41 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
                        xp[0] = int(x2 - hg35); yp[0] = int(y + hg35);
                        xp[1] = int(x2);        yp[1] = int(y + hg);
                        xp[2] = int(x2 + hg35); yp[2] = int(y + hg35);
-                       pain.lines(xp, yp, 3);
+                       pi.pain.lines(xp, yp, 3);
                        break;
                }
                case SPECIAL_CARON:    // special caron
                {
                        switch (ic) {
-                       case 'L': wid = int(4.0 * wid / 5.0); break;
+                       case 'L': dim.wid = int(4.0 * dim.wid / 5.0); break;
                        case 't': y -= int(hg35 / 2.0); break;
                        }
                        int xp[3], yp[3];
-                       xp[0] = int(x + wid);
+                       xp[0] = int(x + dim.wid);
                        yp[0] = int(y + hg35 + hg);
 
-                       xp[1] = int(x + wid + (hg35 / 2.0));
+                       xp[1] = int(x + dim.wid + (hg35 / 2.0));
                        yp[1] = int(y + hg + (hg35 / 2.0));
 
-                       xp[2] = int(x + wid + (hg35 / 2.0));
+                       xp[2] = int(x + dim.wid + (hg35 / 2.0));
                        yp[2] = y + int(hg);
 
-                       pain.lines(xp, yp, 3);
+                       pi.pain.lines(xp, yp, 3);
                        break;
                }
                case HUNGARIAN_UMLAUT:    // hung. umlaut
                {
-                       pain.text(int(x2 - (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font))),
+                       pi.pain.text(int(x2 - (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font))),
                                  baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
                                  '´', font);
-                       pain.text(int(x2),
+                       pi.pain.text(int(x2),
                                  baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2,
                                  '´', font);
                        break;
                }
                case UMLAUT:    // umlaut
                {
-                       pain.text(int(x2 - (font_metrics::rbearing('¨', font) - font_metrics::lbearing('¨', font)) / 2),
+                       pi.pain.text(int(x2 - (font_metrics::rbearing('¨', font) - font_metrics::lbearing('¨', font)) / 2),
                                  baseline - font_metrics::ascent(ic, font) - font_metrics::descent('¨', font) - (font_metrics::ascent('¨', font) + font_metrics::descent('¨', font)) / 2,
                                  '¨', font);
                        break;
@@ -544,7 +543,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
                {
                        LyXFont tmpf(font);
                        tmpf.decSize().decSize().decSize();
-                       pain.text(int(x2 - (font_metrics::rbearing(0x5E, tmpf) - font_metrics::lbearing(0x5E, tmpf)) / 2),
+                       pi.pain.text(int(x2 - (font_metrics::rbearing(0x5E, tmpf) - font_metrics::lbearing(0x5E, tmpf)) / 2),
                                  int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x5E, tmpf) - (font_metrics::ascent(0x5E, tmpf) + font_metrics::descent(0x5E, tmpf)) / 3.0),
                                  char(0x5E), tmpf);
                        break;
@@ -567,7 +566,7 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
                        xp[3] = int(x2 + hg / 4.0);
                        yp[3] = y + int(hg);
 
-                       pain.lines(xp, yp, 4);
+                       pi.pain.lines(xp, yp, 4);
                        break;
                }
                case lSLASH:
@@ -578,10 +577,10 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
                        xp[0] = int(x);
                        yp[0] = y + int(3.0 * hg);
 
-                       xp[1] = int(x + float(wid) * 0.75);
+                       xp[1] = int(x + float(dim.wid) * 0.75);
                        yp[1] = y + int(hg);
 
-                       pain.lines(xp, yp, 2);
+                       pi.pain.lines(xp, yp, 2);
                        break;
                }
                case DOT_LESS_I: // dotless-i
@@ -592,18 +591,13 @@ void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
                }
                }
        } else {
-               pain.fillRectangle(int(x + 1),
-                                  baseline - ascent(bv, font) + 1,
-                                  width(bv, font) - 2,
-                                  ascent(bv, font)
-                                  + descent(bv, font) - 2,
-                                  backgroundColor());
-               pain.rectangle(int(x + 1), baseline - ascent(bv, font) + 1,
-                              width(bv, font) - 2,
-                              ascent(bv, font) + descent(bv, font) - 2);
-               pain.text(int(x + 2), baseline, contents, font);
+               pi.pain.fillRectangle(x + 1,
+                                  baseline - dim.asc + 1, dim.wid - 2,
+                                  dim.asc + dim.des - 2, backgroundColor());
+               pi.pain.rectangle(x + 1, baseline - dim.asc + 1,
+                              dim.wid - 2, dim.asc + dim.des - 2);
+               pi.pain.text(x + 2, baseline, contents, font);
        }
-       x +=  width(bv, font);
 }
 
 
index 0fe5f86273d9d38fb7c6c9132926a018da4d6af0..414369a5a9ba9b42f8c7d8088f409af78ea26d87 100644 (file)
@@ -36,14 +36,13 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
        int lbearing(LyXFont const & font) const;
        ///
        int rbearing(LyXFont const & font) const;
        ///
-       bool displayISO8859_9(BufferView *, LyXFont const & font,
-                             int baseline, float & x) const;
+       bool displayISO8859_9(PainterInfo & pi, int x, int y) const;
        ///
        void write(Buffer const *, std::ostream &) const;
        ///
index dd38c7490d9e84e85b99b46ffab97365e9b328f4..0ac4e9a4426deae3e1049e11755fa02bbff4fc5c 100644 (file)
@@ -17,6 +17,7 @@
 #include "dimension.h"
 #include "paragraph.h"
 #include "lyxtext.h"
+#include "metricsinfo.h"
 #include "support/LOstream.h"
 #include "frontends/Painter.h"
 #include "frontends/font_metrics.h"
@@ -75,18 +76,14 @@ int InsetNewline::docbook(Buffer const *, std::ostream &, bool) const
 }
 
 
-void InsetNewline::draw(BufferView * bv, LyXFont const & font,
-                       int baseline, float & x) const
+void InsetNewline::draw(PainterInfo & pi, int x, int y) const
 {
-       Painter & pain(bv->painter());
-
-       int const wid = font_metrics::width('n', font);
-       int const asc = font_metrics::maxAscent(font);
-       int const y = baseline;
+       int const wid = font_metrics::width('n', pi.base.font);
+       int const asc = font_metrics::maxAscent(pi.base.font);
 
        // hack, and highly dubious
        lyx::pos_type pos = parOwner()->getPositionOfInset(this);
-       bool const ltr_pos = (bv->text->bidi_level(pos) % 2 == 0);
+       bool const ltr_pos = (pi.base.bv->text->bidi_level(pos) % 2 == 0);
 
        int xp[3];
        int yp[3];
@@ -105,7 +102,7 @@ void InsetNewline::draw(BufferView * bv, LyXFont const & font,
                xp[2] = int(x + wid * 0.625);
        }
 
-       pain.lines(xp, yp, 3, LColor::eolmarker);
+       pi.pain.lines(xp, yp, 3, LColor::eolmarker);
 
        yp[0] = int(y - 0.500 * asc * 0.75);
        yp[1] = int(y - 0.500 * asc * 0.75);
@@ -121,7 +118,5 @@ void InsetNewline::draw(BufferView * bv, LyXFont const & font,
                xp[2] = int(x);
        }
 
-       pain.lines(xp, yp, 3, LColor::eolmarker);
-
-       x += wid;
+       pi.pain.lines(xp, yp, 3, LColor::eolmarker);
 }
index 60de3b614010cceaf2e7476ec7b3b95b00e01b9c..7b4188f402d9fd8f9da035f0c4d61b4c68295f2c 100644 (file)
@@ -28,8 +28,7 @@ public:
 
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
 
-       virtual void draw(BufferView *, LyXFont const &,
-                         int baseline, float & x) const;
+       virtual void draw(PainterInfo & pi, int x, int y) const;
 
        virtual int latex(Buffer const *, std::ostream &,
                          LatexRunParams const &) const;
index 3a336968f3e12d34f375d89ef4811f9337e9090d..24f44ff4442aad1eed66df2907bcf048b047bbcc 100644 (file)
@@ -23,6 +23,7 @@
 #include "lyxlex.h"
 #include "lyxrc.h"
 #include "paragraph.h"
+#include "metricsinfo.h"
 #include "frontends/font_metrics.h"
 #include "frontends/Painter.h"
 #include "support/LAssert.h"
@@ -202,18 +203,17 @@ LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
 #endif
 
 
-void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
-                      int baseline, float & x) const
+void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
 {
-       string const text = dispString(font.language());
+       string const text = dispString(pi.base.font.language());
 
        if (text.length() == 2 && text[0] == text[1]) {
-               bv->painter().text(int(x), baseline, text[0], font);
-               int x2 = int(x + font_metrics::width(',', font));
-               bv->painter().text(x2, baseline, text[0], font);
-       } else
-               bv->painter().text(int(x), baseline, text, font);
-       x += width(bv, font);
+               pi.pain.text(x, y, text[0], pi.base.font);
+               int const t = font_metrics::width(',', pi.base.font);
+               pi.pain.text(x + t, y, text[0], pi.base.font);
+       } else {
+               pi.pain.text(x, y, text, pi.base.font);
+       }
 }
 
 
index 29875c70a69e7dea7e953cebe134e403d2c8f7d8..5816a1e86ceddc70ab892beb3063392efa23442d 100644 (file)
@@ -72,7 +72,7 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
 #if 0
        ///
        LyXFont const convertFont(LyXFont const & font) const;
index 3ef75086d5ccf8a1ffddd959f579f90c26f459cf..05f6beca5289575d82a313a257bdd0a63a40c288 100644 (file)
@@ -24,6 +24,7 @@
 #include "frontends/font_metrics.h"
 #include "lyxlex.h"
 #include "lyxfont.h"
+#include "metricsinfo.h"
 
 using std::ostream;
 using std::max;
@@ -73,31 +74,28 @@ void InsetSpace::dimension(BufferView *, LyXFont const & font,
 }
 
 
-void InsetSpace::draw(BufferView * bv, LyXFont const & f,
-                           int baseline, float & x) const
+void InsetSpace::draw(PainterInfo & pi, int x, int y) const
 {
-       Painter & pain = bv->painter();
-       LyXFont font(f);
-
-       float w = width(bv, font);
-       int h = font_metrics::ascent('x', font);
+       int const w = width(pi.base.bv, pi.base.font);
+       int const h = font_metrics::ascent('x', pi.base.font);
        int xp[4], yp[4];
 
-       xp[0] = int(x); yp[0] = baseline - max(h / 4, 1);
+       xp[0] = x;
+       yp[0] = y - max(h / 4, 1);
        if (kind_ == NORMAL) {
-               xp[1] = int(x); yp[1] = baseline;
-               xp[2] = int(x + w); yp[2] = baseline;
+               xp[1] = x;     yp[1] = y;
+               xp[2] = x + w; yp[2] = y;
        } else {
-               xp[1] = int(x); yp[1] = baseline + max(h / 4, 1);
-               xp[2] = int(x + w); yp[2] = baseline + max(h / 4, 1);
+               xp[1] = x;     yp[1] = y + max(h / 4, 1);
+               xp[2] = x + w; yp[2] = y + max(h / 4, 1);
        }
-       xp[3] = int(x + w); yp[3] = baseline - max(h / 4, 1);
+       xp[3] = x + w;
+       yp[3] = y - max(h / 4, 1);
 
        if (kind_ == PROTECTED || kind_ == ENSPACE || kind_ == NEGTHIN)
-               pain.lines(xp, yp, 4, LColor::latex);
+               pi.pain.lines(xp, yp, 4, LColor::latex);
        else
-               pain.lines(xp, yp, 4, LColor::special);
-       x += w;
+               pi.pain.lines(xp, yp, 4, LColor::special);
 }
 
 
index 9a1a872e1121aaeba5a95e1b26c18188bcd1ac1c..a124a670f2aada26e66045d2c9d1d51a71e45486 100644 (file)
@@ -56,7 +56,7 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
        void write(Buffer const *, std::ostream &) const;
        /// Will not be used when lyxf3
index 31e8c0a9ca2f81bcfbca92f182eef13cccb3110a..8a67a6214110647ee00be3e469618a0f2bd50927 100644 (file)
@@ -22,6 +22,7 @@
 #include "frontends/font_metrics.h"
 #include "lyxlex.h"
 #include "lyxfont.h"
+#include "metricsinfo.h"
 
 using std::ostream;
 using std::max;
@@ -58,56 +59,49 @@ void InsetSpecialChar::dimension(BufferView *, LyXFont const & font,
 }
 
 
-void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
-                           int baseline, float & x) const
+void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
 {
-       Painter & pain = bv->painter();
-       LyXFont font(f);
+       LyXFont font = pi.base.font;
 
        switch (kind_) {
        case HYPHENATION:
        {
                font.setColor(LColor::special);
-               pain.text(int(x), baseline, '-', font);
-               x += width(bv, font);
+               pi.pain.text(x, y, '-', font);
                break;
        }
        case LIGATURE_BREAK:
        {
                font.setColor(LColor::special);
-               pain.text(int(x), baseline, '|', font);
-               x += width(bv, font);
+               pi.pain.text(x, y, '|', font);
                break;
        }
        case END_OF_SENTENCE:
        {
                font.setColor(LColor::special);
-               pain.text(int(x), baseline, '.', font);
-               x += width(bv, font);
+               pi.pain.text(x, y, '.', font);
                break;
        }
        case LDOTS:
        {
                font.setColor(LColor::special);
-               pain.text(int(x), baseline, ". . .", font);
-               x += width(bv, font);
+               pi.pain.text(x, y, ". . .", font);
                break;
        }
        case MENU_SEPARATOR:
        {
                // A triangle the width and height of an 'x'
                int w = font_metrics::width('x', font);
-               int ox = font_metrics::width(' ', font) + int(x);
+               int ox = font_metrics::width(' ', font) + x;
                int h = font_metrics::ascent('x', font);
                int xp[4], yp[4];
 
-               xp[0] = ox;     yp[0] = baseline;
-               xp[1] = ox;     yp[1] = baseline - h;
-               xp[2] = ox + w; yp[2] = baseline - h/2;
-               xp[3] = ox;     yp[3] = baseline;
+               xp[0] = ox;     yp[0] = y;
+               xp[1] = ox;     yp[1] = y - h;
+               xp[2] = ox + w; yp[2] = y - h/2;
+               xp[3] = ox;     yp[3] = y;
 
-               pain.lines(xp, yp, 4, LColor::special);
-               x += width(bv, font);
+               pi.pain.lines(xp, yp, 4, LColor::special);
                break;
        }
        }
index bcca7aeab27aa50cefa56e9bf919db8abb8b3889..69264a4e82436a706786a12d1dfdaf79367dc775 100644 (file)
@@ -48,7 +48,7 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
        void write(Buffer const *, std::ostream &) const;
        /// Will not be used when lyxf3
index c5096ba1e3a51e23b52f97af64088b87a4a6818b..cf36af15f0c72e732aab16a42e2a7fb48f836433 100644 (file)
@@ -31,7 +31,7 @@
 #include "ParagraphParameters.h"
 #include "undo_funcs.h"
 #include "WordLangTuple.h"
-#include "Lsstream.h"
+#include "metricsinfo.h"
 
 #include "frontends/Alert.h"
 #include "frontends/Dialogs.h"
@@ -252,40 +252,39 @@ void InsetTabular::dimension(BufferView *, LyXFont const &,
 }
 
 
-void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
-                       float & x) const
+void InsetTabular::draw(PainterInfo & pi, int x, int y) const
 {
        if (nodraw()) {
                need_update = FULL;
                return;
        }
 
-       Painter & pain = bv->painter();
+       BufferView * bv = pi.base.bv;
        int i;
        int j;
        int nx;
 
 #if 0
-       UpdatableInset::draw(bv, font, baseline, x);
+       UpdatableInset::draw(pi, x, y);
 #else
        if (!owner())
-               x += static_cast<float>(scroll());
+               x += scroll();
 #endif
 
-       top_x = int(x);
-       top_baseline = baseline;
+       top_x = x;
+       top_baseline = y;
        x += ADD_TO_TABULAR_WIDTH;
 
        int cell = 0;
-       float cx;
+       int cx;
        first_visible_cell = -1;
        for (i = 0; i < tabular->rows(); ++i) {
-               nx = int(x);
+               nx = x;
                cell = tabular->GetCellNumber(i, 0);
-               if (!((baseline + tabular->GetDescentOfRow(i)) > 0) &&
-                       (baseline - tabular->GetAscentOfRow(i))<pain.paperHeight())
+               if (!((y + tabular->GetDescentOfRow(i)) > 0) &&
+                       (y - tabular->GetAscentOfRow(i)) < pi.pain.paperHeight())
                {
-               baseline += tabular->GetDescentOfRow(i) +
+               y += tabular->GetDescentOfRow(i) +
                                tabular->GetAscentOfRow(i + 1) +
                                tabular->GetAdditionalHeight(i + 1);
                        continue;
@@ -299,32 +298,30 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                        if (first_visible_cell < 0)
                                first_visible_cell = cell;
                        if (hasSelection()) {
-                               drawCellSelection(pain, nx, baseline, i, j, cell);
+                               drawCellSelection(pi.pain, nx, y, i, j, cell);
                        }
 
-                       tabular->GetCellInset(cell)->draw(bv, font, baseline, cx);
-                       drawCellLines(pain, nx, baseline, i, cell);
+                       tabular->GetCellInset(cell)->draw(pi, cx, y);
+                       drawCellLines(pi.pain, nx, y, i, cell);
                        nx += tabular->GetWidthOfColumn(cell);
                        ++cell;
                }
 
                // avoiding drawing the rest of a long table is
                // a pretty big speedup
-               if (baseline > bv->workHeight())
+               if (y > bv->workHeight())
                        break;
 
-               baseline += tabular->GetDescentOfRow(i) +
+               y += tabular->GetDescentOfRow(i) +
                        tabular->GetAscentOfRow(i + 1) +
                        tabular->GetAdditionalHeight(i + 1);
        }
 
-       x -= ADD_TO_TABULAR_WIDTH;
-       x += width(bv, font);
        need_update = NONE;
 }
 
 
-void InsetTabular::drawCellLines(Painter & pain, int x, int baseline,
+void InsetTabular::drawCellLines(Painter & pain, int x, int y,
                                 int row, int cell) const
 {
        int x2 = x + tabular->GetWidthOfColumn(cell);
@@ -332,34 +329,34 @@ void InsetTabular::drawCellLines(Painter & pain, int x, int baseline,
 
        if (!tabular->topAlreadyDrawn(cell)) {
                on_off = !tabular->TopLine(cell);
-               pain.line(x, baseline - tabular->GetAscentOfRow(row),
-                         x2, baseline -  tabular->GetAscentOfRow(row),
+               pain.line(x, y - tabular->GetAscentOfRow(row),
+                         x2, y -  tabular->GetAscentOfRow(row),
                          on_off ? LColor::tabularonoffline : LColor::tabularline,
                          on_off ? Painter::line_onoffdash : Painter::line_solid);
        }
        on_off = !tabular->BottomLine(cell);
-       pain.line(x, baseline + tabular->GetDescentOfRow(row),
-                 x2, baseline + tabular->GetDescentOfRow(row),
+       pain.line(x, y + tabular->GetDescentOfRow(row),
+                 x2, y + tabular->GetDescentOfRow(row),
                  on_off ? LColor::tabularonoffline : LColor::tabularline,
                  on_off ? Painter::line_onoffdash : Painter::line_solid);
        if (!tabular->leftAlreadyDrawn(cell)) {
                on_off = !tabular->LeftLine(cell);
-               pain.line(x, baseline -  tabular->GetAscentOfRow(row),
-                         x, baseline +  tabular->GetDescentOfRow(row),
+               pain.line(x, y -  tabular->GetAscentOfRow(row),
+                         x, y +  tabular->GetDescentOfRow(row),
                          on_off ? LColor::tabularonoffline : LColor::tabularline,
                          on_off ? Painter::line_onoffdash : Painter::line_solid);
        }
        on_off = !tabular->RightLine(cell);
        pain.line(x2 - tabular->GetAdditionalWidth(cell),
-                 baseline -  tabular->GetAscentOfRow(row),
+                 y -  tabular->GetAscentOfRow(row),
                  x2 - tabular->GetAdditionalWidth(cell),
-                 baseline +  tabular->GetDescentOfRow(row),
+                 y +  tabular->GetDescentOfRow(row),
                  on_off ? LColor::tabularonoffline : LColor::tabularline,
                  on_off ? Painter::line_onoffdash : Painter::line_solid);
 }
 
 
-void InsetTabular::drawCellSelection(Painter & pain, int x, int baseline,
+void InsetTabular::drawCellSelection(Painter & pain, int x, int y,
                                     int row, int column, int cell) const
 {
        lyx::Assert(hasSelection());
@@ -380,7 +377,7 @@ void InsetTabular::drawCellSelection(Painter & pain, int x, int baseline,
        if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
                int w = tabular->GetWidthOfColumn(cell);
                int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row)-1;
-               pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row) + 1,
+               pain.fillRectangle(x, y - tabular->GetAscentOfRow(row) + 1,
                                   w, h, LColor::selection);
        }
 }
index dd7a91265b2985d87d06cc1dd32aba54bed4ba78..93a9ef6f5c1baa52c17471d5f3714d2756a5a15d 100644 (file)
@@ -88,7 +88,7 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, const LyXFont &, int , float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
        void update(BufferView *, bool = false);
        ///
index c2e92f51d6be2529ec2c574669afad8bd8ea6ec4..c7c3b74f28f7f0ec9bf3980f8166b65dd5ee14ea 100644 (file)
@@ -39,7 +39,7 @@
 #include "sgml.h"
 #include "rowpainter.h"
 #include "insetnewline.h"
-#include "Lsstream.h"
+#include "metricsinfo.h"
 
 #include "frontends/Alert.h"
 #include "frontends/Dialogs.h"
@@ -321,38 +321,37 @@ int InsetText::textWidth(BufferView * bv, bool fordraw) const
 }
 
 
-void InsetText::draw(BufferView * bv, LyXFont const & f,
-                    int baseline, float & x) const
+void InsetText::draw(PainterInfo & pi, int x, int baseline) const
 {
        if (nodraw())
                return;
 
        // update our idea of where we are. Clearly, we should
        // not have to know this information.
-       if (top_x != int(x))
-               top_x = int(x);
+       if (top_x != x)
+               top_x = x;
 
-       int const start_x = int(x);
+       int const start_x = x;
 
-       Painter & pain = bv->painter();
+       BufferView * bv = pi.base.bv;
+       Painter & pain = pi.pain;
 
        // call this method so that dim_ has the right value
-       dimension(bv, f, dim_);
+       dimension(bv, pi.base.font, dim_);
 
        // repaint the background if needed
        if (backgroundColor() != LColor::background)
                clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, baseline);
 
        // no draw is necessary !!!
-       if ((drawFrame_ == LOCKED) && !locked && paragraphs.begin()->empty()) {
+       if (drawFrame_ == LOCKED && !locked && paragraphs.begin()->empty()) {
                top_baseline = baseline;
-               x += width(bv, f);
                need_update = NONE;
                return;
        }
 
        if (!owner())
-               x += static_cast<float>(scroll());
+               x += scroll();
 
        top_baseline = baseline;
        top_y = baseline - dim_.asc;
index c37a5588f6e79de6d13fd755dc07a47597e6fff9..e1ad8a8788994a1dc1d11ef7066d26ca3ccedec8 100644 (file)
@@ -91,7 +91,7 @@ public:
        ///
        int textWidth(BufferView *, bool fordraw = false) const;
        ///
-       void draw(BufferView *, LyXFont const &, int , float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
        void update(BufferView *, bool = false);
        ///
index a01ec0f3bcc24b37f4563bfbbb575b8dc477cb77..ec6fa2ba81464e6a406acbb7fabf416cd48bd908 100644 (file)
@@ -52,13 +52,11 @@ void UpdatableInset::fitInsetCursor(BufferView *) const
 {}
 
 
-void UpdatableInset::draw(BufferView *, LyXFont const &,
-                         int /* baseline */, float & x) const
+void UpdatableInset::draw(PainterInfo &, int, int) const
 {
-       x += float(scx);
        // ATTENTION: don't do the following here!!!
-       //    top_x = int(x);
-       //    top_baseline = baseline;
+       //    top_x = x;
+       //    top_baseline = y;
 }
 
 
index f41c02387b9098fbc6ab76262601a479030656bd..77046dc1df0568f1a5024c7296555d6f5441de31 100644 (file)
@@ -66,8 +66,7 @@ public:
        ///
        virtual void insetUnlock(BufferView *);
        ///
-       virtual void draw(BufferView *, LyXFont const &,
-                         int baseline, float & x) const;
+       virtual void draw(PainterInfo & pi, int x, int y) const;
        ///
        virtual bool insertInset(BufferView *, Inset *) { return false; }
        ///
index 5b1c8cc9973a916fbe390772c2f5bb9812166b30..6ebf101eace01d9f9e20270ca396d91ab2372bb4 100644 (file)
@@ -212,44 +212,42 @@ void InsetFormula::read(Buffer const *, LyXLex & lex)
 //}
 
 
-void InsetFormula::draw(BufferView * bv, LyXFont const & font,
-                       int y, float & xx) const
+void InsetFormula::draw(PainterInfo & pi, int x, int y) const
 {
-       cache(bv);
+       cache(pi.base.bv);
        // This initiates the loading of the preview, so should come
        // before the metrics are computed.
        bool const use_preview = preview_->previewReady();
 
-       int const x = int(xx);
-       int const w = width(bv, font);
-       int const d = descent(bv, font);
-       int const a = ascent(bv, font);
+       Dimension dim;
+       dimension(pi.base.bv, pi.base.font, dim);
+       int const w = dim.wid;
+       int const d = dim.des;
+       int const a = dim.asc;
        int const h = a + d;
 
-       PainterInfo pi(bv);
-
        if (use_preview) {
                pi.pain.image(x + 1, y - a, w, h,   // one pixel gap in front
                              *(preview_->pimage()->image()));
        } else {
-               pi.base.style = LM_ST_TEXT;
-               pi.base.font  = font;
-               pi.base.font.setColor(LColor::math);
+               PainterInfo p(pi.base.bv);
+               p.base.style = LM_ST_TEXT;
+               p.base.font  = pi.base.font;
+               p.base.font.setColor(LColor::math);
                if (lcolor.getX11Name(LColor::mathbg)
                            != lcolor.getX11Name(LColor::background))
-                       pi.pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
+                       p.pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
 
                if (mathcursor &&
                                const_cast<InsetFormulaBase const *>(mathcursor->formula()) == this)
                {
                        mathcursor->drawSelection(pi);
-                       //pi.pain.rectangle(x, y - a, w, h, LColor::mathframe);
+                       //p.pain.rectangle(x, y - a, w, h, LColor::mathframe);
                }
 
-               par_->draw(pi, x, y);
+               par_->draw(p, x, y);
        }
 
-       xx += w;
        xo_ = x;
        yo_ = y;
 }
index bab0e55c3b54eb733864b125466207640f04cc6b..201b71027ac0c72223b50f51bc1d988cbfc512d6 100644 (file)
@@ -37,7 +37,7 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
 
        ///
        void write(Buffer const *, std::ostream &) const;
index 4482822ef731569af8c39213e57da19b674bd6c3..691b8205f7989106cafeb0f877979960b5d2321c 100644 (file)
@@ -31,8 +31,6 @@ public:
        InsetFormulaBase();
        ///
        Inset * clone(Buffer const &) const = 0;
-       ///
-       virtual void draw(BufferView *,LyXFont const &, int, float &) const = 0;
        /// lowest x coordinate
        virtual int xlow() const;
        /// highest x coordinate
index d75a398617f296fa8448ac09b7ab6a55f52d9209..6eeb17968f60190f8be2cc13b0ca177fe5da3b59 100644 (file)
@@ -171,20 +171,18 @@ Inset::Code InsetFormulaMacro::lyxCode() const
 }
 
 
-void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
-                            int y, float & xx) const
+void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const
 {
        // label
-       LyXFont font(f);
+       LyXFont font = p.base.font;
        font.setColor(LColor::math);
 
-       PainterInfo pi(bv);
+       PainterInfo pi(p.base.bv);
        pi.base.style = LM_ST_TEXT;
        pi.base.font  = font;
 
        Dimension dim;
-       dimension(bv, font, dim);
-       int const x = int(xx);
+       dimension(pi.base.bv, font, dim);
        int const a = y - dim.asc + 1;
        int const w = dim.wid - 2;
        int const h = dim.height() - 2;
@@ -200,8 +198,7 @@ void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
        pi.pain.text(x + 2, y, prefix(), font);
 
        // formula
-       par()->draw(pi, x + font_metrics::width(prefix(), f) + 5, y);
-       xx += w + 2;
+       par()->draw(pi, x + font_metrics::width(prefix(), p.base.font) + 5, y);
        xo_ = x;
        yo_ = y;
 }
index 1d8f03027bc5bd3f3fe61a4a645b20e99be27aca..27f56c5920313b2fa8837c9a194702cc7ee58e62 100644 (file)
@@ -35,7 +35,7 @@ public:
        ///
        void dimension(BufferView *, LyXFont const &, Dimension &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &) const;
+       void draw(PainterInfo & pi, int x, int y) const;
 
        ///
        void read(Buffer const *, LyXLex & lex);
index 8a738fdc412bb009f37fd53dbcac2661e798fc4e..39745f1ecff23eba18c2fcff96af72500e6a9b72 100644 (file)
@@ -33,6 +33,7 @@
 #include "rowpainter.h"
 #include "lyxrc.h"
 #include "lyxrow_funcs.h"
+#include "metricsinfo.h"
 
 using std::max;
 using lyx::pos_type;
@@ -103,12 +104,14 @@ void RowPainter::paintInset(pos_type const pos)
 
        lyx::Assert(inset);
 
-       LyXFont const & font = getFont(pos);
-
 #warning inset->update FIXME
        inset->update(perv(bv_), false);
 
-       inset->draw(perv(bv_), font, yo_ + row_->baseline(), x_);
+       PainterInfo pi(perv(bv_));
+       pi.base.font = getFont(pos);
+       int const w = inset->width(perv(bv_), pi.base.font);
+       inset->draw(pi, int(x_), yo_ + row_->baseline());
+       x_ += w;
 }