]> git.lyx.org Git - lyx.git/blob - src/frontends/screen.h
Spaces menu for math dialog
[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 #ifdef __GNUG__
17 #pragma interface
18 #endif
19
20 class LyXText;
21 class LyXCursor;
22 class WorkArea;
23 class BufferView;
24 struct Row;
25
26 /**
27  * LyXScreen - document rendering management
28  *
29  * This class is used to manage the on-screen rendering inside the
30  * work area; it is responsible for deciding which LyXText rows
31  * need re-drawing.
32  *
33  * This class will arrange for LyXText to paint onto a pixmap
34  * provided by the WorkArea widget.
35  *
36  * The blinking cursor is also handled here.
37  */
38 class LyXScreen {
39 public:
40         /// types of cursor in work area
41         enum Cursor_Shape {
42                 /// normal I-beam
43                 BAR_SHAPE,
44                 /// L-shape for locked insets of a different language
45                 L_SHAPE,
46                 /// reverse L-shape for RTL text
47                 REVERSED_L_SHAPE
48         };
49
50         LyXScreen();
51
52         virtual ~LyXScreen();
53
54         /**
55          * draw the screen from a given position
56          * @param y the text position to draw from
57          *
58          * Uses as much of the already printed pixmap as possible
59          */
60         virtual void draw(LyXText *, BufferView *, unsigned int y) = 0;
61
62         /**
63          * showManualCursor - display the cursor on the work area
64          * @param text the lyx text containing the cursor
65          * @param x the x position of the cursor
66          * @param y the y position of the row's baseline
67          * @param asc ascent of the row
68          * @param desc descent of the row
69          * @param shape the current shape
70          */
71         virtual void showManualCursor(LyXText const *, int x, int y,
72                               int asc, int desc,
73                               Cursor_Shape shape) = 0;
74
75         /// unpaint the cursor painted by showManualCursor()
76         virtual void hideCursor() = 0;
77
78         /**
79          * fit the cursor onto the visible work area, scrolling if necessary
80          * @param bv the buffer view
81          * @param vheight the height of the visible region
82          * @param base_y the top of the lyxtext to look at
83          * @param x the new x position
84          * @param y the new y position
85          * @param a ascent of the cursor's row
86          * @param d descent of the cursor's row
87          * @return true if the work area needs scrolling as a result
88          */
89         bool fitManualCursor(BufferView * bv, LyXText * text,
90                 int x, int y, int a, int d);
91
92         /// redraw the screen, without using existing pixmap
93         virtual void redraw(LyXText *, BufferView *);
94
95         /// draw the cursor if it's not already shown
96         virtual void showCursor(LyXText const *, BufferView const *);
97
98         /**
99          * topCursorVisible - get a new "top" to make the cursor visible
100          * @param c the cursor
101          * @param top_y the current y location of the containing region
102          *
103          * This helper function calculates a new y co-ordinate for
104          * the top of the containing region such that the cursor contained
105          * within the LyXText is "nicely" visible.
106          */
107         virtual unsigned int topCursorVisible(LyXCursor const & c, int top_y);
108
109         /**
110          * fitCursor - fit the cursor onto the work area
111          * @param text the text containing the cursor
112          * @param bv the bufferview
113          * @return true if a change was necessary
114          *
115          * Scrolls the screen so that the cursor is visible
116          */
117         virtual bool fitCursor(LyXText *, BufferView *);
118
119         /// show the cursor if it's not, and vice versa
120         virtual void cursorToggle(BufferView *) const;
121
122         /**
123          * update - update part of the screen rendering
124          * @param text the containing text region
125          * @param bv the bufferview
126          * @param xo the x offset into the text
127          * @param yo the x offset into the text
128          *
129          * Updates part of the screen. If text->status is
130          * LyXText::NEED_MORE_REFRESH, we update from the
131          * point of change and to the end of the screen.
132          * If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
133          * we only update the current row.
134          */
135         virtual void update(LyXText * text, BufferView * bv, int yo = 0, int xo = 0);
136
137         /// FIXME
138         virtual void toggleSelection(LyXText *, BufferView *, bool = true,
139                              int y_offset = 0, int x_offset = 0);
140
141         /// FIXME - at least change the name !!
142         virtual void toggleToggle(LyXText *, BufferView *,
143                           int y_offset = 0, int x_offset = 0);
144
145         /// FIXME
146         virtual bool forceClear() const { return force_clear_; }
147
148 protected:
149         /// cause the display of the given area of the work area
150         virtual void expose(int x, int y, int w, int h) = 0;
151
152         /// get the work area
153         virtual WorkArea & workarea() const = 0;
154
155         /// y1 and y2 are coordinates of the screen
156         virtual void drawFromTo(LyXText *, BufferView *, int y1, int y2,
157                         int y_offset = 0, int x_offset = 0, bool internal = false);
158
159         /// y is a coordinate of the text
160         virtual void drawOneRow(LyXText *, BufferView *, Row * row,
161                         int y_text, int y_offset = 0, int x_offset = 0);
162
163         /// grey out (no buffer)
164         void greyOut();
165
166         /// FIXME ?
167         bool force_clear_;
168
169         /// is the blinking cursor currently drawn
170         bool cursor_visible_;
171 };
172
173 #endif // SCREEN_H