2002-06-18 15:44:30 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file WorkArea.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-18 15:44:30 +00:00
|
|
|
*
|
|
|
|
* \author unknown
|
2002-10-21 17:38:09 +00:00
|
|
|
* \author John Levon
|
2006-06-20 08:39:16 +00:00
|
|
|
* \author Abdelrazak Younes
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-18 15:44:30 +00:00
|
|
|
*/
|
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
#ifndef BASE_WORKAREA_H
|
|
|
|
#define BASE_WORKAREA_H
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
#include "frontends/key_state.h"
|
|
|
|
|
2007-08-11 22:37:09 +00:00
|
|
|
#include "support/Timeout.h"
|
2006-09-11 08:54:10 +00:00
|
|
|
#include "support/docstring.h"
|
|
|
|
|
2007-08-19 09:44:34 +00:00
|
|
|
#undef CursorShape
|
2006-09-17 10:00:15 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
2007-09-17 18:41:03 +00:00
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
class Buffer;
|
2006-06-20 08:39:16 +00:00
|
|
|
class BufferView;
|
2006-07-13 16:37:55 +00:00
|
|
|
class FuncRequest;
|
2007-09-17 18:41:03 +00:00
|
|
|
class KeySymbol;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
namespace frontend {
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2007-08-14 09:54:59 +00:00
|
|
|
class LyXView;
|
2002-06-19 23:55:55 +00:00
|
|
|
class Painter;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2006-07-08 22:55:22 +00:00
|
|
|
/// 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
|
|
|
|
};
|
|
|
|
|
2002-06-19 23:55:55 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2006-06-20 08:39:16 +00:00
|
|
|
* It works in concert with the BaseScreen class to update the
|
2002-06-19 23:55:55 +00:00
|
|
|
* widget view of a document.
|
|
|
|
*/
|
2007-10-02 09:00:08 +00:00
|
|
|
class WorkArea
|
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
public:
|
2007-08-21 07:33:46 +00:00
|
|
|
///
|
|
|
|
WorkArea(Buffer & buffer, LyXView & lv);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
virtual ~WorkArea();
|
2006-10-23 16:29:24 +00:00
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
///
|
|
|
|
void setLyXView(LyXView & lv) { lyx_view_ = &lv; }
|
2006-06-26 16:55:35 +00:00
|
|
|
|
2006-07-03 22:31:51 +00:00
|
|
|
///
|
|
|
|
BufferView & bufferView();
|
|
|
|
///
|
|
|
|
BufferView const & bufferView() const;
|
|
|
|
|
2006-11-04 07:29:25 +00:00
|
|
|
/// \return true if has the keyboard input focus.
|
|
|
|
virtual bool hasFocus() const = 0;
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
/// \return true if has this WorkArea is visible.
|
|
|
|
virtual bool isVisible() const = 0;
|
|
|
|
|
2002-06-19 23:55:55 +00:00
|
|
|
/// return the width of the work area in pixels
|
2006-06-20 08:39:16 +00:00
|
|
|
virtual int width() const = 0;
|
|
|
|
|
2002-06-19 23:55:55 +00:00
|
|
|
/// return the height of the work area in pixels
|
2006-06-20 08:39:16 +00:00
|
|
|
virtual int height() const = 0;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-19 23:55:55 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2007-01-16 15:16:09 +00:00
|
|
|
///
|
2007-01-18 21:47:27 +00:00
|
|
|
virtual void scheduleRedraw() = 0;
|
2007-01-16 15:16:09 +00:00
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
/// redraw the screen, without using existing pixmap
|
2006-11-20 14:42:18 +00:00
|
|
|
virtual void redraw();
|
2006-10-23 08:47:27 +00:00
|
|
|
///
|
2006-10-26 13:29:10 +00:00
|
|
|
void stopBlinkingCursor();
|
|
|
|
void startBlinkingCursor();
|
2006-06-20 08:39:16 +00:00
|
|
|
|
2006-12-20 21:28:05 +00:00
|
|
|
/// Process Key pressed event.
|
|
|
|
/// This needs to be public because it is accessed externally by GuiView.
|
2007-09-17 18:41:03 +00:00
|
|
|
void processKeySym(KeySymbol const & key, key_modifier::state state);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
2007-10-02 09:00:08 +00:00
|
|
|
/// close this work area.
|
|
|
|
/// Slot for Buffer::closing signal.
|
|
|
|
void close();
|
|
|
|
|
2006-12-20 21:28:05 +00:00
|
|
|
protected:
|
2006-07-13 16:37:55 +00:00
|
|
|
/// cause the display of the given area of the work area
|
|
|
|
virtual void expose(int x, int y, int w, int h) = 0;
|
2006-10-22 18:05:16 +00:00
|
|
|
///
|
2007-01-27 10:41:03 +00:00
|
|
|
void dispatch(FuncRequest const & cmd0,
|
|
|
|
key_modifier::state = key_modifier::none);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
2006-10-22 18:05:16 +00:00
|
|
|
///
|
2006-07-13 16:37:55 +00:00
|
|
|
void resizeBufferView();
|
|
|
|
/// hide the visible cursor, if it is visible
|
2006-07-08 22:06:50 +00:00
|
|
|
void hideCursor();
|
2006-07-13 16:37:55 +00:00
|
|
|
/// show the cursor if it is not visible
|
|
|
|
void showCursor();
|
2006-07-08 22:06:50 +00:00
|
|
|
/// toggle the cursor's visibility
|
|
|
|
void toggleCursor();
|
2006-07-13 16:37:55 +00:00
|
|
|
/// 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;
|
2006-10-23 08:47:27 +00:00
|
|
|
///
|
|
|
|
void updateScrollbar();
|
2006-06-20 08:39:16 +00:00
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
///
|
|
|
|
BufferView * buffer_view_;
|
2006-10-23 08:47:27 +00:00
|
|
|
///
|
2007-08-21 07:33:46 +00:00
|
|
|
LyXView * lyx_view_;
|
2006-08-15 21:57:23 +00:00
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
private:
|
2006-07-13 16:37:55 +00:00
|
|
|
/// is the cursor currently displayed
|
2006-07-08 22:06:50 +00:00
|
|
|
bool cursor_visible_;
|
|
|
|
|
|
|
|
///
|
|
|
|
Timeout cursor_timeout_;
|
2002-06-18 15:44:30 +00:00
|
|
|
};
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif // BASE_WORKAREA_H
|