]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
This commit removes the needRedraw() interface and simplify the screen update procedu...
[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 #include "metricsinfo.h"
25
26 #include "frontends/LyXKeySym.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
38 namespace lyx {
39 namespace frontend {
40 class Gui;
41 }
42 }
43
44
45 ///
46 class BufferView::Pimpl : public boost::signals::trackable {
47 public:
48         ///
49         Pimpl(BufferView & bv, LyXView * owner);
50         ///
51         void setBuffer(Buffer * buf);
52         /// return the first layout of the Buffer.
53         std::string firstLayout();
54         ///
55         void resizeCurrentBuffer();
56         //
57         bool fitCursor();
58         //
59         bool multiParSel();
60         ///
61         bool update(Update::flags flags = Update::Force);
62         /// load a buffer into the view
63         bool loadLyXFile(std::string const &, bool);
64         ///
65         void workAreaResize(int width, int height);
66         ///
67         void updateScrollbar();
68         ///
69         ScrollbarParameters const & scrollbarParameters() const;
70         ///
71         void scrollDocView(int value);
72         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
73         void scroll(int lines);
74         ///
75         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
76         ///
77         void selectionRequested();
78         ///
79         void selectionLost();
80         ///
81         bool available() const;
82         /// get the change at the cursor position
83         Change const getCurrentChange();
84         ///
85         void savePosition(unsigned int i);
86         ///
87         void restorePosition(unsigned int i);
88         ///
89         bool isSavedPosition(unsigned int i);
90         /// save bookmarks to .lyx/session
91         void saveSavedPositions();
92         ///
93         void switchKeyMap();
94         ///
95         void center();
96         /// a function should be executed from the workarea
97         bool workAreaDispatch(FuncRequest const & ev);
98         /// return true for events that will handle
99         FuncStatus getStatus(FuncRequest const & cmd);
100         /// a function should be executed
101         bool dispatch(FuncRequest const & ev);
102
103         /// the frontend
104         lyx::frontend::Gui & gui() const;
105
106         /// Width and height of the BufferView in Pixels
107         /**
108         This is set externally by the workAreaResize method.
109         */
110         int width() const;
111         /// Height of the BufferView in Pixels
112         /**
113         This is set externally by the workAreaResize method.
114         */
115         int height() const;
116
117         ///
118         ViewMetricsInfo const & viewMetricsInfo();
119         ///
120         void updateMetrics(bool singlepar = false);
121
122 private:
123         ///
124         int width_;
125         ///
126         int height_;
127         ///
128         ScrollbarParameters scrollbarParameters_;
129
130         /// An error list (replaces the error insets)
131         ErrorList errorlist_;
132         /// add an error to the list
133         void addError(ErrorItem const &);
134         /// buffer errors signal connection
135         boost::signals::connection errorConnection_;
136         /// buffer messages signal connection
137         boost::signals::connection messageConnection_;
138         /// buffer busy status signal connection
139         boost::signals::connection busyConnection_;
140         /// buffer title changed signal connection
141         boost::signals::connection titleConnection_;
142         /// buffer reset timers signal connection
143         boost::signals::connection timerConnection_;
144         /// buffer readonly status changed signal connection
145         boost::signals::connection readonlyConnection_;
146         /// buffer closing signal connection
147         boost::signals::connection closingConnection_;
148         /// connect to signals in the given buffer
149         void connectBuffer(Buffer & buf);
150         /// disconnect from signals in the given buffer
151         void disconnectBuffer();
152         /// track changes for the document
153         void trackChanges();
154         /// notify readonly status
155         void showReadonly(bool);
156
157         ///
158         ViewMetricsInfo metrics_info_;
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         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 };
208 #endif // BUFFERVIEW_PIMPL_H