]> git.lyx.org Git - lyx.git/blob - src/frontends/screen.h
shift rowpainter interface a bit
[lyx.git] / src / frontends / screen.h
1 // -*- C++ -*-
2 /**
3  * \file screen.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 #ifndef SCREEN_H
14 #define SCREEN_H
15
16 #include "RowList.h"
17
18 class LyXText;
19 class LyXCursor;
20 class WorkArea;
21 class BufferView;
22
23 /**
24  * LyXScreen - document rendering management
25  *
26  * This class is used to manage the on-screen rendering inside the
27  * work area; it is responsible for deciding which LyXText rows
28  * need re-drawing.
29  *
30  * This class will arrange for LyXText to paint onto a pixmap
31  * provided by the WorkArea widget.
32  *
33  * The blinking cursor is also handled here.
34  */
35 class LyXScreen {
36 public:
37         LyXScreen();
38
39         virtual ~LyXScreen();
40
41         /**
42          * fit the cursor onto the visible work area, scrolling if necessary
43          * @param bv the buffer view
44          * @param vheight the height of the visible region
45          * @param base_y the top of the lyxtext to look at
46          * @param x the new x position
47          * @param y the new y position
48          * @param a ascent of the cursor's row
49          * @param d descent of the cursor's row
50          * @return true if the work area needs scrolling as a result
51          */
52         bool fitManualCursor(BufferView * bv, LyXText * text,
53                 int x, int y, int a, int d);
54
55         /// redraw the screen, without using existing pixmap
56         virtual void redraw(BufferView & bv);
57
58         /**
59          * topCursorVisible - get a new "top" to make the cursor visible
60          * in a LyXText
61          *
62          * This helper function calculates a new y co-ordinate for
63          * the top of the containing region such that the cursor contained
64          * within the LyXText is "nicely" visible.
65          */
66         virtual unsigned int topCursorVisible(LyXText *);
67
68         /**
69          * fitCursor - fit the cursor onto the work area
70          * @param text the text containing the cursor
71          * @param bv the bufferview
72          * @return true if a change was necessary
73          *
74          * Scrolls the screen so that the cursor is visible
75          */
76         virtual bool fitCursor(LyXText *, BufferView *);
77
78         /// hide the visible cursor, if it is visible
79         void hideCursor();
80         
81         /// show the cursor if it is not visible
82         void showCursor(BufferView & bv);
83
84         /// toggle the cursor's visibility
85         void toggleCursor(BufferView & bv);
86
87 protected:
88         /// cause the display of the given area of the work area
89         virtual void expose(int x, int y, int w, int h) = 0;
90
91         /// get the work area
92         virtual WorkArea & workarea() const = 0;
93
94         /// types of cursor in work area
95         enum Cursor_Shape {
96                 /// normal I-beam
97                 BAR_SHAPE,
98                 /// L-shape for locked insets of a different language
99                 L_SHAPE,
100                 /// reverse L-shape for RTL text
101                 REVERSED_L_SHAPE
102         };
103
104         /// paint the cursor and store the background
105         virtual void showCursor(int x, int y, int h, Cursor_Shape shape) = 0;
106
107         /// hide the cursor
108         virtual void removeCursor() = 0;
109
110 private:
111         /// grey out (no buffer)
112         void greyOut();
113
114         /// is the cursor currently displayed
115         bool cursor_visible_;
116
117         /// is the screen displaying text or the splash screen?
118         bool greyed_out_;
119 };
120
121 #endif // SCREEN_H