]> git.lyx.org Git - lyx.git/blob - src/lyxscreen.h
LyX Drinkers Union: patch 1
[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-2001 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         ///
54         ~LyXScreen();
55  
56         /// Sets the cursor color to LColor::cursor.
57         void setCursorColor();
58         
59         /** Draws the screen form textposition y. Uses as much of
60             the already printed pixmap as possible */
61         void Draw(LyXText *, BufferView *, unsigned int y);
62
63         /// Redraws the screen, without using existing pixmap
64         void Redraw(LyXText *, BufferView *);
65    
66         /// Returns a new top so that the cursor is visible
67         unsigned int TopCursorVisible(LyXText const *);
68         /// Redraws the screen such that the cursor is visible
69         bool FitCursor(LyXText *, BufferView *);
70         ///
71         void ShowCursor(LyXText const *, BufferView const *);
72         ///
73         void HideCursor();
74         ///
75         void CursorToggle(LyXText const *, BufferView const *);
76         ///
77         void ShowManualCursor(LyXText const *, int x, int y,
78                               int asc, int desc,
79                               Cursor_Shape shape);
80         /// returns 1 if first has changed, otherwise 0
81         bool FitManualCursor(LyXText *, BufferView *, int, int, int, int);
82         ///
83         void ToggleSelection(LyXText *, BufferView *, bool = true,
84                              int y_offset = 0, int x_offset = 0);
85         ///
86         void ToggleToggle(LyXText *, BufferView *,
87                           int y_offset = 0, int x_offset = 0);
88         
89         /** Updates part of the screen. If text->status is
90             LyXText::NEED_MORE_REFRESH, we update from the
91             point of change and to the end of the screen.
92             If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
93             we only update the current row. */
94         void Update(LyXText *, BufferView *, int y_offset=0, int x_offset=0);
95         ///
96         bool forceClear() const { return force_clear; }
97
98         ///
99         bool cursor_visible;
100 private:
101         /// Copies specified area of pixmap to screen
102         void expose(int x, int y, int exp_width, int exp_height); 
103
104         /// y1 and y2 are coordinates of the screen
105         void DrawFromTo(LyXText *, BufferView *, int y1, int y2,
106                         int y_offset = 0, int x_offset = 0);
107
108         /// y is a coordinate of the text
109         void DrawOneRow(LyXText *, BufferView *, Row * row,
110                         int y_text, int y_offset = 0, int x_offset = 0);
111
112         ///
113         WorkArea & owner;
114         
115         ///
116         Pixmap cursor_pixmap;
117         ///
118         int cursor_pixmap_x;
119         ///
120         int cursor_pixmap_y;
121         ///
122         int cursor_pixmap_w;
123         ///
124         int cursor_pixmap_h;
125         ///
126         GC gc_copy;
127         ///
128         bool force_clear;
129 };
130
131 #endif