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 <boost/utility.hpp>
39 * A buffer view encapsulates a view onto a particular
40 * buffer, and allows access to operate upon it. A view
41 * is a sliding window of the entire document rendering.
43 * Eventually we will allow several views onto a single
44 * buffer, but not yet.
46 class BufferView : boost::noncopyable {
49 * Create a view with the given owner main window,
50 * of the given dimensions.
52 BufferView(LyXView * owner, int x, int y, int w, int h);
56 /// set the buffer we are viewing
57 void buffer(Buffer * b);
58 /// return the buffer being viewed
59 Buffer * buffer() const;
61 /// return the painter object for drawing onto the view
62 Painter & painter() const;
63 /// return the screen object for handling re-drawing
64 LyXScreen & screen() const;
65 /// return the owning main view
66 LyXView * owner() const;
68 /// return the visible top y
71 /// set the visible top y
74 /// resize event has happened
77 /// reload the contained buffer
79 /// create a new buffer based on template
80 bool newFile(std::string const & fname, std::string const & tname,
82 /// load a buffer into the view
83 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
85 /// fit the user cursor within the visible view
87 /// perform pending painting updates
89 /// reset the scrollbar to reflect current view position
90 void updateScrollbar();
92 void redoCurrentBuffer();
95 bool available() const;
97 /// Save the current position as bookmark i
98 void savePosition(unsigned int i);
99 /// Restore the position from bookmark i
100 void restorePosition(unsigned int i);
101 /// does the given bookmark have a saved position ?
102 bool isSavedPosition(unsigned int i);
104 /// return the current change at the cursor
105 Change const getCurrentChange();
107 /// return the lyxtext we are using
108 LyXText * getLyXText() const;
110 /// update paragraph dialogs
111 void updateParagraphDialog();
113 /// return the current encoding at the cursor
114 Encoding const * getEncoding() const;
116 /// return the parent language of the given inset
117 Language const * getParentLanguage(InsetOld * inset) const;
119 /// replace the currently selected word
120 void replaceWord(std::string const & replacestring);
122 /// move cursor to the named label
123 void gotoLabel(std::string const & label);
130 /// get the stored error list
131 ErrorList const & getErrorList() const;
132 /// show the error list to the user
133 void showErrorList(std::string const &) const;
134 /// set the cursor based on the given TeX source row
135 void setCursorFromRow(int row);
138 * Insert an inset into the buffer.
139 * Place it in a layout of lout,
141 bool insertInset(InsetOld * inset, std::string const & lout = std::string());
143 /// Inserts a lyx file at cursor position. return false if it fails
144 bool insertLyXFile(std::string const & file);
147 bool fitLockedInsetCursor(int x, int y, int asc, int desc);
149 /// hide the cursor if it is visible
152 /// center the document view around the cursor
154 /// scroll document by the given number of lines of default height
155 void scroll(int lines);
156 /// Scroll the view by a number of pixels
157 void scrollDocView(int);
159 /// return the pixel width of the document view
160 int workWidth() const;
161 /// return the pixel height of the document view
162 int workHeight() const;
164 /// switch between primary and secondary keymaps for RTL entry
168 bool ChangeRefsIfUnique(std::string const & from, std::string const & to);
170 /// get the contents of the window system clipboard
171 std::string const getClipboard() const;
172 /// fill the window system clipboard
173 void stuffClipboard(std::string const &) const;
174 /// tell the window system we have a selection
175 void haveSelection(bool sel);
177 /// execute the given function
178 bool dispatch(FuncRequest const & argument);
180 /// set target x position of cursor
181 void x_target(int x);
182 /// return target x position of cursor
183 int x_target() const;
188 LCursor const & cursor() const;
190 UpdatableInset * innerInset() const;
192 LyXText * text() const;
198 friend struct BufferView::Pimpl;
203 * The target x position of the cursor. This is used for when
204 * we have text like :
206 * blah blah blah blah| blah blah blah
208 * blah blah blah blah blah blah
210 * When we move onto row 3, we would like to be vertically aligned
211 * with where we were in row 1, despite the fact that row 2 is
218 #endif // BUFFERVIEW_H