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