]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
revert last accidental commit and do the intended one
[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 "insets/inset.h"
26
27 #include "frontends/key_state.h"
28 #include "frontends/LyXKeySym.h"
29 #include "frontends/Timeout.h"
30
31 #include "support/types.h"
32
33 #include <boost/scoped_ptr.hpp>
34 #include <boost/shared_ptr.hpp>
35 #include <boost/signals/trackable.hpp>
36
37 class Change;
38 class LyXKeySym;
39 class LyXView;
40
41 class FuncRequest;
42 class FuncStatus;
43 class ViewMetricsInfo;
44
45 namespace lyx {
46 namespace frontend {
47 class Gui;
48 class WorkArea;
49 class Clipboard;
50 class Painter;
51 class GuiCursor;
52 }
53 }
54
55
56 ///
57 class BufferView::Pimpl : public boost::signals::trackable {
58 public:
59         ///
60         Pimpl(BufferView & bv, LyXView * owner, int width, int height);
61         ///
62         lyx::frontend::Painter & painter() const;
63         ///
64         void setBuffer(Buffer * buf);
65         ///
66         void resizeCurrentBuffer();
67         //
68         bool fitCursor();
69         //
70         bool multiParSel();
71         ///
72         void update(Update::flags flags = Update::Force);
73         ///
74         void newFile(std::string const &, std::string const &, bool);
75         ///
76         bool loadLyXFile(std::string const &, bool);
77         ///
78         void workAreaResize();
79         ///
80         void updateScrollbar();
81         ///
82         void scrollDocView(int value);
83         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
84         void scroll(int lines);
85         ///
86         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
87         ///
88         void selectionRequested();
89         ///
90         void selectionLost();
91         ///
92         void cursorToggle();
93         ///
94         bool available() const;
95         /// get the change at the cursor position
96         Change const getCurrentChange();
97         ///
98         void savePosition(unsigned int i);
99         ///
100         void restorePosition(unsigned int i);
101         ///
102         bool isSavedPosition(unsigned int i);
103         /// save bookmarks to .lyx/session
104         void saveSavedPositions();
105         ///
106         void switchKeyMap();
107         ///
108         void center();
109         /// a function should be executed from the workarea
110         bool workAreaDispatch(FuncRequest const & ev);
111         /// return true for events that will handle
112         FuncStatus getStatus(FuncRequest const & cmd);
113         /// a function should be executed
114         bool dispatch(FuncRequest const & ev);
115         /// Flag: do a full redraw of inside text of inset
116         bool repaintAll() { return refresh_inside_; }
117         ///
118         void repaintAll(bool r) {refresh_inside_ = r; }
119
120         /// the frontend
121         lyx::frontend::Gui & gui() const;
122         /// our workarea
123         lyx::frontend::WorkArea & workarea() const;
124         /// the clipboard
125         lyx::frontend::Clipboard & clipboard() const;
126
127 private:
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         void stuffClipboard(std::string const &) const;
172         ///
173         bool using_xterm_cursor;
174         ///
175         class Position {
176         public:
177                 /// Filename
178                 std::string filename;
179                 /// Cursor paragraph Id
180                 int par_id;
181                 /// Cursor position
182                 lyx::pos_type par_pos;
183                 ///
184                 Position() : par_id(0), par_pos(0) {}
185                 ///
186                 Position(std::string const & f, int id, lyx::pos_type pos)
187                         : filename(f), par_id(id), par_pos(pos) {}
188         };
189         ///
190         std::vector<Position> saved_positions;
191         ///
192         void menuInsertLyXFile(std::string const & filen);
193
194         lyx::frontend::WorkArea * workArea_;
195         int workAreaId_;
196
197         /// this is used to handle XSelection events in the right manner
198         struct {
199                 CursorSlice cursor;
200                 CursorSlice anchor;
201                 bool set;
202         } xsel_cache_;
203         ///
204         LCursor cursor_;
205         ///
206         bool multiparsel_cache_;
207         ///
208         lyx::pit_type anchor_ref_;
209         ///
210         int offset_ref_;
211         ///
212         ViewMetricsInfo metrics(bool singlepar = false);
213         /// Working variable indicating a full screen refresh
214         mutable bool refresh_inside_;
215
216 };
217 #endif // BUFFERVIEW_PIMPL_H