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