]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
* gtk/lyx_gui.C:
[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 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         bool available() const;
83         /// get the change at the cursor position
84         Change const getCurrentChange();
85         ///
86         void savePosition(unsigned int i);
87         ///
88         void restorePosition(unsigned int i);
89         ///
90         bool isSavedPosition(unsigned int i);
91         /// save bookmarks to .lyx/session
92         void saveSavedPositions();
93         ///
94         void switchKeyMap();
95         ///
96         void center();
97         /// a function should be executed from the workarea
98         bool workAreaDispatch(FuncRequest const & ev);
99         /// return true for events that will handle
100         FuncStatus getStatus(FuncRequest const & cmd);
101         /// a function should be executed
102         bool dispatch(FuncRequest const & ev);
103
104         /// the frontend
105         lyx::frontend::Gui & gui() const;
106
107         /// Width and height of the BufferView in Pixels
108         /**
109         This is set externally by the workAreaResize method.
110         */
111         int width() const;
112         /// Height of the BufferView in Pixels
113         /**
114         This is set externally by the workAreaResize method.
115         */
116         int height() const;
117
118         ///
119         ViewMetricsInfo const & viewMetricsInfo();
120         ///
121         bool needsRedraw() const
122         {
123                 return needs_redraw_;
124         }
125         void needsRedraw(bool redraw_needed)
126         {
127                 needs_redraw_ = redraw_needed;
128         }
129 private:
130         ///
131         int width_;
132         ///
133         int height_;
134         ///
135         ScrollbarParameters scrollbarParameters_;
136         ///
137         bool needs_redraw_;
138
139         /// An error list (replaces the error insets)
140         ErrorList errorlist_;
141         /// add an error to the list
142         void addError(ErrorItem const &);
143         /// buffer errors signal connection
144         boost::signals::connection errorConnection_;
145         /// buffer messages signal connection
146         boost::signals::connection messageConnection_;
147         /// buffer busy status signal connection
148         boost::signals::connection busyConnection_;
149         /// buffer title changed signal connection
150         boost::signals::connection titleConnection_;
151         /// buffer reset timers signal connection
152         boost::signals::connection timerConnection_;
153         /// buffer readonly status changed signal connection
154         boost::signals::connection readonlyConnection_;
155         /// buffer closing signal connection
156         boost::signals::connection closingConnection_;
157         /// connect to signals in the given buffer
158         void connectBuffer(Buffer & buf);
159         /// disconnect from signals in the given buffer
160         void disconnectBuffer();
161         /// track changes for the document
162         void trackChanges();
163         /// notify readonly status
164         void showReadonly(bool);
165
166
167         ///
168         friend class BufferView;
169
170         ///
171         ViewMetricsInfo metrics_info_;
172         ///
173         void updateMetrics(bool singlepar = false);
174
175         ///
176         BufferView * bv_;
177         ///
178         LyXView * owner_;
179         ///
180         Buffer * buffer_;
181
182         /// Estimated average par height for scrollbar
183         int wh_;
184         ///
185         class Position {
186         public:
187                 /// Filename
188                 std::string filename;
189                 /// Cursor paragraph Id
190                 int par_id;
191                 /// Cursor position
192                 lyx::pos_type par_pos;
193                 ///
194                 Position() : par_id(0), par_pos(0) {}
195                 ///
196                 Position(std::string const & f, int id, lyx::pos_type pos)
197                         : filename(f), par_id(id), par_pos(pos) {}
198         };
199         ///
200         std::vector<Position> saved_positions;
201         ///
202         void menuInsertLyXFile(std::string const & filen);
203
204         /// this is used to handle XSelection events in the right manner
205         struct {
206                 CursorSlice cursor;
207                 CursorSlice anchor;
208                 bool set;
209         } xsel_cache_;
210         ///
211         LCursor cursor_;
212         ///
213         bool multiparsel_cache_;
214         ///
215         lyx::pit_type anchor_ref_;
216         ///
217         int offset_ref_;
218 };
219 #endif // BUFFERVIEW_PIMPL_H