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>
40 * A buffer view encapsulates a view onto a particular
41 * buffer, and allows access to operate upon it. A view
42 * is a sliding window of the entire document rendering.
44 * Eventually we will allow several views onto a single
45 * buffer, but not yet.
47 class BufferView : boost::noncopyable {
50 * Create a view with the given owner main window,
51 * of the given dimensions.
53 BufferView(LyXView * owner, int x, int y, int w, int h);
57 /// set the buffer we are viewing
58 void buffer(Buffer * b);
59 /// return the buffer being viewed
60 Buffer * buffer() const;
62 /// return the painter object for drawing onto the view
63 Painter & painter() const;
64 /// return the screen object for handling re-drawing
65 LyXScreen & screen() const;
66 /// return the owning main view
67 LyXView * owner() const;
69 /// return the visible top y
72 /// set the visible top y
75 /// resize event has happened
78 /// reload the contained buffer
80 /// create a new buffer based on template
81 bool newFile(std::string const & fname, std::string const & tname,
83 /// load a buffer into the view
84 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
86 /// fit the user cursor within the visible view
88 /// perform pending painting updates
90 /// reset the scrollbar to reflect current view position
91 void updateScrollbar();
93 void redoCurrentBuffer();
96 bool available() const;
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();
108 /// return the lyxtext we are using
109 LyXText * getLyXText() const;
111 /// update paragraph dialogs
112 void updateParagraphDialog();
114 /// return the current encoding at the cursor
115 Encoding const * getEncoding() const;
117 /// return the parent language of the given inset
118 Language const * getParentLanguage(InsetOld * inset) const;
120 /// replace the currently selected word
121 void replaceWord(std::string const & replacestring);
122 /// simple replacing. Use the font of the first selected character
123 void replaceSelectionWithString(std::string const & str);
125 /// move cursor to the named label
126 void gotoLabel(std::string const & label);
133 /// get the stored error list
134 ErrorList const & getErrorList() const;
135 /// show the error list to the user
136 void showErrorList(std::string const &) const;
137 /// set the cursor based on the given TeX source row
138 void setCursorFromRow(int row);
141 * Insert an inset into the buffer.
142 * Place it in a layout of lout,
144 bool insertInset(InsetBase * inset, std::string const & lout = std::string());
146 /// Inserts a lyx file at cursor position. return false if it fails
147 bool insertLyXFile(std::string const & file);
150 bool fitLockedInsetCursor(int x, int y, int asc, int desc);
152 /// hide the cursor if it is visible
155 /// center the document view around the cursor
157 /// scroll document by the given number of lines of default height
158 void scroll(int lines);
159 /// Scroll the view by a number of pixels
160 void scrollDocView(int);
162 /// return the pixel width of the document view
163 int workWidth() const;
164 /// return the pixel height of the document view
165 int workHeight() const;
167 /// switch between primary and secondary keymaps for RTL entry
171 bool ChangeRefsIfUnique(std::string const & from, std::string const & to);
173 /// get the contents of the window system clipboard
174 std::string const getClipboard() const;
175 /// fill the window system clipboard
176 void stuffClipboard(std::string const &) const;
177 /// tell the window system we have a selection
178 void haveSelection(bool sel);
180 /// execute the given function
181 bool dispatch(FuncRequest const & argument);
183 /// clear the X selection
186 /// access to full cursor
188 /// access to full cursor
189 LCursor const & cursor() const;
191 LyXText * text() const;
193 void putSelectionAt(PosIterator const & cur, int length, bool backwards);
199 friend struct BufferView::Pimpl;
204 #endif // BUFFERVIEW_H