]> git.lyx.org Git - features.git/blob - src/frontends/WorkArea.h
implement --enable-monolithic-{client,frontend-qt4,controllers}. Careful with fronten...
[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 #ifndef BASE_WORKAREA_H
15 #define BASE_WORKAREA_H
16
17 #include "frontends/key_state.h"
18 #include "frontends/KeySymbol.h"
19
20 #include "support/Timeout.h"
21 #include "support/docstring.h"
22
23 #include <boost/signals/trackable.hpp>
24
25 #undef CursorShape
26
27 namespace lyx {
28
29 class BufferView;
30 class FuncRequest;
31
32 namespace frontend {
33
34 class LyXView;
35 class Painter;
36
37 /// types of cursor in work area
38 enum CursorShape {
39         /// normal I-beam
40         BAR_SHAPE,
41         /// L-shape for locked insets of a different language
42         L_SHAPE,
43         /// reverse L-shape for RTL text
44         REVERSED_L_SHAPE
45 };
46
47 /**
48  * The work area class represents the widget that provides the
49  * view onto a document. It is owned by the BufferView, and
50  * is responsible for handing events back to its owning BufferView.
51  * It works in concert with the BaseScreen class to update the
52  * widget view of a document.
53  */
54 class WorkArea : public boost::signals::trackable {
55 public:
56         WorkArea(int id, LyXView & lyx_view);
57
58         virtual ~WorkArea() {}
59
60         int const id() const { return id_; }
61
62         void setBufferView(BufferView * buffer_view);
63
64         ///
65         BufferView & bufferView();
66         ///
67         BufferView const & bufferView() const;
68
69         /// \return true if has the keyboard input focus.
70         virtual bool hasFocus() const = 0;
71
72         /// return the width of the work area in pixels
73         virtual int width() const = 0;
74
75         /// return the height of the work area in pixels
76         virtual int height() const = 0;
77
78         /**
79          * Update the scrollbar.
80          * @param height the total document height in pixels
81          * @param pos the current position in the document, in pixels
82          * @param line_height the line-scroll amount, in pixels
83          */
84         virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
85
86         ///
87         virtual void scheduleRedraw() = 0;
88
89         /// redraw the screen, without using existing pixmap
90         virtual void redraw();
91         ///
92         void stopBlinkingCursor();
93         void startBlinkingCursor();
94
95         /// Process Key pressed event.
96         /// This needs to be public because it is accessed externally by GuiView.
97         void processKeySym(KeySymbolPtr key, key_modifier::state state);
98 protected:
99         /// cause the display of the given area of the work area
100         virtual void expose(int x, int y, int w, int h) = 0;
101         ///
102         void dispatch(FuncRequest const & cmd0,
103                 key_modifier::state = key_modifier::none);
104         ///
105         void resizeBufferView();
106         ///
107         void scrollBufferView(int position);
108         /// hide the visible cursor, if it is visible
109         void hideCursor();
110         /// show the cursor if it is not visible
111         void showCursor();
112         /// toggle the cursor's visibility
113         void toggleCursor();
114         /// hide the cursor
115         virtual void removeCursor() = 0;
116         /// paint the cursor and store the background
117         virtual void showCursor(int x, int y, int h, CursorShape shape) = 0;
118         ///
119         void updateScrollbar();
120
121         ///
122         BufferView * buffer_view_;
123
124         ///
125         LyXView & lyx_view_;
126         ///
127         bool greyed_out_;
128
129 private:
130         ///
131         int id_;
132         ///
133         void displayMessage(docstring const &);
134         /// buffer messages signal connection
135         boost::signals::connection message_connection_;
136
137         /// is the cursor currently displayed
138         bool cursor_visible_;
139
140         ///
141         Timeout cursor_timeout_;
142 };
143
144 } // namespace frontend
145 } // namespace lyx
146
147 #endif // BASE_WORKAREA_H