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);
123 /// save bookmarks to .lyx/session
124 void saveSavedPositions();
126 /// return the current change at the cursor
127 Change const getCurrentChange();
129 /// return the lyxtext we are using
130 LyXText * getLyXText();
132 /// return the lyxtext we are using
133 LyXText const * getLyXText() const;
135 /// simple replacing. Use the font of the first selected character
136 void replaceSelectionWithString(std::string const & str);
138 /// move cursor to the named label
139 void gotoLabel(std::string const & label);
141 /// get the stored error list
142 ErrorList const & getErrorList() const;
143 /// show the error list to the user
144 void showErrorList(std::string const &) const;
145 /// set the cursor based on the given TeX source row
146 void setCursorFromRow(int row);
148 /// hide the cursor if it is visible
151 /// center the document view around the cursor
153 /// scroll document by the given number of lines of default height
154 void scroll(int lines);
155 /// Scroll the view by a number of pixels
156 void scrollDocView(int pixels);
158 /// return the pixel width of the document view
159 int workWidth() const;
160 /// return the pixel height of the document view
161 int workHeight() const;
163 /// switch between primary and secondary keymaps for RTL entry
166 /// get the contents of the window system clipboard
167 std::string const getClipboard() const;
168 /// fill the window system clipboard
169 void stuffClipboard(std::string const &) const;
170 /// tell the window system we have a selection
171 void haveSelection(bool sel);
173 /// return true for events that will handle
174 FuncStatus getStatus(FuncRequest const & cmd);
175 /// execute the given function
176 bool dispatch(FuncRequest const & argument);
178 /// clear the X selection
182 int offset_ref() const;
184 lyx::pit_type anchor_ref() const;
186 /// access to full cursor
188 /// access to full cursor
189 LCursor const & cursor() const;
191 LyXText * text() const;
192 /// sets cursor and open all relevant collapsable insets.
193 void setCursor(DocIterator const &);
194 /// sets cursor; this is used when handling LFUN_MOUSE_PRESS.
195 void mouseSetCursor(LCursor & cur);
197 /* Sets the selection. When \c backwards == false, set anchor
198 * to \c cur and cursor to \c cur + \c length. When \c
199 * backwards == true, set anchor to \c cur and cursor to \c
202 void putSelectionAt(DocIterator const & cur,
203 int length, bool backwards);
205 bool const repaintAll() const;
207 void const repaintAll(bool r) const;
213 friend class BufferView::Pimpl;
218 #endif // BUFFERVIEW_H