From 1ff081141d708ef45aa74c1f04d837d81b53a070 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Tue, 4 Jul 2006 00:04:46 +0000 Subject: [PATCH] Extraced from r14281 from the younes branch. * BufferView, BufferView::pimpl: - metrics_info_: private variable holding ViewMetricsInfo - viewMetricsInfo(): accessor function - updateMetrics(): renamed from metrics(), sets metrics_info_ - update(): change to use updateMetrics() * frontends/WorkArea: - redraw(): get the ViewMetricsInfo through accessor to BufferView. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14331 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 7 +++++++ src/BufferView.h | 3 +++ src/BufferView_pimpl.C | 18 ++++++++++++------ src/BufferView_pimpl.h | 10 ++++++++-- src/frontends/WorkArea.C | 3 ++- src/frontends/WorkArea.h | 3 +-- src/metricsinfo.h | 8 ++++++-- 7 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index bedd197e57..f1c1834b1c 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -37,6 +37,7 @@ #include "texrow.h" #include "undo.h" #include "WordLangTuple.h" +#include "metricsinfo.h" #include "frontends/Alert.h" #include "frontends/Clipboard.h" @@ -401,3 +402,9 @@ int BufferView::offset_ref() const { return pimpl_->offset_ref_; } + + +ViewMetricsInfo const & BufferView::viewMetricsInfo() +{ + return pimpl_->viewMetricsInfo(); +} diff --git a/src/BufferView.h b/src/BufferView.h index ec48a0ffcc..924637e10c 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -34,6 +34,7 @@ class LCursor; class LyXText; class LyXView; class ParIterator; +class ViewMetricsInfo; namespace Update { enum flags { @@ -223,6 +224,8 @@ public: void putSelectionAt(DocIterator const & cur, int length, bool backwards); + /// + ViewMetricsInfo const & viewMetricsInfo(); private: /// class Pimpl; diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 673332de9b..43f384f602 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -681,6 +681,12 @@ bool BufferView::Pimpl::multiParSel() } +ViewMetricsInfo const & BufferView::Pimpl::viewMetricsInfo() +{ + return metrics_info_; +} + + void BufferView::Pimpl::update(Update::flags flags) { lyxerr[Debug::DEBUG] @@ -704,20 +710,20 @@ void BufferView::Pimpl::update(Update::flags flags) theCoords.startUpdating(); // First drawing step - ViewMetricsInfo vi = metrics(flags & Update::SinglePar); + updateMetrics(flags & Update::SinglePar); bool forceupdate(flags & (Update::Force | Update::SinglePar)); if ((flags & Update::FitCursor) && fitCursor()) { forceupdate = true; - vi = metrics(); + updateMetrics(); } if ((flags & Update::MultiParSel) && multiParSel()) { forceupdate = true; - vi = metrics(); + updateMetrics(); } if (forceupdate) { // Second drawing step - owner_->workArea()->redraw(*bv_, vi); + owner_->workArea()->redraw(*bv_); } else { // Abort updating of the coord // cache - just restore the old one @@ -1404,7 +1410,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd) } -ViewMetricsInfo BufferView::Pimpl::metrics(bool singlepar) +void BufferView::Pimpl::updateMetrics(bool singlepar) { // Remove old position cache theCoords.clear(); @@ -1501,5 +1507,5 @@ ViewMetricsInfo BufferView::Pimpl::metrics(bool singlepar) << "size: " << size << endl; - return ViewMetricsInfo(pit1, pit2, y1, y2, singlepar, size); + metrics_info_ = ViewMetricsInfo(pit1, pit2, y1, y2, singlepar, size); } diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 7bf4d2cef6..c39e137dc2 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -21,6 +21,7 @@ #include "BufferView.h" #include "cursor.h" #include "errorlist.h" +#include "metricsinfo.h" #include "frontends/LyXKeySym.h" #include "frontends/Timeout.h" @@ -117,6 +118,8 @@ public: */ int height() const; + /// + ViewMetricsInfo const & viewMetricsInfo(); private: /// int width_; @@ -156,6 +159,11 @@ private: /// friend class BufferView; + /// + ViewMetricsInfo metrics_info_; + /// + void updateMetrics(bool singlepar = false); + /// BufferView * bv_; /// @@ -203,7 +211,5 @@ private: lyx::pit_type anchor_ref_; /// int offset_ref_; - /// - ViewMetricsInfo metrics(bool singlepar = false); }; #endif // BUFFERVIEW_PIMPL_H diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index 4dc2314b8c..9abf811b11 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -155,9 +155,10 @@ void WorkArea::checkAndGreyOut() } -void WorkArea::redraw(BufferView & bv, ViewMetricsInfo const & vi) +void WorkArea::redraw(BufferView & bv) { greyed_out_ = false; + ViewMetricsInfo const & vi = bv.viewMetricsInfo(); getPainter().start(); paintText(*buffer_view_, vi); lyxerr[Debug::DEBUG] << "Redraw screen" << endl; diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index 33ca042d09..ad55382e60 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -20,7 +20,6 @@ #include "frontends/LyXKeySym.h" class BufferView; -class ViewMetricsInfo; namespace lyx { namespace frontend { @@ -65,7 +64,7 @@ public: virtual void setScrollbarParams(int height, int pos, int line_height) = 0; /// redraw the screen, without using existing pixmap - virtual void redraw(BufferView & bv, ViewMetricsInfo const & vi); + virtual void redraw(BufferView & bv); /// grey out (no buffer) void greyOut(); diff --git a/src/metricsinfo.h b/src/metricsinfo.h index 8416311695..b2366783f6 100644 --- a/src/metricsinfo.h +++ b/src/metricsinfo.h @@ -106,9 +106,13 @@ class TextMetricsInfo {}; class ViewMetricsInfo { public: + ViewMetricsInfo() + : p1(0), p2(0), y1(0), y2(0), + singlepar(false), size(0) {} ViewMetricsInfo(lyx::pit_type p1, lyx::pit_type p2, int y1, int y2, - bool singlepar, lyx::pit_type size) : p1(p1), p2(p2), - y1(y1), y2(y2), singlepar(singlepar), size(size) {} + bool singlepar, lyx::pit_type size) + : p1(p1), p2(p2), y1(y1), y2(y2), + singlepar(singlepar), size(size) {} lyx::pit_type p1; lyx::pit_type p2; int y1; -- 2.39.2