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