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