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