]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
GUI API Cleanup step 3: merge with "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 #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         void 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         bool needsRedraw() const
121         {
122                 return needs_redraw_;
123         }
124         void needsRedraw(bool redraw_needed)
125         {
126                 needs_redraw_ = redraw_needed;
127         }
128 private:
129         ///
130         int width_;
131         ///
132         int height_;
133         ///
134         ScrollbarParameters scrollbarParameters_;
135         ///
136         bool needs_redraw_;
137
138         /// An error list (replaces the error insets)
139         ErrorList errorlist_;
140         /// add an error to the list
141         void addError(ErrorItem const &);
142         /// buffer errors signal connection
143         boost::signals::connection errorConnection_;
144         /// buffer messages signal connection
145         boost::signals::connection messageConnection_;
146         /// buffer busy status signal connection
147         boost::signals::connection busyConnection_;
148         /// buffer title changed signal connection
149         boost::signals::connection titleConnection_;
150         /// buffer reset timers signal connection
151         boost::signals::connection timerConnection_;
152         /// buffer readonly status changed signal connection
153         boost::signals::connection readonlyConnection_;
154         /// buffer closing signal connection
155         boost::signals::connection closingConnection_;
156         /// connect to signals in the given buffer
157         void connectBuffer(Buffer & buf);
158         /// disconnect from signals in the given buffer
159         void disconnectBuffer();
160         /// track changes for the document
161         void trackChanges();
162         /// notify readonly status
163         void showReadonly(bool);
164
165         ///
166         ViewMetricsInfo metrics_info_;
167         ///
168         void updateMetrics(bool singlepar = false);
169
170         ///
171         friend class BufferView;
172
173         ///
174         BufferView * bv_;
175         ///
176         LyXView * owner_;
177         ///
178         Buffer * buffer_;
179
180         /// Estimated average par height for scrollbar
181         int wh_;
182         ///
183         class Position {
184         public:
185                 /// Filename
186                 std::string filename;
187                 /// Cursor paragraph Id
188                 int par_id;
189                 /// Cursor position
190                 lyx::pos_type par_pos;
191                 ///
192                 Position() : par_id(0), par_pos(0) {}
193                 ///
194                 Position(std::string const & f, int id, lyx::pos_type pos)
195                         : filename(f), par_id(id), par_pos(pos) {}
196         };
197         ///
198         std::vector<Position> saved_positions;
199         ///
200         void menuInsertLyXFile(std::string const & filen);
201
202         /// this is used to handle XSelection events in the right manner
203         struct {
204                 CursorSlice cursor;
205                 CursorSlice anchor;
206                 bool set;
207         } xsel_cache_;
208         ///
209         LCursor cursor_;
210         ///
211         bool multiparsel_cache_;
212         ///
213         lyx::pit_type anchor_ref_;
214         ///
215         int offset_ref_;
216
217 };
218 #endif // BUFFERVIEW_PIMPL_H