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 "frontends/LyXKeySym.h"
20 #include "support/types.h"
22 #include <boost/utility.hpp>
52 inline flags operator|(flags const f, flags const g)
54 return static_cast<flags>(int(f) | int(g));
57 inline flags operator&(flags const f, flags const g)
59 return static_cast<flags>(int(f) & int(g));
64 /// Scrollbar Parameters
65 struct ScrollbarParameters
67 void reset(int h = 0, int p = 0, int l = 0)
74 /// The total document height in pixels
76 /// The current position in the document, in pixels
78 /// the line-scroll amount, in pixels
83 * A buffer view encapsulates a view onto a particular
84 * buffer, and allows access to operate upon it. A view
85 * is a sliding window of the entire document rendering.
87 * Eventually we will allow several views onto a single
88 * buffer, but not yet.
90 class BufferView : boost::noncopyable {
93 * Create a view with the given owner main window,
94 * of the given dimensions.
96 BufferView(LyXView * owner);
100 /// set the buffer we are viewing
101 void setBuffer(Buffer * b);
102 /// return the buffer being viewed
103 Buffer * buffer() const;
105 /// return the painter object for drawing onto the view
106 lyx::frontend::Painter & painter() const;
108 /// return the owning main view
109 LyXView * owner() const;
111 /// resize event has happened
114 /// reload the contained buffer
116 /// create a new buffer based on template
117 void newFile(std::string const & fname, std::string const & tname,
119 /// load a buffer into the view
120 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
122 /** perform pending painting updates. \c fitcursor means first
123 * to do a fitcursor, and to force an update if screen
124 * position changes. \c forceupdate means to force an update
128 void update(Update::flags flags = Update::FitCursor | Update::Force);
129 /// move the screen to fit the cursor. Only to be called with
130 /// good y coordinates (after a bv::metrics)
132 /// reset the scrollbar to reflect current view position
133 void updateScrollbar();
134 /// return the Scrollbar Parameters
135 ScrollbarParameters const & scrollbarParameters() const;
138 bool available() const;
140 /// Save the current position as bookmark i
141 void savePosition(unsigned int i);
142 /// Restore the position from bookmark i
143 void restorePosition(unsigned int i);
144 /// does the given bookmark have a saved position ?
145 bool isSavedPosition(unsigned int i);
146 /// save bookmarks to .lyx/session
147 void saveSavedPositions();
149 /// return the current change at the cursor
150 Change const getCurrentChange();
152 /// return the lyxtext we are using
153 LyXText * getLyXText();
155 /// return the lyxtext we are using
156 LyXText const * getLyXText() const;
158 /// simple replacing. Use the font of the first selected character
159 void replaceSelectionWithString(std::string const & str);
161 /// move cursor to the named label
162 void gotoLabel(std::string const & label);
164 /// get the stored error list
165 ErrorList const & getErrorList() const;
166 /// show the error list to the user
167 void showErrorList(std::string const &) const;
168 /// set the cursor based on the given TeX source row
169 void setCursorFromRow(int row);
171 /// hide the cursor if it is visible
174 /// center the document view around the cursor
176 /// scroll document by the given number of lines of default height
177 void scroll(int lines);
178 /// Scroll the view by a number of pixels
179 void scrollDocView(int pixels);
181 /// return the pixel width of the document view
182 int workWidth() const;
183 /// return the pixel height of the document view
184 int workHeight() const;
186 /// switch between primary and secondary keymaps for RTL entry
189 /// return true for events that will handle
190 FuncStatus getStatus(FuncRequest const & cmd);
191 /// execute the given function
192 bool dispatch(FuncRequest const & argument);
195 void selectionRequested();
197 void selectionLost();
200 void workAreaResize(int width, int height);
202 /// Receive a keypress
203 void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
205 /// a function should be executed from the workarea
206 bool workAreaDispatch(FuncRequest const & ev);
208 /// clear the X selection
212 int offset_ref() const;
214 lyx::pit_type anchor_ref() const;
216 /// access to full cursor
218 /// access to full cursor
219 LCursor const & cursor() const;
221 LyXText * text() const;
222 /// sets cursor and open all relevant collapsable insets.
223 void setCursor(DocIterator const &);
224 /// sets cursor; this is used when handling LFUN_MOUSE_PRESS.
225 void mouseSetCursor(LCursor & cur);
227 /* Sets the selection. When \c backwards == false, set anchor
228 * to \c cur and cursor to \c cur + \c length. When \c
229 * backwards == true, set anchor to \c cur and cursor to \c
232 void putSelectionAt(DocIterator const & cur,
233 int length, bool backwards);
239 friend class BufferView::Pimpl;
244 #endif // BUFFERVIEW_H