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>
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));
61 * A buffer view encapsulates a view onto a particular
62 * buffer, and allows access to operate upon it. A view
63 * is a sliding window of the entire document rendering.
65 * Eventually we will allow several views onto a single
66 * buffer, but not yet.
68 class BufferView : boost::noncopyable {
71 * Create a view with the given owner main window,
72 * of the given dimensions.
74 BufferView(LyXView * owner, int w, int h);
78 /// set the buffer we are viewing
79 void setBuffer(Buffer * b);
80 /// return the buffer being viewed
81 Buffer * buffer() const;
83 /// return the painter object for drawing onto the view
84 Painter & painter() const;
85 /// return the screen object for handling re-drawing
86 LyXScreen & screen() const;
87 /// return the owning main view
88 LyXView * owner() const;
90 /// resize event has happened
93 /// reload the contained buffer
95 /// create a new buffer based on template
96 void newFile(std::string const & fname, std::string const & tname,
98 /// load a buffer into the view
99 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
101 /** perform pending painting updates. \c fitcursor means first
102 * to do a fitcursor, and to force an update if screen
103 * position changes. \c forceupdate means to force an update
107 void update(Update::flags flags = Update::FitCursor | Update::Force);
108 /// move the screen to fit the cursor. Only to be called with
109 /// good y coordinates (after a bv::metrics)
111 /// reset the scrollbar to reflect current view position
112 void updateScrollbar();
115 bool available() const;
117 /// Save the current position as bookmark i
118 void savePosition(unsigned int i);
119 /// Restore the position from bookmark i
120 void restorePosition(unsigned int i);
121 /// does the given bookmark have a saved position ?
122 bool isSavedPosition(unsigned int i);
124 /// return the current change at the cursor
125 Change const getCurrentChange();
127 /// return the lyxtext we are using
128 LyXText * getLyXText();
130 /// return the lyxtext we are using
131 LyXText const * getLyXText() const;
133 /// simple replacing. Use the font of the first selected character
134 void replaceSelectionWithString(std::string const & str);
136 /// move cursor to the named label
137 void gotoLabel(std::string const & label);
139 /// get the stored error list
140 ErrorList const & getErrorList() const;
141 /// show the error list to the user
142 void showErrorList(std::string const &) const;
143 /// set the cursor based on the given TeX source row
144 void setCursorFromRow(int row);
146 /// hide the cursor if it is visible
149 /// center the document view around the cursor
151 /// scroll document by the given number of lines of default height
152 void scroll(int lines);
153 /// Scroll the view by a number of pixels
154 void scrollDocView(int pixels);
156 /// return the pixel width of the document view
157 int workWidth() const;
158 /// return the pixel height of the document view
159 int workHeight() const;
161 /// switch between primary and secondary keymaps for RTL entry
164 /// get the contents of the window system clipboard
165 std::string const getClipboard() const;
166 /// fill the window system clipboard
167 void stuffClipboard(std::string const &) const;
168 /// tell the window system we have a selection
169 void haveSelection(bool sel);
171 /// return true for events that will handle
172 FuncStatus getStatus(FuncRequest const & cmd);
173 /// execute the given function
174 bool dispatch(FuncRequest const & argument);
176 /// clear the X selection
180 int offset_ref() const;
182 lyx::pit_type anchor_ref() const;
184 /// access to full cursor
186 /// access to full cursor
187 LCursor const & cursor() const;
189 LyXText * text() const;
190 /// sets cursor and open all relevant collapsable insets.
191 void setCursor(DocIterator const &);
192 /// sets cursor; this is used when handling LFUN_MOUSE_PRESS.
193 void mouseSetCursor(LCursor & cur);
195 /* Sets the selection. When \c backwards == false, set anchor
196 * to \c cur and cursor to \c cur + \c length. When \c
197 * backwards == true, set anchor to \c cur and cursor to \c
200 void putSelectionAt(DocIterator const & cur,
201 int length, bool backwards);
203 bool const repaintAll() const;
205 void const repaintAll(bool r) const;
211 friend class BufferView::Pimpl;
216 #endif // BUFFERVIEW_H