]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
Second part of r14315 from the younes branch:
[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 "frontends/LyXKeySym.h"
26 #include "frontends/Timeout.h"
27
28 #include "support/types.h"
29
30 #include <boost/signals/trackable.hpp>
31
32 class Change;
33 class LyXView;
34
35 class FuncRequest;
36 class FuncStatus;
37 class ViewMetricsInfo;
38
39 namespace lyx {
40 namespace frontend {
41 class Gui;
42 class WorkArea;
43 class Painter;
44 }
45 }
46
47
48 ///
49 class BufferView::Pimpl : public boost::signals::trackable {
50 public:
51         ///
52         Pimpl(BufferView & bv, LyXView * owner, lyx::frontend::WorkArea * workArea);
53         ///
54         lyx::frontend::Painter & painter() const;
55         ///
56         void setBuffer(Buffer * buf);
57         ///
58         void resizeCurrentBuffer();
59         //
60         bool fitCursor();
61         //
62         bool multiParSel();
63         ///
64         void update(Update::flags flags = Update::Force);
65         ///
66         void newFile(std::string const &, std::string const &, bool);
67         ///
68         bool loadLyXFile(std::string const &, bool);
69         ///
70         void workAreaResize(int width, int height);
71         ///
72         void updateScrollbar();
73         ///
74         ScrollbarParameters const & scrollbarParameters() const;
75         ///
76         void scrollDocView(int value);
77         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
78         void scroll(int lines);
79         ///
80         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
81         ///
82         void selectionRequested();
83         ///
84         void selectionLost();
85         ///
86         void cursorToggle();
87         ///
88         bool available() const;
89         /// get the change at the cursor position
90         Change const getCurrentChange();
91         ///
92         void savePosition(unsigned int i);
93         ///
94         void restorePosition(unsigned int i);
95         ///
96         bool isSavedPosition(unsigned int i);
97         /// save bookmarks to .lyx/session
98         void saveSavedPositions();
99         ///
100         void switchKeyMap();
101         ///
102         void center();
103         /// a function should be executed from the workarea
104         bool workAreaDispatch(FuncRequest const & ev);
105         /// return true for events that will handle
106         FuncStatus getStatus(FuncRequest const & cmd);
107         /// a function should be executed
108         bool dispatch(FuncRequest const & ev);
109
110         /// the frontend
111         lyx::frontend::Gui & gui() const;
112
113         /// Width and height of the BufferView in Pixels
114         /**
115         This is set externally by the workAreaResize method.
116         */
117         int width() const;
118         /// Height of the BufferView in Pixels
119         /**
120         This is set externally by the workAreaResize method.
121         */
122         int height() const;
123
124 private:
125         ///
126         int width_;
127         ///
128         int height_;
129         ///
130         ScrollbarParameters scrollbarParameters_;
131
132         /// An error list (replaces the error insets)
133         ErrorList errorlist_;
134         /// add an error to the list
135         void addError(ErrorItem const &);
136         /// buffer errors signal connection
137         boost::signals::connection errorConnection_;
138         /// buffer messages signal connection
139         boost::signals::connection messageConnection_;
140         /// buffer busy status signal connection
141         boost::signals::connection busyConnection_;
142         /// buffer title changed signal connection
143         boost::signals::connection titleConnection_;
144         /// buffer reset timers signal connection
145         boost::signals::connection timerConnection_;
146         /// buffer readonly status changed signal connection
147         boost::signals::connection readonlyConnection_;
148         /// buffer closing signal connection
149         boost::signals::connection closingConnection_;
150         /// connect to signals in the given buffer
151         void connectBuffer(Buffer & buf);
152         /// disconnect from signals in the given buffer
153         void disconnectBuffer();
154         /// track changes for the document
155         void trackChanges();
156         /// notify readonly status
157         void showReadonly(bool);
158
159
160         ///
161         friend class BufferView;
162
163         ///
164         BufferView * bv_;
165         ///
166         LyXView * owner_;
167         ///
168         Buffer * buffer_;
169
170         /// Estimated average par height for scrollbar
171         int wh_;
172         ///
173         Timeout cursor_timeout;
174         ///
175         bool using_xterm_cursor;
176         ///
177         class Position {
178         public:
179                 /// Filename
180                 std::string filename;
181                 /// Cursor paragraph Id
182                 int par_id;
183                 /// Cursor position
184                 lyx::pos_type par_pos;
185                 ///
186                 Position() : par_id(0), par_pos(0) {}
187                 ///
188                 Position(std::string const & f, int id, lyx::pos_type pos)
189                         : filename(f), par_id(id), par_pos(pos) {}
190         };
191         ///
192         std::vector<Position> saved_positions;
193         ///
194         void menuInsertLyXFile(std::string const & filen);
195
196         lyx::frontend::WorkArea * workArea_;
197
198         /// this is used to handle XSelection events in the right manner
199         struct {
200                 CursorSlice cursor;
201                 CursorSlice anchor;
202                 bool set;
203         } xsel_cache_;
204         ///
205         LCursor cursor_;
206         ///
207         bool multiparsel_cache_;
208         ///
209         lyx::pit_type anchor_ref_;
210         ///
211         int offset_ref_;
212         ///
213         ViewMetricsInfo metrics(bool singlepar = false);
214 };
215 #endif // BUFFERVIEW_PIMPL_H