refresh_status_ trisate -> need_refresh_ bool

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7276 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-07-15 11:08:02 +00:00
parent e347e9e925
commit 4ec8f6453d
8 changed files with 34 additions and 73 deletions

View File

@ -306,25 +306,17 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
void LyXScreen::update(BufferView & bv, int yo, int xo) void LyXScreen::update(BufferView & bv, int yo, int xo)
{ {
int const vwidth = workarea().workWidth();
int const vheight = workarea().workHeight();
LyXText * text = bv.text; LyXText * text = bv.text;
workarea().getPainter().start(); workarea().getPainter().start();
switch (text->refreshStatus()) { if (text->needRefresh()) {
case LyXText::REFRESH_ROW: int const vwidth = workarea().workWidth();
case LyXText::REFRESH_AREA: int const vheight = workarea().workHeight();
{
text->updateRowPositions(); text->updateRowPositions();
int const y = max(int(text->refresh_y - text->top_y()), 0); int const y = max(int(text->refresh_y - text->top_y()), 0);
drawFromTo(text, &bv, y, vheight, yo, xo); drawFromTo(text, &bv, y, vheight, yo, xo);
expose(0, y, vwidth, vheight - y); expose(0, y, vwidth, vheight - y);
break;
}
case LyXText::REFRESH_NONE:
// Nothing needs done
break;
} }
workarea().getPainter().end(); workarea().getPainter().end();

View File

@ -89,11 +89,9 @@ public:
* @param xo the x offset into the text * @param xo the x offset into the text
* @param yo the x offset into the text * @param yo the x offset into the text
* *
* Updates part of the screen. If bv->text->status is * Updates part of the screen. If bv->text->needRefresh is
* LyXText::REFRESH_AREA, we update from the * true, we update from the
* point of change and to the end of the screen. * point of change to the end of the screen.
* If text->status is LyXText::REFRESH_ROW,
* we only update the current row.
*/ */
virtual void update(BufferView & bv, int yo = 0, int xo = 0); virtual void update(BufferView & bv, int yo = 0, int xo = 0);
@ -141,11 +139,6 @@ protected:
void drawFromTo(LyXText *, BufferView *, int y1, int y2, void drawFromTo(LyXText *, BufferView *, int y1, int y2,
int y_offset = 0, int x_offset = 0); int y_offset = 0, int x_offset = 0);
/// y is a coordinate of the text
void drawOneRow(LyXText *, BufferView *,
RowList::iterator row,
int y_text, int y_offset = 0, int x_offset = 0);
private: private:
/// grey out (no buffer) /// grey out (no buffer)
void greyOut(); void greyOut();

View File

@ -431,11 +431,8 @@ void InsetTabular::update(BufferView * bv, bool reinit)
} }
if (the_locking_inset) if (the_locking_inset)
the_locking_inset->update(bv, reinit); the_locking_inset->update(bv, reinit);
if (need_update < FULL && if (need_update < FULL && bv->text->needRefresh())
bv->text->refreshStatus() == LyXText::REFRESH_AREA)
{
need_update = FULL; need_update = FULL;
}
switch (need_update) { switch (need_update) {
case INIT: case INIT:

View File

@ -440,12 +440,12 @@ void InsetText::update(BufferView * bv, bool reinit)
the_locking_inset->update(bv, reinit); the_locking_inset->update(bv, reinit);
} }
if ((need_update & CURSOR_PAR) && (text_.refreshStatus() == LyXText::REFRESH_NONE) && if ((need_update & CURSOR_PAR) && !text_.needRefresh() &&
the_locking_inset) { the_locking_inset) {
text_.updateInset(the_locking_inset); text_.updateInset(the_locking_inset);
} }
if (text_.refreshStatus() == LyXText::REFRESH_AREA) if (text_.needRefresh())
need_update |= FULL; need_update |= FULL;
in_update = false; in_update = false;
@ -461,16 +461,9 @@ void InsetText::update(BufferView * bv, bool reinit)
void InsetText::setUpdateStatus(int what) const void InsetText::setUpdateStatus(int what) const
{ {
need_update |= what; need_update |= what;
// we have to redraw us full if our LyXText REFRESH_AREA or // we will to redraw us full if our LyXText wants it
// if we don't break row so that we only have one row to update! if (text_.needRefresh())
if ((text_.refreshStatus() == LyXText::REFRESH_AREA) ||
(!autoBreakRows &&
(text_.refreshStatus() == LyXText::REFRESH_ROW)))
{
need_update |= FULL; need_update |= FULL;
} else if (text_.refreshStatus() == LyXText::REFRESH_ROW) {
need_update |= CURSOR_PAR;
}
// this to not draw a selection when we redraw all of it! // this to not draw a selection when we redraw all of it!
if (need_update & CURSOR && !(need_update & SELECTION)) { if (need_update & CURSOR && !(need_update & SELECTION)) {
@ -489,8 +482,8 @@ void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty)
text_.partialRebreak(); text_.partialRebreak();
setUpdateStatus(what); setUpdateStatus(what);
bool flag = mark_dirty || bool flag = mark_dirty ||
(((need_update != CURSOR) && (need_update != NONE)) || ((need_update != CURSOR && need_update != NONE) ||
(text_.refreshStatus() != LyXText::REFRESH_NONE) || text_.selection.set()); text_.needRefresh() || text_.selection.set());
if (!text_.selection.set()) if (!text_.selection.set())
text_.selection.cursor = text_.cursor; text_.selection.cursor = text_.cursor;

View File

@ -44,16 +44,6 @@ class ParagraphList;
// transition... // transition...
class LyXText : public TextCursor { class LyXText : public TextCursor {
public: public:
/// what repainting is needed
enum refresh_status {
/// no repaint is needed
REFRESH_NONE = 0,
/// the refresh_row needs repainting
REFRESH_ROW = 1,
/// everything from refresh_y downwards needs repainting
REFRESH_AREA = 2
};
/// Constructor /// Constructor
LyXText(BufferView *); LyXText(BufferView *);
/// sets inset as owner /// sets inset as owner
@ -180,14 +170,10 @@ public:
/// clear any pending paints /// clear any pending paints
void clearPaint(); void clearPaint();
/** /// Mark position y as the starting point for a repaint
* Mark position y as the starting point for a repaint
*/
void postPaint(int start_y); void postPaint(int start_y);
/** /// Mark the given row at position y as needing a repaint.
* Mark the given row at position y as needing a repaint.
*/
void postRowPaint(RowList::iterator rit, int start_y); void postRowPaint(RowList::iterator rit, int start_y);
/// ///
@ -203,14 +189,14 @@ public:
* Return the status. This represents what repaints are * Return the status. This represents what repaints are
* pending after some operation (e.g. inserting a char). * pending after some operation (e.g. inserting a char).
*/ */
refresh_status refreshStatus() const; bool needRefresh() const;
private: private:
/** /**
* The pixel y position from which to repaint the screen. * The pixel y position from which to repaint the screen.
* The position is absolute along the height of outermost * The position is absolute along the height of outermost
* lyxtext (I think). REFRESH_AREA and REFRESH_ROW * lyxtext (I think). If need_refresh_ is true
* repaints both use this as a starting point (if it's within * repaints use this as a starting point (if it's within
* the viewable portion of the lyxtext). * the viewable portion of the lyxtext).
*/ */
int refresh_y; int refresh_y;
@ -220,8 +206,8 @@ private:
* It doesn't make any difference for REFRESH_AREA. * It doesn't make any difference for REFRESH_AREA.
*/ */
RowList::iterator refresh_row; RowList::iterator refresh_row;
// do we need a refresh?
refresh_status refresh_status_; bool need_refresh_;
public: public:
/// only the top-level LyXText has this non-zero /// only the top-level LyXText has this non-zero

View File

@ -259,7 +259,7 @@ void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
{ {
pos_type pos = text_.vis2log(vpos); pos_type pos = text_.vis2log(vpos);
pos_type const last = lastPrintablePos(text_, row_); pos_type const last = lastPrintablePos(text_, row_);
LyXFont orig_font(getFont(pos)); LyXFont orig_font = getFont(pos);
// first character // first character
string str; string str;

View File

@ -2288,15 +2288,15 @@ ParagraphList & LyXText::ownerParagraphs() const
} }
LyXText::refresh_status LyXText::refreshStatus() const bool LyXText::needRefresh() const
{ {
return refresh_status_; return need_refresh_;
} }
void LyXText::clearPaint() void LyXText::clearPaint()
{ {
refresh_status_ = REFRESH_NONE; need_refresh_ = true;
refresh_row = rows().end(); refresh_row = rows().end();
refresh_y = 0; refresh_y = 0;
} }
@ -2304,12 +2304,12 @@ void LyXText::clearPaint()
void LyXText::postPaint(int start_y) void LyXText::postPaint(int start_y)
{ {
refresh_status old = refresh_status_; bool old = need_refresh_;
refresh_status_ = REFRESH_AREA; need_refresh_ = true;
refresh_row = rows().end(); refresh_row = rows().end();
if (old != REFRESH_NONE && refresh_y < start_y) if (old && refresh_y < start_y)
return; return;
refresh_y = start_y; refresh_y = start_y;
@ -2328,17 +2328,17 @@ void LyXText::postPaint(int start_y)
// make refresh_y be 0, and use row->y etc. // make refresh_y be 0, and use row->y etc.
void LyXText::postRowPaint(RowList::iterator rit, int start_y) void LyXText::postRowPaint(RowList::iterator rit, int start_y)
{ {
if (refresh_status_ != REFRESH_NONE && refresh_y < start_y) { if (need_refresh_ && refresh_y < start_y) {
refresh_status_ = REFRESH_AREA; need_refresh_ = true;
return; return;
} else {
refresh_y = start_y;
} }
if (refresh_status_ == REFRESH_AREA) refresh_y = start_y;
if (need_refresh_)
return; return;
refresh_status_ = REFRESH_ROW; need_refresh_ = true;
refresh_row = rit; refresh_row = rit;
if (!inset_owner) if (!inset_owner)

View File

@ -75,7 +75,7 @@ namespace {
} }
if (!lt->isInInset()) { if (!lt->isInInset()) {
bv->update(lt, BufferView::SELECT); bv->update(lt, BufferView::SELECT);
} else if (bv->text->refreshStatus() != LyXText::REFRESH_NONE) { } else if (bv->text->needRefresh()) {
bv->update(BufferView::SELECT); bv->update(BufferView::SELECT);
} }