1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-06-12 10:31:34 +00:00
|
|
|
/**
|
|
|
|
* \file screen.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2002-06-12 10:31:34 +00:00
|
|
|
* \author unknown
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-06-18 15:44:30 +00:00
|
|
|
*/
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
#ifndef SCREEN_H
|
|
|
|
#define SCREEN_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
class LyXText;
|
2002-06-12 10:31:34 +00:00
|
|
|
class LyXCursor;
|
2000-08-07 20:58:24 +00:00
|
|
|
class WorkArea;
|
2001-01-02 16:06:14 +00:00
|
|
|
class BufferView;
|
1999-09-27 18:44:28 +00:00
|
|
|
struct Row;
|
2000-08-07 20:58:24 +00:00
|
|
|
|
2002-06-12 10:31:34 +00:00
|
|
|
/**
|
2002-06-18 15:44:30 +00:00
|
|
|
* LyXScreen - document rendering management
|
2002-06-12 10:31:34 +00:00
|
|
|
*
|
2002-06-24 20:28:12 +00:00
|
|
|
* This class is used to manage the on-screen rendering inside the
|
2002-06-12 10:31:34 +00:00
|
|
|
* 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.
|
1999-09-27 18:44:28 +00:00
|
|
|
*/
|
2002-06-18 15:44:30 +00:00
|
|
|
class LyXScreen {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2002-06-18 15:44:30 +00:00
|
|
|
/// types of cursor in work area
|
2000-03-10 13:22:20 +00:00
|
|
|
enum Cursor_Shape {
|
2002-06-18 15:44:30 +00:00
|
|
|
/// normal I-beam
|
2000-03-10 13:22:20 +00:00
|
|
|
BAR_SHAPE,
|
2002-06-18 15:44:30 +00:00
|
|
|
/// L-shape for locked insets of a different language
|
2000-03-10 13:22:20 +00:00
|
|
|
L_SHAPE,
|
2002-06-18 15:44:30 +00:00
|
|
|
/// reverse L-shape for RTL text
|
2000-03-10 13:22:20 +00:00
|
|
|
REVERSED_L_SHAPE
|
|
|
|
};
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
LyXScreen();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
virtual ~LyXScreen();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/**
|
|
|
|
* draw the screen from a given position
|
|
|
|
* @param y the text position to draw from
|
|
|
|
*
|
2002-06-24 20:28:12 +00:00
|
|
|
* Uses as much of the already printed pixmap as possible
|
2002-06-18 15:44:30 +00:00
|
|
|
*/
|
|
|
|
virtual void draw(LyXText *, BufferView *, unsigned int y) = 0;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/**
|
|
|
|
* showManualCursor - display the cursor on the work area
|
|
|
|
* @param text the lyx text containing the cursor
|
|
|
|
* @param x the x position of the cursor
|
|
|
|
* @param y the y position of the row's baseline
|
|
|
|
* @param asc ascent of the row
|
|
|
|
* @param desc descent of the row
|
|
|
|
* @param shape the current shape
|
|
|
|
*/
|
|
|
|
virtual void showManualCursor(LyXText const *, int x, int y,
|
|
|
|
int asc, int desc,
|
|
|
|
Cursor_Shape shape) = 0;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// unpaint the cursor painted by showManualCursor()
|
|
|
|
virtual void hideCursor() = 0;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/**
|
|
|
|
* fit the cursor onto the visible work area, scrolling if necessary
|
|
|
|
* @param bv the buffer view
|
|
|
|
* @param vheight the height of the visible region
|
|
|
|
* @param base_y the top of the lyxtext to look at
|
|
|
|
* @param x the new x position
|
|
|
|
* @param y the new y position
|
|
|
|
* @param a ascent of the cursor's row
|
|
|
|
* @param d descent of the cursor's row
|
|
|
|
* @return true if the work area needs scrolling as a result
|
|
|
|
*/
|
|
|
|
bool fitManualCursor(BufferView * bv, LyXText * text,
|
|
|
|
int x, int y, int a, int d);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// redraw the screen, without using existing pixmap
|
|
|
|
virtual void redraw(LyXText *, BufferView *);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// draw the cursor if it's not already shown
|
|
|
|
virtual void showCursor(LyXText const *, BufferView const *);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-12 10:31:34 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2002-06-18 15:44:30 +00:00
|
|
|
*/
|
|
|
|
virtual unsigned int topCursorVisible(LyXCursor const & c, int top_y);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/**
|
|
|
|
* fitCursor - fit the cursor onto the work area
|
|
|
|
* @param text the text containing the cursor
|
|
|
|
* @param bv the bufferview
|
|
|
|
* @return true if a change was necessary
|
|
|
|
*
|
2002-07-09 16:23:20 +00:00
|
|
|
* Scrolls the screen so that the cursor is visible
|
2002-06-18 15:44:30 +00:00
|
|
|
*/
|
|
|
|
virtual bool fitCursor(LyXText *, BufferView *);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// show the cursor if it's not, and vice versa
|
|
|
|
virtual void cursorToggle(BufferView *) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* update - update part of the screen rendering
|
|
|
|
* @param text the containing text region
|
|
|
|
* @param bv the bufferview
|
|
|
|
* @param xo the x offset into the text
|
|
|
|
* @param yo the x offset into the text
|
2002-06-24 20:28:12 +00:00
|
|
|
*
|
2002-06-18 15:44:30 +00:00
|
|
|
* Updates part of the screen. If text->status is
|
|
|
|
* LyXText::NEED_MORE_REFRESH, we update from the
|
|
|
|
* point of change and to the end of the screen.
|
|
|
|
* If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
|
2002-06-24 20:28:12 +00:00
|
|
|
* we only update the current row.
|
2002-06-18 15:44:30 +00:00
|
|
|
*/
|
|
|
|
virtual void update(LyXText * text, BufferView * bv, int yo = 0, int xo = 0);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// FIXME
|
|
|
|
virtual void toggleSelection(LyXText *, BufferView *, bool = true,
|
2001-01-02 16:06:14 +00:00
|
|
|
int y_offset = 0, int x_offset = 0);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// FIXME - at least change the name !!
|
|
|
|
virtual void toggleToggle(LyXText *, BufferView *,
|
2001-01-02 16:06:14 +00:00
|
|
|
int y_offset = 0, int x_offset = 0);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// FIXME
|
|
|
|
virtual bool forceClear() const { return force_clear_; }
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
protected:
|
2002-06-21 02:22:13 +00:00
|
|
|
/// cause the display of the given area of the work area
|
|
|
|
virtual void expose(int x, int y, int w, int h) = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// get the work area
|
|
|
|
virtual WorkArea & workarea() const = 0;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// y1 and y2 are coordinates of the screen
|
2002-06-18 15:44:30 +00:00
|
|
|
virtual void drawFromTo(LyXText *, BufferView *, int y1, int y2,
|
2002-06-24 20:28:12 +00:00
|
|
|
int y_offset = 0, int x_offset = 0, bool internal = false);
|
2000-04-26 13:57:28 +00:00
|
|
|
|
|
|
|
/// y is a coordinate of the text
|
2002-06-18 15:44:30 +00:00
|
|
|
virtual void drawOneRow(LyXText *, BufferView *, Row * row,
|
2001-01-02 16:06:14 +00:00
|
|
|
int y_text, int y_offset = 0, int x_offset = 0);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// grey out (no buffer)
|
|
|
|
void greyOut();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// FIXME ?
|
|
|
|
bool force_clear_;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// is the blinking cursor currently drawn
|
|
|
|
bool cursor_visible_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
#endif // SCREEN_H
|