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>
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 w, int h);
56 /// set the buffer we are viewing
57 void setBuffer(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 /// resize event has happened
71 /// reload the contained buffer
73 /// create a new buffer based on template
74 void newFile(std::string const & fname, std::string const & tname,
76 /// load a buffer into the view
77 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
79 /** perform pending painting updates. \c fitcursor means first
80 * to do a fitcursor, and to force an update if screen
81 * position changes. \c forceupdate means to force an update
84 void update(bool fitcursor = true, bool forceupdate = true);
85 /// move the screen to fit the cursor. Only to be called with
86 /// good y coordinates (after a bv::metrics)
88 /// reset the scrollbar to reflect current view position
89 void updateScrollbar();
92 bool available() const;
94 /// Save the current position as bookmark i
95 void savePosition(unsigned int i);
96 /// Restore the position from bookmark i
97 void restorePosition(unsigned int i);
98 /// does the given bookmark have a saved position ?
99 bool isSavedPosition(unsigned int i);
101 /// return the current change at the cursor
102 Change const getCurrentChange();
104 /// return the lyxtext we are using
105 LyXText * getLyXText();
107 /// return the lyxtext we are using
108 LyXText const * getLyXText() const;
110 /// simple replacing. Use the font of the first selected character
111 void replaceSelectionWithString(std::string const & str);
113 /// move cursor to the named label
114 void gotoLabel(std::string const & label);
116 /// get the stored error list
117 ErrorList const & getErrorList() const;
118 /// show the error list to the user
119 void showErrorList(std::string const &) const;
120 /// set the cursor based on the given TeX source row
121 void setCursorFromRow(int row);
123 /// hide the cursor if it is visible
126 /// center the document view around the cursor
128 /// scroll document by the given number of lines of default height
129 void scroll(int lines);
130 /// Scroll the view by a number of pixels
131 void scrollDocView(int pixels);
133 /// return the pixel width of the document view
134 int workWidth() const;
135 /// return the pixel height of the document view
136 int workHeight() const;
138 /// switch between primary and secondary keymaps for RTL entry
141 /// get the contents of the window system clipboard
142 std::string const getClipboard() const;
143 /// fill the window system clipboard
144 void stuffClipboard(std::string const &) const;
145 /// tell the window system we have a selection
146 void haveSelection(bool sel);
148 /// return true for events that will handle
149 FuncStatus getStatus(FuncRequest const & cmd);
150 /// execute the given function
151 bool dispatch(FuncRequest const & argument);
153 /// clear the X selection
157 int offset_ref() const;
159 lyx::pit_type anchor_ref() const;
161 /// access to full cursor
163 /// access to full cursor
164 LCursor const & cursor() const;
166 LyXText * text() const;
168 void setCursor(DocIterator const &);
169 /* Sets the selection. When \c backwards == false, set anchor
170 * to \c cur and cursor to \c cur + \c length. When \c
171 * backwards == true, set anchor to \c cur and cursor to \c
174 void putSelectionAt(DocIterator const & cur,
175 int length, bool backwards);
182 friend class BufferView::Pimpl;
187 #endif // BUFFERVIEW_H