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