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