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 /// center the document view around the cursor
165 /// scroll document by the given number of lines of default height
166 void scroll(int lines);
167 /// Scroll the view by a number of pixels
168 void scrollDocView(int pixels);
170 /// return the pixel width of the document view
171 int workWidth() const;
172 /// return the pixel height of the document view
173 int workHeight() const;
175 /// switch between primary and secondary keymaps for RTL entry
178 /// return true for events that will handle
179 FuncStatus getStatus(FuncRequest const & cmd);
180 /// execute the given function
181 bool dispatch(FuncRequest const & argument);
184 void selectionRequested();
186 void selectionLost();
189 void workAreaResize(int width, int height);
191 /// Receive a keypress
192 void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
194 /// a function should be executed from the workarea
195 bool workAreaDispatch(FuncRequest const & ev);
197 /// clear the X selection
201 int offset_ref() const;
203 lyx::pit_type anchor_ref() const;
205 /// access to full cursor
207 /// access to full cursor
208 LCursor const & cursor() const;
210 LyXText * text() const;
211 /// sets cursor and open all relevant collapsable insets.
212 void setCursor(DocIterator const &);
213 /// sets cursor; this is used when handling LFUN_MOUSE_PRESS.
214 void mouseSetCursor(LCursor & cur);
216 /* Sets the selection. When \c backwards == false, set anchor
217 * to \c cur and cursor to \c cur + \c length. When \c
218 * backwards == true, set anchor to \c cur and cursor to \c
221 void putSelectionAt(DocIterator const & cur,
222 int length, bool backwards);
225 ViewMetricsInfo const & viewMetricsInfo();
228 bool needsRedraw() const;
229 void needsRedraw(bool redraw_needed);
234 friend class BufferView::Pimpl;
239 #endif // BUFFERVIEW_H