1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-08-04 23:11:50 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file BufferView.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
1999-11-04 01:40:20 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Alfredo Braustein
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
#ifndef BUFFER_VIEW_H
|
|
|
|
|
#define BUFFER_VIEW_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-10-13 16:44:44 +00:00
|
|
|
|
#include "coordcache.h"
|
2006-09-16 10:08:51 +00:00
|
|
|
|
#include "cursor.h"
|
2006-07-13 16:37:55 +00:00
|
|
|
|
#include "metricsinfo.h"
|
2006-10-22 11:46:36 +00:00
|
|
|
|
#include "UpdateFlags.h"
|
2004-02-02 11:07:51 +00:00
|
|
|
|
#include "support/types.h"
|
|
|
|
|
|
2000-10-02 00:55:02 +00:00
|
|
|
|
#include <boost/utility.hpp>
|
2006-08-24 14:10:22 +00:00
|
|
|
|
#include <boost/signal.hpp>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2003-09-06 19:16:30 +00:00
|
|
|
|
class Buffer;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
class Change;
|
2004-03-31 19:11:56 +00:00
|
|
|
|
class DocIterator;
|
2003-09-06 19:16:30 +00:00
|
|
|
|
class FuncRequest;
|
2004-04-01 08:58:45 +00:00
|
|
|
|
class FuncStatus;
|
2006-09-17 10:03:00 +00:00
|
|
|
|
class Intl;
|
2003-09-06 19:16:30 +00:00
|
|
|
|
class Language;
|
2003-11-04 12:36:59 +00:00
|
|
|
|
class LCursor;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
class LyXText;
|
2004-02-02 11:07:51 +00:00
|
|
|
|
class ParIterator;
|
2006-07-04 00:04:46 +00:00
|
|
|
|
class ViewMetricsInfo;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
|
/// Scrollbar Parameters
|
|
|
|
|
struct ScrollbarParameters
|
|
|
|
|
{
|
|
|
|
|
void reset(int h = 0, int p = 0, int l = 0)
|
|
|
|
|
{
|
|
|
|
|
height = h;
|
|
|
|
|
position = p;
|
|
|
|
|
lineScrollHeight = l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The total document height in pixels
|
|
|
|
|
int height;
|
|
|
|
|
/// The current position in the document, in pixels
|
|
|
|
|
int position;
|
|
|
|
|
/// the line-scroll amount, in pixels
|
|
|
|
|
int lineScrollHeight;
|
|
|
|
|
};
|
2005-05-31 14:40:30 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* A buffer view encapsulates a view onto a particular
|
|
|
|
|
* buffer, and allows access to operate upon it. A view
|
|
|
|
|
* is a sliding window of the entire document rendering.
|
|
|
|
|
*
|
|
|
|
|
* Eventually we will allow several views onto a single
|
|
|
|
|
* buffer, but not yet.
|
|
|
|
|
*/
|
2001-04-17 13:43:57 +00:00
|
|
|
|
class BufferView : boost::noncopyable {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2006-09-26 10:06:46 +00:00
|
|
|
|
BufferView();
|
2002-10-21 16:21:56 +00:00
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
|
~BufferView();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// set the buffer we are viewing
|
2004-03-18 12:53:43 +00:00
|
|
|
|
void setBuffer(Buffer * b);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the buffer being viewed
|
2000-04-08 17:02:02 +00:00
|
|
|
|
Buffer * buffer() const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// resize event has happened
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void resize();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2003-03-08 05:37:54 +00:00
|
|
|
|
/// reload the contained buffer
|
|
|
|
|
void reload();
|
2003-06-20 12:46:28 +00:00
|
|
|
|
/// load a buffer into the view
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool loadLyXFile(std::string const & name, bool tolastfiles = true);
|
2003-03-08 05:37:54 +00:00
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
/** perform pending painting updates. \c fitcursor means first
|
|
|
|
|
* to do a fitcursor, and to force an update if screen
|
|
|
|
|
* position changes. \c forceupdate means to force an update
|
2005-01-12 10:30:46 +00:00
|
|
|
|
* in any case.
|
2006-07-14 09:56:21 +00:00
|
|
|
|
* \return true if a full updateMetrics() is needed.
|
2004-11-30 01:59:49 +00:00
|
|
|
|
*/
|
2006-07-14 09:56:21 +00:00
|
|
|
|
bool update(Update::flags flags = Update::FitCursor | Update::Force);
|
2005-05-31 14:40:30 +00:00
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
/// move the screen to fit the cursor. Only to be called with
|
|
|
|
|
/// good y coordinates (after a bv::metrics)
|
2002-03-29 15:49:45 +00:00
|
|
|
|
bool fitCursor();
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// reset the scrollbar to reflect current view position
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void updateScrollbar();
|
2006-06-26 16:55:35 +00:00
|
|
|
|
/// return the Scrollbar Parameters
|
|
|
|
|
ScrollbarParameters const & scrollbarParameters() const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2006-11-01 15:55:17 +00:00
|
|
|
|
/// Save the current position as bookmark, if persistent=false, save to temp_bookmark
|
|
|
|
|
void saveBookmark(bool persistent);
|
|
|
|
|
/// goto a specified position
|
|
|
|
|
void moveToPosition(int par_id, pos_type par_pos);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// return the current change at the cursor
|
2006-10-11 20:01:32 +00:00
|
|
|
|
Change const getCurrentChange() const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the lyxtext we are using
|
2005-01-31 16:29:48 +00:00
|
|
|
|
LyXText * getLyXText();
|
|
|
|
|
|
|
|
|
|
/// return the lyxtext we are using
|
|
|
|
|
LyXText const * getLyXText() const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// move cursor to the named label
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void gotoLabel(docstring const & label);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// set the cursor based on the given TeX source row
|
2000-01-08 21:02:58 +00:00
|
|
|
|
void setCursorFromRow(int row);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// center the document view around the cursor
|
2000-02-17 19:59:08 +00:00
|
|
|
|
void center();
|
2002-10-21 00:15:48 +00:00
|
|
|
|
/// scroll document by the given number of lines of default height
|
|
|
|
|
void scroll(int lines);
|
2002-06-12 15:01:32 +00:00
|
|
|
|
/// Scroll the view by a number of pixels
|
2004-08-14 19:55:00 +00:00
|
|
|
|
void scrollDocView(int pixels);
|
2006-08-16 15:24:38 +00:00
|
|
|
|
/// Set the cursor position based on the scrollbar one.
|
|
|
|
|
void setCursorFromScrollbar();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the pixel width of the document view
|
|
|
|
|
int workWidth() const;
|
|
|
|
|
/// return the pixel height of the document view
|
|
|
|
|
int workHeight() const;
|
|
|
|
|
|
|
|
|
|
/// switch between primary and secondary keymaps for RTL entry
|
2002-07-17 04:13:41 +00:00
|
|
|
|
void switchKeyMap();
|
2000-02-03 19:51:27 +00:00
|
|
|
|
|
2004-04-01 08:58:45 +00:00
|
|
|
|
/// return true for events that will handle
|
|
|
|
|
FuncStatus getStatus(FuncRequest const & cmd);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// execute the given function
|
|
|
|
|
bool dispatch(FuncRequest const & argument);
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
* frontends/WorkArea.h(workAreaResize, scrollDocView, workAreaKeyPress,
dispatch, selectionReuqested, selectionLost): remove signals
* BufferView.[Ch] (selectionRequested, selectionLost, workAreaResize,
workAreaKeyPress, workAreaDispatch): add forwarding functions to the pimpl
* BufferView_pimpl.C (Pimpl): Remove the setup of the now deleted signals,
also remove corresponding connection objects.
* frontends/xforms/XWorkArea.h:
* frontends/qt2/QWorkArea.h:
* frontends/qt4/QWorkArea.h:
* frontends/gtk/GWorkArea.h: add LyXView as class variable view_ (qt
classes also get view() medthod)
* frontends/qt2/QWorkArea.C:
* frontends/qt2/QContentPane.C:
* frontends/qt4/QWorkArea.C:
* frontends/xforms/XWorkArea.C:
* frontends/gtk/GWorkArea.C: Change from calling signals to call
the functions directly through view_.view()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13671 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-13 18:58:48 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
docstring const requestSelection();
|
* frontends/WorkArea.h(workAreaResize, scrollDocView, workAreaKeyPress,
dispatch, selectionReuqested, selectionLost): remove signals
* BufferView.[Ch] (selectionRequested, selectionLost, workAreaResize,
workAreaKeyPress, workAreaDispatch): add forwarding functions to the pimpl
* BufferView_pimpl.C (Pimpl): Remove the setup of the now deleted signals,
also remove corresponding connection objects.
* frontends/xforms/XWorkArea.h:
* frontends/qt2/QWorkArea.h:
* frontends/qt4/QWorkArea.h:
* frontends/gtk/GWorkArea.h: add LyXView as class variable view_ (qt
classes also get view() medthod)
* frontends/qt2/QWorkArea.C:
* frontends/qt2/QContentPane.C:
* frontends/qt4/QWorkArea.C:
* frontends/xforms/XWorkArea.C:
* frontends/gtk/GWorkArea.C: Change from calling signals to call
the functions directly through view_.view()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13671 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-13 18:58:48 +00:00
|
|
|
|
///
|
2006-09-17 08:35:12 +00:00
|
|
|
|
void clearSelection();
|
* frontends/WorkArea.h(workAreaResize, scrollDocView, workAreaKeyPress,
dispatch, selectionReuqested, selectionLost): remove signals
* BufferView.[Ch] (selectionRequested, selectionLost, workAreaResize,
workAreaKeyPress, workAreaDispatch): add forwarding functions to the pimpl
* BufferView_pimpl.C (Pimpl): Remove the setup of the now deleted signals,
also remove corresponding connection objects.
* frontends/xforms/XWorkArea.h:
* frontends/qt2/QWorkArea.h:
* frontends/qt4/QWorkArea.h:
* frontends/gtk/GWorkArea.h: add LyXView as class variable view_ (qt
classes also get view() medthod)
* frontends/qt2/QWorkArea.C:
* frontends/qt2/QContentPane.C:
* frontends/qt4/QWorkArea.C:
* frontends/xforms/XWorkArea.C:
* frontends/gtk/GWorkArea.C: Change from calling signals to call
the functions directly through view_.view()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13671 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-13 18:58:48 +00:00
|
|
|
|
|
|
|
|
|
///
|
2006-06-26 16:55:35 +00:00
|
|
|
|
void workAreaResize(int width, int height);
|
* frontends/WorkArea.h(workAreaResize, scrollDocView, workAreaKeyPress,
dispatch, selectionReuqested, selectionLost): remove signals
* BufferView.[Ch] (selectionRequested, selectionLost, workAreaResize,
workAreaKeyPress, workAreaDispatch): add forwarding functions to the pimpl
* BufferView_pimpl.C (Pimpl): Remove the setup of the now deleted signals,
also remove corresponding connection objects.
* frontends/xforms/XWorkArea.h:
* frontends/qt2/QWorkArea.h:
* frontends/qt4/QWorkArea.h:
* frontends/gtk/GWorkArea.h: add LyXView as class variable view_ (qt
classes also get view() medthod)
* frontends/qt2/QWorkArea.C:
* frontends/qt2/QContentPane.C:
* frontends/qt4/QWorkArea.C:
* frontends/xforms/XWorkArea.C:
* frontends/gtk/GWorkArea.C: Change from calling signals to call
the functions directly through view_.view()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13671 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-13 18:58:48 +00:00
|
|
|
|
|
|
|
|
|
/// a function should be executed from the workarea
|
|
|
|
|
bool workAreaDispatch(FuncRequest const & ev);
|
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
/// access to anchor
|
2006-10-21 00:16:43 +00:00
|
|
|
|
pit_type anchor_ref() const;
|
2005-04-26 11:12:20 +00:00
|
|
|
|
|
2004-01-13 18:08:13 +00:00
|
|
|
|
/// access to full cursor
|
2004-01-20 14:25:24 +00:00
|
|
|
|
LCursor & cursor();
|
2004-01-13 18:08:13 +00:00
|
|
|
|
/// access to full cursor
|
2004-01-20 14:25:24 +00:00
|
|
|
|
LCursor const & cursor() const;
|
2005-12-01 10:28:50 +00:00
|
|
|
|
/// sets cursor and open all relevant collapsable insets.
|
2005-02-22 11:41:22 +00:00
|
|
|
|
void setCursor(DocIterator const &);
|
2005-12-01 10:28:50 +00:00
|
|
|
|
/// sets cursor; this is used when handling LFUN_MOUSE_PRESS.
|
|
|
|
|
void mouseSetCursor(LCursor & cur);
|
|
|
|
|
|
2004-09-17 16:28:47 +00:00
|
|
|
|
/* Sets the selection. When \c backwards == false, set anchor
|
|
|
|
|
* to \c cur and cursor to \c cur + \c length. When \c
|
|
|
|
|
* backwards == true, set anchor to \c cur and cursor to \c
|
|
|
|
|
* cur + \c length.
|
|
|
|
|
*/
|
2004-03-31 19:11:56 +00:00
|
|
|
|
void putSelectionAt(DocIterator const & cur,
|
2004-03-25 09:16:36 +00:00
|
|
|
|
int length, bool backwards);
|
2006-07-04 00:04:46 +00:00
|
|
|
|
///
|
|
|
|
|
ViewMetricsInfo const & viewMetricsInfo();
|
2006-07-08 20:24:32 +00:00
|
|
|
|
///
|
2006-07-14 09:56:21 +00:00
|
|
|
|
void updateMetrics(bool singlepar = false);
|
|
|
|
|
|
2006-10-13 16:44:44 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
CoordCache & coordCache() {
|
2006-10-13 16:44:44 +00:00
|
|
|
|
return coord_cache_;
|
|
|
|
|
}
|
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
CoordCache const & coordCache() const {
|
2006-10-13 16:44:44 +00:00
|
|
|
|
return coord_cache_;
|
|
|
|
|
}
|
2006-09-17 10:03:00 +00:00
|
|
|
|
/// get this view's keyboard map handler
|
|
|
|
|
Intl & getIntl() { return *intl_.get(); }
|
|
|
|
|
///
|
|
|
|
|
Intl const & getIntl() const { return *intl_.get(); }
|
|
|
|
|
|
2006-08-24 14:10:22 +00:00
|
|
|
|
/// This signal is emitted when some message shows up.
|
2006-10-21 00:16:43 +00:00
|
|
|
|
boost::signal<void(docstring)> message;
|
2006-08-24 14:10:22 +00:00
|
|
|
|
|
2006-09-19 13:36:20 +00:00
|
|
|
|
/// This signal is emitted when some dialog needs to be shown.
|
|
|
|
|
boost::signal<void(std::string name)> showDialog;
|
|
|
|
|
|
|
|
|
|
/// This signal is emitted when some dialog needs to be shown with
|
|
|
|
|
/// some data
|
|
|
|
|
boost::signal<void(std::string name,
|
|
|
|
|
std::string data)> showDialogWithData;
|
|
|
|
|
|
|
|
|
|
/// This signal is emitted when some inset dialogs needs to be shown.
|
|
|
|
|
boost::signal<void(std::string name, std::string data,
|
|
|
|
|
InsetBase * inset)> showInsetDialog;
|
|
|
|
|
|
|
|
|
|
/// This signal is emitted when some dialogs needs to be updated.
|
|
|
|
|
boost::signal<void(std::string name,
|
|
|
|
|
std::string data)> updateDialog;
|
|
|
|
|
|
2006-09-26 10:06:46 +00:00
|
|
|
|
/// This signal is emitted when the layout at the cursor is changed.
|
|
|
|
|
boost::signal<void(std::string layout)> layoutChanged;
|
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
private:
|
2003-11-28 08:55:12 +00:00
|
|
|
|
///
|
2006-09-16 10:08:51 +00:00
|
|
|
|
bool multiParSel();
|
2003-11-28 08:55:12 +00:00
|
|
|
|
///
|
2006-09-16 10:08:51 +00:00
|
|
|
|
int width_;
|
2003-11-28 08:55:12 +00:00
|
|
|
|
///
|
2006-09-16 10:08:51 +00:00
|
|
|
|
int height_;
|
|
|
|
|
///
|
|
|
|
|
ScrollbarParameters scrollbarParameters_;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
ViewMetricsInfo metrics_info_;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
CoordCache coord_cache_;
|
2006-09-16 10:08:51 +00:00
|
|
|
|
///
|
|
|
|
|
Buffer * buffer_;
|
|
|
|
|
|
|
|
|
|
/// Estimated average par height for scrollbar
|
|
|
|
|
int wh_;
|
|
|
|
|
///
|
|
|
|
|
///
|
|
|
|
|
void menuInsertLyXFile(std::string const & filen);
|
|
|
|
|
|
|
|
|
|
/// this is used to handle XSelection events in the right manner
|
|
|
|
|
struct {
|
|
|
|
|
CursorSlice cursor;
|
|
|
|
|
CursorSlice anchor;
|
|
|
|
|
bool set;
|
|
|
|
|
} xsel_cache_;
|
|
|
|
|
///
|
|
|
|
|
LCursor cursor_;
|
|
|
|
|
///
|
|
|
|
|
bool multiparsel_cache_;
|
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
pit_type anchor_ref_;
|
2006-09-16 10:08:51 +00:00
|
|
|
|
///
|
|
|
|
|
int offset_ref_;
|
2006-09-17 10:03:00 +00:00
|
|
|
|
|
|
|
|
|
/// keyboard mapping object
|
|
|
|
|
boost::scoped_ptr<Intl> const intl_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
#endif // BUFFERVIEW_H
|