4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Alfredo Braustein
8 * \author Lars Gullik Bjønnes
10 * \author Jürgen Vigna
12 * Full author contact details are available in file CREDITS.
18 #include "support/types.h"
20 #include <boost/utility.hpp>
44 * A buffer view encapsulates a view onto a particular
45 * buffer, and allows access to operate upon it. A view
46 * is a sliding window of the entire document rendering.
48 * Eventually we will allow several views onto a single
49 * buffer, but not yet.
51 class BufferView : boost::noncopyable {
54 * Create a view with the given owner main window,
55 * of the given dimensions.
57 BufferView(LyXView * owner, int x, int y, int w, int h);
61 /// set the buffer we are viewing
62 void setBuffer(Buffer * b);
63 /// return the buffer being viewed
64 Buffer * buffer() const;
66 /// return the painter object for drawing onto the view
67 Painter & painter() const;
68 /// return the screen object for handling re-drawing
69 LyXScreen & screen() const;
70 /// return the owning main view
71 LyXView * owner() const;
73 /// return the visible top y
76 /// set the visible top y
79 /// resize event has happened
82 /// reload the contained buffer
84 /// create a new buffer based on template
85 void newFile(std::string const & fname, std::string const & tname,
87 /// load a buffer into the view
88 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
90 /// fit the user cursor within the visible view
92 /// perform pending painting updates
94 /// reset the scrollbar to reflect current view position
95 void updateScrollbar();
97 void redoCurrentBuffer();
100 bool available() const;
102 /// Save the current position as bookmark i
103 void savePosition(unsigned int i);
104 /// Restore the position from bookmark i
105 void restorePosition(unsigned int i);
106 /// does the given bookmark have a saved position ?
107 bool isSavedPosition(unsigned int i);
109 /// return the current change at the cursor
110 Change const getCurrentChange();
112 /// return the lyxtext we are using
113 LyXText * getLyXText() const;
115 /// return the parent language of the given inset
116 Language const * getParentLanguage(InsetOld * inset) const;
118 /// simple replacing. Use the font of the first selected character
119 void replaceSelectionWithString(std::string const & str);
121 /// move cursor to the named label
122 void gotoLabel(std::string const & label);
124 /// get the stored error list
125 ErrorList const & getErrorList() const;
126 /// show the error list to the user
127 void showErrorList(std::string const &) const;
128 /// set the cursor based on the given TeX source row
129 void setCursorFromRow(int row);
131 /// Inserts a lyx file at cursor position. return false if it fails
132 bool insertLyXFile(std::string const & file);
135 bool fitLockedInsetCursor(int x, int y, int asc, int desc);
137 /// hide the cursor if it is visible
140 /// center the document view around the cursor
142 /// scroll document by the given number of lines of default height
143 void scroll(int lines);
144 /// Scroll the view by a number of pixels
145 void scrollDocView(int);
147 /// return the pixel width of the document view
148 int workWidth() const;
149 /// return the pixel height of the document view
150 int workHeight() const;
152 /// switch between primary and secondary keymaps for RTL entry
155 /// get the contents of the window system clipboard
156 std::string const getClipboard() const;
157 /// fill the window system clipboard
158 void stuffClipboard(std::string const &) const;
159 /// tell the window system we have a selection
160 void haveSelection(bool sel);
162 /// return true for events that will handle
163 FuncStatus getStatus(FuncRequest const & cmd);
164 /// execute the given function
165 bool dispatch(FuncRequest const & argument);
167 /// clear the X selection
170 /// access to full cursor
172 /// access to full cursor
173 LCursor const & cursor() const;
175 LyXText * text() const;
177 void setCursor(ParIterator const & par, lyx::pos_type pos);
179 void putSelectionAt(DocIterator const & cur,
180 int length, bool backwards);
186 friend struct BufferView::Pimpl;
191 #endif // BUFFERVIEW_H