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>
37 class ViewMetricsInfo;
47 inline flags operator|(flags const f, flags const g)
49 return static_cast<flags>(int(f) | int(g));
52 inline flags operator&(flags const f, flags const g)
54 return static_cast<flags>(int(f) & int(g));
59 /// Scrollbar Parameters
60 struct ScrollbarParameters
62 void reset(int h = 0, int p = 0, int l = 0)
69 /// The total document height in pixels
71 /// The current position in the document, in pixels
73 /// the line-scroll amount, in pixels
78 * A buffer view encapsulates a view onto a particular
79 * buffer, and allows access to operate upon it. A view
80 * is a sliding window of the entire document rendering.
82 * Eventually we will allow several views onto a single
83 * buffer, but not yet.
85 class BufferView : boost::noncopyable {
88 * Create a view with the given owner main window,
89 * of the given dimensions.
91 BufferView(LyXView * owner);
95 /// set the buffer we are viewing
96 void setBuffer(Buffer * b);
97 /// return the buffer being viewed
98 Buffer * buffer() const;
100 /// return the owning main view
101 LyXView * owner() const;
103 /// resize event has happened
106 /// reload the contained buffer
108 /// create a new buffer based on template
109 void newFile(std::string const & fname, std::string const & tname,
111 /// load a buffer into the view
112 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
114 /** perform pending painting updates. \c fitcursor means first
115 * to do a fitcursor, and to force an update if screen
116 * position changes. \c forceupdate means to force an update
120 void update(Update::flags flags = Update::FitCursor | Update::Force);
121 /// move the screen to fit the cursor. Only to be called with
122 /// good y coordinates (after a bv::metrics)
124 /// reset the scrollbar to reflect current view position
125 void updateScrollbar();
126 /// return the Scrollbar Parameters
127 ScrollbarParameters const & scrollbarParameters() const;
130 bool available() const;
132 /// Save the current position as bookmark i
133 void savePosition(unsigned int i);
134 /// Restore the position from bookmark i
135 void restorePosition(unsigned int i);
136 /// does the given bookmark have a saved position ?
137 bool isSavedPosition(unsigned int i);
138 /// save bookmarks to .lyx/session
139 void saveSavedPositions();
141 /// return the current change at the cursor
142 Change const getCurrentChange();
144 /// return the lyxtext we are using
145 LyXText * getLyXText();
147 /// return the lyxtext we are using
148 LyXText const * getLyXText() const;
150 /// simple replacing. Use the font of the first selected character
151 void replaceSelectionWithString(std::string const & str);
153 /// move cursor to the named label
154 void gotoLabel(std::string const & label);
156 /// get the stored error list
157 ErrorList const & getErrorList() const;
158 /// show the error list to the user
159 void showErrorList(std::string const &) const;
160 /// set the cursor based on the given TeX source row
161 void setCursorFromRow(int row);
163 /// hide the cursor if it is visible
166 /// center the document view around the cursor
168 /// scroll document by the given number of lines of default height
169 void scroll(int lines);
170 /// Scroll the view by a number of pixels
171 void scrollDocView(int pixels);
173 /// return the pixel width of the document view
174 int workWidth() const;
175 /// return the pixel height of the document view
176 int workHeight() const;
178 /// switch between primary and secondary keymaps for RTL entry
181 /// return true for events that will handle
182 FuncStatus getStatus(FuncRequest const & cmd);
183 /// execute the given function
184 bool dispatch(FuncRequest const & argument);
187 void selectionRequested();
189 void selectionLost();
192 void workAreaResize(int width, int height);
194 /// Receive a keypress
195 void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
197 /// a function should be executed from the workarea
198 bool workAreaDispatch(FuncRequest const & ev);
200 /// clear the X selection
204 int offset_ref() const;
206 lyx::pit_type anchor_ref() const;
208 /// access to full cursor
210 /// access to full cursor
211 LCursor const & cursor() const;
213 LyXText * text() const;
214 /// sets cursor and open all relevant collapsable insets.
215 void setCursor(DocIterator const &);
216 /// sets cursor; this is used when handling LFUN_MOUSE_PRESS.
217 void mouseSetCursor(LCursor & cur);
219 /* Sets the selection. When \c backwards == false, set anchor
220 * to \c cur and cursor to \c cur + \c length. When \c
221 * backwards == true, set anchor to \c cur and cursor to \c
224 void putSelectionAt(DocIterator const & cur,
225 int length, bool backwards);
228 ViewMetricsInfo const & viewMetricsInfo();
233 friend class BufferView::Pimpl;
238 #endif // BUFFERVIEW_H