Rename screen, and don't re-construct it on a buffer change (that is far too

nosy of the core), and use an accessor ...


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4372 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-06-11 23:47:58 +00:00
parent ddcd73acd7
commit 92e53dc01b
15 changed files with 136 additions and 120 deletions

View File

@ -42,9 +42,9 @@ Buffer * BufferView::buffer() const
} }
LyXScreen * BufferView::screen() const LScreen & BufferView::screen() const
{ {
return pimpl_->screen_.get(); return pimpl_->screen();
} }

View File

@ -25,7 +25,7 @@ class LyXView;
class LyXText; class LyXText;
class TeXErrors; class TeXErrors;
class Buffer; class Buffer;
class LyXScreen; class LScreen;
class Language; class Language;
class Painter; class Painter;
class UpdatableInset; class UpdatableInset;
@ -54,7 +54,7 @@ public:
/// ///
Painter & painter(); Painter & painter();
/// ///
LyXScreen * screen() const; LScreen & screen() const;
/// ///
void buffer(Buffer * b); void buffer(Buffer * b);
/// ///

View File

@ -564,7 +564,7 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc)
locking_inset)) locking_inset))
text->setCursor(this, cursor, text->setCursor(this, cursor,
cursor.par(), cursor.pos() - 1); cursor.par(), cursor.pos() - 1);
LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE; LScreen::Cursor_Shape shape = LScreen::BAR_SHAPE;
LyXText * txt = getLyXText(); LyXText * txt = getLyXText();
if (locking_inset->isTextInset() && if (locking_inset->isTextInset() &&
locking_inset->lyxCode() != Inset::ERT_CODE && locking_inset->lyxCode() != Inset::ERT_CODE &&
@ -573,8 +573,8 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc)
|| txt->real_current_font.isVisibleRightToLeft() || txt->real_current_font.isVisibleRightToLeft()
!= buffer()->params.language->RightToLeft())) != buffer()->params.language->RightToLeft()))
shape = (txt->real_current_font.isVisibleRightToLeft()) shape = (txt->real_current_font.isVisibleRightToLeft())
? LyXScreen::REVERSED_L_SHAPE ? LScreen::REVERSED_L_SHAPE
: LyXScreen::L_SHAPE; : LScreen::L_SHAPE;
y += cursor.iy() + theLockingInset()->insetInInsetY(); y += cursor.iy() + theLockingInset()->insetInInsetY();
pimpl_->screen_->showManualCursor(text, x, y, asc, desc, pimpl_->screen_->showManualCursor(text, x, y, asc, desc,
shape); shape);

View File

@ -139,6 +139,7 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
using_xterm_cursor(false), inset_slept(false) using_xterm_cursor(false), inset_slept(false)
{ {
workarea_.reset(new WorkArea(xpos, ypos, width, height)); workarea_.reset(new WorkArea(xpos, ypos, width, height));
screen_.reset(new LScreen(workarea()));
// Setup the signals // Setup the signals
workarea().scrollCB.connect(boost::bind(&BufferView::Pimpl::scrollCB, this, _1)); workarea().scrollCB.connect(boost::bind(&BufferView::Pimpl::scrollCB, this, _1));
@ -178,6 +179,12 @@ WorkArea & BufferView::Pimpl::workarea() const
} }
LScreen & BufferView::Pimpl::screen() const
{
return *screen_.get();
}
Painter & BufferView::Pimpl::painter() Painter & BufferView::Pimpl::painter()
{ {
return workarea().getPainter(); return workarea().getPainter();
@ -210,10 +217,6 @@ void BufferView::Pimpl::buffer(Buffer * b)
if (bufferlist.getState() == BufferList::CLOSING) return; if (bufferlist.getState() == BufferList::CLOSING) return;
// Nuke old image
// screen is always deleted when the buffer is changed.
screen_.reset(0);
// If we are closing the buffer, use the first buffer as current // If we are closing the buffer, use the first buffer as current
if (!buffer_) { if (!buffer_) {
buffer_ = bufferlist.first(); buffer_ = bufferlist.first();
@ -229,7 +232,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
updateScreen(); updateScreen();
updateScrollbar(); updateScrollbar();
} }
bv_->text->first_y = screen_->topCursorVisible(bv_->text); bv_->text->first_y = screen().topCursorVisible(bv_->text);
owner_->updateMenubar(); owner_->updateMenubar();
owner_->updateToolbar(); owner_->updateToolbar();
// Similarly, buffer-dependent dialogs should be updated or // Similarly, buffer-dependent dialogs should be updated or
@ -286,15 +289,13 @@ void BufferView::Pimpl::redraw()
bool BufferView::Pimpl::fitCursor() bool BufferView::Pimpl::fitCursor()
{ {
lyx::Assert(screen_.get());
bool ret; bool ret;
if (bv_->theLockingInset()) { if (bv_->theLockingInset()) {
bv_->theLockingInset()->fitInsetCursor(bv_); bv_->theLockingInset()->fitInsetCursor(bv_);
ret = true; ret = true;
} else { } else {
ret = screen_->fitCursor(bv_->text, bv_); ret = screen().fitCursor(bv_->text, bv_);
} }
bv_->owner()->getDialogs()->updateParagraph(); bv_->owner()->getDialogs()->updateParagraph();
@ -391,7 +392,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
bv_->theLockingInset(the_locking_inset); bv_->theLockingInset(the_locking_inset);
} }
bv_->text->first_y = screen_->topCursorVisible(bv_->text); bv_->text->first_y = screen().topCursorVisible(bv_->text);
// this will scroll the screen such that the cursor becomes visible // this will scroll the screen such that the cursor becomes visible
updateScrollbar(); updateScrollbar();
@ -410,7 +411,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
void BufferView::Pimpl::updateScreen() void BufferView::Pimpl::updateScreen()
{ {
// Regenerate the screen. // Regenerate the screen.
screen_.reset(new LyXScreen(workarea())); screen().reset();
} }
@ -462,10 +463,7 @@ void BufferView::Pimpl::scrollCB(double value)
if (current_scrollbar_value < 0) if (current_scrollbar_value < 0)
current_scrollbar_value = 0; current_scrollbar_value = 0;
if (!screen_.get()) screen().draw(bv_->text, bv_, current_scrollbar_value);
return;
screen_->draw(bv_->text, bv_, current_scrollbar_value);
if (!lyxrc.cursor_follows_scrollbar) { if (!lyxrc.cursor_follows_scrollbar) {
waitForX(); waitForX();
@ -489,7 +487,7 @@ void BufferView::Pimpl::scrollCB(double value)
int BufferView::Pimpl::scrollUp(long time) int BufferView::Pimpl::scrollUp(long time)
{ {
if (!buffer_ || !screen_.get()) if (!buffer_)
return 0; return 0;
double value = workarea().getScrollbarValue(); double value = workarea().getScrollbarValue();
@ -522,7 +520,7 @@ int BufferView::Pimpl::scrollUp(long time)
int BufferView::Pimpl::scrollDown(long time) int BufferView::Pimpl::scrollDown(long time)
{ {
if (!buffer_ || !screen_.get()) if (!buffer_)
return 0; return 0;
double value = workarea().getScrollbarValue(); double value = workarea().getScrollbarValue();
@ -567,7 +565,8 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state s
if (!(state & mouse_button::button1)) if (!(state & mouse_button::button1))
return; return;
if (!buffer_ || !screen_.get()) return; if (!buffer_)
return;
// Check for inset locking // Check for inset locking
if (bv_->theLockingInset()) { if (bv_->theLockingInset()) {
@ -592,7 +591,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state s
if (!selection_possible) if (!selection_possible)
return; return;
screen_->hideCursor(); screen().hideCursor();
#if 0 #if 0
int y_before = bv_->text->cursor.y(); int y_before = bv_->text->cursor.y();
#endif #endif
@ -619,7 +618,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state s
update(bv_->text, BufferView::UPDATE); // Maybe an empty line was deleted update(bv_->text, BufferView::UPDATE); // Maybe an empty line was deleted
bv_->text->setSelection(bv_); bv_->text->setSelection(bv_);
screen_->toggleToggle(bv_->text, bv_); screen().toggleToggle(bv_->text, bv_);
fitCursor(); fitCursor();
showCursor(); showCursor();
} }
@ -629,7 +628,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state s
void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
mouse_button::state button) mouse_button::state button)
{ {
if (!buffer_ || !screen_.get()) if (!buffer_)
return; return;
// ok ok, this is a hack. // ok ok, this is a hack.
@ -678,10 +677,10 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
if (!inset_hit) if (!inset_hit)
selection_possible = true; selection_possible = true;
screen_->hideCursor(); screen().hideCursor();
// Clear the selection // Clear the selection
screen_->toggleSelection(bv_->text, bv_); screen().toggleSelection(bv_->text, bv_);
bv_->text->clearSelection(); bv_->text->clearSelection();
bv_->text->fullRebreak(bv_); bv_->text->fullRebreak(bv_);
update(); update();
@ -747,12 +746,12 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, mouse_button::state bu
if (text->bv_owner && bv_->theLockingInset()) if (text->bv_owner && bv_->theLockingInset())
return; return;
if (screen_.get() && button == mouse_button::button1) { if (button == mouse_button::button1) {
if (text->bv_owner) { if (text->bv_owner) {
screen_->hideCursor(); screen().hideCursor();
screen_->toggleSelection(text, bv_); screen().toggleSelection(text, bv_);
text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT); text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT);
screen_->toggleSelection(text, bv_, false); screen().toggleSelection(text, bv_, false);
} else { } else {
text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT); text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT);
} }
@ -773,17 +772,17 @@ void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, mouse_button::state bu
if (text->bv_owner && bv_->theLockingInset()) if (text->bv_owner && bv_->theLockingInset())
return; return;
if (screen_.get() && (button == mouse_button::button1)) { if (button == mouse_button::button1) {
if (text->bv_owner) { if (text->bv_owner) {
screen_->hideCursor(); screen().hideCursor();
screen_->toggleSelection(text, bv_); screen().toggleSelection(text, bv_);
} }
text->cursorHome(bv_); text->cursorHome(bv_);
text->selection.cursor = text->cursor; text->selection.cursor = text->cursor;
text->cursorEnd(bv_); text->cursorEnd(bv_);
text->setSelection(bv_); text->setSelection(bv_);
if (text->bv_owner) { if (text->bv_owner) {
screen_->toggleSelection(text, bv_, false); screen().toggleSelection(text, bv_, false);
} }
/* This will fit the cursor on the screen /* This will fit the cursor on the screen
* if necessary */ * if necessary */
@ -852,7 +851,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
mouse_button::state button) mouse_button::state button)
{ {
// do nothing if we used the mouse wheel // do nothing if we used the mouse wheel
if (!buffer_ || !screen_.get() || button == mouse_button::button4 || button == mouse_button::button5) if (!buffer_ || button == mouse_button::button4 || button == mouse_button::button5)
return; return;
// If we hit an inset, we have the inset coordinates in these // If we hit an inset, we have the inset coordinates in these
@ -1011,9 +1010,6 @@ Inset * BufferView::Pimpl::checkInset(LyXText const & text,
Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y) Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y)
{ {
if (!screen_.get())
return 0;
int y_tmp = y + text->first_y; int y_tmp = y + text->first_y;
LyXCursor cursor; LyXCursor cursor;
@ -1079,8 +1075,9 @@ void BufferView::Pimpl::workAreaExpose()
// The main window size has changed, repaint most stuff // The main window size has changed, repaint most stuff
redraw(); redraw();
} else if (screen_.get()) } else {
screen_->redraw(bv_->text, bv_); screen().redraw(bv_->text, bv_);
}
} else { } else {
// Grey box when we don't have a buffer // Grey box when we don't have a buffer
workarea().greyOut(); workarea().greyOut();
@ -1095,11 +1092,9 @@ void BufferView::Pimpl::workAreaExpose()
void BufferView::Pimpl::update() void BufferView::Pimpl::update()
{ {
if (screen_.get() && if (!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()) {
(!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()))
{
LyXText::text_status st = bv_->text->status(); LyXText::text_status st = bv_->text->status();
screen_->update(bv_->text, bv_); screen().update(bv_->text, bv_);
bool fitc = false; bool fitc = false;
while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) { while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) {
bv_->text->fullRebreak(bv_); bv_->text->fullRebreak(bv_);
@ -1116,7 +1111,7 @@ void BufferView::Pimpl::update()
} }
fitc = true; fitc = true;
bv_->text->status(bv_, st); bv_->text->status(bv_, st);
screen_->update(bv_->text, bv_); screen().update(bv_->text, bv_);
} }
// do this here instead of in the screen::update because of // do this here instead of in the screen::update because of
// the above loop! // the above loop!
@ -1199,17 +1194,12 @@ void BufferView::Pimpl::cursorToggle()
return; return;
} }
if (!screen_.get()) {
cursor_timeout.restart();
return;
}
/* FIXME */ /* FIXME */
extern void reapSpellchecker(void); extern void reapSpellchecker(void);
reapSpellchecker(); reapSpellchecker();
if (!bv_->theLockingInset()) { if (!bv_->theLockingInset()) {
screen_->cursorToggle(bv_); screen().cursorToggle(bv_);
} else { } else {
bv_->theLockingInset()->toggleInsetCursor(bv_); bv_->theLockingInset()->toggleInsetCursor(bv_);
} }
@ -1223,7 +1213,7 @@ void BufferView::Pimpl::cursorPrevious(LyXText * text)
if (!text->cursor.row()->previous()) { if (!text->cursor.row()->previous()) {
if (text->first_y > 0) { if (text->first_y > 0) {
int new_y = bv_->text->first_y - workarea().height(); int new_y = bv_->text->first_y - workarea().height();
screen_->draw(bv_->text, bv_, new_y < 0 ? 0 : new_y); screen().draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
updateScrollbar(); updateScrollbar();
} }
return; return;
@ -1256,7 +1246,7 @@ void BufferView::Pimpl::cursorPrevious(LyXText * text)
- workarea().height() + 1; - workarea().height() + 1;
} }
} }
screen_->draw(bv_->text, bv_, new_y < 0 ? 0 : new_y); screen().draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
if (text->cursor.row()->previous()) { if (text->cursor.row()->previous()) {
LyXCursor cur; LyXCursor cur;
text->setCursor(bv_, cur, text->cursor.row()->previous()->par(), text->setCursor(bv_, cur, text->cursor.row()->previous()->par(),
@ -1275,7 +1265,7 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
int y = text->cursor.y() - text->cursor.row()->baseline() + int y = text->cursor.y() - text->cursor.row()->baseline() +
text->cursor.row()->height(); text->cursor.row()->height();
if (y > int(text->first_y + workarea().height())) { if (y > int(text->first_y + workarea().height())) {
screen_->draw(bv_->text, bv_, screen().draw(bv_->text, bv_,
bv_->text->first_y + workarea().height()); bv_->text->first_y + workarea().height());
updateScrollbar(); updateScrollbar();
} }
@ -1310,7 +1300,7 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
new_y = text->cursor.y() - text->cursor.row()->baseline(); new_y = text->cursor.y() - text->cursor.row()->baseline();
} }
} }
screen_->draw(bv_->text, bv_, new_y); screen().draw(bv_->text, bv_, new_y);
if (text->cursor.row()->next()) { if (text->cursor.row()->next()) {
LyXCursor cur; LyXCursor cur;
text->setCursor(bv_, cur, text->cursor.row()->next()->par(), text->setCursor(bv_, cur, text->cursor.row()->next()->par(),
@ -1460,40 +1450,31 @@ void BufferView::Pimpl::focus(bool f)
void BufferView::Pimpl::showCursor() void BufferView::Pimpl::showCursor()
{ {
if (screen_.get()) { if (bv_->theLockingInset())
if (bv_->theLockingInset()) bv_->theLockingInset()->showInsetCursor(bv_);
bv_->theLockingInset()->showInsetCursor(bv_); else
else screen().showCursor(bv_->text, bv_);
screen_->showCursor(bv_->text, bv_);
}
} }
void BufferView::Pimpl::hideCursor() void BufferView::Pimpl::hideCursor()
{ {
if (screen_.get()) { if (!bv_->theLockingInset())
if (!bv_->theLockingInset()) screen().hideCursor();
// bv_->theLockingInset()->hideInsetCursor(bv_);
// else
screen_->hideCursor();
}
} }
void BufferView::Pimpl::toggleSelection(bool b) void BufferView::Pimpl::toggleSelection(bool b)
{ {
if (screen_.get()) { if (bv_->theLockingInset())
if (bv_->theLockingInset()) bv_->theLockingInset()->toggleSelection(bv_, b);
bv_->theLockingInset()->toggleSelection(bv_, b); screen().toggleSelection(bv_->text, bv_, b);
screen_->toggleSelection(bv_->text, bv_, b);
}
} }
void BufferView::Pimpl::toggleToggle() void BufferView::Pimpl::toggleToggle()
{ {
if (screen_.get()) screen().toggleToggle(bv_->text, bv_);
screen_->toggleToggle(bv_->text, bv_);
} }
@ -1501,9 +1482,9 @@ void BufferView::Pimpl::center()
{ {
beforeChange(bv_->text); beforeChange(bv_->text);
if (bv_->text->cursor.y() > static_cast<int>((workarea().height() / 2))) { if (bv_->text->cursor.y() > static_cast<int>((workarea().height() / 2))) {
screen_->draw(bv_->text, bv_, bv_->text->cursor.y() - workarea().height() / 2); screen().draw(bv_->text, bv_, bv_->text->cursor.y() - workarea().height() / 2);
} else { } else {
screen_->draw(bv_->text, bv_, 0); screen().draw(bv_->text, bv_, 0);
} }
update(bv_->text, BufferView::SELECT|BufferView::FITCUR); update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
redraw(); redraw();
@ -1515,7 +1496,7 @@ void BufferView::Pimpl::pasteClipboard(bool asPara)
if (!buffer_) if (!buffer_)
return; return;
screen_->hideCursor(); screen().hideCursor();
beforeChange(bv_->text); beforeChange(bv_->text);
string const clip(workarea().getClipboard()); string const clip(workarea().getClipboard());

View File

@ -21,7 +21,7 @@
class LyXView; class LyXView;
class WorkArea; class WorkArea;
class LyXScreen; class LScreen;
// FIXME: remove // FIXME: remove
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -35,6 +35,8 @@ struct BufferView::Pimpl : public boost::signals::trackable {
Painter & painter(); Painter & painter();
/// return the work area for this bview /// return the work area for this bview
WorkArea & workarea() const; WorkArea & workarea() const;
/// return the screen for this bview
LScreen & screen() const;
/// ///
void buffer(Buffer *); void buffer(Buffer *);
/// ///
@ -175,7 +177,7 @@ private:
/// ///
Buffer * buffer_; Buffer * buffer_;
/// ///
boost::scoped_ptr<LyXScreen> screen_; boost::scoped_ptr<LScreen> screen_;
/// ///
boost::scoped_ptr<WorkArea> workarea_; boost::scoped_ptr<WorkArea> workarea_;
/// ///

View File

@ -1,3 +1,14 @@
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* BufferView.h:
* BufferView.C:
* BufferView2.C:
* BufferView_pimpl.h:
* BufferView_pimpl.C: only construct screen once,
rename
* lyxrc.C: remove pointless comment
2002-06-11 John Levon <moz@compsoc.man.ac.uk> 2002-06-11 John Levon <moz@compsoc.man.ac.uk>
* BufferView.h: * BufferView.h:

View File

@ -1,3 +1,8 @@
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* screen.h:
* screen.C: rename, add reset()
2002-06-11 John Levon <moz@compsoc.man.ac.uk> 2002-06-11 John Levon <moz@compsoc.man.ac.uk>
* font_metrics.h: move X-specific stuff out of namespace * font_metrics.h: move X-specific stuff out of namespace

View File

@ -52,7 +52,7 @@ GC createGC()
// Constructor // Constructor
LyXScreen::LyXScreen(WorkArea & o) LScreen::LScreen(WorkArea & o)
: owner(o), force_clear(true) : owner(o), force_clear(true)
{ {
// the cursor isnt yet visible // the cursor isnt yet visible
@ -68,13 +68,29 @@ LyXScreen::LyXScreen(WorkArea & o)
} }
LyXScreen::~LyXScreen() LScreen::~LScreen()
{ {
XFreeGC(fl_get_display(), gc_copy); XFreeGC(fl_get_display(), gc_copy);
} }
void LyXScreen::setCursorColor() void LScreen::reset()
{
XFreeGC(fl_get_display(), gc_copy);
// the cursor isnt yet visible
cursor_visible = false;
cursor_pixmap = 0;
cursor_pixmap_x = 0;
cursor_pixmap_y = 0;
cursor_pixmap_w = 0;
cursor_pixmap_h = 0;
// We need this GC
gc_copy = createGC();
}
void LScreen::setCursorColor()
{ {
if (!lyxColorHandler.get()) return; if (!lyxColorHandler.get()) return;
@ -87,7 +103,7 @@ void LyXScreen::setCursorColor()
} }
void LyXScreen::redraw(LyXText * text, BufferView * bv) void LScreen::redraw(LyXText * text, BufferView * bv)
{ {
drawFromTo(text, bv, 0, owner.height(), 0, 0, text == bv->text); drawFromTo(text, bv, 0, owner.height(), 0, 0, text == bv->text);
expose(0, 0, owner.workWidth(), owner.height()); expose(0, 0, owner.workWidth(), owner.height());
@ -98,7 +114,7 @@ void LyXScreen::redraw(LyXText * text, BufferView * bv)
} }
void LyXScreen::expose(int x, int y, int exp_width, int exp_height) void LScreen::expose(int x, int y, int exp_width, int exp_height)
{ {
XCopyArea(fl_get_display(), XCopyArea(fl_get_display(),
owner.getPixmap(), owner.getPixmap(),
@ -111,7 +127,7 @@ void LyXScreen::expose(int x, int y, int exp_width, int exp_height)
} }
void LyXScreen::drawFromTo(LyXText * text, BufferView * bv, void LScreen::drawFromTo(LyXText * text, BufferView * bv,
int y1, int y2, int y_offset, int x_offset, int y1, int y2, int y_offset, int x_offset,
bool internal) bool internal)
{ {
@ -158,7 +174,7 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
} }
void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row, void LScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
int y_text, int y_offset, int x_offset) int y_text, int y_offset, int x_offset)
{ {
int const y = y_text - text->first_y + y_offset; int const y = y_text - text->first_y + y_offset;
@ -174,7 +190,7 @@ void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
/* draws the screen, starting with textposition y. uses as much already /* draws the screen, starting with textposition y. uses as much already
* printed pixels as possible */ * printed pixels as possible */
void LyXScreen::draw(LyXText * text, BufferView * bv, unsigned int y) void LScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
{ {
if (cursor_visible) hideCursor(); if (cursor_visible) hideCursor();
@ -230,7 +246,7 @@ void LyXScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
} }
void LyXScreen::showCursor(LyXText const * text, BufferView const * bv) void LScreen::showCursor(LyXText const * text, BufferView const * bv)
{ {
if (!cursor_visible) { if (!cursor_visible) {
Cursor_Shape shape = BAR_SHAPE; Cursor_Shape shape = BAR_SHAPE;
@ -249,7 +265,7 @@ void LyXScreen::showCursor(LyXText const * text, BufferView const * bv)
/* returns true if first has changed, otherwise false */ /* returns true if first has changed, otherwise false */
bool LyXScreen::fitManualCursor(LyXText * text, BufferView * bv, bool LScreen::fitManualCursor(LyXText * text, BufferView * bv,
int /*x*/, int y, int asc, int desc) int /*x*/, int y, int asc, int desc)
{ {
int newtop = text->first_y; int newtop = text->first_y;
@ -272,7 +288,7 @@ bool LyXScreen::fitManualCursor(LyXText * text, BufferView * bv,
} }
void LyXScreen::showManualCursor(LyXText const * text, int x, int y, void LScreen::showManualCursor(LyXText const * text, int x, int y,
int asc, int desc, Cursor_Shape shape) int asc, int desc, Cursor_Shape shape)
{ {
// Update the cursor color. // Update the cursor color.
@ -351,7 +367,7 @@ void LyXScreen::showManualCursor(LyXText const * text, int x, int y,
} }
void LyXScreen::hideCursor() void LScreen::hideCursor()
{ {
if (!cursor_visible) return; if (!cursor_visible) return;
@ -369,7 +385,7 @@ void LyXScreen::hideCursor()
} }
void LyXScreen::cursorToggle(BufferView * bv) const void LScreen::cursorToggle(BufferView * bv) const
{ {
if (cursor_visible) if (cursor_visible)
bv->hideCursor(); bv->hideCursor();
@ -379,7 +395,7 @@ void LyXScreen::cursorToggle(BufferView * bv) const
/* returns a new top so that the cursor is visible */ /* returns a new top so that the cursor is visible */
unsigned int LyXScreen::topCursorVisible(LyXText const * text) unsigned int LScreen::topCursorVisible(LyXText const * text)
{ {
int newtop = text->first_y; int newtop = text->first_y;
@ -422,7 +438,7 @@ unsigned int LyXScreen::topCursorVisible(LyXText const * text)
/* scrolls the screen so that the cursor is visible, if necessary. /* scrolls the screen so that the cursor is visible, if necessary.
* returns true if a change was made, otherwise false */ * returns true if a change was made, otherwise false */
bool LyXScreen::fitCursor(LyXText * text, BufferView * bv) bool LScreen::fitCursor(LyXText * text, BufferView * bv)
{ {
// Is a change necessary? // Is a change necessary?
int const newtop = topCursorVisible(text); int const newtop = topCursorVisible(text);
@ -433,7 +449,7 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
} }
void LyXScreen::update(LyXText * text, BufferView * bv, void LScreen::update(LyXText * text, BufferView * bv,
int y_offset, int x_offset) int y_offset, int x_offset)
{ {
switch (text->status()) { switch (text->status()) {
@ -474,7 +490,7 @@ void LyXScreen::update(LyXText * text, BufferView * bv,
} }
void LyXScreen::toggleSelection(LyXText * text, BufferView * bv, void LScreen::toggleSelection(LyXText * text, BufferView * bv,
bool kill_selection, bool kill_selection,
int y_offset, int x_offset) int y_offset, int x_offset)
{ {
@ -503,7 +519,7 @@ void LyXScreen::toggleSelection(LyXText * text, BufferView * bv,
} }
void LyXScreen::toggleToggle(LyXText * text, BufferView * bv, void LScreen::toggleToggle(LyXText * text, BufferView * bv,
int y_offset, int x_offset) int y_offset, int x_offset)
{ {
if (text->toggle_cursor.par() == text->toggle_end_cursor.par() if (text->toggle_cursor.par() == text->toggle_end_cursor.par()

View File

@ -25,12 +25,12 @@ class BufferView;
struct Row; struct Row;
/** The class LyXScreen is used for the main Textbody. /** The class LScreen is used for the main Textbody.
Concretely, the screen is held in a pixmap. This pixmap is kept up to Concretely, the screen is held in a pixmap. This pixmap is kept up to
date and used to optimize drawing on the screen. date and used to optimize drawing on the screen.
This class also handles the drawing of the cursor and partly the selection. This class also handles the drawing of the cursor and partly the selection.
*/ */
class LyXScreen { class LScreen {
public: public:
/// ///
enum Cursor_Shape { enum Cursor_Shape {
@ -43,11 +43,13 @@ public:
}; };
/// ///
LyXScreen(WorkArea &); LScreen(WorkArea &);
/// ///
~LyXScreen(); ~LScreen();
void reset();
/// Sets the cursor color to LColor::cursor. /// Sets the cursor color to LColor::cursor.
void setCursorColor(); void setCursorColor();

View File

@ -1,3 +1,8 @@
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* insettext.h:
* insettext.C: rename/change of LyXScreen
2002-06-07 Angus Leeming <leeming@lyx.org> 2002-06-07 Angus Leeming <leeming@lyx.org>
Fixes needed to compile with Compaq cxx 6.5. Fixes needed to compile with Compaq cxx 6.5.

View File

@ -486,21 +486,21 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
} }
} else if (!locked) { } else if (!locked) {
if (need_update & CURSOR) { if (need_update & CURSOR) {
bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x)); bv->screen().toggleSelection(lt, bv, true, y_offset,int(x));
lt->clearSelection(); lt->clearSelection();
lt->selection.cursor = lt->cursor; lt->selection.cursor = lt->cursor;
} }
bv->screen()->update(lt, bv, y_offset, int(x)); bv->screen().update(lt, bv, y_offset, int(x));
} else { } else {
locked = false; locked = false;
if (need_update & SELECTION) { if (need_update & SELECTION) {
bv->screen()->toggleToggle(lt, bv, y_offset, int(x)); bv->screen().toggleToggle(lt, bv, y_offset, int(x));
} else if (need_update & CURSOR) { } else if (need_update & CURSOR) {
bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x)); bv->screen().toggleSelection(lt, bv, true, y_offset,int(x));
lt->clearSelection(); lt->clearSelection();
lt->selection.cursor = lt->cursor; lt->selection.cursor = lt->cursor;
} }
bv->screen()->update(lt, bv, y_offset, int(x)); bv->screen().update(lt, bv, y_offset, int(x));
locked = true; locked = true;
} }
@ -2374,9 +2374,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
inset_y = ciy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
} }
if (bv->screen()) { t->first_y = bv->screen().topCursorVisible(t);
t->first_y = bv->screen()->topCursorVisible(t);
}
if (!owner()) { if (!owner()) {
updateLocal(bv, FULL, false); updateLocal(bv, FULL, false);
// this will scroll the screen such that the cursor becomes visible // this will scroll the screen such that the cursor becomes visible
@ -2414,9 +2412,7 @@ void InsetText::reinitLyXText() const
inset_x = cix(bv) - top_x + drawTextXOffset; inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset; inset_y = ciy(bv) + drawTextYOffset;
} }
if (bv->screen()) { t->first_y = bv->screen().topCursorVisible(t);
t->first_y = bv->screen()->topCursorVisible(t);
}
if (!owner()) { if (!owner()) {
updateLocal(bv, FULL, false); updateLocal(bv, FULL, false);
// this will scroll the screen such that the cursor becomes visible // this will scroll the screen such that the cursor becomes visible
@ -2677,7 +2673,7 @@ void InsetText::toggleSelection(BufferView * bv, bool kill_selection)
if (need_update & SELECTION) if (need_update & SELECTION)
need_update = NONE; need_update = NONE;
bv->screen()->toggleSelection(lt, bv, kill_selection, y_offset, x); bv->screen().toggleSelection(lt, bv, kill_selection, y_offset, x);
if (clear) if (clear)
lt = 0; lt = 0;
} }

View File

@ -33,7 +33,6 @@ class Buffer;
class BufferParams; class BufferParams;
class LyXCursor; class LyXCursor;
class LyXText; class LyXText;
class LyXScreen;
class Row; class Row;
/** /**

View File

@ -149,7 +149,6 @@ keyword_item lyxrcTags[] = {
{ "\\wheel_jump", LyXRC::RC_WHEEL_JUMP } { "\\wheel_jump", LyXRC::RC_WHEEL_JUMP }
}; };
/* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item); const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
} // namespace anon } // namespace anon

View File

@ -83,7 +83,7 @@ public:
mutable LyXFont current_font; mutable LyXFont current_font;
/// the current font /// the current font
mutable LyXFont real_current_font; mutable LyXFont real_current_font;
/// first visible pixel-row is set from LyXScreen!!! /// first visible pixel-row is set from LScreen!!!
// unsigned is wrong here for text-insets! // unsigned is wrong here for text-insets!
int first_y; int first_y;
/// ///

View File

@ -3034,7 +3034,7 @@ bool LyXText::paintRowBackground(DrawRowParams & p)
pos_type const last = rowLastPrintable(p.row); pos_type const last = rowLastPrintable(p.row);
if (!p.bv->screen()->forceClear() && last == p.row->pos() if (!p.bv->screen().forceClear() && last == p.row->pos()
&& p.row->par()->isInset(p.row->pos())) { && p.row->par()->isInset(p.row->pos())) {
inset = p.row->par()->getInset(p.row->pos()); inset = p.row->par()->getInset(p.row->pos());
if (inset) { if (inset) {