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