]> git.lyx.org Git - lyx.git/commitdiff
slimmer row painter interface
authorAndré Pönitz <poenitz@gmx.net>
Mon, 14 Jul 2003 17:50:00 +0000 (17:50 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 14 Jul 2003 17:50:00 +0000 (17:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7272 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/frontends/ChangeLog
src/frontends/screen.C
src/insets/ChangeLog
src/insets/insetert.C
src/insets/insettext.C
src/rowpainter.C
src/rowpainter.h

index 2e86ed7ed0aac470eed1716289cdb6abc2f7fa04..f4a56ee1319af7f310cb198dba8558d10523459d 100644 (file)
@@ -1,4 +1,8 @@
 
+2003-07-14  André Pönitz  <poenitz@gmx.net>
+
+       * rowpainter.[Ch]: reduce interface
+
 2003-07-14  André Pönitz  <poenitz@gmx.net>
 
        * BufferView_pimpl.C:
index 91800c17dcee5b13d78822f7d054980bb426409d..6f96d4098ab3283af4dcf4e1c98c842e69df7b91 100644 (file)
@@ -1,3 +1,8 @@
+
+2003-07-14  André Pönitz  <poenitz@gmx.net>
+
+       * screen.C: use slimmed down rowpainter interface
+
 2003-07-04  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * introduce namespace lyx::graphics
index e902141367a6a4e15baef8d9840cabbd9eded099..301c41f207d20cb806a53b90477a6e1740f6d757 100644 (file)
@@ -478,8 +478,7 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
 
        RowList::iterator const rend = text->rows().end();
        while (rit != rend && y < y2) {
-               RowPainter rp(*bv, *text, rit);
-               rp.paint(y + yo, xo, y + topy);
+               paintRows(*bv, *text, rit, y + yo, xo, y + topy);
                y += rit->height();
                ++rit;
        }
@@ -507,6 +506,5 @@ void LyXScreen::drawOneRow(LyXText * text, BufferView * bv,
 
        hideCursor();
 
-       RowPainter rp(*bv, *text, row);
-       rp.paint(y, xo, y + text->top_y());
+       paintRows(*bv, *text, row, y, xo, y + text->top_y());
 }
index 28abbb4c7cca7bc3d7d12e54f85d99b5ccec13bd..44aa7244dcf708cfa3363c210f71b9407d882e89 100644 (file)
@@ -1,9 +1,13 @@
 
 2003-07-14  André Pönitz  <poenitz@gmx.net>
 
-       * insets/insetcollapsable.C:
-       * insets/insetert.C:
-       * insets/insettext.[Ch] (cy, ciy, setUpdateStatus):
+       * insettext.C (draw): use slimmed down rowpainter interface
+
+2003-07-14  André Pönitz  <poenitz@gmx.net>
+
+       * insetcollapsable.C:
+       * insetert.C:
+       * insettext.[Ch] (cy, ciy, setUpdateStatus):
        remove unused BufferView * argument
 
 2003-07-14  André Pönitz  <poenitz@gmx.net>
index f88b46bf98f0492b5c12999444a403d6ec3539f3..b0f96d24973d2b8d7a28cd86202eab7c0833a002 100644 (file)
@@ -106,8 +106,7 @@ InsetERT::InsetERT(BufferParams const & bp,
 
 InsetERT::~InsetERT()
 {
-       InsetERTMailer mailer(*this);
-       mailer.hideDialog();
+       InsetERTMailer(*this).hideDialog();
 }
 
 
@@ -608,8 +607,7 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const
 
 bool InsetERT::showInsetDialog(BufferView * bv) const
 {
-       InsetERTMailer mailer(const_cast<InsetERT &>(*this));
-       mailer.showDialog(bv);
+       InsetERTMailer(const_cast<InsetERT &>(*this)).showDialog(bv);
        return true;
 }
 
index f7b593a504cddd8925c95902e5ae02d0b4796d33..7c40d596923509551e9acfcf0d8975798159a44e 100644 (file)
@@ -368,9 +368,9 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
 
        bv->hideCursor();
 
-       while ((rowit != end) && (yf < ph)) {
-               RowPainter rp(*bv, text_, rowit);
-               rp.paint(y + y_offset + first, int(x), y + text_.top_y());
+       while (rowit != end && yf < ph) {
+               paintRows(*bv, text_, rowit,
+                       y + y_offset + first, int(x), y + text_.top_y());
                y += rowit->height();
                yf += rowit->height();
                ++rowit;
index b43895acc15818ebd78305c8cb34ff5633711f12..820755e811dd047c1ac5d59bc34ca726c62e5473 100644 (file)
@@ -54,12 +54,84 @@ BufferView * perv(BufferView const & bv)
        return const_cast<BufferView *>(&bv);
 }
 
-} // namespace anon
-
-
-RowPainter::RowPainter(BufferView const & bv,
-                      LyXText const & text, RowList::iterator rit)
-       : bv_(bv), pain_(bv_.painter()), text_(text), row_(rit), pit_(rit->par())
+/**
+ * A class used for painting an individual row of text.
+ */
+class RowPainter {
+public:
+       /// initialise painter
+       RowPainter(BufferView const & bv, LyXText const & text,
+               RowList::iterator rit, int y_offset, int x_offset, int y);
+
+       /// do the painting
+       void paint();
+private:
+       // paint various parts
+       void paintBackground();
+       void paintSelection();
+       void paintAppendix();
+       void paintDepthBar();
+       void paintChangeBar();
+       void paintFirst();
+       void paintLast();
+       void paintForeignMark(float const orig_x, LyXFont const & orig_font);
+       void paintHebrewComposeChar(lyx::pos_type & vpos);
+       void paintArabicComposeChar(lyx::pos_type & vpos);
+       void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic);
+       int paintPageBreak(string const & label, int y);
+       int paintAppendixStart(int y);
+       int paintLengthMarker(string const & prefix, VSpace const & vsp, int start);
+       void paintText();
+       void paintFromPos(lyx::pos_type & vpos);
+       void paintInset(lyx::pos_type const pos);
+
+       /// return left margin
+       int leftMargin() const;
+
+       /// return the font at the given pos
+       LyXFont const getFont(lyx::pos_type pos) const;
+
+       /// return the label font for this row
+       LyXFont const getLabelFont() const;
+
+       char const transformChar(char c, lyx::pos_type pos) const;
+
+       /// return pixel width for the given pos
+       int singleWidth(lyx::pos_type pos) const;
+       int singleWidth(lyx::pos_type pos, char c) const;
+
+       /// bufferview to paint on
+       BufferView const & bv_;
+
+       /// Painter to use
+       Painter & pain_;
+
+       /// LyXText for the row
+       LyXText const & text_;
+
+       /// The row to paint
+       RowList::iterator row_;
+
+       /// Row's paragraph
+       mutable ParagraphList::iterator  pit_;
+
+       // Looks ugly - is
+       int xo_;
+       int yo_;
+       float x_;
+       int y_;
+       int width_;
+       float separator_;
+       float hfill_;
+       float label_hfill_;
+};
+
+RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
+     RowList::iterator rit,
+     int y_offset, int x_offset, int y)
+       : bv_(bv), pain_(bv_.painter()), text_(text), row_(rit),
+         pit_(rit->par()), 
+               xo_(x_offset), yo_(y_offset), y_(y)
 {}
 
 
@@ -480,27 +552,6 @@ void RowPainter::paintDepthBar()
 }
 
 
-int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
-{
-       if (vsp.kind() == VSpace::NONE)
-               return 0;
-
-       int const arrow_size = 4;
-       int const space_size = int(vsp.inPixels(bv));
-
-       LyXFont font;
-       font.decSize();
-       int const min_size = max(3 * arrow_size,
-               font_metrics::maxAscent(font)
-               + font_metrics::maxDescent(font));
-
-       if (vsp.length().len().value() < 0.0)
-               return min_size;
-       else
-               return max(min_size, space_size);
-}
-
-
 int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp, int start)
 {
        if (vsp.kind() == VSpace::NONE)
@@ -828,12 +879,7 @@ void RowPainter::paintLast()
        }
        case END_LABEL_STATIC:
        {
-#if 0
-               LyXFont font(LyXFont::ALL_SANE);
-               font = getLabelFont();
-#else
                LyXFont font = getLabelFont();
-#endif
                string const & str = pit_->layout()->endlabelstring();
                int const x = is_rtl ?
                        int(x_) - font_metrics::width(str, font)
@@ -961,11 +1007,8 @@ void RowPainter::paintText()
 }
 
 
-void RowPainter::paint(int y_offset, int x_offset, int y)
+void RowPainter::paint()
 {
-       xo_ = x_offset;
-       yo_ = y_offset;
-       y_ = y;
        width_ = text_.isInInset()
                ? text_.inset_owner->textWidth(perv(bv_), true) : bv_.workWidth();
 
@@ -1008,3 +1051,35 @@ void RowPainter::paint(int y_offset, int x_offset, int y)
        // paint text
        paintText();
 }
+
+
+} // namespace anon
+
+
+int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
+{
+       if (vsp.kind() == VSpace::NONE)
+               return 0;
+
+       int const arrow_size = 4;
+       int const space_size = int(vsp.inPixels(bv));
+
+       LyXFont font;
+       font.decSize();
+       int const min_size = max(3 * arrow_size,
+               font_metrics::maxAscent(font)
+               + font_metrics::maxDescent(font));
+
+       if (vsp.length().len().value() < 0.0)
+               return min_size;
+       else
+               return max(min_size, space_size);
+}
+
+
+void paintRows(BufferView const & bv, LyXText const & text,
+       RowList::iterator rit, int y_offset, int x_offset, int y)
+{
+       RowPainter painter(bv, text, rit, y_offset, x_offset, y);
+       painter.paint();
+}
index 868b97c6a170c6fb0b45c646b1d1716a6b7dd449..4d58ab5f041e261606d648b8e0ff3a183c692287 100644 (file)
 #include <config.h>
 
 #include "RowList.h"
-#include "LString.h"
-#include "support/types.h"
 
 class LyXText;
 class BufferView;
-class Paragraph;
-class Painter;
-class LyXFont;
 class VSpace;
 
-/**
- * A class used for painting an individual row of text.
- */
-class RowPainter {
-public:
-       /// initialise painter
-       RowPainter(BufferView const & bv, LyXText const & text, RowList::iterator rit);
-
-       /// paint the row.
-       void paint(int y_offset, int x_offset, int y);
-
-private:
-       // paint various parts
-       void paintBackground();
-       void paintSelection();
-       void paintAppendix();
-       void paintDepthBar();
-       void paintChangeBar();
-       void paintFirst();
-       void paintLast();
-       void paintForeignMark(float const orig_x, LyXFont const & orig_font);
-       void paintHebrewComposeChar(lyx::pos_type & vpos);
-       void paintArabicComposeChar(lyx::pos_type & vpos);
-       void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic);
-       int paintPageBreak(string const & label, int y);
-       int paintAppendixStart(int y);
-       int paintLengthMarker(string const & prefix, VSpace const & vsp, int start);
-       void paintText();
-       void paintFromPos(lyx::pos_type & vpos);
-       void paintInset(lyx::pos_type const pos);
-
-       /// return left margin
-       int leftMargin() const;
-
-       /// return the font at the given pos
-       LyXFont const getFont(lyx::pos_type pos) const;
-
-       /// return the label font for this row
-       LyXFont const getLabelFont() const;
-
-       char const transformChar(char c, lyx::pos_type pos) const;
-
-       /// return pixel width for the given pos
-       int singleWidth(lyx::pos_type pos) const;
-       int singleWidth(lyx::pos_type pos, char c) const;
-
-       /// bufferview to paint on
-       BufferView const & bv_;
-
-       /// Painter to use
-       Painter & pain_;
-
-       /// LyXText for the row
-       LyXText const & text_;
-
-       /// The row to paint
-       RowList::iterator row_;
-
-       /// Row's paragraph
-       mutable ParagraphList::iterator  pit_;
-
-       // Looks ugly - is
-       int xo_;
-       int yo_;
-       float x_;
-       int y_;
-       int width_;
-       float separator_;
-       float hfill_;
-       float label_hfill_;
-};
+/// initialise painter and paint the row
+void paintRows(BufferView const & bv, LyXText const & text,
+       RowList::iterator rit, int y_offset, int x_offset, int y);
 
 /// return the pixel height of a space marker before/after a par
 int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp);