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 /// resize event has happened
70 /// reload the contained buffer
72 /// create a new buffer based on template
73 bool newFile(string const & fname, string const & tname,
75 /// load a buffer into the view
76 bool loadLyXFile(string const & name, bool tolastfiles = true);
78 /// fit the user cursor within the visible view
80 /// perform pending painting updates
82 /** update for a particular inset. Gets a pointer and not a
83 * reference because we really need the pointer information
84 * to find it in the buffer.
86 void updateInset(InsetOld const *);
87 /// reset the scrollbar to reflect current view position
88 void updateScrollbar();
90 void redoCurrentBuffer();
93 bool available() const;
96 void beforeChange(LyXText *);
98 /// Save the current position as bookmark i
99 void savePosition(unsigned int i);
100 /// Restore the position from bookmark i
101 void restorePosition(unsigned int i);
102 /// does the given bookmark have a saved position ?
103 bool isSavedPosition(unsigned int i);
105 /// return the current change at the cursor
106 Change const getCurrentChange();
109 * This holds the mapping between buffer paragraphs and screen rows.
110 * This should be private...but not yet. (Lgb)
113 /// return the lyxtext we are using
114 LyXText * getLyXText() const;
116 /// Return the current inset we are "locked" in
117 UpdatableInset * theLockingInset() const;
118 /// lock the given inset FIXME: return value ?
119 bool lockInset(UpdatableInset * inset);
120 /// unlock the given inset
121 int unlockInset(UpdatableInset * inset);
122 /// unlock the currently locked inset
125 /// return the current encoding at the cursor
126 Encoding const * getEncoding() const;
128 /// return the parent language of the given inset
129 Language const * getParentLanguage(InsetOld * inset) const;
131 /// Select the "current" word
132 void selectLastWord();
133 /// replace the currently selected word
134 void replaceWord(string const & replacestring);
135 /// Update after spellcheck finishes
136 void endOfSpellCheck();
137 /// return the next word
138 WordLangTuple const nextWord(float & value);
140 /// move cursor to the named label
141 void gotoLabel(string const & label);
148 /// get the stored error list
149 ErrorList const & getErrorList() const;
150 /// show the error list to the user
151 void showErrorList(string const &) const;
152 /// set the cursor based on the given TeX source row
153 void setCursorFromRow(int row);
156 * Insert an inset into the buffer.
157 * Place it in a layout of lout,
159 bool insertInset(InsetOld * inset, string const & lout = string());
161 /// Inserts a lyx file at cursor position. return false if it fails
162 bool insertLyXFile(string const & file);
165 bool fitLockedInsetCursor(int x, int y, int asc, int desc);
167 /// hide the cursor if it is visible
170 /// center the document view around the cursor
172 /// scroll document by the given number of lines of default height
173 void scroll(int lines);
174 /// Scroll the view by a number of pixels
175 void scrollDocView(int);
177 /// return the pixel width of the document view
178 int workWidth() const;
179 /// return the pixel height of the document view
180 int workHeight() const;
182 /// switch between primary and secondary keymaps for RTL entry
186 bool ChangeRefsIfUnique(string const & from, string const & to);
188 /// get the contents of the window system clipboard
189 string const getClipboard() const;
190 /// fill the window system clipboard
191 void stuffClipboard(string const &) const;
192 /// tell the window system we have a selection
193 void haveSelection(bool sel);
195 /// execute the given function
196 bool dispatch(FuncRequest const & argument);
199 /// Set the current locking inset
200 void theLockingInset(UpdatableInset * inset);
202 /// return the lyxtext containing this inset
203 LyXText * getParentText(InsetOld * inset) const;
206 * Change all insets with the given code's contents to a new
207 * string. May only be used with InsetCommand-derived insets
208 * Returns true if a screen update is needed.
210 bool ChangeInsets(InsetOld::Code code, string const & from,
215 friend struct BufferView::Pimpl;
220 #endif // BUFFERVIEW_H