]> git.lyx.org Git - lyx.git/blob - src/frontends/WorkArea.h
edd0742310ab84e904a0f9d92ecc2880c4edf61c
[lyx.git] / src / frontends / WorkArea.h
1 // -*- C++ -*-
2 /**
3  * \file WorkArea.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 // X11 use a define called CursorShape, and we really want to use
15 // that name our selves. Therefore we do something similar to what is done
16 // in kde/fixx11h.h:
17 namespace X {
18 #ifdef CursorShape
19 #ifndef FIXX11H_CursorShape
20 #define FIXX11H_CursorShape
21 int const XCursorShape = CursorShape;
22 #undef CursorShape
23 int const CursorShape = CursorShape;
24 #endif
25 #undef CursorShape
26 #endif
27 } // namespace X
28
29
30 #ifndef BASE_WORKAREA_H
31 #define BASE_WORKAREA_H
32
33 #include "frontends/key_state.h"
34 #include "frontends/LyXKeySym.h"
35 #include "frontends/Timeout.h"
36
37
38 class BufferView;
39 class FuncRequest;
40
41 namespace lyx {
42 namespace frontend {
43
44 class Painter;
45
46 /// types of cursor in work area
47 enum CursorShape {
48         /// normal I-beam
49         BAR_SHAPE,
50         /// L-shape for locked insets of a different language
51         L_SHAPE,
52         /// reverse L-shape for RTL text
53         REVERSED_L_SHAPE
54 };
55
56 /**
57  * The work area class represents the widget that provides the
58  * view onto a document. It is owned by the BufferView, and
59  * is responsible for handing events back to its owning BufferView.
60  * It works in concert with the BaseScreen class to update the
61  * widget view of a document.
62  */
63 class WorkArea {
64 public:
65         WorkArea(BufferView * buffer_view = 0);
66
67         virtual ~WorkArea() {}
68
69         void setBufferView(BufferView * buffer_view);
70
71         ///
72         BufferView & bufferView();
73         ///
74         BufferView const & bufferView() const;
75
76
77         /// return the painter object for this work area
78         virtual Painter & getPainter() = 0;
79
80         /// return the width of the work area in pixels
81         virtual int width() const = 0;
82
83         /// return the height of the work area in pixels
84         virtual int height() const = 0;
85
86         /**
87          * Update the scrollbar.
88          * @param height the total document height in pixels
89          * @param pos the current position in the document, in pixels
90          * @param line_height the line-scroll amount, in pixels
91          */
92         virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
93
94         /// redraw the screen, without using existing pixmap
95         virtual void redraw();
96
97         /// grey out (no buffer)
98         void greyOut();
99
100         /// FIXME: should be protected, public until the qt3 and gtk frontends are
101         /// cleaned up.
102         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
103
104 protected:
105         /// cause the display of the given area of the work area
106         virtual void expose(int x, int y, int w, int h) = 0;
107
108 public:
109         /// FIXME: This is public because of qt3 and gtk, should be protected
110         void dispatch(FuncRequest const & cmd0);
111
112 protected:
113         ///
114         void resizeBufferView();
115
116
117         /// hide the visible cursor, if it is visible
118         void hideCursor();
119
120         /// show the cursor if it is not visible
121         void showCursor();
122
123         /// toggle the cursor's visibility
124         void toggleCursor();
125
126         /// hide the cursor
127         virtual void removeCursor() = 0;
128
129         /// paint the cursor and store the background
130         virtual void showCursor(int x, int y, int h, CursorShape shape) = 0;
131
132         ///
133         BufferView * buffer_view_;
134
135 private:
136         ///
137         void checkAndGreyOut();
138
139         ///
140         bool greyed_out_;
141
142         /// is the cursor currently displayed
143         bool cursor_visible_;
144
145         ///
146         Timeout cursor_timeout_;
147 };
148
149 } // namespace frontend
150 } // namespace lyx
151
152 #endif // BASE_WORKAREA_H