]> git.lyx.org Git - lyx.git/blob - src/frontends/WorkArea.h
49e5b0c946872d8652a744870828ae40c679d1ee
[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 class LyXView;
41
42 namespace lyx {
43 namespace frontend {
44
45 class Painter;
46
47 /// types of cursor in work area
48 enum CursorShape {
49         /// normal I-beam
50         BAR_SHAPE,
51         /// L-shape for locked insets of a different language
52         L_SHAPE,
53         /// reverse L-shape for RTL text
54         REVERSED_L_SHAPE
55 };
56
57 /**
58  * The work area class represents the widget that provides the
59  * view onto a document. It is owned by the BufferView, and
60  * is responsible for handing events back to its owning BufferView.
61  * It works in concert with the BaseScreen class to update the
62  * widget view of a document.
63  */
64 class WorkArea {
65 public:
66         WorkArea(LyXView & lyx_view);
67
68         virtual ~WorkArea() {}
69
70         void setBufferView(BufferView * buffer_view);
71
72         ///
73         BufferView & bufferView();
74         ///
75         BufferView const & bufferView() const;
76
77
78         /// return the painter object for this work area
79         virtual Painter & getPainter() = 0;
80
81         /// return the width of the work area in pixels
82         virtual int width() const = 0;
83
84         /// return the height of the work area in pixels
85         virtual int height() const = 0;
86
87         /**
88          * Update the scrollbar.
89          * @param height the total document height in pixels
90          * @param pos the current position in the document, in pixels
91          * @param line_height the line-scroll amount, in pixels
92          */
93         virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
94
95         /// redraw the screen, without using existing pixmap
96         virtual void redraw();
97
98         /// grey out (no buffer)
99         void greyOut();
100
101         /// FIXME: should be protected, public until the qt3 and gtk frontends are
102         /// cleaned up.
103         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
104
105 protected:
106         /// cause the display of the given area of the work area
107         virtual void expose(int x, int y, int w, int h) = 0;
108
109 public:
110         /// FIXME: This is public because of qt3 and gtk, should be protected
111         void dispatch(FuncRequest const & cmd0);
112
113         /// FIXME: This is public because of qt3 and gtk, should be protected
114         void resizeBufferView();
115
116         /// FIXME: This is public because of qt3 and gtk, should be protected
117         void scrollBufferView(int position);
118
119 protected:
120         /// hide the visible cursor, if it is visible
121         void hideCursor();
122
123         /// show the cursor if it is not visible
124         void showCursor();
125
126         /// toggle the cursor's visibility
127         void toggleCursor();
128
129         /// hide the cursor
130         virtual void removeCursor() = 0;
131
132         /// paint the cursor and store the background
133         virtual void showCursor(int x, int y, int h, CursorShape shape) = 0;
134
135         ///
136         BufferView * buffer_view_;
137
138         ///
139         LyXView & lyx_view_;
140
141 private:
142         ///
143         void updateScrollbar();
144         ///
145         void checkAndGreyOut();
146
147         ///
148         bool greyed_out_;
149
150         /// is the cursor currently displayed
151         bool cursor_visible_;
152
153         ///
154         Timeout cursor_timeout_;
155 };
156
157 } // namespace frontend
158 } // namespace lyx
159
160 #endif // BASE_WORKAREA_H