]> git.lyx.org Git - lyx.git/blob - src/lyxscreen.h
get builddir!=srcdir compiling working; allow successful make even without noweb...
[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
26 struct Row;
27
28 ///
29 typedef unsigned short Dimension;
30
31
32 /** The class LyXScreen is used for the main Textbody.
33     Concretely, the screen is held in a pixmap.  This pixmap is kept up to
34     date and used to optimize drawing on the screen.
35     This class also handles the drawing of the cursor and partly the selection.
36  */
37 class LyXScreen {
38 public:
39         ///
40         enum Cursor_Shape {
41                 ///
42                 BAR_SHAPE,
43                 ///
44                 L_SHAPE,
45                 ///
46                 REVERSED_L_SHAPE
47         };
48
49         ///
50         LyXScreen(WorkArea &);
51
52         /** Draws the screen form textposition y. Uses as much of
53             the already printed pixmap as possible */
54         void Draw(LyXText *, unsigned int y);
55
56         /// Redraws the screen, without using existing pixmap
57         void Redraw(LyXText *);
58    
59         /// Returns a new top so that the cursor is visible
60         unsigned int TopCursorVisible(LyXText const *);
61         /// Redraws the screen such that the cursor is visible
62         bool FitCursor(LyXText *);
63         ///
64         void ShowCursor(LyXText const *);
65         ///
66         void HideCursor();
67         ///
68         void CursorToggle(LyXText const *);
69         ///
70         void ShowManualCursor(LyXText const *, int x, int y,
71                               int asc, int desc,
72                               Cursor_Shape shape);
73         /// returns 1 if first has changed, otherwise 0
74         bool FitManualCursor(LyXText *, int, int, int, int);
75         ///
76         void ToggleSelection(LyXText *, bool = true, int y_offset = 0,
77                              int x_offset = 0);
78         ///
79         void ToggleToggle(LyXText *, int y_offset = 0, int x_offset = 0);
80         
81         /** Updates part of the screen. If text->status is
82             LyXText::NEED_MORE_REFRESH, we update from the
83             point of change and to the end of the screen.
84             If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
85             we only update the current row. */
86         void Update(LyXText *, int y_offset=0, int x_offset=0);
87         ///
88         bool forceClear() const { return force_clear; }
89
90         ///
91         bool cursor_visible;
92 private:
93         /// Copies specified area of pixmap to screen
94         void expose(int x, int y, int exp_width, int exp_height); 
95
96         /// y1 and y2 are coordinates of the screen
97         void DrawFromTo(LyXText *, int y1, int y2,
98                         int y_offset = 0, int x_offset = 0);
99
100         /// y is a coordinate of the text
101         void DrawOneRow(LyXText *, Row * row, int y_text, int y_offset = 0,
102                         int x_offset = 0);
103
104         ///
105         WorkArea & owner;
106         
107         ///
108         Pixmap cursor_pixmap;
109         ///
110         int cursor_pixmap_x;
111         ///
112         int cursor_pixmap_y;
113         ///
114         int cursor_pixmap_w;
115         ///
116         int cursor_pixmap_h;
117         ///
118         GC gc_copy;
119         ///
120         bool force_clear;
121 };
122
123 #endif