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