]> git.lyx.org Git - lyx.git/blob - src/frontends/screen.h
refactor topCursorVisible() prototype a little. Compile fix
[lyx.git] / src / frontends / screen.h
1 // -*- C++ -*-
2 /**
3  * \file screen.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author unknown
8  * \author John Levon <moz@compsoc.man.ac.uk>
9  */ 
10
11 #ifndef LYXSCREEN_H
12 #define LYXSCREEN_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include <X11/Xlib.h>
19
20 class LyXText;
21 class LyXCursor;
22 class WorkArea;
23 class Buffer;
24 class BufferView;
25
26 struct Row;
27
28 /**
29  * LScreen - document rendering management
30  *
31  * This class is used to manage the on-screen rendering inside the
32  * work area; it is responsible for deciding which LyXText rows
33  * need re-drawing.
34  *
35  * This class will arrange for LyXText to paint onto a pixmap
36  * provided by the WorkArea widget.
37  *
38  * The blinking cursor is also handled here.
39  */
40 class LScreen {
41 public:
42         ///
43         enum Cursor_Shape {
44                 ///
45                 BAR_SHAPE,
46                 ///
47                 L_SHAPE,
48                 ///
49                 REVERSED_L_SHAPE
50         };
51
52         ///
53         LScreen(WorkArea &);
54
55         ///
56         ~LScreen();
57
58         void reset();
59  
60         /// Sets the cursor color to LColor::cursor.
61         void setCursorColor();
62
63         /** Draws the screen form textposition y. Uses as much of
64             the already printed pixmap as possible */
65         void draw(LyXText *, BufferView *, unsigned int y);
66
67         /// Redraws the screen, without using existing pixmap
68         void redraw(LyXText *, BufferView *);
69
70         /**
71          * topCursorVisible - get a new "top" to make the cursor visible
72          * @param c the cursor
73          * @param top_y the current y location of the containing region
74          *
75          * This helper function calculates a new y co-ordinate for
76          * the top of the containing region such that the cursor contained
77          * within the LyXText is "nicely" visible.
78          */ 
79         unsigned int topCursorVisible(LyXCursor const & c, int top_y);
80  
81         /// Redraws the screen such that the cursor is visible
82         bool fitCursor(LyXText *, BufferView *);
83         ///
84         void showCursor(LyXText const *, BufferView const *);
85         ///
86         void hideCursor();
87         ///
88         void cursorToggle(BufferView *) const;
89         ///
90         void showManualCursor(LyXText const *, int x, int y,
91                               int asc, int desc,
92                               Cursor_Shape shape);
93         /// returns 1 if first has changed, otherwise 0
94         bool fitManualCursor(LyXText *, BufferView *, int, int, int, int);
95         ///
96         void toggleSelection(LyXText *, BufferView *, bool = true,
97                              int y_offset = 0, int x_offset = 0);
98         ///
99         void toggleToggle(LyXText *, BufferView *,
100                           int y_offset = 0, int x_offset = 0);
101
102         /** Updates part of the screen. If text->status is
103             LyXText::NEED_MORE_REFRESH, we update from the
104             point of change and to the end of the screen.
105             If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
106             we only update the current row. */
107         void update(LyXText *, BufferView *, int y_offset=0, int x_offset=0);
108         ///
109         bool forceClear() const { return force_clear; }
110
111         ///
112         bool cursor_visible;
113 private:
114         /// Copies specified area of pixmap to screen
115         void expose(int x, int y, int exp_width, int exp_height);
116
117         /// y1 and y2 are coordinates of the screen
118         void drawFromTo(LyXText *, BufferView *, int y1, int y2,
119                         int y_offset = 0, int x_offset = 0, bool internal=false);
120
121         /// y is a coordinate of the text
122         void drawOneRow(LyXText *, BufferView *, Row * row,
123                         int y_text, int y_offset = 0, int x_offset = 0);
124
125         ///
126         WorkArea & owner;
127
128         ///
129         Pixmap cursor_pixmap;
130         ///
131         int cursor_pixmap_x;
132         ///
133         int cursor_pixmap_y;
134         ///
135         int cursor_pixmap_w;
136         ///
137         int cursor_pixmap_h;
138         ///
139         GC gc_copy;
140         ///
141         bool force_clear;
142 };
143
144 #endif