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