4 * Copyright 2002 the LyX Team
5 * Read the file COPYING
7 * \author Lars Gullik Bjønnes
15 #include "insets/inset.h"
17 #include <boost/utility.hpp>
33 * A buffer view encapsulates a view onto a particular
34 * buffer, and allows access to operate upon it. A view
35 * is a sliding window of the entire document rendering.
37 * Eventually we will allow several views onto a single
38 * buffer, but not yet.
40 class BufferView : boost::noncopyable {
43 * Create a view with the given owner main window,
44 * of the given dimensions.
46 BufferView(LyXView * owner, int x, int y, int w, int h);
50 /// set the buffer we are viewing
51 void buffer(Buffer * b);
52 /// return the buffer being viewed
53 Buffer * buffer() const;
55 /// return the painter object for drawing onto the view
56 Painter & painter() const;
57 /// return the screen object for handling re-drawing
58 LyXScreen & screen() const;
59 /// return the owning main view
60 LyXView * owner() const;
62 /// resize event has happened
65 /// reload the contained buffer
67 /// create a new buffer based on template
68 bool newFile(string const & fname, string const & tname,
70 /// load a buffer into the view
71 bool loadLyXFile(string const & name, bool tolastfiles = true);
73 /// fit the user cursor within the visible view
75 /// perform pending painting updates
77 /// update for a particular inset
79 /// reset the scrollbar to reflect current view position
80 void updateScrollbar();
82 void redoCurrentBuffer();
85 bool available() const;
88 void beforeChange(LyXText *);
90 /// Save the current position as bookmark i
91 void savePosition(unsigned int i);
92 /// Restore the position from bookmark i
93 void restorePosition(unsigned int i);
94 /// does the given bookmark have a saved position ?
95 bool isSavedPosition(unsigned int i);
97 /// return the current change at the cursor
98 Change const getCurrentChange();
101 * This holds the mapping between buffer paragraphs and screen rows.
102 * This should be private...but not yet. (Lgb)
105 /// return the lyxtext we are using
106 LyXText * getLyXText() const;
108 /// Return the current inset we are "locked" in
109 UpdatableInset * theLockingInset() const;
110 /// lock the given inset FIXME: return value ?
111 bool lockInset(UpdatableInset * inset);
112 /// unlock the given inset
113 int unlockInset(UpdatableInset * inset);
114 /// unlock the currently locked inset
117 /// return the current encoding at the cursor
118 Encoding const * getEncoding() const;
120 /// return the parent language of the given inset
121 Language const * getParentLanguage(InsetOld * inset) const;
123 /// Select the "current" word
124 void selectLastWord();
125 /// replace the currently selected word
126 void replaceWord(string const & replacestring);
127 /// Update after spellcheck finishes
128 void endOfSpellCheck();
129 /// return the next word
130 WordLangTuple const nextWord(float & value);
132 /// move cursor to the named label
133 void gotoLabel(string const & label);
140 /// get the stored error list
141 ErrorList const & getErrorList() const;
142 /// show the error list to the user
143 void showErrorList(string const &) const;
144 /// set the cursor based on the given TeX source row
145 void setCursorFromRow(int row);
148 * Insert an inset into the buffer.
149 * Place it in a layout of lout,
151 bool insertInset(InsetOld * inset, string const & lout = string());
153 /// Inserts a lyx file at cursor position. return false if it fails
154 bool insertLyXFile(string const & file);
157 bool fitLockedInsetCursor(int x, int y, int asc, int desc);
159 /// hide the cursor if it is visible
162 /// center the document view around the cursor
164 /// scroll document by the given number of lines of default height
165 void scroll(int lines);
166 /// Scroll the view by a number of pixels
167 void scrollDocView(int);
169 /// return the pixel width of the document view
170 int workWidth() const;
171 /// return the pixel height of the document view
172 int workHeight() const;
174 /// switch between primary and secondary keymaps for RTL entry
178 bool ChangeRefsIfUnique(string const & from, string const & to);
180 /// get the contents of the window system clipboard
181 string const getClipboard() const;
182 /// fill the window system clipboard
183 void stuffClipboard(string const &) const;
184 /// tell the window system we have a selection
185 void haveSelection(bool sel);
187 /// execute the given function
188 bool dispatch(FuncRequest const & argument);
191 /// Set the current locking inset
192 void theLockingInset(UpdatableInset * inset);
194 /// return the lyxtext containing this inset
195 LyXText * getParentText(InsetOld * inset) const;
198 * Change all insets with the given code's contents to a new
199 * string. May only be used with InsetCommand-derived insets
200 * Returns true if a screen update is needed.
202 bool ChangeInsets(InsetOld::Code code, string const & from,
207 friend struct BufferView::Pimpl;
212 #endif // BUFFERVIEW_H