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>
53 inline flags operator|(flags const f, flags const g)
55 return static_cast<flags>(int(f) | int(g));
58 inline flags operator&(flags const f, flags const g)
60 return static_cast<flags>(int(f) & int(g));
65 /// Scrollbar Parameters
66 struct ScrollbarParameters
68 void reset(int h = 0, int p = 0, int l = 0)
75 /// The total document height in pixels
77 /// The current position in the document, in pixels
79 /// the line-scroll amount, in pixels
84 * A buffer view encapsulates a view onto a particular
85 * buffer, and allows access to operate upon it. A view
86 * is a sliding window of the entire document rendering.
88 * Eventually we will allow several views onto a single
89 * buffer, but not yet.
91 class BufferView : boost::noncopyable {
94 * Create a view with the given owner main window,
95 * of the given dimensions.
97 BufferView(LyXView * owner, lyx::frontend::WorkArea * workArea);
101 /// set the buffer we are viewing
102 void setBuffer(Buffer * b);
103 /// return the buffer being viewed
104 Buffer * buffer() const;
106 /// return the painter object for drawing onto the view
107 lyx::frontend::Painter & painter() const;
109 /// return the owning main view
110 LyXView * owner() const;
112 /// resize event has happened
115 /// reload the contained buffer
117 /// create a new buffer based on template
118 void newFile(std::string const & fname, std::string const & tname,
120 /// load a buffer into the view
121 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
123 /** perform pending painting updates. \c fitcursor means first
124 * to do a fitcursor, and to force an update if screen
125 * position changes. \c forceupdate means to force an update
129 void update(Update::flags flags = Update::FitCursor | Update::Force);
130 /// move the screen to fit the cursor. Only to be called with
131 /// good y coordinates (after a bv::metrics)
133 /// reset the scrollbar to reflect current view position
134 void updateScrollbar();
135 /// return the Scrollbar Parameters
136 ScrollbarParameters const & scrollbarParameters() const;
139 bool available() const;
141 /// Save the current position as bookmark i
142 void savePosition(unsigned int i);
143 /// Restore the position from bookmark i
144 void restorePosition(unsigned int i);
145 /// does the given bookmark have a saved position ?
146 bool isSavedPosition(unsigned int i);
147 /// save bookmarks to .lyx/session
148 void saveSavedPositions();
150 /// return the current change at the cursor
151 Change const getCurrentChange();
153 /// return the lyxtext we are using
154 LyXText * getLyXText();
156 /// return the lyxtext we are using
157 LyXText const * getLyXText() const;
159 /// simple replacing. Use the font of the first selected character
160 void replaceSelectionWithString(std::string const & str);
162 /// move cursor to the named label
163 void gotoLabel(std::string const & label);
165 /// get the stored error list
166 ErrorList const & getErrorList() const;
167 /// show the error list to the user
168 void showErrorList(std::string const &) const;
169 /// set the cursor based on the given TeX source row
170 void setCursorFromRow(int row);
172 /// hide the cursor if it is visible
175 /// center the document view around the cursor
177 /// scroll document by the given number of lines of default height
178 void scroll(int lines);
179 /// Scroll the view by a number of pixels
180 void scrollDocView(int pixels);
182 /// return the pixel width of the document view
183 int workWidth() const;
184 /// return the pixel height of the document view
185 int workHeight() const;
187 /// switch between primary and secondary keymaps for RTL entry
190 /// return true for events that will handle
191 FuncStatus getStatus(FuncRequest const & cmd);
192 /// execute the given function
193 bool dispatch(FuncRequest const & argument);
196 void selectionRequested();
198 void selectionLost();
201 void workAreaResize(int width, int height);
203 /// Receive a keypress
204 void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
206 /// a function should be executed from the workarea
207 bool workAreaDispatch(FuncRequest const & ev);
209 /// clear the X selection
213 int offset_ref() const;
215 lyx::pit_type anchor_ref() const;
217 /// access to full cursor
219 /// access to full cursor
220 LCursor const & cursor() const;
222 LyXText * text() const;
223 /// sets cursor and open all relevant collapsable insets.
224 void setCursor(DocIterator const &);
225 /// sets cursor; this is used when handling LFUN_MOUSE_PRESS.
226 void mouseSetCursor(LCursor & cur);
228 /* Sets the selection. When \c backwards == false, set anchor
229 * to \c cur and cursor to \c cur + \c length. When \c
230 * backwards == true, set anchor to \c cur and cursor to \c
233 void putSelectionAt(DocIterator const & cur,
234 int length, bool backwards);
236 bool const repaintAll() const;
238 void const repaintAll(bool r) const;
244 friend class BufferView::Pimpl;
249 #endif // BUFFERVIEW_H