}
-LyXScreen * BufferView::screen() const
+LScreen & BufferView::screen() const
{
- return pimpl_->screen_.get();
+ return pimpl_->screen();
}
class LyXText;
class TeXErrors;
class Buffer;
-class LyXScreen;
+class LScreen;
class Language;
class Painter;
class UpdatableInset;
///
Painter & painter();
///
- LyXScreen * screen() const;
+ LScreen & screen() const;
///
void buffer(Buffer * b);
///
locking_inset))
text->setCursor(this, cursor,
cursor.par(), cursor.pos() - 1);
- LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE;
+ LScreen::Cursor_Shape shape = LScreen::BAR_SHAPE;
LyXText * txt = getLyXText();
if (locking_inset->isTextInset() &&
locking_inset->lyxCode() != Inset::ERT_CODE &&
|| txt->real_current_font.isVisibleRightToLeft()
!= buffer()->params.language->RightToLeft()))
shape = (txt->real_current_font.isVisibleRightToLeft())
- ? LyXScreen::REVERSED_L_SHAPE
- : LyXScreen::L_SHAPE;
+ ? LScreen::REVERSED_L_SHAPE
+ : LScreen::L_SHAPE;
y += cursor.iy() + theLockingInset()->insetInInsetY();
pimpl_->screen_->showManualCursor(text, x, y, asc, desc,
shape);
using_xterm_cursor(false), inset_slept(false)
{
workarea_.reset(new WorkArea(xpos, ypos, width, height));
+ screen_.reset(new LScreen(workarea()));
// Setup the signals
workarea().scrollCB.connect(boost::bind(&BufferView::Pimpl::scrollCB, this, _1));
}
+LScreen & BufferView::Pimpl::screen() const
+{
+ return *screen_.get();
+}
+
+
Painter & BufferView::Pimpl::painter()
{
return workarea().getPainter();
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 (!buffer_) {
buffer_ = bufferlist.first();
updateScreen();
updateScrollbar();
}
- bv_->text->first_y = screen_->topCursorVisible(bv_->text);
+ bv_->text->first_y = screen().topCursorVisible(bv_->text);
owner_->updateMenubar();
owner_->updateToolbar();
// Similarly, buffer-dependent dialogs should be updated or
bool BufferView::Pimpl::fitCursor()
{
- lyx::Assert(screen_.get());
-
bool ret;
if (bv_->theLockingInset()) {
bv_->theLockingInset()->fitInsetCursor(bv_);
ret = true;
} else {
- ret = screen_->fitCursor(bv_->text, bv_);
+ ret = screen().fitCursor(bv_->text, bv_);
}
bv_->owner()->getDialogs()->updateParagraph();
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
updateScrollbar();
void BufferView::Pimpl::updateScreen()
{
// Regenerate the screen.
- screen_.reset(new LyXScreen(workarea()));
+ screen().reset();
}
if (current_scrollbar_value < 0)
current_scrollbar_value = 0;
- if (!screen_.get())
- return;
-
- screen_->draw(bv_->text, bv_, current_scrollbar_value);
+ screen().draw(bv_->text, bv_, current_scrollbar_value);
if (!lyxrc.cursor_follows_scrollbar) {
waitForX();
int BufferView::Pimpl::scrollUp(long time)
{
- if (!buffer_ || !screen_.get())
+ if (!buffer_)
return 0;
double value = workarea().getScrollbarValue();
int BufferView::Pimpl::scrollDown(long time)
{
- if (!buffer_ || !screen_.get())
+ if (!buffer_)
return 0;
double value = workarea().getScrollbarValue();
if (!(state & mouse_button::button1))
return;
- if (!buffer_ || !screen_.get()) return;
+ if (!buffer_)
+ return;
// Check for inset locking
if (bv_->theLockingInset()) {
if (!selection_possible)
return;
- screen_->hideCursor();
+ screen().hideCursor();
#if 0
int y_before = bv_->text->cursor.y();
#endif
update(bv_->text, BufferView::UPDATE); // Maybe an empty line was deleted
bv_->text->setSelection(bv_);
- screen_->toggleToggle(bv_->text, bv_);
+ screen().toggleToggle(bv_->text, bv_);
fitCursor();
showCursor();
}
void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
mouse_button::state button)
{
- if (!buffer_ || !screen_.get())
+ if (!buffer_)
return;
// ok ok, this is a hack.
if (!inset_hit)
selection_possible = true;
- screen_->hideCursor();
+ screen().hideCursor();
// Clear the selection
- screen_->toggleSelection(bv_->text, bv_);
+ screen().toggleSelection(bv_->text, bv_);
bv_->text->clearSelection();
bv_->text->fullRebreak(bv_);
update();
if (text->bv_owner && bv_->theLockingInset())
return;
- if (screen_.get() && button == mouse_button::button1) {
+ if (button == mouse_button::button1) {
if (text->bv_owner) {
- screen_->hideCursor();
- screen_->toggleSelection(text, bv_);
+ screen().hideCursor();
+ screen().toggleSelection(text, bv_);
text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT);
- screen_->toggleSelection(text, bv_, false);
+ screen().toggleSelection(text, bv_, false);
} else {
text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT);
}
if (text->bv_owner && bv_->theLockingInset())
return;
- if (screen_.get() && (button == mouse_button::button1)) {
+ if (button == mouse_button::button1) {
if (text->bv_owner) {
- screen_->hideCursor();
- screen_->toggleSelection(text, bv_);
+ screen().hideCursor();
+ screen().toggleSelection(text, bv_);
}
text->cursorHome(bv_);
text->selection.cursor = text->cursor;
text->cursorEnd(bv_);
text->setSelection(bv_);
if (text->bv_owner) {
- screen_->toggleSelection(text, bv_, false);
+ screen().toggleSelection(text, bv_, false);
}
/* This will fit the cursor on the screen
* if necessary */
mouse_button::state button)
{
// 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;
// If we hit an inset, we have the inset coordinates in these
Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y)
{
- if (!screen_.get())
- return 0;
-
int y_tmp = y + text->first_y;
LyXCursor cursor;
// The main window size has changed, repaint most stuff
redraw();
- } else if (screen_.get())
- screen_->redraw(bv_->text, bv_);
+ } else {
+ screen().redraw(bv_->text, bv_);
+ }
} else {
// Grey box when we don't have a buffer
workarea().greyOut();
void BufferView::Pimpl::update()
{
- if (screen_.get() &&
- (!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()))
- {
+ if (!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()) {
LyXText::text_status st = bv_->text->status();
- screen_->update(bv_->text, bv_);
+ screen().update(bv_->text, bv_);
bool fitc = false;
while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) {
bv_->text->fullRebreak(bv_);
}
fitc = true;
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
// the above loop!
return;
}
- if (!screen_.get()) {
- cursor_timeout.restart();
- return;
- }
-
/* FIXME */
extern void reapSpellchecker(void);
reapSpellchecker();
if (!bv_->theLockingInset()) {
- screen_->cursorToggle(bv_);
+ screen().cursorToggle(bv_);
} else {
bv_->theLockingInset()->toggleInsetCursor(bv_);
}
if (!text->cursor.row()->previous()) {
if (text->first_y > 0) {
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();
}
return;
- 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()) {
LyXCursor cur;
text->setCursor(bv_, cur, text->cursor.row()->previous()->par(),
int y = text->cursor.y() - text->cursor.row()->baseline() +
text->cursor.row()->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());
updateScrollbar();
}
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()) {
LyXCursor cur;
text->setCursor(bv_, cur, text->cursor.row()->next()->par(),
void BufferView::Pimpl::showCursor()
{
- if (screen_.get()) {
- if (bv_->theLockingInset())
- bv_->theLockingInset()->showInsetCursor(bv_);
- else
- screen_->showCursor(bv_->text, bv_);
- }
+ if (bv_->theLockingInset())
+ bv_->theLockingInset()->showInsetCursor(bv_);
+ else
+ screen().showCursor(bv_->text, bv_);
}
void BufferView::Pimpl::hideCursor()
{
- if (screen_.get()) {
- if (!bv_->theLockingInset())
-// bv_->theLockingInset()->hideInsetCursor(bv_);
-// else
- screen_->hideCursor();
- }
+ if (!bv_->theLockingInset())
+ screen().hideCursor();
}
void BufferView::Pimpl::toggleSelection(bool b)
{
- if (screen_.get()) {
- if (bv_->theLockingInset())
- bv_->theLockingInset()->toggleSelection(bv_, b);
- screen_->toggleSelection(bv_->text, bv_, b);
- }
+ if (bv_->theLockingInset())
+ bv_->theLockingInset()->toggleSelection(bv_, b);
+ screen().toggleSelection(bv_->text, bv_, b);
}
void BufferView::Pimpl::toggleToggle()
{
- if (screen_.get())
- screen_->toggleToggle(bv_->text, bv_);
+ screen().toggleToggle(bv_->text, bv_);
}
{
beforeChange(bv_->text);
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 {
- screen_->draw(bv_->text, bv_, 0);
+ screen().draw(bv_->text, bv_, 0);
}
update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
redraw();
if (!buffer_)
return;
- screen_->hideCursor();
+ screen().hideCursor();
beforeChange(bv_->text);
string const clip(workarea().getClipboard());
class LyXView;
class WorkArea;
-class LyXScreen;
+class LScreen;
// FIXME: remove
#include <X11/Xlib.h>
Painter & painter();
/// return the work area for this bview
WorkArea & workarea() const;
+ /// return the screen for this bview
+ LScreen & screen() const;
///
void buffer(Buffer *);
///
///
Buffer * buffer_;
///
- boost::scoped_ptr<LyXScreen> screen_;
+ boost::scoped_ptr<LScreen> screen_;
///
boost::scoped_ptr<WorkArea> workarea_;
///
+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>
* BufferView.h:
+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>
* font_metrics.h: move X-specific stuff out of namespace
// Constructor
-LyXScreen::LyXScreen(WorkArea & o)
+LScreen::LScreen(WorkArea & o)
: owner(o), force_clear(true)
{
// the cursor isnt yet visible
}
-LyXScreen::~LyXScreen()
+LScreen::~LScreen()
{
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;
}
-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);
expose(0, 0, owner.workWidth(), owner.height());
}
-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(),
owner.getPixmap(),
}
-void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
+void LScreen::drawFromTo(LyXText * text, BufferView * bv,
int y1, int y2, int y_offset, int x_offset,
bool internal)
{
}
-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 const y = y_text - text->first_y + y_offset;
/* draws the screen, starting with textposition y. uses as much already
* 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();
}
-void LyXScreen::showCursor(LyXText const * text, BufferView const * bv)
+void LScreen::showCursor(LyXText const * text, BufferView const * bv)
{
if (!cursor_visible) {
Cursor_Shape shape = BAR_SHAPE;
/* 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 newtop = text->first_y;
}
-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)
{
// Update the cursor color.
}
-void LyXScreen::hideCursor()
+void LScreen::hideCursor()
{
if (!cursor_visible) return;
}
-void LyXScreen::cursorToggle(BufferView * bv) const
+void LScreen::cursorToggle(BufferView * bv) const
{
if (cursor_visible)
bv->hideCursor();
/* 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;
/* scrolls the screen so that the cursor is visible, if necessary.
* 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?
int const newtop = topCursorVisible(text);
}
-void LyXScreen::update(LyXText * text, BufferView * bv,
+void LScreen::update(LyXText * text, BufferView * bv,
int y_offset, int x_offset)
{
switch (text->status()) {
}
-void LyXScreen::toggleSelection(LyXText * text, BufferView * bv,
+void LScreen::toggleSelection(LyXText * text, BufferView * bv,
bool kill_selection,
int y_offset, int x_offset)
{
}
-void LyXScreen::toggleToggle(LyXText * text, BufferView * bv,
+void LScreen::toggleToggle(LyXText * text, BufferView * bv,
int y_offset, int x_offset)
{
if (text->toggle_cursor.par() == text->toggle_end_cursor.par()
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
date and used to optimize drawing on the screen.
This class also handles the drawing of the cursor and partly the selection.
*/
-class LyXScreen {
+class LScreen {
public:
///
enum Cursor_Shape {
};
///
- LyXScreen(WorkArea &);
+ LScreen(WorkArea &);
///
- ~LyXScreen();
+ ~LScreen();
+ void reset();
+
/// Sets the cursor color to LColor::cursor.
void setCursorColor();
+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>
Fixes needed to compile with Compaq cxx 6.5.
}
} else if (!locked) {
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->selection.cursor = lt->cursor;
}
- bv->screen()->update(lt, bv, y_offset, int(x));
+ bv->screen().update(lt, bv, y_offset, int(x));
} else {
locked = false;
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) {
- bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x));
+ bv->screen().toggleSelection(lt, bv, true, y_offset,int(x));
lt->clearSelection();
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;
}
inset_y = ciy(bv) + drawTextYOffset;
}
- if (bv->screen()) {
- t->first_y = bv->screen()->topCursorVisible(t);
- }
+ t->first_y = bv->screen().topCursorVisible(t);
if (!owner()) {
updateLocal(bv, FULL, false);
// this will scroll the screen such that the cursor becomes visible
inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
}
- if (bv->screen()) {
- t->first_y = bv->screen()->topCursorVisible(t);
- }
+ t->first_y = bv->screen().topCursorVisible(t);
if (!owner()) {
updateLocal(bv, FULL, false);
// this will scroll the screen such that the cursor becomes visible
if (need_update & SELECTION)
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)
lt = 0;
}
class BufferParams;
class LyXCursor;
class LyXText;
-class LyXScreen;
class Row;
/**
{ "\\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);
} // namespace anon
mutable LyXFont current_font;
/// the 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!
int first_y;
///
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())) {
inset = p.row->par()->getInset(p.row->pos());
if (inset) {