As all RowPainter usage follows the mantra RowPainter painter(bv, text, rit); painter.paint(y_offset, x_offset, y);
I thought it could be moved behind a single void paint(BufferView const & bv, LyXText const & text, RowList::iterator rit, int y_offset, int x_offset, int y) function. This cuts down rowpainter.h to a minimum... Ok? Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)
Index: rowpainter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v retrieving revision 1.21 diff -u -p -r1.21 rowpainter.C --- rowpainter.C 30 Jun 2003 23:55:57 -0000 1.21 +++ rowpainter.C 14 Jul 2003 16:57:21 -0000 @@ -54,8 +54,77 @@ BufferView * perv(BufferView const & bv) return const_cast<BufferView *>(&bv); } -} // namespace anon - +/** + * 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_; +}; RowPainter::RowPainter(BufferView const & bv, LyXText const & text, RowList::iterator rit) @@ -480,27 +549,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) @@ -1007,4 +1055,37 @@ void RowPainter::paint(int y_offset, int // 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 paint(BufferView const & bv, LyXText const & text, RowList::iterator rit, + int y_offset, int x_offset, int y) +{ + RowPainter painter(bv, text, rit); + painter.paint(y_offset, x_offset, y); } Index: rowpainter.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.h,v retrieving revision 1.8 diff -u -p -r1.8 rowpainter.h --- rowpainter.h 9 Apr 2003 21:34:31 -0000 1.8 +++ rowpainter.h 14 Jul 2003 16:57:21 -0000 @@ -16,87 +16,14 @@ #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 paint(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); Index: frontends/screen.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/screen.C,v retrieving revision 1.46 diff -u -p -r1.46 screen.C --- frontends/screen.C 4 Jul 2003 08:23:19 -0000 1.46 +++ frontends/screen.C 14 Jul 2003 16:57:21 -0000 @@ -478,8 +478,7 @@ void LyXScreen::drawFromTo(LyXText * tex RowList::iterator const rend = text->rows().end(); while (rit != rend && y < y2) { - RowPainter rp(*bv, *text, rit); - rp.paint(y + yo, xo, y + topy); + paint(*bv, *text, rit, y + yo, xo, y + topy); y += rit->height(); ++rit; } @@ -507,6 +506,5 @@ void LyXScreen::drawOneRow(LyXText * tex hideCursor(); - RowPainter rp(*bv, *text, row); - rp.paint(y, xo, y + text->top_y()); + paint(*bv, *text, row, y, xo, y + text->top_y()); } Index: insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.425 diff -u -p -r1.425 insettext.C --- insets/insettext.C 14 Jul 2003 16:34:23 -0000 1.425 +++ insets/insettext.C 14 Jul 2003 16:57:22 -0000 @@ -368,9 +368,9 @@ void InsetText::draw(PainterInfo & pi, i 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) { + paint(*bv, text_, rowit, + y + y_offset + first, int(x), y + text_.top_y()); y += rowit->height(); yf += rowit->height(); ++rowit;