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-07-08 22:55:22 +00:00
|
|
|
// X11 use a define called CursorShape, and we really want to use
|
|
|
|
// that name our selves. Therefore we do something similar to what is done
|
|
|
|
// in kde/fixx11h.h:
|
|
|
|
namespace X {
|
|
|
|
#ifdef CursorShape
|
|
|
|
#ifndef FIXX11H_CursorShape
|
|
|
|
#define FIXX11H_CursorShape
|
|
|
|
int const XCursorShape = CursorShape;
|
|
|
|
#undef CursorShape
|
|
|
|
int const CursorShape = CursorShape;
|
|
|
|
#endif
|
|
|
|
#undef CursorShape
|
|
|
|
#endif
|
|
|
|
} // namespace X
|
|
|
|
|
|
|
|
|
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"
|
2006-04-13 12:18:42 +00:00
|
|
|
#include "frontends/LyXKeySym.h"
|
2006-07-08 22:06:50 +00:00
|
|
|
#include "frontends/Timeout.h"
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2006-08-24 14:10:22 +00:00
|
|
|
#include <boost/signals/trackable.hpp>
|
2006-07-13 16:37:55 +00:00
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
class BufferView;
|
2006-07-13 16:37:55 +00:00
|
|
|
class FuncRequest;
|
2006-08-15 21:57:23 +00:00
|
|
|
class LyXView;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2002-06-18 15:44:30 +00:00
|
|
|
|
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.
|
|
|
|
*/
|
2006-08-24 14:10:22 +00:00
|
|
|
class WorkArea : public boost::signals::trackable {
|
2002-06-18 15:44:30 +00:00
|
|
|
public:
|
2006-08-15 21:57:23 +00:00
|
|
|
WorkArea(LyXView & lyx_view);
|
2002-06-19 23:55:55 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
virtual ~WorkArea() {}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
void setBufferView(BufferView * buffer_view);
|
|
|
|
|
2006-07-03 22:31:51 +00:00
|
|
|
///
|
|
|
|
BufferView & bufferView();
|
|
|
|
///
|
|
|
|
BufferView const & bufferView() const;
|
|
|
|
|
2006-07-13 16:37:55 +00:00
|
|
|
|
2002-06-19 23:55:55 +00:00
|
|
|
/// return the painter object for this work area
|
2002-06-18 15:44:30 +00:00
|
|
|
virtual Painter & getPainter() = 0;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
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
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
/// redraw the screen, without using existing pixmap
|
2006-07-08 20:24:32 +00:00
|
|
|
virtual void redraw();
|
2006-06-20 08:39:16 +00:00
|
|
|
|
|
|
|
/// grey out (no buffer)
|
|
|
|
void greyOut();
|
|
|
|
|
2006-07-13 16:37:55 +00:00
|
|
|
/// FIXME: should be protected, public until the qt3 and gtk frontends are
|
|
|
|
/// cleaned up.
|
|
|
|
void processKeySym(LyXKeySymPtr key, key_modifier::state state);
|
2006-06-20 08:39:16 +00:00
|
|
|
|
2006-07-13 16:37:55 +00:00
|
|
|
protected:
|
|
|
|
/// cause the display of the given area of the work area
|
|
|
|
virtual void expose(int x, int y, int w, int h) = 0;
|
2006-06-20 08:39:16 +00:00
|
|
|
|
2006-07-30 14:57:01 +00:00
|
|
|
public:
|
|
|
|
/// FIXME: This is public because of qt3 and gtk, should be protected
|
2006-07-13 16:37:55 +00:00
|
|
|
void dispatch(FuncRequest const & cmd0);
|
|
|
|
|
2006-08-15 21:57:23 +00:00
|
|
|
/// FIXME: This is public because of qt3 and gtk, should be protected
|
2006-07-13 16:37:55 +00:00
|
|
|
void resizeBufferView();
|
|
|
|
|
2006-08-15 21:57:23 +00:00
|
|
|
/// FIXME: This is public because of qt3 and gtk, should be protected
|
|
|
|
void scrollBufferView(int position);
|
2006-07-13 16:37:55 +00:00
|
|
|
|
2006-08-15 21:57:23 +00:00
|
|
|
protected:
|
2006-07-13 16:37:55 +00:00
|
|
|
/// 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-06-20 08:39:16 +00:00
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
///
|
|
|
|
BufferView * buffer_view_;
|
|
|
|
|
2006-08-15 21:57:23 +00:00
|
|
|
///
|
|
|
|
LyXView & lyx_view_;
|
|
|
|
|
2006-06-20 08:39:16 +00:00
|
|
|
private:
|
2006-08-16 15:24:38 +00:00
|
|
|
///
|
|
|
|
void updateScrollbar();
|
2006-06-20 08:39:16 +00:00
|
|
|
///
|
|
|
|
void checkAndGreyOut();
|
2006-08-24 14:10:22 +00:00
|
|
|
///
|
|
|
|
void displayMessage(std::string const &);
|
|
|
|
/// buffer messages signal connection
|
|
|
|
boost::signals::connection message_connection_;
|
2006-06-20 08:39:16 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
bool greyed_out_;
|
2006-07-08 22:06:50 +00:00
|
|
|
|
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
|