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.
20 #include "insets/inset.h"
22 #include <boost/utility.hpp>
38 * A buffer view encapsulates a view onto a particular
39 * buffer, and allows access to operate upon it. A view
40 * is a sliding window of the entire document rendering.
42 * Eventually we will allow several views onto a single
43 * buffer, but not yet.
45 class BufferView : boost::noncopyable {
48 * Create a view with the given owner main window,
49 * of the given dimensions.
51 BufferView(LyXView * owner, int x, int y, int w, int h);
55 /// set the buffer we are viewing
56 void buffer(Buffer * b);
57 /// return the buffer being viewed
58 Buffer * buffer() const;
60 /// return the painter object for drawing onto the view
61 Painter & painter() const;
62 /// return the screen object for handling re-drawing
63 LyXScreen & screen() const;
64 /// return the owning main view
65 LyXView * owner() const;
67 /// return the visible top y
70 /// set the visible top y
73 /// resize event has happened
76 /// reload the contained buffer
78 /// create a new buffer based on template
79 bool newFile(string const & fname, string const & tname,
81 /// load a buffer into the view
82 bool loadLyXFile(string const & name, bool tolastfiles = true);
84 /// fit the user cursor within the visible view
86 /// perform pending painting updates
88 /** update for a particular inset. Gets a pointer and not a
89 * reference because we really need the pointer information
90 * to find it in the buffer.
92 void updateInset(InsetOld const *);
93 /// reset the scrollbar to reflect current view position
94 void updateScrollbar();
96 void redoCurrentBuffer();
99 bool available() const;
102 void beforeChange(LyXText *);
104 /// Save the current position as bookmark i
105 void savePosition(unsigned int i);
106 /// Restore the position from bookmark i
107 void restorePosition(unsigned int i);
108 /// does the given bookmark have a saved position ?
109 bool isSavedPosition(unsigned int i);
111 /// return the current change at the cursor
112 Change const getCurrentChange();
115 * This holds the mapping between buffer paragraphs and screen rows.
116 * This should be private...but not yet. (Lgb)
119 /// return the lyxtext we are using
120 LyXText * getLyXText() const;
122 /// Return the current inset we are "locked" in
123 UpdatableInset * theLockingInset() const;
124 /// lock the given inset FIXME: return value ?
125 bool lockInset(UpdatableInset * inset);
126 /// unlock the given inset
127 int unlockInset(UpdatableInset * inset);
128 /// unlock the currently locked inset
131 /// return the current encoding at the cursor
132 Encoding const * getEncoding() const;
134 /// return the parent language of the given inset
135 Language const * getParentLanguage(InsetOld * inset) const;
137 /// Select the "current" word
138 void selectLastWord();
139 /// replace the currently selected word
140 void replaceWord(string const & replacestring);
141 /// Update after spellcheck finishes
142 void endOfSpellCheck();
143 /// return the next word
144 WordLangTuple const nextWord(float & value);
146 /// move cursor to the named label
147 void gotoLabel(string const & label);
154 /// get the stored error list
155 ErrorList const & getErrorList() const;
156 /// show the error list to the user
157 void showErrorList(string const &) const;
158 /// set the cursor based on the given TeX source row
159 void setCursorFromRow(int row);
162 * Insert an inset into the buffer.
163 * Place it in a layout of lout,
165 bool insertInset(InsetOld * inset, string const & lout = string());
167 /// Inserts a lyx file at cursor position. return false if it fails
168 bool insertLyXFile(string const & file);
171 bool fitLockedInsetCursor(int x, int y, int asc, int desc);
173 /// hide the cursor if it is visible
176 /// center the document view around the cursor
178 /// scroll document by the given number of lines of default height
179 void scroll(int lines);
180 /// Scroll the view by a number of pixels
181 void scrollDocView(int);
183 /// return the pixel width of the document view
184 int workWidth() const;
185 /// return the pixel height of the document view
186 int workHeight() const;
188 /// switch between primary and secondary keymaps for RTL entry
192 bool ChangeRefsIfUnique(string const & from, string const & to);
194 /// get the contents of the window system clipboard
195 string const getClipboard() const;
196 /// fill the window system clipboard
197 void stuffClipboard(string const &) const;
198 /// tell the window system we have a selection
199 void haveSelection(bool sel);
201 /// execute the given function
202 bool dispatch(FuncRequest const & argument);
205 /// Set the current locking inset
206 void theLockingInset(UpdatableInset * inset);
208 /// return the lyxtext containing this inset
209 LyXText * getParentText(InsetOld * inset) const;
212 * Change all insets with the given code's contents to a new
213 * string. May only be used with InsetCommand-derived insets
214 * Returns true if a screen update is needed.
216 bool ChangeInsets(InsetOld::Code code, string const & from,
221 friend struct BufferView::Pimpl;
226 #endif // BUFFERVIEW_H