]> git.lyx.org Git - lyx.git/blob - src/frontends/WorkArea.h
enable Font cache only for MacOSX and inline width() for other platform.
[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/LyXKeySym.h"
19 #include "frontends/Timeout.h"
20
21 #include "support/docstring.h"
22
23 #include <boost/signals/trackable.hpp>
24
25 // FIXME: defined in X.h, spuriously pulled in by Qt 3 headers
26 #undef CursorShape
27
28 class BufferView;
29 class FuncRequest;
30 class LyXView;
31
32
33 namespace lyx {
34 namespace frontend {
35
36 class Painter;
37
38 /// types of cursor in work area
39 enum CursorShape {
40         /// normal I-beam
41         BAR_SHAPE,
42         /// L-shape for locked insets of a different language
43         L_SHAPE,
44         /// reverse L-shape for RTL text
45         REVERSED_L_SHAPE
46 };
47
48 /**
49  * The work area class represents the widget that provides the
50  * view onto a document. It is owned by the BufferView, and
51  * is responsible for handing events back to its owning BufferView.
52  * It works in concert with the BaseScreen class to update the
53  * widget view of a document.
54  */
55 class WorkArea : public boost::signals::trackable {
56 public:
57         WorkArea(LyXView & lyx_view);
58
59         virtual ~WorkArea() {}
60
61         void setBufferView(BufferView * buffer_view);
62
63         ///
64         BufferView & bufferView();
65         ///
66         BufferView const & bufferView() const;
67
68
69         /// return the painter object for this work area
70         virtual Painter & getPainter() = 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         /// redraw the screen, without using existing pixmap
87         virtual void redraw();
88
89         /// grey out (no buffer)
90         void greyOut();
91
92         /// FIXME: should be protected, public until the qt3 and gtk frontends are
93         /// cleaned up.
94         void processKeySym(LyXKeySymPtr key, key_modifier::state state);
95
96 protected:
97         /// cause the display of the given area of the work area
98         virtual void expose(int x, int y, int w, int h) = 0;
99
100 public:
101         /// FIXME: This is public because of qt3 and gtk, should be protected
102         void dispatch(FuncRequest const & cmd0);
103
104         /// FIXME: This is public because of qt3 and gtk, should be protected
105         void resizeBufferView();
106
107         /// FIXME: This is public because of qt3 and gtk, should be protected
108         void scrollBufferView(int position);
109
110 protected:
111         /// hide the visible cursor, if it is visible
112         void hideCursor();
113
114         /// show the cursor if it is not visible
115         void showCursor();
116
117         /// toggle the cursor's visibility
118         void toggleCursor();
119
120         /// hide the cursor
121         virtual void removeCursor() = 0;
122
123         /// paint the cursor and store the background
124         virtual void showCursor(int x, int y, int h, CursorShape shape) = 0;
125
126         ///
127         BufferView * buffer_view_;
128
129         ///
130         LyXView & lyx_view_;
131
132 private:
133         ///
134         void updateScrollbar();
135         ///
136         void checkAndGreyOut();
137         ///
138         void displayMessage(lyx::docstring const &);
139         /// buffer messages signal connection
140         boost::signals::connection message_connection_;
141
142         ///
143         bool greyed_out_;
144
145         /// is the cursor currently displayed
146         bool cursor_visible_;
147
148         ///
149         Timeout cursor_timeout_;
150 };
151
152 } // namespace frontend
153 } // namespace lyx
154
155 #endif // BASE_WORKAREA_H