From 4ec8f6453d37a0815a738fcb826f02dad2efbcd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 15 Jul 2003 11:08:02 +0000 Subject: [PATCH] refresh_status_ trisate -> need_refresh_ bool git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7276 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/screen.C | 14 +++----------- src/frontends/screen.h | 13 +++---------- src/insets/insettabular.C | 5 +---- src/insets/insettext.C | 19 ++++++------------- src/lyxtext.h | 28 +++++++--------------------- src/rowpainter.C | 2 +- src/text2.C | 24 ++++++++++++------------ src/text3.C | 2 +- 8 files changed, 34 insertions(+), 73 deletions(-) diff --git a/src/frontends/screen.C b/src/frontends/screen.C index cd5e6bf931..2b375be2f5 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -306,25 +306,17 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv) void LyXScreen::update(BufferView & bv, int yo, int xo) { - int const vwidth = workarea().workWidth(); - int const vheight = workarea().workHeight(); LyXText * text = bv.text; workarea().getPainter().start(); - switch (text->refreshStatus()) { - case LyXText::REFRESH_ROW: - case LyXText::REFRESH_AREA: - { + if (text->needRefresh()) { + int const vwidth = workarea().workWidth(); + int const vheight = workarea().workHeight(); text->updateRowPositions(); int const y = max(int(text->refresh_y - text->top_y()), 0); drawFromTo(text, &bv, y, vheight, yo, xo); expose(0, y, vwidth, vheight - y); - break; - } - case LyXText::REFRESH_NONE: - // Nothing needs done - break; } workarea().getPainter().end(); diff --git a/src/frontends/screen.h b/src/frontends/screen.h index fd1b229e3a..4628e9ea43 100644 --- a/src/frontends/screen.h +++ b/src/frontends/screen.h @@ -89,11 +89,9 @@ public: * @param xo the x offset into the text * @param yo the x offset into the text * - * Updates part of the screen. If bv->text->status is - * LyXText::REFRESH_AREA, we update from the - * point of change and to the end of the screen. - * If text->status is LyXText::REFRESH_ROW, - * we only update the current row. + * Updates part of the screen. If bv->text->needRefresh is + * true, we update from the + * point of change to the end of the screen. */ virtual void update(BufferView & bv, int yo = 0, int xo = 0); @@ -141,11 +139,6 @@ protected: void drawFromTo(LyXText *, BufferView *, int y1, int y2, 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: /// grey out (no buffer) void greyOut(); diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 055d680db8..4808426553 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -431,11 +431,8 @@ void InsetTabular::update(BufferView * bv, bool reinit) } if (the_locking_inset) the_locking_inset->update(bv, reinit); - if (need_update < FULL && - bv->text->refreshStatus() == LyXText::REFRESH_AREA) - { + if (need_update < FULL && bv->text->needRefresh()) need_update = FULL; - } switch (need_update) { case INIT: diff --git a/src/insets/insettext.C b/src/insets/insettext.C index d4b3e0e14b..0f9a42e2b8 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -440,12 +440,12 @@ void InsetText::update(BufferView * bv, bool 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) { text_.updateInset(the_locking_inset); } - if (text_.refreshStatus() == LyXText::REFRESH_AREA) + if (text_.needRefresh()) need_update |= FULL; in_update = false; @@ -461,16 +461,9 @@ void InsetText::update(BufferView * bv, bool reinit) void InsetText::setUpdateStatus(int what) const { need_update |= what; - // we have to redraw us full if our LyXText REFRESH_AREA or - // if we don't break row so that we only have one row to update! - if ((text_.refreshStatus() == LyXText::REFRESH_AREA) || - (!autoBreakRows && - (text_.refreshStatus() == LyXText::REFRESH_ROW))) - { + // we will to redraw us full if our LyXText wants it + if (text_.needRefresh()) 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! if (need_update & CURSOR && !(need_update & SELECTION)) { @@ -489,8 +482,8 @@ void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) text_.partialRebreak(); setUpdateStatus(what); bool flag = mark_dirty || - (((need_update != CURSOR) && (need_update != NONE)) || - (text_.refreshStatus() != LyXText::REFRESH_NONE) || text_.selection.set()); + ((need_update != CURSOR && need_update != NONE) || + text_.needRefresh() || text_.selection.set()); if (!text_.selection.set()) text_.selection.cursor = text_.cursor; diff --git a/src/lyxtext.h b/src/lyxtext.h index 438b41e99c..0c0a5a3a29 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -44,16 +44,6 @@ class ParagraphList; // transition... class LyXText : public TextCursor { 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 LyXText(BufferView *); /// sets inset as owner @@ -180,14 +170,10 @@ public: /// clear any pending paints 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); - /** - * 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); /// @@ -203,14 +189,14 @@ public: * Return the status. This represents what repaints are * pending after some operation (e.g. inserting a char). */ - refresh_status refreshStatus() const; + bool needRefresh() const; private: /** * The pixel y position from which to repaint the screen. * The position is absolute along the height of outermost - * lyxtext (I think). REFRESH_AREA and REFRESH_ROW - * repaints both use this as a starting point (if it's within + * lyxtext (I think). If need_refresh_ is true + * repaints use this as a starting point (if it's within * the viewable portion of the lyxtext). */ int refresh_y; @@ -220,8 +206,8 @@ private: * It doesn't make any difference for REFRESH_AREA. */ RowList::iterator refresh_row; - - refresh_status refresh_status_; + // do we need a refresh? + bool need_refresh_; public: /// only the top-level LyXText has this non-zero diff --git a/src/rowpainter.C b/src/rowpainter.C index 820755e811..8c0ee616b3 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -259,7 +259,7 @@ void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic) { pos_type pos = text_.vis2log(vpos); pos_type const last = lastPrintablePos(text_, row_); - LyXFont orig_font(getFont(pos)); + LyXFont orig_font = getFont(pos); // first character string str; diff --git a/src/text2.C b/src/text2.C index 16de638e2a..d8204f0b7c 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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() { - refresh_status_ = REFRESH_NONE; + need_refresh_ = true; refresh_row = rows().end(); refresh_y = 0; } @@ -2304,12 +2304,12 @@ void LyXText::clearPaint() 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(); - if (old != REFRESH_NONE && refresh_y < start_y) + if (old && refresh_y < start_y) return; refresh_y = start_y; @@ -2328,17 +2328,17 @@ void LyXText::postPaint(int start_y) // make refresh_y be 0, and use row->y etc. void LyXText::postRowPaint(RowList::iterator rit, int start_y) { - if (refresh_status_ != REFRESH_NONE && refresh_y < start_y) { - refresh_status_ = REFRESH_AREA; + if (need_refresh_ && refresh_y < start_y) { + need_refresh_ = true; return; - } else { - refresh_y = start_y; } - if (refresh_status_ == REFRESH_AREA) + refresh_y = start_y; + + if (need_refresh_) return; - refresh_status_ = REFRESH_ROW; + need_refresh_ = true; refresh_row = rit; if (!inset_owner) diff --git a/src/text3.C b/src/text3.C index a99d1d4ba6..d22969ca00 100644 --- a/src/text3.C +++ b/src/text3.C @@ -75,7 +75,7 @@ namespace { } if (!lt->isInInset()) { bv->update(lt, BufferView::SELECT); - } else if (bv->text->refreshStatus() != LyXText::REFRESH_NONE) { + } else if (bv->text->needRefresh()) { bv->update(BufferView::SELECT); }