]> git.lyx.org Git - features.git/commitdiff
Transfer rowpainter.cpp:paintText() to BufferView::draw()
authorAbdelrazak Younes <younes@lyx.org>
Mon, 27 Aug 2007 22:53:16 +0000 (22:53 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 27 Aug 2007 22:53:16 +0000 (22:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19843 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/BufferView.h
src/frontends/qt4/GuiWorkArea.cpp
src/rowpainter.cpp
src/rowpainter.h

index 5b9cb3332391376a44b778ac25032535ff28c7cb..cb59a98575923f3453957e85049e6e8558d04e9b 100644 (file)
@@ -21,6 +21,7 @@
 #include "BufferList.h"
 #include "BufferParams.h"
 #include "bufferview_funcs.h"
+#include "callback.h" // added for Dispatch functions
 #include "CoordCache.h"
 #include "CutAndPaste.h"
 #include "debug.h"
 #include "InsetIterator.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "callback.h" // added for Dispatch functions
 #include "LyX.h"
 #include "lyxfind.h"
 #include "LyXFunc.h"
 #include "Layout.h"
-#include "Text.h"
-#include "TextClass.h"
 #include "LyXRC.h"
-#include "Session.h"
+#include "MetricsInfo.h"
 #include "Paragraph.h"
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
 #include "ParIterator.h"
+#include "rowpainter.h"
+#include "Session.h"
 #include "TexRow.h"
+#include "Text.h"
+#include "TextClass.h"
 #include "toc.h"
 #include "Undo.h"
 #include "VSpace.h"
 #include "WordLangTuple.h"
-#include "MetricsInfo.h"
 
 #include "insets/InsetBibtex.h"
 #include "insets/InsetCommand.h" // ChangeRefs
@@ -63,6 +64,7 @@
 #include "frontends/alert.h"
 #include "frontends/FileDialog.h"
 #include "frontends/FontMetrics.h"
+#include "frontends/Painter.h"
 #include "frontends/Selection.h"
 
 #include "graphics/Previews.h"
@@ -1085,7 +1087,7 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
                        //metrics_info_.y1 = ymin of button;
                        //metrics_info_.y2 = ymax of button;
                        //
-                       // Unfortunately, rowpainter.cpp:paintText() does not distinguish
+                       // Unfortunately, BufferView::draw() does not distinguish
                        // between background updates and text updates. So we use the hammer
                        // solution for now. We could also avoid the updateMetrics() below
                        // by using the first and last pit of the CoordCache. Have a look
@@ -1527,4 +1529,49 @@ void BufferView::menuInsertLyXFile(string const & filenm)
        updateMetrics(false);
 }
 
+
+void BufferView::draw(frontend::Painter & pain)
+{
+       Text & text = buffer_.text();
+       bool const select = cursor_.selection();
+
+       PainterInfo pi(this, pain);
+       // Should the whole screen, including insets, be refreshed?
+       // FIXME: We should also distinguish DecorationUpdate to avoid text
+       // drawing if possible. This is not possible to do easily right now
+       // because of the single backing pixmap.
+       bool repaintAll = select 
+               || metrics_info_.update_strategy != SingleParUpdate;
+
+       if (repaintAll)
+               // Clear background (if not delegated to rows)
+               pain.fillRectangle(0, metrics_info_.y1, width_,
+                       metrics_info_.y2 - metrics_info_.y1, text.backgroundColor());
+
+       if (select)
+               text.drawSelection(pi, 0, 0);
+
+       int yy = metrics_info_.y1;
+       // draw contents
+       for (pit_type pit = metrics_info_.p1; pit <= metrics_info_.p2; ++pit) {
+               ParagraphMetrics const & pm = parMetrics(&text, pit);
+               yy += pm.ascent();
+               paintPar(pi, text, pit, 0, yy, repaintAll);
+               yy += pm.descent();
+       }
+
+       // and grey out above (should not happen later)
+//     lyxerr << "par ascent: " << text.getPar(metrics_info_.p1).ascent() << endl;
+       if (metrics_info_.y1 > 0 
+               && metrics_info_.update_strategy == FullScreenUpdate)
+               pain.fillRectangle(0, 0, width_, metrics_info_.y1, Color::bottomarea);
+
+       // and possibly grey out below
+//     lyxerr << "par descent: " << text.getPar(metrics_info_.p1).ascent() << endl;
+       if (metrics_info_.y2 < height_ 
+               && metrics_info_.update_strategy == FullScreenUpdate)
+               pain.fillRectangle(0, metrics_info_.y2, width_,
+                       height_ - metrics_info_.y2, Color::bottomarea);
+}
+
 } // namespace lyx
index 2c8e3e0717c6d5d67c4775cdcefb59fa0b7a0352..3f68b00cfd6b8eaccc2babd4b6189b477f178bdd 100644 (file)
@@ -35,6 +35,8 @@ namespace lyx {
 
 namespace support { class FileName; }
 
+namespace frontend { class Painter; }
+
 class Buffer;
 class Change;
 class DocIterator;
@@ -211,6 +213,10 @@ public:
        CoordCache const & coordCache() const {
                return coord_cache_;
        }
+
+       ///
+       void draw(frontend::Painter & pain);
+
        /// get this view's keyboard map handler.
        Intl & getIntl() { return *intl_.get(); }
        ///
index 137de10185877a6aa79f9be44042d94d0f02a939..b44433d3608e63b1e526133a42a316abdab83fcf 100644 (file)
@@ -490,7 +490,7 @@ void GuiWorkArea::updateScreen()
 {
        QLPainter pain(&screen_);
        verticalScrollBar()->show();
-       paintText(*buffer_view_, pain);
+       buffer_view_->draw(pain);
 }
 
 
@@ -559,7 +559,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
 
        QLPainter pain(&screen_);
        buffer_view_->updateMetrics(false);
-       paintText(*buffer_view_, pain);
+       buffer_view_->draw(pain);
        Font font = buffer_view_->cursor().getFont();
        FontMetrics const & fm = theFontMetrics(font);
        int height = fm.maxHeight();
index 9751a5c016a7e43ef35822641f2fff433fe5e3a3..dbd9d0f0e3e3ca60e61d4eaf10c3487d8ecb89cf 100644 (file)
@@ -950,49 +950,4 @@ void paintPar
        LYXERR(Debug::PAINTING) << "." << endl;
 }
 
-
-void paintText(BufferView & bv,
-              Painter & pain)
-{
-       Buffer const & buffer = bv.buffer();
-       Text & text = buffer.text();
-       bool const select = bv.cursor().selection();
-       ViewMetricsInfo const & vi = bv.viewMetricsInfo();
-
-       PainterInfo pi(const_cast<BufferView *>(&bv), pain);
-       // Should the whole screen, including insets, be refreshed?
-       // FIXME: We should also distinguish DecorationUpdate to avoid text
-       // drawing if possible. This is not possible to do easily right now
-       // because of the single backing pixmap.
-       bool repaintAll = select || vi.update_strategy != SingleParUpdate;
-
-       if (repaintAll) {
-               // Clear background (if not delegated to rows)
-               pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
-                       text.backgroundColor());
-       }
-       if (select) {
-               text.drawSelection(pi, 0, 0);
-       }
-
-       int yy = vi.y1;
-       // draw contents
-       for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
-               ParagraphMetrics const & pm = bv.parMetrics(&text, pit);
-               yy += pm.ascent();
-               paintPar(pi, text, pit, 0, yy, repaintAll);
-               yy += pm.descent();
-       }
-
-       // and grey out above (should not happen later)
-//     lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
-       if (vi.y1 > 0 && vi.update_strategy == FullScreenUpdate)
-               pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, Color::bottomarea);
-
-       // and possibly grey out below
-//     lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
-       if (vi.y2 < bv.workHeight() && vi.update_strategy == FullScreenUpdate)
-               pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, Color::bottomarea);
-}
-
 } // namespace lyx
index a602bfe6ecdb622ecd2cebfc330f101a4c01eeae..fab612735b47a88ac81f560ea7cbe027b2249451 100644 (file)
@@ -25,9 +25,6 @@ class ViewMetricsInfo;
 
 namespace frontend { class Painter; }
 
-/// paint visible paragraph of main text
-void paintText(BufferView & bv, frontend::Painter & painter);
-
 /// paint paragraph.
 void paintPar
        (PainterInfo & pi, Text const & text, pit_type pit, int x, int y,