]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
Remove cached var from RenderPreview. Changes elsewhere to suit.
[lyx.git] / src / BufferView.h
1 // -*- C++ -*-
2 /**
3  * \file BufferView.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alfredo Braustein
8  * \author Lars Gullik Bjønnes
9  * \author John Levon
10  * \author Jürgen Vigna
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef BUFFER_VIEW_H
16 #define BUFFER_VIEW_H
17
18 #include "support/types.h"
19
20 #include <boost/utility.hpp>
21
22 #include <string>
23
24 class Buffer;
25 class Change;
26 class DocIterator;
27 class Encoding;
28 class ErrorList;
29 class FuncRequest;
30 class FuncStatus;
31 class InsetBase;
32 class InsetOld;
33 class Language;
34 class LCursor;
35 class LyXText;
36 class LyXScreen;
37 class LyXView;
38 class Painter;
39 class ParIterator;
40 class TeXErrors;
41 class UpdatableInset;
42
43 /**
44  * A buffer view encapsulates a view onto a particular
45  * buffer, and allows access to operate upon it. A view
46  * is a sliding window of the entire document rendering.
47  *
48  * Eventually we will allow several views onto a single
49  * buffer, but not yet.
50  */
51 class BufferView : boost::noncopyable {
52 public:
53         /**
54          * Create a view with the given owner main window,
55          * of the given dimensions.
56          */
57         BufferView(LyXView * owner, int x, int y, int w, int h);
58
59         ~BufferView();
60
61         /// set the buffer we are viewing
62         void setBuffer(Buffer * b);
63         /// return the buffer being viewed
64         Buffer * buffer() const;
65
66         /// return the painter object for drawing onto the view
67         Painter & painter() const;
68         /// return the screen object for handling re-drawing
69         LyXScreen & screen() const;
70         /// return the owning main view
71         LyXView * owner() const;
72
73         /// return the visible top y
74         int top_y() const;
75
76         /// set the visible top y
77         void top_y(int);
78
79         /// resize event has happened
80         void resize();
81
82         /// reload the contained buffer
83         void reload();
84         /// create a new buffer based on template
85         void newFile(std::string const & fname, std::string const & tname,
86                      bool named = true);
87         /// load a buffer into the view
88         bool loadLyXFile(std::string const & name, bool tolastfiles = true);
89
90         /// fit the user cursor within the visible view
91         bool fitCursor();
92         /// perform pending painting updates
93         void update();
94         /// reset the scrollbar to reflect current view position
95         void updateScrollbar();
96         /// FIXME
97         void redoCurrentBuffer();
98
99         /// FIXME
100         bool available() const;
101
102         /// Save the current position as bookmark i
103         void savePosition(unsigned int i);
104         /// Restore the position from bookmark i
105         void restorePosition(unsigned int i);
106         /// does the given bookmark have a saved position ?
107         bool isSavedPosition(unsigned int i);
108
109         /// return the current change at the cursor
110         Change const getCurrentChange();
111
112         /// return the lyxtext we are using
113         LyXText * getLyXText() const;
114
115         /// return the parent language of the given inset
116         Language const * getParentLanguage(InsetOld * inset) const;
117
118         /// simple replacing. Use the font of the first selected character
119         void replaceSelectionWithString(std::string const & str);
120
121         /// move cursor to the named label
122         void gotoLabel(std::string const & label);
123
124         /// get the stored error list
125         ErrorList const & getErrorList() const;
126         /// show the error list to the user
127         void showErrorList(std::string const &) const;
128         /// set the cursor based on the given TeX source row
129         void setCursorFromRow(int row);
130
131         /// Inserts a lyx file at cursor position. return false if it fails
132         bool insertLyXFile(std::string const & file);
133
134         /// FIXME
135         bool fitLockedInsetCursor(int x, int y, int asc, int desc);
136
137         /// hide the cursor if it is visible
138         void hideCursor();
139
140         /// center the document view around the cursor
141         void center();
142         /// scroll document by the given number of lines of default height
143         void scroll(int lines);
144         /// Scroll the view by a number of pixels
145         void scrollDocView(int);
146
147         /// return the pixel width of the document view
148         int workWidth() const;
149         /// return the pixel height of the document view
150         int workHeight() const;
151
152         /// switch between primary and secondary keymaps for RTL entry
153         void switchKeyMap();
154
155         /// get the contents of the window system clipboard
156         std::string const getClipboard() const;
157         /// fill the window system clipboard
158         void stuffClipboard(std::string const &) const;
159         /// tell the window system we have a selection
160         void haveSelection(bool sel);
161
162         /// return true for events that will handle
163         FuncStatus getStatus(FuncRequest const & cmd);
164         /// execute the given function
165         bool dispatch(FuncRequest const & argument);
166
167         /// clear the X selection
168         void unsetXSel();
169
170         /// access to full cursor
171         LCursor & cursor();
172         /// access to full cursor
173         LCursor const & cursor() const;
174         ///
175         LyXText * text() const;
176         ///
177         void setCursor(ParIterator const & par, lyx::pos_type pos);
178         ///
179         void putSelectionAt(DocIterator const & cur,
180                 int length, bool backwards);
181
182 private:
183         ///
184         struct Pimpl;
185         ///
186         friend struct BufferView::Pimpl;
187         ///
188         Pimpl * pimpl_;
189 };
190
191 #endif // BUFFERVIEW_H