]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/WorkArea.h
* src/frontends/qt4/ui/TextLayoutUi.ui:
[lyx.git] / src / frontends / WorkArea.h
index 2449b8e4a6d6dd31133cce53157cb6389a0d1f7c..f45e2eefd671de49049ef9a8668bfa833abef85c 100644 (file)
 // -*- C++ -*-
 /**
  * \file WorkArea.h
- * Copyright 1995-2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author unknown
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author John Levon
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
-#ifndef WORKAREA_H
-#define WORKAREA_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
+#ifndef BASE_WORKAREA_H
+#define BASE_WORKAREA_H
 
-#include "frontends/Painter.h"
-#include "frontends/mouse_state.h"
 #include "frontends/key_state.h"
-#include "frontends/LyXKeySym.h"
+#include "frontends/KeySymbol.h"
+#include "frontends/Timeout.h"
+
+#include "support/docstring.h"
+
+#include <boost/signals/trackable.hpp>
+
+
+namespace lyx {
 
-#include <boost/signals/signal0.hpp>
-#include <boost/signals/signal1.hpp>
-#include <boost/signals/signal2.hpp>
-#include <boost/signals/signal3.hpp>
+class BufferView;
+class FuncRequest;
+class LyXView;
 
-#include <utility>
+namespace frontend {
 
-///
-class WorkArea {
+class Painter;
+
+/// types of cursor in work area
+enum CursorShape {
+       /// normal I-beam
+       BAR_SHAPE,
+       /// L-shape for locked insets of a different language
+       L_SHAPE,
+       /// reverse L-shape for RTL text
+       REVERSED_L_SHAPE
+};
+
+/**
+ * The work area class represents the widget that provides the
+ * view onto a document. It is owned by the BufferView, and
+ * is responsible for handing events back to its owning BufferView.
+ * It works in concert with the BaseScreen class to update the
+ * widget view of a document.
+ */
+class WorkArea : public boost::signals::trackable {
 public:
-       ///
-       WorkArea() {}
-       ///
+       WorkArea(int id, LyXView & lyx_view);
+
        virtual ~WorkArea() {}
+
+       int const id() const { return id_; }
+
+       void setBufferView(BufferView * buffer_view);
+
        ///
-       virtual Painter & getPainter() = 0;
-       ///
-       virtual int workWidth() const = 0;
-       ///
-       virtual int workHeight() const = 0;
-  
-       ///
-       virtual int xpos() const = 0;
-       ///
-       virtual int ypos() const = 0;
-       ///
-       virtual void resize(int xpos, int ypos, int width, int height) = 0;
-       ///
-       virtual void redraw() const = 0;
-       ///
-       virtual void setFocus() const = 0;
+       BufferView & bufferView();
        ///
+       BufferView const & bufferView() const;
+
+       /// \return true if has the keyboard input focus.
        virtual bool hasFocus() const = 0;
+
+       /// return the width of the work area in pixels
+       virtual int width() const = 0;
+
+       /// return the height of the work area in pixels
+       virtual int height() const = 0;
+
+       /**
+        * Update the scrollbar.
+        * @param height the total document height in pixels
+        * @param pos the current position in the document, in pixels
+        * @param line_height the line-scroll amount, in pixels
+        */
+       virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
+
        ///
-       virtual bool visible() const = 0;
-       ///
-       virtual void greyOut() const = 0;
-        ///
-        virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
-       /// a selection exists
-       virtual void haveSelection(bool) const = 0;
-       ///
-       virtual string const getClipboard() const = 0;
-       ///
-       virtual void putClipboard(string const &) const = 0;
-       // Signals
-       ///
-       boost::signal0<void> workAreaExpose;
-       ///
-       boost::signal1<void, int> scrollDocView;
-       ///
-       boost::signal2<void, LyXKeySymPtr, key_modifier::state> workAreaKeyPress;
+       virtual void scheduleRedraw() = 0;
+
+       /// redraw the screen, without using existing pixmap
+       virtual void redraw();
        ///
-       boost::signal3<void, int, int, mouse_button::state> workAreaButtonPress;
+       void stopBlinkingCursor();
+       void startBlinkingCursor();
+
+       /// Process Key pressed event.
+       /// This needs to be public because it is accessed externally by GuiView.
+       void processKeySym(KeySymbolPtr key, key_modifier::state state);
+protected:
+       /// cause the display of the given area of the work area
+       virtual void expose(int x, int y, int w, int h) = 0;
+       ///
+       void dispatch(FuncRequest const & cmd0,
+               key_modifier::state = key_modifier::none);
+       ///
+       void resizeBufferView();
+       ///
+       void scrollBufferView(int position);
+       /// hide the visible cursor, if it is visible
+       void hideCursor();
+       /// show the cursor if it is not visible
+       void showCursor();
+       /// toggle the cursor's visibility
+       void toggleCursor();
+       /// hide the cursor
+       virtual void removeCursor() = 0;
+       /// paint the cursor and store the background
+       virtual void showCursor(int x, int y, int h, CursorShape shape) = 0;
+       ///
+       void updateScrollbar();
+
        ///
-       boost::signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
+       BufferView * buffer_view_;
+
        ///
-       boost::signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
+       LyXView & lyx_view_;
        ///
-       boost::signal0<void> workAreaFocus;
+       bool greyed_out_;
+
+private:
        ///
-       boost::signal0<void> workAreaUnfocus;
+       int id_;
        ///
-       boost::signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
+       void displayMessage(docstring const &);
+       /// buffer messages signal connection
+       boost::signals::connection message_connection_;
+
+       /// is the cursor currently displayed
+       bool cursor_visible_;
+
        ///
-       boost::signal3<void, int, int, mouse_button::state> workAreaTripleClick;
-       /// emitted when an X client has requested our selection
-       boost::signal0<void> selectionRequested;
-       /// emitted when another X client has stolen our selection
-       boost::signal0<void> selectionLost;
+       Timeout cursor_timeout_;
 };
-#endif // WORKAREA_H
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // BASE_WORKAREA_H