4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * \author Abdelrazak Younes
11 * Full author contact details are available in file CREDITS.
14 #ifndef BASE_WORKAREA_H
15 #define BASE_WORKAREA_H
17 #include "frontends/key_state.h"
19 #include "support/Timeout.h"
20 #include "support/docstring.h"
22 #include <boost/signals/trackable.hpp>
38 /// types of cursor in work area
42 /// L-shape for locked insets of a different language
44 /// reverse L-shape for RTL text
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.
55 class WorkArea : public boost::signals::trackable {
58 WorkArea(Buffer & buffer, LyXView & lv);
63 void setLyXView(LyXView & lv) { lyx_view_ = &lv; }
66 BufferView & bufferView();
68 BufferView const & bufferView() const;
70 /// \return true if has the keyboard input focus.
71 virtual bool hasFocus() const = 0;
73 /// \return true if has this WorkArea is visible.
74 virtual bool isVisible() const = 0;
76 /// return the width of the work area in pixels
77 virtual int width() const = 0;
79 /// return the height of the work area in pixels
80 virtual int height() const = 0;
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
88 virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
91 virtual void scheduleRedraw() = 0;
93 /// redraw the screen, without using existing pixmap
94 virtual void redraw();
96 void stopBlinkingCursor();
97 void startBlinkingCursor();
99 /// Process Key pressed event.
100 /// This needs to be public because it is accessed externally by GuiView.
101 void processKeySym(KeySymbol const & key, key_modifier::state state);
104 /// cause the display of the given area of the work area
105 virtual void expose(int x, int y, int w, int h) = 0;
107 void dispatch(FuncRequest const & cmd0,
108 key_modifier::state = key_modifier::none);
110 /// close this work area.
111 /// Slot for Buffer::closing boost signal.
114 void resizeBufferView();
115 /// hide the visible cursor, if it is visible
117 /// show the cursor if it is not visible
119 /// toggle the cursor's visibility
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;
126 void updateScrollbar();
129 BufferView * buffer_view_;
134 /// is the cursor currently displayed
135 bool cursor_visible_;
138 Timeout cursor_timeout_;
140 /// buffer changed signal connection
141 boost::signals::connection bufferChangedConnection_;
142 /// buffer closing signal connection
143 boost::signals::connection bufferClosingConnection_;
146 } // namespace frontend
149 #endif // BASE_WORKAREA_H