]> git.lyx.org Git - lyx.git/blob - src/lyxscreen.h
Fix working of the spellchecker dialog with ispell when there are no
[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 <X11/Xlib.h>
20
21 class LyXText;
22 class WorkArea;
23 class Buffer;
24 class BufferView;
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         ///
53         ~LyXScreen();
54  
55         /// Sets the cursor color to LColor::cursor.
56         void setCursorColor();
57         
58         /** Draws the screen form textposition y. Uses as much of
59             the already printed pixmap as possible */
60         void draw(LyXText *, BufferView *, unsigned int y);
61
62         /// Redraws the screen, without using existing pixmap
63         void redraw(LyXText *, BufferView *);
64    
65         /// Returns a new top so that the cursor is visible
66         unsigned int topCursorVisible(LyXText const *);
67         /// Redraws the screen such that the cursor is visible
68         bool fitCursor(LyXText *, BufferView *);
69         ///
70         void showCursor(LyXText const *, BufferView const *);
71         ///
72         void hideCursor();
73         ///
74         void cursorToggle(BufferView *) const;
75         ///
76         void showManualCursor(LyXText const *, int x, int y,
77                               int asc, int desc,
78                               Cursor_Shape shape);
79         /// returns 1 if first has changed, otherwise 0
80         bool fitManualCursor(LyXText *, BufferView *, int, int, int, int);
81         ///
82         void toggleSelection(LyXText *, BufferView *, bool = true,
83                              int y_offset = 0, int x_offset = 0);
84         ///
85         void toggleToggle(LyXText *, BufferView *,
86                           int y_offset = 0, int x_offset = 0);
87         
88         /** Updates part of the screen. If text->status is
89             LyXText::NEED_MORE_REFRESH, we update from the
90             point of change and to the end of the screen.
91             If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
92             we only update the current row. */
93         void update(LyXText *, BufferView *, int y_offset=0, int x_offset=0);
94         ///
95         bool forceClear() const { return force_clear; }
96
97         ///
98         bool cursor_visible;
99 private:
100         /// Copies specified area of pixmap to screen
101         void expose(int x, int y, int exp_width, int exp_height); 
102
103         /// y1 and y2 are coordinates of the screen
104         void drawFromTo(LyXText *, BufferView *, int y1, int y2,
105                         int y_offset = 0, int x_offset = 0, bool internal=false);
106
107         /// y is a coordinate of the text
108         void drawOneRow(LyXText *, BufferView *, Row * row,
109                         int y_text, int y_offset = 0, int x_offset = 0);
110
111         ///
112         WorkArea & owner;
113         
114         ///
115         Pixmap cursor_pixmap;
116         ///
117         int cursor_pixmap_x;
118         ///
119         int cursor_pixmap_y;
120         ///
121         int cursor_pixmap_w;
122         ///
123         int cursor_pixmap_h;
124         ///
125         GC gc_copy;
126         ///
127         bool force_clear;
128 };
129
130 #endif