]> git.lyx.org Git - lyx.git/blob - src/lyxscreen.h
Fixes for/in insettabular/text.
[lyx.git] / src / lyxscreen.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2000 The LyX Team
9  *
10  * ====================================================== */
11
12 #ifndef LYXSCREEN_H
13 #define LYXSCREEN_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include FORMS_H_LOCATION
20 #include <X11/Xlib.h>
21
22 class LyXText;
23 class WorkArea;
24 class Buffer;
25 class BufferView;
26
27 struct Row;
28
29 ///
30 typedef unsigned short Dimension;
31
32
33 /** The class LyXScreen is used for the main Textbody.
34     Concretely, the screen is held in a pixmap.  This pixmap is kept up to
35     date and used to optimize drawing on the screen.
36     This class also handles the drawing of the cursor and partly the selection.
37  */
38 class LyXScreen {
39 public:
40         ///
41         enum Cursor_Shape {
42                 ///
43                 BAR_SHAPE,
44                 ///
45                 L_SHAPE,
46                 ///
47                 REVERSED_L_SHAPE
48         };
49
50         ///
51         LyXScreen(WorkArea &);
52
53         /// Sets the cursor color to LColor::cursor.
54         void setCursorColor();
55         
56         /** Draws the screen form textposition y. Uses as much of
57             the already printed pixmap as possible */
58         void Draw(LyXText *, BufferView *, unsigned int y);
59
60         /// Redraws the screen, without using existing pixmap
61         void Redraw(LyXText *, BufferView *);
62    
63         /// Returns a new top so that the cursor is visible
64         unsigned int TopCursorVisible(LyXText const *);
65         /// Redraws the screen such that the cursor is visible
66         bool FitCursor(LyXText *, BufferView *);
67         ///
68         void ShowCursor(LyXText const *, BufferView const *);
69         ///
70         void HideCursor();
71         ///
72         void CursorToggle(LyXText const *, BufferView const *);
73         ///
74         void ShowManualCursor(LyXText const *, int x, int y,
75                               int asc, int desc,
76                               Cursor_Shape shape);
77         /// returns 1 if first has changed, otherwise 0
78         bool FitManualCursor(LyXText *, BufferView *, int, int, int, int);
79         ///
80         void ToggleSelection(LyXText *, BufferView *, bool = true,
81                              int y_offset = 0, int x_offset = 0);
82         ///
83         void ToggleToggle(LyXText *, BufferView *,
84                           int y_offset = 0, int x_offset = 0);
85         
86         /** Updates part of the screen. If text->status is
87             LyXText::NEED_MORE_REFRESH, we update from the
88             point of change and to the end of the screen.
89             If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
90             we only update the current row. */
91         void Update(LyXText *, BufferView *, int y_offset=0, int x_offset=0);
92         ///
93         bool forceClear() const { return force_clear; }
94
95         ///
96         bool cursor_visible;
97 private:
98         /// Copies specified area of pixmap to screen
99         void expose(int x, int y, int exp_width, int exp_height); 
100
101         /// y1 and y2 are coordinates of the screen
102         void DrawFromTo(LyXText *, BufferView *, int y1, int y2,
103                         int y_offset = 0, int x_offset = 0);
104
105         /// y is a coordinate of the text
106         void DrawOneRow(LyXText *, BufferView *, Row * row,
107                         int y_text, int y_offset = 0, int x_offset = 0);
108
109         ///
110         WorkArea & owner;
111         
112         ///
113         Pixmap cursor_pixmap;
114         ///
115         int cursor_pixmap_x;
116         ///
117         int cursor_pixmap_y;
118         ///
119         int cursor_pixmap_w;
120         ///
121         int cursor_pixmap_h;
122         ///
123         GC gc_copy;
124         ///
125         bool force_clear;
126 };
127
128 #endif