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
This commit is contained in:
Lars Gullik Bjønnes 2006-07-04 00:04:46 +00:00
parent ee1871ef71
commit 1ff081141d
7 changed files with 39 additions and 13 deletions

View File

@ -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();
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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;