]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
GUI API Cleanup step 2: merge of the "younes" branch. What's missing
[lyx.git] / src / BufferView_pimpl.h
1 // -*- C++ -*-
2 /**
3  * \file BufferView_pimpl.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Asger Alstrup
8  * \author Alfredo Braustein
9  * \author Lars Gullik Bjønnes
10  * \author John Levon
11  * \author André Pönitz
12  * \author Dekel Tsur
13  * \author Jürgen Vigna
14  *
15  * Full author contact details are available in file CREDITS.
16  */
17
18 #ifndef BUFFERVIEW_PIMPL_H
19 #define BUFFERVIEW_PIMPL_H
20
21 #include "BufferView.h"
22 #include "cursor.h"
23 #include "errorlist.h"
24
25 #include "insets/inset.h"
26
27 #include "frontends/key_state.h"
28 #include "frontends/LyXKeySym.h"
29 #include "frontends/Timeout.h"
30
31 #include "support/types.h"
32
33 #include <boost/scoped_ptr.hpp>
34 #include <boost/shared_ptr.hpp>
35 #include <boost/signals/trackable.hpp>
36
37 class Change;
38 class LyXKeySym;
39 class LyXView;
40
41 class FuncRequest;
42 class FuncStatus;
43 class ViewMetricsInfo;
44
45 namespace lyx {
46 namespace frontend {
47 class Gui;
48 class WorkArea;
49 class Clipboard;
50 class Painter;
51 class GuiCursor;
52 }
53 }
54
55
56 ///
57 class BufferView::Pimpl : public boost::signals::trackable {
58 public:
59         ///
60         Pimpl(BufferView & bv, LyXView * owner, lyx::frontend::WorkArea * workArea);
61         ///
62         lyx::frontend::Painter & painter() const;
63         ///
64         void setBuffer(Buffer * buf);
65         ///
66         void resizeCurrentBuffer();
67         //
68         bool fitCursor();
69         //
70         bool multiParSel();
71         ///
72         void update(Update::flags flags = Update::Force);
73         ///
74         void newFile(std::string const &, std::string const &, bool);
75         ///
76         bool loadLyXFile(std::string const &, bool);
77         ///
78         void workAreaResize(int width, int height);
79         ///
80         void updateScrollbar();
81         ///
82         ScrollbarParameters const & scrollbarParameters() const;
83         ///
84         void scrollDocView(int value);
85         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
86         void scroll(int lines);
87         ///
88         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
89         ///
90         void selectionRequested();
91         ///
92         void selectionLost();
93         ///
94         void cursorToggle();
95         ///
96         bool available() const;
97         /// get the change at the cursor position
98         Change const getCurrentChange();
99         ///
100         void savePosition(unsigned int i);
101         ///
102         void restorePosition(unsigned int i);
103         ///
104         bool isSavedPosition(unsigned int i);
105         /// save bookmarks to .lyx/session
106         void saveSavedPositions();
107         ///
108         void switchKeyMap();
109         ///
110         void center();
111         /// a function should be executed from the workarea
112         bool workAreaDispatch(FuncRequest const & ev);
113         /// return true for events that will handle
114         FuncStatus getStatus(FuncRequest const & cmd);
115         /// a function should be executed
116         bool dispatch(FuncRequest const & ev);
117         /// Flag: do a full redraw of inside text of inset
118         bool repaintAll() { return refresh_inside_; }
119         ///
120         void repaintAll(bool r) {refresh_inside_ = r; }
121
122         /// the frontend
123         lyx::frontend::Gui & gui() const;
124         /// our workarea
125         lyx::frontend::WorkArea & workarea() const;
126         /// the clipboard
127         lyx::frontend::Clipboard & clipboard() const;
128
129         /// Width and height of the BufferView in Pixels
130         /**
131         This is set externally by the workAreaResize method.
132         */
133         int width() const;
134         /// Height of the BufferView in Pixels
135         /**
136         This is set externally by the workAreaResize method.
137         */
138         int height() const;
139
140 private:
141         ///
142         int width_;
143         ///
144         int height_;
145         ///
146         ScrollbarParameters scrollbarParameters_;
147
148         /// An error list (replaces the error insets)
149         ErrorList errorlist_;
150         /// add an error to the list
151         void addError(ErrorItem const &);
152         /// buffer errors signal connection
153         boost::signals::connection errorConnection_;
154         /// buffer messages signal connection
155         boost::signals::connection messageConnection_;
156         /// buffer busy status signal connection
157         boost::signals::connection busyConnection_;
158         /// buffer title changed signal connection
159         boost::signals::connection titleConnection_;
160         /// buffer reset timers signal connection
161         boost::signals::connection timerConnection_;
162         /// buffer readonly status changed signal connection
163         boost::signals::connection readonlyConnection_;
164         /// buffer closing signal connection
165         boost::signals::connection closingConnection_;
166         /// connect to signals in the given buffer
167         void connectBuffer(Buffer & buf);
168         /// disconnect from signals in the given buffer
169         void disconnectBuffer();
170         /// track changes for the document
171         void trackChanges();
172         /// notify readonly status
173         void showReadonly(bool);
174
175
176         ///
177         friend class BufferView;
178
179         ///
180         BufferView * bv_;
181         ///
182         LyXView * owner_;
183         ///
184         Buffer * buffer_;
185
186         /// Estimated average par height for scrollbar
187         int wh_;
188         ///
189         Timeout cursor_timeout;
190         ///
191         void stuffClipboard(std::string const &) const;
192         ///
193         bool using_xterm_cursor;
194         ///
195         class Position {
196         public:
197                 /// Filename
198                 std::string filename;
199                 /// Cursor paragraph Id
200                 int par_id;
201                 /// Cursor position
202                 lyx::pos_type par_pos;
203                 ///
204                 Position() : par_id(0), par_pos(0) {}
205                 ///
206                 Position(std::string const & f, int id, lyx::pos_type pos)
207                         : filename(f), par_id(id), par_pos(pos) {}
208         };
209         ///
210         std::vector<Position> saved_positions;
211         ///
212         void menuInsertLyXFile(std::string const & filen);
213
214         lyx::frontend::WorkArea * workArea_;
215
216         /// this is used to handle XSelection events in the right manner
217         struct {
218                 CursorSlice cursor;
219                 CursorSlice anchor;
220                 bool set;
221         } xsel_cache_;
222         ///
223         LCursor cursor_;
224         ///
225         bool multiparsel_cache_;
226         ///
227         lyx::pit_type anchor_ref_;
228         ///
229         int offset_ref_;
230         ///
231         ViewMetricsInfo metrics(bool singlepar = false);
232         /// Working variable indicating a full screen refresh
233         mutable bool refresh_inside_;
234
235 };
236 #endif // BUFFERVIEW_PIMPL_H