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