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