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();
* @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);
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();
}
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:
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;
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)) {
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;
// 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
/// 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);
///
* 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;
* 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
{
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;
}
-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;
}
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;
// 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)
}
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);
}