]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
More 'standard conformant blurb' nonsense.
[lyx.git] / src / BufferView.h
1 // -*- C++ -*-
2 /**
3  * \file BufferView.h
4  * Copyright 2002 the LyX Team
5  * Read the file COPYING
6  *
7  *  \author Lars Gullik Bjønnes
8 */
9
10 #ifndef BUFFER_VIEW_H
11 #define BUFFER_VIEW_H
12
13 #include "LString.h"
14
15 #include "insets/inset.h"
16
17 #include <boost/utility.hpp>
18
19 class Change;
20 class LyXView;
21 class LyXText;
22 class TeXErrors;
23 class Buffer;
24 class LyXScreen;
25 class Language;
26 class Painter;
27 class UpdatableInset;
28 class WordLangTuple;
29 class Encoding;
30 class ErrorList;
31
32 /**
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.
36  *
37  * Eventually we will allow several views onto a single
38  * buffer, but not yet.
39  */
40 class BufferView : boost::noncopyable {
41 public:
42         /**
43          * Create a view with the given owner main window,
44          * of the given dimensions.
45          */
46         BufferView(LyXView * owner, int x, int y, int w, int h);
47
48         ~BufferView();
49
50         /// set the buffer we are viewing
51         void buffer(Buffer * b);
52         /// return the buffer being viewed
53         Buffer * buffer() const;
54
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;
61
62         /// resize event has happened
63         void resize();
64
65         /// reload the contained buffer
66         void reload();
67         /// create a new buffer based on template
68         bool newFile(string const & fname, string const & tname,
69                      bool named = true);
70         /// load a buffer into the view
71         bool loadLyXFile(string const & name, bool tolastfiles = true);
72
73         /// fit the user cursor within the visible view
74         bool fitCursor();
75         /// perform pending painting updates
76         void update();
77         /// update for a particular inset
78         void updateInset();
79         /// reset the scrollbar to reflect current view position
80         void updateScrollbar();
81         /// FIXME
82         void redoCurrentBuffer();
83
84         /// FIXME
85         bool available() const;
86
87         /// FIXME
88         void beforeChange(LyXText *);
89
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);
96
97         /// return the current change at the cursor
98         Change const getCurrentChange();
99
100         /**
101          * This holds the mapping between buffer paragraphs and screen rows.
102          * This should be private...but not yet. (Lgb)
103          */
104         LyXText * text;
105         /// return the lyxtext we are using
106         LyXText * getLyXText() const;
107
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
115         void insetUnlock();
116
117         /// return the current encoding at the cursor
118         Encoding const * getEncoding() const;
119
120         /// return the parent language of the given inset
121         Language const * getParentLanguage(InsetOld * inset) const;
122
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);
131
132         /// move cursor to the named label
133         void gotoLabel(string const & label);
134
135         /// undo last action
136         void undo();
137         /// redo last action
138         void redo();
139
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);
146
147         /**
148          * Insert an inset into the buffer.
149          * Place it in a layout of lout,
150          */
151         bool insertInset(InsetOld * inset, string const & lout = string());
152
153         /// Inserts a lyx file at cursor position. return false if it fails
154         bool insertLyXFile(string const & file);
155
156         /// FIXME
157         bool fitLockedInsetCursor(int x, int y, int asc, int desc);
158
159         /// hide the cursor if it is visible
160         void hideCursor();
161
162         /// center the document view around the cursor
163         void center();
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);
168
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;
173
174         /// switch between primary and secondary keymaps for RTL entry
175         void switchKeyMap();
176
177         /// FIXME
178         bool ChangeRefsIfUnique(string const & from, string const & to);
179
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);
186
187         /// execute the given function
188         bool dispatch(FuncRequest const & argument);
189
190 private:
191         /// Set the current locking inset
192         void theLockingInset(UpdatableInset * inset);
193
194         /// return the lyxtext containing this inset
195         LyXText * getParentText(InsetOld * inset) const;
196
197         /**
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.
201          */
202         bool ChangeInsets(InsetOld::Code code, string const & from,
203                           string const & to);
204
205
206         struct Pimpl;
207         friend struct BufferView::Pimpl;
208
209         Pimpl * pimpl_;
210 };
211
212 #endif // BUFFERVIEW_H