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