]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
Make signals and slots to not be defined, and replace them with Q_SIGNALS and Q_SLOTS
[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 WorkArea;
43 class Painter;
44 }
45 }
46
47
48 ///
49 class BufferView::Pimpl : public boost::signals::trackable {
50 public:
51         ///
52         Pimpl(BufferView & bv, LyXView * owner, lyx::frontend::WorkArea * workArea);
53         ///
54         lyx::frontend::Painter & painter() const;
55         ///
56         void setBuffer(Buffer * buf);
57         ///
58         void resizeCurrentBuffer();
59         //
60         bool fitCursor();
61         //
62         bool multiParSel();
63         ///
64         void update(Update::flags flags = Update::Force);
65         ///
66         void newFile(std::string const &, std::string const &, bool);
67         ///
68         bool loadLyXFile(std::string const &, bool);
69         ///
70         void workAreaResize(int width, int height);
71         ///
72         void updateScrollbar();
73         ///
74         ScrollbarParameters const & scrollbarParameters() const;
75         ///
76         void scrollDocView(int value);
77         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
78         void scroll(int lines);
79         ///
80         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
81         ///
82         void selectionRequested();
83         ///
84         void selectionLost();
85         ///
86         void cursorToggle();
87         ///
88         bool available() const;
89         /// get the change at the cursor position
90         Change const getCurrentChange();
91         ///
92         void savePosition(unsigned int i);
93         ///
94         void restorePosition(unsigned int i);
95         ///
96         bool isSavedPosition(unsigned int i);
97         /// save bookmarks to .lyx/session
98         void saveSavedPositions();
99         ///
100         void switchKeyMap();
101         ///
102         void center();
103         /// a function should be executed from the workarea
104         bool workAreaDispatch(FuncRequest const & ev);
105         /// return true for events that will handle
106         FuncStatus getStatus(FuncRequest const & cmd);
107         /// a function should be executed
108         bool dispatch(FuncRequest const & ev);
109         /// Flag: do a full redraw of inside text of inset
110         bool repaintAll() { return refresh_inside_; }
111         ///
112         void repaintAll(bool r) {refresh_inside_ = r; }
113
114         /// the frontend
115         lyx::frontend::Gui & gui() const;
116
117         /// Width and height of the BufferView in Pixels
118         /**
119         This is set externally by the workAreaResize method.
120         */
121         int width() const;
122         /// Height of the BufferView in Pixels
123         /**
124         This is set externally by the workAreaResize method.
125         */
126         int height() const;
127
128 private:
129         ///
130         int width_;
131         ///
132         int height_;
133         ///
134         ScrollbarParameters scrollbarParameters_;
135
136         /// An error list (replaces the error insets)
137         ErrorList errorlist_;
138         /// add an error to the list
139         void addError(ErrorItem const &);
140         /// buffer errors signal connection
141         boost::signals::connection errorConnection_;
142         /// buffer messages signal connection
143         boost::signals::connection messageConnection_;
144         /// buffer busy status signal connection
145         boost::signals::connection busyConnection_;
146         /// buffer title changed signal connection
147         boost::signals::connection titleConnection_;
148         /// buffer reset timers signal connection
149         boost::signals::connection timerConnection_;
150         /// buffer readonly status changed signal connection
151         boost::signals::connection readonlyConnection_;
152         /// buffer closing signal connection
153         boost::signals::connection closingConnection_;
154         /// connect to signals in the given buffer
155         void connectBuffer(Buffer & buf);
156         /// disconnect from signals in the given buffer
157         void disconnectBuffer();
158         /// track changes for the document
159         void trackChanges();
160         /// notify readonly status
161         void showReadonly(bool);
162
163
164         ///
165         friend class BufferView;
166
167         ///
168         BufferView * bv_;
169         ///
170         LyXView * owner_;
171         ///
172         Buffer * buffer_;
173
174         /// Estimated average par height for scrollbar
175         int wh_;
176         ///
177         Timeout cursor_timeout;
178         ///
179         void stuffClipboard(std::string const &) const;
180         ///
181         bool using_xterm_cursor;
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         lyx::frontend::WorkArea * workArea_;
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         ViewMetricsInfo metrics(bool singlepar = false);
220         /// Working variable indicating a full screen refresh
221         mutable bool refresh_inside_;
222
223 };
224 #endif // BUFFERVIEW_PIMPL_H