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