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"
18 #include "frontends/KeySymbol.h"
20 #include "support/Timeout.h"
21 #include "support/docstring.h"
23 #include <boost/signals/trackable.hpp>
37 /// types of cursor in work area
41 /// L-shape for locked insets of a different language
43 /// reverse L-shape for RTL text
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.
54 class WorkArea : public boost::signals::trackable {
57 WorkArea(Buffer & buffer, LyXView & lv);
62 void setLyXView(LyXView & lv) { lyx_view_ = &lv; }
65 BufferView & bufferView();
67 BufferView const & bufferView() const;
69 /// \return true if has the keyboard input focus.
70 virtual bool hasFocus() const = 0;
72 /// \return true if has this WorkArea is visible.
73 virtual bool isVisible() const = 0;
75 /// return the width of the work area in pixels
76 virtual int width() const = 0;
78 /// return the height of the work area in pixels
79 virtual int height() const = 0;
82 * Update the scrollbar.
83 * @param height the total document height in pixels
84 * @param pos the current position in the document, in pixels
85 * @param line_height the line-scroll amount, in pixels
87 virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
90 virtual void scheduleRedraw() = 0;
92 /// redraw the screen, without using existing pixmap
93 virtual void redraw();
95 void stopBlinkingCursor();
96 void startBlinkingCursor();
98 /// Process Key pressed event.
99 /// This needs to be public because it is accessed externally by GuiView.
100 void processKeySym(KeySymbolPtr key, key_modifier::state state);
103 /// cause the display of the given area of the work area
104 virtual void expose(int x, int y, int w, int h) = 0;
106 void dispatch(FuncRequest const & cmd0,
107 key_modifier::state = key_modifier::none);
109 /// close this work area.
110 /// Slot for Buffer::closing boost signal.
113 void resizeBufferView();
115 void scrollBufferView(int position);
116 /// hide the visible cursor, if it is visible
118 /// show the cursor if it is not visible
120 /// toggle the cursor's visibility
123 virtual void removeCursor() = 0;
124 /// paint the cursor and store the background
125 virtual void showCursor(int x, int y, int h, CursorShape shape) = 0;
127 void updateScrollbar();
130 BufferView * buffer_view_;
135 /// is the cursor currently displayed
136 bool cursor_visible_;
139 Timeout cursor_timeout_;
141 /// buffer changed signal connection
142 boost::signals::connection bufferChangedConnection_;
143 /// buffer closing signal connection
144 boost::signals::connection bufferClosingConnection_;
147 } // namespace frontend
150 #endif // BASE_WORKAREA_H