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>
43 * A buffer view encapsulates a view onto a particular
44 * buffer, and allows access to operate upon it. A view
45 * is a sliding window of the entire document rendering.
47 * Eventually we will allow several views onto a single
48 * buffer, but not yet.
50 class BufferView : boost::noncopyable {
53 * Create a view with the given owner main window,
54 * of the given dimensions.
56 BufferView(LyXView * owner, int x, int y, int w, int h);
60 /// set the buffer we are viewing
61 void buffer(Buffer * b);
62 /// return the buffer being viewed
63 Buffer * buffer() const;
65 /// return the painter object for drawing onto the view
66 Painter & painter() const;
67 /// return the screen object for handling re-drawing
68 LyXScreen & screen() const;
69 /// return the owning main view
70 LyXView * owner() const;
72 /// return the visible top y
75 /// set the visible top y
78 /// resize event has happened
81 /// reload the contained buffer
83 /// create a new buffer based on template
84 bool newFile(std::string const & fname, std::string const & tname,
86 /// load a buffer into the view
87 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
89 /// fit the user cursor within the visible view
91 /// perform pending painting updates
93 /// reset the scrollbar to reflect current view position
94 void updateScrollbar();
96 void redoCurrentBuffer();
99 bool available() const;
101 /// Save the current position as bookmark i
102 void savePosition(unsigned int i);
103 /// Restore the position from bookmark i
104 void restorePosition(unsigned int i);
105 /// does the given bookmark have a saved position ?
106 bool isSavedPosition(unsigned int i);
108 /// return the current change at the cursor
109 Change const getCurrentChange();
111 /// return the lyxtext we are using
112 LyXText * getLyXText() const;
114 /// update paragraph dialogs
115 void updateParagraphDialog();
117 /// return the current encoding at the cursor
118 Encoding const * getEncoding() const;
120 /// return the parent language of the given inset
121 Language const * getParentLanguage(InsetOld * inset) const;
123 /// replace the currently selected word
124 void replaceWord(std::string const & replacestring);
125 /// simple replacing. Use the font of the first selected character
126 void replaceSelectionWithString(std::string const & str);
128 /// move cursor to the named label
129 void gotoLabel(std::string const & label);
136 /// get the stored error list
137 ErrorList const & getErrorList() const;
138 /// show the error list to the user
139 void showErrorList(std::string const &) const;
140 /// set the cursor based on the given TeX source row
141 void setCursorFromRow(int row);
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 /// clear the X selection
183 /// access to full cursor
185 /// access to full cursor
186 LCursor const & cursor() const;
188 LyXText * text() const;
190 void setCursor(ParIterator const & par, lyx::pos_type pos);
192 void putSelectionAt(PosIterator const & cur, int length, bool backwards);
198 friend struct BufferView::Pimpl;
203 #endif // BUFFERVIEW_H