2000-04-08 17:02:02 +00:00
|
|
|
// -*- C++ -*-
|
2002-06-12 02:54:19 +00:00
|
|
|
/**
|
|
|
|
* \file BufferView_pimpl.h
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author various
|
|
|
|
*/
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
|
|
#ifndef BUFFERVIEW_PIMPL_H
|
|
|
|
#define BUFFERVIEW_PIMPL_H
|
|
|
|
|
|
|
|
#include "BufferView.h"
|
2001-02-07 16:44:49 +00:00
|
|
|
#include "frontends/Timeout.h"
|
2002-06-12 02:54:19 +00:00
|
|
|
#include "frontends/key_state.h"
|
|
|
|
#include "frontends/mouse_state.h"
|
2002-06-18 15:44:30 +00:00
|
|
|
#include "frontends/LyXKeySym.h"
|
2001-12-17 14:25:04 +00:00
|
|
|
#include "box.h"
|
2001-07-20 09:38:19 +00:00
|
|
|
#include "insets/insetspecialchar.h"
|
2001-11-26 16:42:04 +00:00
|
|
|
#include "support/types.h"
|
2000-04-08 17:02:02 +00:00
|
|
|
|
2002-05-22 01:16:37 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2002-05-29 16:21:03 +00:00
|
|
|
#include <boost/signals/trackable.hpp>
|
2002-05-22 01:16:37 +00:00
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class LyXView;
|
|
|
|
class WorkArea;
|
2002-06-18 15:44:30 +00:00
|
|
|
class LyXScreen;
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2002-05-29 16:21:03 +00:00
|
|
|
struct BufferView::Pimpl : public boost::signals::trackable {
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
Pimpl(BufferView * i, LyXView * o,
|
|
|
|
int xpos, int ypos, int width, int height);
|
2000-04-09 22:48:51 +00:00
|
|
|
///
|
2002-06-12 02:54:19 +00:00
|
|
|
Painter & painter() const;
|
2002-06-11 22:38:49 +00:00
|
|
|
/// return the work area for this bview
|
|
|
|
WorkArea & workarea() const;
|
2002-06-11 23:47:58 +00:00
|
|
|
/// return the screen for this bview
|
2002-06-18 15:44:30 +00:00
|
|
|
LyXScreen & screen() const;
|
2000-04-09 22:48:51 +00:00
|
|
|
///
|
|
|
|
void buffer(Buffer *);
|
2000-04-26 13:57:28 +00:00
|
|
|
/// Return true if the cursor was fitted.
|
2001-08-02 14:55:06 +00:00
|
|
|
bool fitCursor();
|
2000-04-09 22:48:51 +00:00
|
|
|
///
|
|
|
|
void redoCurrentBuffer();
|
|
|
|
///
|
|
|
|
int resizeCurrentBuffer();
|
|
|
|
///
|
|
|
|
void update();
|
2000-08-07 20:58:24 +00:00
|
|
|
//
|
2001-02-14 08:38:21 +00:00
|
|
|
void update(LyXText *, BufferView::UpdateCodes);
|
2002-06-21 02:22:13 +00:00
|
|
|
/**
|
|
|
|
* Repaint pixmap. Used for when we've made a visible
|
|
|
|
* change but don't need the full update() logic
|
|
|
|
*/
|
|
|
|
void repaint();
|
2000-04-08 17:02:02 +00:00
|
|
|
///
|
2002-06-20 20:37:42 +00:00
|
|
|
void workAreaResize();
|
2000-04-08 17:02:02 +00:00
|
|
|
///
|
2000-04-09 22:48:51 +00:00
|
|
|
void updateScrollbar();
|
|
|
|
///
|
2002-06-12 15:01:32 +00:00
|
|
|
void scrollDocView(int value);
|
2001-12-17 14:25:04 +00:00
|
|
|
/**
|
|
|
|
* Returns an inset if inset was hit, or 0 if not.
|
|
|
|
*
|
|
|
|
* If hit, the coordinates are changed relative to the inset.
|
|
|
|
*/
|
|
|
|
Inset * checkInsetHit(LyXText *, int & x, int & y);
|
2002-06-12 15:01:32 +00:00
|
|
|
/// wheel mouse scroll
|
|
|
|
int scroll(long time);
|
2002-03-21 17:27:08 +00:00
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
void workAreaKeyPress(LyXKeySymPtr key,
|
|
|
|
key_modifier::state state);
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
void workAreaMotionNotify(int x, int y, mouse_button::state state);
|
2000-04-08 17:02:02 +00:00
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
void workAreaButtonPress(int x, int y, mouse_button::state button);
|
2000-04-08 17:02:02 +00:00
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
void workAreaButtonRelease(int x, int y, mouse_button::state button);
|
2000-04-08 17:02:02 +00:00
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
void doubleClick(int x, int y, mouse_button::state button);
|
2000-04-08 17:02:02 +00:00
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
void tripleClick(int x, int y, mouse_button::state button);
|
2000-04-08 17:02:02 +00:00
|
|
|
///
|
2002-01-13 17:28:42 +00:00
|
|
|
void selectionRequested();
|
|
|
|
///
|
2002-02-07 16:43:54 +00:00
|
|
|
void selectionLost();
|
|
|
|
///
|
2000-04-09 22:48:51 +00:00
|
|
|
void cursorToggle();
|
|
|
|
///
|
|
|
|
bool available() const;
|
|
|
|
///
|
2001-02-14 10:11:22 +00:00
|
|
|
void beforeChange(LyXText *);
|
2000-04-09 22:48:51 +00:00
|
|
|
///
|
2002-08-20 13:00:25 +00:00
|
|
|
void finishChange(bool fitcur);
|
|
|
|
///
|
2001-01-28 18:31:36 +00:00
|
|
|
void savePosition(unsigned int i);
|
2000-04-09 22:48:51 +00:00
|
|
|
///
|
2001-01-28 18:31:36 +00:00
|
|
|
void restorePosition(unsigned int i);
|
2000-04-09 22:48:51 +00:00
|
|
|
///
|
2001-01-28 18:31:36 +00:00
|
|
|
bool isSavedPosition(unsigned int i);
|
2000-06-05 15:12:09 +00:00
|
|
|
///
|
2002-07-17 04:13:41 +00:00
|
|
|
void switchKeyMap();
|
2000-04-09 22:48:51 +00:00
|
|
|
///
|
|
|
|
void insetUnlock();
|
|
|
|
///
|
|
|
|
void showCursor();
|
|
|
|
///
|
|
|
|
void hideCursor();
|
|
|
|
///
|
|
|
|
void toggleSelection(bool = true);
|
|
|
|
///
|
|
|
|
void toggleToggle();
|
|
|
|
///
|
|
|
|
void center();
|
|
|
|
///
|
2001-06-04 23:57:32 +00:00
|
|
|
bool insertInset(Inset * inset, string const & lout = string());
|
|
|
|
///
|
|
|
|
void updateInset(Inset * inset, bool mark_dirty);
|
|
|
|
///
|
2002-08-07 08:11:41 +00:00
|
|
|
bool dispatch(FuncRequest const & ev);
|
2001-03-06 19:29:58 +00:00
|
|
|
private:
|
2001-12-17 14:25:04 +00:00
|
|
|
/**
|
|
|
|
* Return the on-screen dimensions of the inset at the cursor.
|
|
|
|
* Pre-condition: the cursor must be at an inset.
|
|
|
|
*/
|
|
|
|
Box insetDimensions(LyXText const & text, LyXCursor const & cursor) const;
|
|
|
|
/**
|
2002-07-28 18:13:51 +00:00
|
|
|
* check if the given co-ordinates are inside an inset at the
|
|
|
|
* given cursor, if one exists. If so, the inset is returned,
|
|
|
|
* and the co-ordinates are made relative. Otherwise, 0 is returned.
|
2001-12-17 14:25:04 +00:00
|
|
|
*/
|
2002-07-28 18:13:51 +00:00
|
|
|
Inset * checkInset(LyXText const & text, LyXCursor const & cursor,
|
|
|
|
int & x, int & y) const;
|
2001-03-06 19:29:58 +00:00
|
|
|
///
|
|
|
|
friend class BufferView;
|
2001-05-18 07:37:14 +00:00
|
|
|
/// open and lock an updatable inset
|
|
|
|
bool open_new_inset(UpdatableInset * new_inset, bool behind = false);
|
2002-03-21 17:27:08 +00:00
|
|
|
///
|
2001-05-29 09:50:02 +00:00
|
|
|
void hfill();
|
|
|
|
///
|
2001-07-23 09:11:14 +00:00
|
|
|
void smartQuote();
|
|
|
|
///
|
2001-06-04 23:57:32 +00:00
|
|
|
void gotoInset(std::vector<Inset::Code> const & codes,
|
|
|
|
bool same_content);
|
|
|
|
///
|
|
|
|
void gotoInset(Inset::Code codes, bool same_content);
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
BufferView * bv_;
|
|
|
|
///
|
|
|
|
LyXView * owner_;
|
|
|
|
///
|
|
|
|
Buffer * buffer_;
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
boost::scoped_ptr<LyXScreen> screen_;
|
2000-04-08 17:02:02 +00:00
|
|
|
///
|
2002-06-11 22:38:49 +00:00
|
|
|
boost::scoped_ptr<WorkArea> workarea_;
|
|
|
|
///
|
2000-06-08 23:16:16 +00:00
|
|
|
Timeout cursor_timeout;
|
2000-04-08 17:02:02 +00:00
|
|
|
///
|
2000-05-20 21:37:05 +00:00
|
|
|
void stuffClipboard(string const &) const;
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-04-14 19:20:33 +00:00
|
|
|
bool using_xterm_cursor;
|
2001-03-06 19:29:58 +00:00
|
|
|
///
|
2001-01-28 18:31:36 +00:00
|
|
|
struct Position {
|
|
|
|
/// Filename
|
2001-11-26 16:42:04 +00:00
|
|
|
string filename;
|
|
|
|
/// Cursor paragraph Id
|
|
|
|
int par_id;
|
|
|
|
/// Cursor position
|
2001-11-27 10:34:16 +00:00
|
|
|
lyx::pos_type par_pos;
|
2001-01-28 18:31:36 +00:00
|
|
|
///
|
|
|
|
Position() : par_id(0), par_pos(0) {}
|
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
Position(string const & f, int id, lyx::pos_type pos)
|
2001-11-26 16:42:04 +00:00
|
|
|
: filename(f), par_id(id), par_pos(pos) {}
|
2001-01-28 18:31:36 +00:00
|
|
|
};
|
2001-03-06 19:29:58 +00:00
|
|
|
///
|
2001-01-28 18:33:17 +00:00
|
|
|
std::vector<Position> saved_positions;
|
2001-03-06 19:29:58 +00:00
|
|
|
///
|
2002-04-17 08:34:59 +00:00
|
|
|
void moveCursorUpdate(bool selecting, bool fitcur = true);
|
2002-03-21 17:27:08 +00:00
|
|
|
/// Get next inset of this class from current cursor position
|
2001-02-23 16:10:03 +00:00
|
|
|
Inset * getInsetByCode(Inset::Code code);
|
2001-03-06 19:29:58 +00:00
|
|
|
///
|
2001-02-23 16:10:03 +00:00
|
|
|
void MenuInsertLyXFile(string const & filen);
|
2000-04-08 17:02:02 +00:00
|
|
|
};
|
2002-06-12 15:01:32 +00:00
|
|
|
#endif // BUFFERVIEW_PIMPL_H
|