]> git.lyx.org Git - features.git/commitdiff
shift rowpainter interface a bit
authorAndré Pönitz <poenitz@gmx.net>
Tue, 19 Aug 2003 16:46:47 +0000 (16:46 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 19 Aug 2003 16:46:47 +0000 (16:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7575 a592a061-630c-0410-9148-cb99ea01b6c8

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

index 1db57f3c9f21e439e9bafeebc3363a569429d87d..6c8ab57e01d8ab1e3fcb302e2c1452c40ff0df01 100644 (file)
@@ -3,6 +3,9 @@
 
        * funcrequest.C: initialize button_ member
 
+       * text3.C:
+       * rowpainter.[Ch]: interface consolidation
+
 2003-08-18  André Pönitz  <poenitz@gmx.net>
 
        * BufferView.C:
index ae67922f43ae12db57ae20d6bbcfda053d7f16f7..7de4f12c75ad5b860c31a03545a1909fd990075e 100644 (file)
@@ -1,4 +1,8 @@
 
+2003-08-19  André Pönitz  <poenitz@gmx.net>
+
+       * screen.[Ch]: use new rowpainter interface
+
 2003-08-18  André Pönitz  <poenitz@gmx.net>
 
        * screen.[Ch]: remove draw()
index 2302ee3202839f69c9ee9184b6ca80d249accb35..2b7321198e88d1efd21843ccca9e0156df7511ba 100644 (file)
@@ -220,7 +220,7 @@ void LyXScreen::toggleCursor(BufferView & bv)
 }
 
 
-bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
+bool LyXScreen::fitManualCursor(BufferView * /*bv*/, LyXText * text,
        int /*x*/, int y, int asc, int desc)
 {
        int const vheight = workarea().workHeight();
@@ -237,7 +237,6 @@ bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
                return false;
 
        text->top_y(newtop);
-       //draw();
        return true;
 }
 
@@ -251,13 +250,7 @@ unsigned int LyXScreen::topCursorVisible(LyXText * text)
 
        RowList::iterator row = text->cursorRow();
 
-#warning SUPER HACK DISABLED (Lgb)
-#if 0
-       // Is this a hack? Yes, probably... (Lgb)
-       if (!row)
-               return max(newtop, 0);
-#endif
-       if (cursor.y() - row->baseline() + row->height() - top_y >= vheight) {
+       if (int(cursor.y() - row->baseline() + row->height() - top_y) >= vheight) {
                if (row->height() < vheight
                    && row->height() > vheight / 4) {
                        newtop = cursor.y()
@@ -278,9 +271,7 @@ unsigned int LyXScreen::topCursorVisible(LyXText * text)
                }
        }
 
-       newtop = max(newtop, 0);
-
-       return newtop;
+       return max(newtop, 0);
 }
 
 
@@ -290,8 +281,6 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
        int const newtop = topCursorVisible(text);
        bool const result = (newtop != text->top_y());
        text->top_y(newtop);
-       //if (result)
-       //      draw();
        return result;
 }
 
@@ -308,7 +297,18 @@ void LyXScreen::redraw(BufferView & bv)
        workarea().getPainter().start();
 
        bv.text->updateRowPositions();
-       drawFromTo(bv.text, &bv);
+       hideCursor();
+
+       int const y = paintText(bv, *bv.text);
+
+       // maybe we have to clear the screen at the bottom
+       int const y2 = workarea().workHeight();
+       if (y < y2 && !bv.text->isInInset()) {
+               workarea().getPainter().fillRectangle(0, y,
+                       workarea().workWidth(), y2 - y,
+                       LColor::bottomarea);
+       }
+
        expose(0, 0, workarea().workWidth(), workarea().workHeight());
 
        workarea().getPainter().end();
@@ -347,24 +347,3 @@ void LyXScreen::greyOut()
        expose(0, 0, workarea().workWidth(), workarea().workHeight());
        workarea().getPainter().end();
 }
-
-
-void LyXScreen::drawFromTo(LyXText * text, BufferView * bv)
-{
-       hideCursor();
-       int const topy = text->top_y();
-       int y_text = topy;
-       ParagraphList::iterator pit;
-       RowList::iterator rit = text->getRowNearY(y_text, pit);
-       int y = y_text - topy;
-
-       y = paintRows(*bv, *text, pit, rit, 0, y, y, 0);
-
-       // maybe we have to clear the screen at the bottom
-       int const y2 = workarea().workHeight();
-       if (y < y2 && !text->isInInset()) {
-               workarea().getPainter().fillRectangle(0, y,
-                       workarea().workWidth(), y2 - y,
-                       LColor::bottomarea);
-       }
-}
index 5ba7bbf22233723acc97b980e152356ba2a60fe3..74661739cba062203c2a395eb2bcc4c23b1661a6 100644 (file)
@@ -108,9 +108,6 @@ protected:
        virtual void removeCursor() = 0;
 
 private:
-       /// y1 and y2 are coordinates of the screen
-       void drawFromTo(LyXText *, BufferView *);
-
        /// grey out (no buffer)
        void greyOut();
 
index 2dc82f11f241187631092afbaec3a52b1458e3fd..9907a26789b39c5eef51d71f3fa035e186ec52de 100644 (file)
@@ -1,3 +1,8 @@
+
+2003-08-19  André Pönitz  <poenitz@gmx.net>
+
+       * insettext.C: use new RowPainter interface
+
 2003-08-18  John Levon  <levon@movementarian.org>
 
        * insetref.C: require amsmath for eqref
index 569c7e744a8d7d8d985c294764f655a33504e024..ae83c6032e743dde1c4272ad50953a75e40dba0c 100644 (file)
@@ -251,7 +251,7 @@ int InsetText::textWidth() const
 }
 
 
-void InsetText::draw(PainterInfo & pi, int x, int baseline) const
+void InsetText::draw(PainterInfo & pi, int x, int y) const
 {
        // update our idea of where we are. Clearly, we should
        // not have to know this information.
@@ -264,11 +264,11 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
 
        // repaint the background if needed
        if (backgroundColor() != LColor::background)
-               clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, baseline);
+               clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, y);
 
        // no draw is necessary !!!
        if (drawFrame_ == LOCKED && !locked && paragraphs.begin()->empty()) {
-               top_baseline = baseline;
+               top_baseline = y;
                return;
        }
 
@@ -277,8 +277,8 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
        if (!owner())
                x += scroll();
 
-       top_baseline = baseline;
-       top_y = baseline - dim_.asc;
+       top_baseline = y;
+       top_y = y - dim_.asc;
 
        if (the_locking_inset && cpar() == inset_par && cpos() == inset_pos) {
                inset_x = cix() - x + drawTextXOffset;
@@ -287,33 +287,10 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
 
        x += TEXT_TO_INSET_OFFSET;
 
-       RowList::iterator rit = text_.firstRow();
-       RowList::iterator end = text_.endRow();
-       ParagraphList::iterator pit = paragraphs.begin();
-
-       int y_offset = baseline - rit->ascent_of_text();
-       int first = 0;
-       int y = y_offset;
-       while (rit != end && y + rit->height() <= 0) {
-               y += rit->height();
-               first += rit->height();
-               text_.nextRow(pit, rit);
-       }
-       if (y_offset < 0) {
-               text_.top_y(-y_offset);
-               first = y;
-               y_offset = 0;
-       } else {
-               text_.top_y(first);
-               first = 0;
-       }
-
-       int yo = y_offset + first;
-
-       paintRows(*bv, text_, pit, rit, x, 0, yo, yo);
+       paintTextInset(*bv, text_, x, y);
 
        if (drawFrame_ == ALWAYS || (drawFrame_ == LOCKED && locked))
-               drawFrame(pain, int(start_x));
+               drawFrame(pain, start_x);
 }
 
 
@@ -1629,7 +1606,7 @@ int InsetText::scroll(bool recursive) const
 
 void InsetText::clearSelection(BufferView * bv)
 {
-       getLyXText(bv)->clearSelection();
+       text_.clearSelection();
 }
 
 
@@ -1776,12 +1753,7 @@ bool InsetText::searchBackward(BufferView * bv, string const & str,
                        return true;
        }
        if (!locked) {
-               ParagraphList::iterator pit = paragraphs.begin();
-               ParagraphList::iterator pend = paragraphs.end();
-
-               while (boost::next(pit) != pend)
-                       ++pit;
-
+               ParagraphList::iterator pit = boost::prior(paragraphs.end());
                text_.setCursor(pit, pit->size());
        }
        lyx::find::SearchResult result =
index 6f7a77446e843542da1d72675da773dab3a09d9e..f1adf7e0ee4eb902f8a59420c45cf6c3605b4639 100644 (file)
@@ -1041,30 +1041,6 @@ void RowPainter::paint()
 }
 
 
-} // 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 = 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 paintRows(BufferView const & bv, LyXText const & text,
        ParagraphList::iterator pit, RowList::iterator rit,
        int xo, int y, int yf, int yo)
@@ -1099,3 +1075,61 @@ int paintRows(BufferView const & bv, LyXText const & text,
        return y;
 }
 
+
+} // namespace anon
+
+
+int paintText(BufferView & bv, LyXText & text)
+{
+       int const topy = text.top_y();
+       int y_text = topy;
+       ParagraphList::iterator pit;
+       RowList::iterator rit = text.getRowNearY(y_text, pit);
+       int y = y_text - topy;
+       return paintRows(bv, text, pit, rit, 0, y, y, 0);
+}
+
+
+void paintTextInset(BufferView & bv, LyXText & text, int x, int baseline)
+{
+       RowList::iterator rit = text.firstRow();
+       RowList::iterator end = text.endRow();
+       ParagraphList::iterator pit = text.ownerParagraphs().begin();
+
+       int y_offset = baseline - rit->ascent_of_text();
+       int y = y_offset;
+       while (rit != end && y + rit->height() <= 0) {
+               y += rit->height();
+               text.nextRow(pit, rit);
+       }
+       if (y_offset < 0) {
+               text.top_y(-y_offset);
+               paintRows(bv, text, pit, rit, x, 0, y, y);
+       } else {
+               text.top_y(y - y_offset);
+               paintRows(bv, text, pit, rit, x, 0, y_offset, y_offset);
+       }
+}
+
+
+int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
+{
+       if (vsp.kind() == VSpace::NONE)
+               return 0;
+
+       int const arrow_size = 4;
+       int const space_size = 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);
+}
+
+
index dbd9d75ca9d29291876fd995e81c78f41cf7e99c..dbc17abff2ff5a5c59962c3bec812a32ea63eff4 100644 (file)
 
 #include <config.h>
 
-#include "RowList.h"
-
 class LyXText;
 class BufferView;
 class VSpace;
 
-/// paint the rows
-// return last used y
-int paintRows(BufferView const & bv, LyXText const & text,
-       ParagraphList::iterator pit,
-       RowList::iterator rit, int xo, int y, int yf, int yo);
-
 /// return the pixel height of a space marker before/after a par
 int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp);
 
+/// paint the rows of the main text, return last drawn y value
+int paintText(BufferView & bv, LyXText & text);
+
+/// paint the rows of a text inset
+void paintTextInset(BufferView & bv, LyXText & text, int x, int y);
+
 #endif // ROWPAINTER_H
index 29c8d568133ce15f93f89ed0aa858af383860f8a..09b84dd5a051410c51c2b26a4eb2e98341c75b6b 100644 (file)
@@ -1454,7 +1454,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                }
 
                bv->beforeChange(this);
-               LyXFont const old_font(real_current_font);
+               LyXFont const old_font = real_current_font;
 
                string::const_iterator cit = cmd.argument.begin();
                string::const_iterator end = cmd.argument.end();
@@ -1469,6 +1469,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
                // update the minibuffer
                if (old_font != real_current_font)
                        bv->owner()->view_state_changed();
+               bv->updateScrollbar();
                break;
        }