From: André Pönitz Date: Mon, 14 Jul 2003 17:50:00 +0000 (+0000) Subject: slimmer row painter interface X-Git-Tag: 1.6.10~16550 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8aff4a15305479bba3000a0cd91bc40d1529a229;p=features.git slimmer row painter interface git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7272 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 2e86ed7ed0..f4a56ee131 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,8 @@ +2003-07-14 André Pönitz + + * rowpainter.[Ch]: reduce interface + 2003-07-14 André Pönitz * BufferView_pimpl.C: diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 91800c17dc..6f96d4098a 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ + +2003-07-14 André Pönitz + + * screen.C: use slimmed down rowpainter interface + 2003-07-04 Lars Gullik Bjønnes * introduce namespace lyx::graphics diff --git a/src/frontends/screen.C b/src/frontends/screen.C index e902141367..301c41f207 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -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()); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 28abbb4c7c..44aa7244dc 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,9 +1,13 @@ 2003-07-14 André Pönitz - * 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 + + * insetcollapsable.C: + * insetert.C: + * insettext.[Ch] (cy, ciy, setUpdateStatus): remove unused BufferView * argument 2003-07-14 André Pönitz diff --git a/src/insets/insetert.C b/src/insets/insetert.C index f88b46bf98..b0f96d2497 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -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(*this)); - mailer.showDialog(bv); + InsetERTMailer(const_cast(*this)).showDialog(bv); return true; } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index f7b593a504..7c40d59692 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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; diff --git a/src/rowpainter.C b/src/rowpainter.C index b43895acc1..820755e811 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -54,12 +54,84 @@ BufferView * perv(BufferView const & bv) return const_cast(&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(); +} diff --git a/src/rowpainter.h b/src/rowpainter.h index 868b97c6a1..4d58ab5f04 100644 --- a/src/rowpainter.h +++ b/src/rowpainter.h @@ -16,87 +16,14 @@ #include #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);