#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
#include "frontends/alert.h"
#include "frontends/FileDialog.h"
#include "frontends/FontMetrics.h"
+#include "frontends/Painter.h"
#include "frontends/Selection.h"
#include "graphics/Previews.h"
//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
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
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