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>
46 inline flags operator|(flags const f, flags const g)
48 return static_cast<flags>(int(f) | int(g));
51 inline flags operator&(flags const f, flags const g)
53 return static_cast<flags>(int(f) & int(g));
60 * A buffer view encapsulates a view onto a particular
61 * buffer, and allows access to operate upon it. A view
62 * is a sliding window of the entire document rendering.
64 * Eventually we will allow several views onto a single
65 * buffer, but not yet.
67 class BufferView : boost::noncopyable {
70 * Create a view with the given owner main window,
71 * of the given dimensions.
73 BufferView(LyXView * owner, int w, int h);
77 /// set the buffer we are viewing
78 void setBuffer(Buffer * b);
79 /// return the buffer being viewed
80 Buffer * buffer() const;
82 /// return the painter object for drawing onto the view
83 Painter & painter() const;
84 /// return the screen object for handling re-drawing
85 LyXScreen & screen() const;
86 /// return the owning main view
87 LyXView * owner() const;
89 /// resize event has happened
92 /// reload the contained buffer
94 /// create a new buffer based on template
95 void newFile(std::string const & fname, std::string const & tname,
97 /// load a buffer into the view
98 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
100 /** perform pending painting updates. \c fitcursor means first
101 * to do a fitcursor, and to force an update if screen
102 * position changes. \c forceupdate means to force an update
106 void update(Update::flags flags = Update::FitCursor | Update::Force);
107 /// move the screen to fit the cursor. Only to be called with
108 /// good y coordinates (after a bv::metrics)
110 /// reset the scrollbar to reflect current view position
111 void updateScrollbar();
114 bool available() const;
116 /// Save the current position as bookmark i
117 void savePosition(unsigned int i);
118 /// Restore the position from bookmark i
119 void restorePosition(unsigned int i);
120 /// does the given bookmark have a saved position ?
121 bool isSavedPosition(unsigned int i);
123 /// return the current change at the cursor
124 Change const getCurrentChange();
126 /// return the lyxtext we are using
127 LyXText * getLyXText();
129 /// return the lyxtext we are using
130 LyXText const * getLyXText() const;
132 /// simple replacing. Use the font of the first selected character
133 void replaceSelectionWithString(std::string const & str);
135 /// move cursor to the named label
136 void gotoLabel(std::string const & label);
138 /// get the stored error list
139 ErrorList const & getErrorList() const;
140 /// show the error list to the user
141 void showErrorList(std::string const &) const;
142 /// set the cursor based on the given TeX source row
143 void setCursorFromRow(int row);
145 /// hide the cursor if it is visible
148 /// center the document view around the cursor
150 /// scroll document by the given number of lines of default height
151 void scroll(int lines);
152 /// Scroll the view by a number of pixels
153 void scrollDocView(int pixels);
155 /// return the pixel width of the document view
156 int workWidth() const;
157 /// return the pixel height of the document view
158 int workHeight() const;
160 /// switch between primary and secondary keymaps for RTL entry
163 /// get the contents of the window system clipboard
164 std::string const getClipboard() const;
165 /// fill the window system clipboard
166 void stuffClipboard(std::string const &) const;
167 /// tell the window system we have a selection
168 void haveSelection(bool sel);
170 /// return true for events that will handle
171 FuncStatus getStatus(FuncRequest const & cmd);
172 /// execute the given function
173 bool dispatch(FuncRequest const & argument);
175 /// clear the X selection
179 int offset_ref() const;
181 lyx::pit_type anchor_ref() const;
183 /// access to full cursor
185 /// access to full cursor
186 LCursor const & cursor() const;
188 LyXText * text() const;
190 void setCursor(DocIterator const &);
191 /* Sets the selection. When \c backwards == false, set anchor
192 * to \c cur and cursor to \c cur + \c length. When \c
193 * backwards == true, set anchor to \c cur and cursor to \c
196 void putSelectionAt(DocIterator const & cur,
197 int length, bool backwards);
204 friend class BufferView::Pimpl;
209 #endif // BUFFERVIEW_H