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