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