updateScreen();
updateScrollbar();
}
- bv_->text->first_y = screen().topCursorVisible(bv_->text);
+ bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
owner_->updateMenubar();
owner_->updateToolbar();
// Similarly, buffer-dependent dialogs should be updated or
bv_->theLockingInset(the_locking_inset);
}
- bv_->text->first_y = screen().topCursorVisible(bv_->text);
+ bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
// this will scroll the screen such that the cursor becomes visible
updateScrollbar();
+2002-06-12 John Levon <moz@compsoc.man.ac.uk>
+
+ * BufferView_pimpl.C: topCursorVisible
+ prototype change
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:
+2002-06-12 John Levon <moz@compsoc.man.ac.uk>
+
+ * screen.h:
+ * screen.C: change topCursorVisible() prototype
+
2002-06-12 Angus Leeming <leeming@lyx.org>
* font_metrics.h: remove trailing semi-colon after the brace closing
/* returns a new top so that the cursor is visible */
-unsigned int LScreen::topCursorVisible(LyXText const * text)
+unsigned int LScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
{
- int newtop = text->first_y;
+ int const vheight = owner.workHeight();
+ int newtop = top_y;
- Row * row = text->cursor.row();
+ Row * row = cursor.row();
// Is this a hack? Yes, probably... (Lgb)
if (!row)
return max(newtop, 0);
- if (text->cursor.y() - row->baseline() + row->height()
- - text->first_y >= owner.workHeight()) {
- if (row->height() < owner.workHeight()
- && row->height() > owner.workHeight() / 4) {
- newtop = text->cursor.y()
+ if (cursor.y() - row->baseline() + row->height()
+ - top_y >= vheight) {
+ if (row->height() < vheight
+ && row->height() > vheight / 4) {
+ newtop = cursor.y()
+ row->height()
- - row->baseline() - owner.workHeight();
+ - row->baseline() - vheight;
} else {
// scroll down
- newtop = text->cursor.y()
- - owner.workHeight() / 2; /* the scroll region must be so big!! */
+ newtop = cursor.y()
+ - vheight / 2; /* the scroll region must be so big!! */
}
- } else if (static_cast<int>((text->cursor.y()) - row->baseline()) <
- text->first_y && text->first_y > 0) {
- if (row->height() < owner.workHeight()
- && row->height() > owner.workHeight() / 4) {
- newtop = text->cursor.y() - row->baseline();
+ } else if (static_cast<int>(cursor.y() - row->baseline()) <
+ top_y && top_y > 0) {
+ if (row->height() < vheight
+ && row->height() > vheight / 4) {
+ newtop = cursor.y() - row->baseline();
} else {
// scroll up
- newtop = text->cursor.y() - owner.workHeight() / 2;
- newtop = min(newtop, text->first_y);
+ newtop = cursor.y() - vheight / 2;
+ newtop = min(newtop, top_y);
}
}
bool LScreen::fitCursor(LyXText * text, BufferView * bv)
{
// Is a change necessary?
- int const newtop = topCursorVisible(text);
+ int const newtop = topCursorVisible(text->cursor, text->first_y);
bool const result = (newtop != text->first_y);
if (result)
draw(text, bv, newtop);
// -*- C++ -*-
-/* This file is part of
- * ======================================================
+/**
+ * \file screen.h
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
*
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team
- *
- * ====================================================== */
+ * \author unknown
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
#ifndef LYXSCREEN_H
#define LYXSCREEN_H
#include <X11/Xlib.h>
class LyXText;
+class LyXCursor;
class WorkArea;
class Buffer;
class BufferView;
struct Row;
-/** 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.
+/**
+ * LScreen - document rendering management
+ *
+ * This class is used to manage the on-screen rendering inside the
+ * work area; it is responsible for deciding which LyXText rows
+ * need re-drawing.
+ *
+ * This class will arrange for LyXText to paint onto a pixmap
+ * provided by the WorkArea widget.
+ *
+ * The blinking cursor is also handled here.
*/
class LScreen {
public:
/// Redraws the screen, without using existing pixmap
void redraw(LyXText *, BufferView *);
- /// Returns a new top so that the cursor is visible
- unsigned int topCursorVisible(LyXText const *);
+ /**
+ * topCursorVisible - get a new "top" to make the cursor visible
+ * @param c the cursor
+ * @param top_y the current y location of the containing region
+ *
+ * This helper function calculates a new y co-ordinate for
+ * the top of the containing region such that the cursor contained
+ * within the LyXText is "nicely" visible.
+ */
+ unsigned int topCursorVisible(LyXCursor const & c, int top_y);
+
/// Redraws the screen such that the cursor is visible
bool fitCursor(LyXText *, BufferView *);
///
+2002-06-12 John Levon <moz@compsoc.man.ac.uk>
+
+ * GraphicsCache.C: use right colormap incantation
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* GraphicsCache.C: use lyx_gui namespace
return;
Display * display = fl_get_display();
- Colormap cmap = fl_colormap;
+ Colormap cmap = fl_state[fl_get_vclass()].colormap;
XColor xcol;
XColor ccol;
if (XLookupColor(display, cmap, c_color, &xcol, &ccol) == 0)
+2002-06-12 John Levon <moz@compsoc.man.ac.uk>
+
+ * insettext.C: change of topCursorVisible()
+ prototype
+
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
* insettext.h:
inset_y = ciy(bv) + drawTextYOffset;
}
- t->first_y = bv->screen().topCursorVisible(t);
+ t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
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;
}
- t->first_y = bv->screen().topCursorVisible(t);
+ t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
if (!owner()) {
updateLocal(bv, FULL, false);
// this will scroll the screen such that the cursor becomes visible