]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
* remove various xforms relicts, in particular:
[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 #include "frontends/Timeout.h"
28
29 #include "support/types.h"
30
31 #include <boost/signals/trackable.hpp>
32
33 class Change;
34 class LyXView;
35
36 class FuncRequest;
37 class FuncStatus;
38 class ViewMetricsInfo;
39
40 namespace lyx {
41 namespace frontend {
42 class Gui;
43 }
44 }
45
46
47 ///
48 class BufferView::Pimpl : public boost::signals::trackable {
49 public:
50         ///
51         Pimpl(BufferView & bv, LyXView * owner);
52         ///
53         void setBuffer(Buffer * buf);
54         ///
55         void resizeCurrentBuffer();
56         //
57         bool fitCursor();
58         //
59         bool multiParSel();
60         ///
61         void update(Update::flags flags = Update::Force);
62         ///
63         void newFile(std::string const &, std::string const &, bool);
64         ///
65         bool loadLyXFile(std::string const &, bool);
66         ///
67         void workAreaResize(int width, int height);
68         ///
69         void updateScrollbar();
70         ///
71         ScrollbarParameters const & scrollbarParameters() const;
72         ///
73         void scrollDocView(int value);
74         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
75         void scroll(int lines);
76         ///
77         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
78         ///
79         void selectionRequested();
80         ///
81         void selectionLost();
82         ///
83         void cursorToggle();
84         ///
85         bool available() const;
86         /// get the change at the cursor position
87         Change const getCurrentChange();
88         ///
89         void savePosition(unsigned int i);
90         ///
91         void restorePosition(unsigned int i);
92         ///
93         bool isSavedPosition(unsigned int i);
94         /// save bookmarks to .lyx/session
95         void saveSavedPositions();
96         ///
97         void switchKeyMap();
98         ///
99         void center();
100         /// a function should be executed from the workarea
101         bool workAreaDispatch(FuncRequest const & ev);
102         /// return true for events that will handle
103         FuncStatus getStatus(FuncRequest const & cmd);
104         /// a function should be executed
105         bool dispatch(FuncRequest const & ev);
106
107         /// the frontend
108         lyx::frontend::Gui & gui() const;
109
110         /// Width and height of the BufferView in Pixels
111         /**
112         This is set externally by the workAreaResize method.
113         */
114         int width() const;
115         /// Height of the BufferView in Pixels
116         /**
117         This is set externally by the workAreaResize method.
118         */
119         int height() const;
120
121         ///
122         ViewMetricsInfo const & viewMetricsInfo();
123 private:
124         ///
125         int width_;
126         ///
127         int height_;
128         ///
129         ScrollbarParameters scrollbarParameters_;
130
131         /// An error list (replaces the error insets)
132         ErrorList errorlist_;
133         /// add an error to the list
134         void addError(ErrorItem const &);
135         /// buffer errors signal connection
136         boost::signals::connection errorConnection_;
137         /// buffer messages signal connection
138         boost::signals::connection messageConnection_;
139         /// buffer busy status signal connection
140         boost::signals::connection busyConnection_;
141         /// buffer title changed signal connection
142         boost::signals::connection titleConnection_;
143         /// buffer reset timers signal connection
144         boost::signals::connection timerConnection_;
145         /// buffer readonly status changed signal connection
146         boost::signals::connection readonlyConnection_;
147         /// buffer closing signal connection
148         boost::signals::connection closingConnection_;
149         /// connect to signals in the given buffer
150         void connectBuffer(Buffer & buf);
151         /// disconnect from signals in the given buffer
152         void disconnectBuffer();
153         /// track changes for the document
154         void trackChanges();
155         /// notify readonly status
156         void showReadonly(bool);
157
158
159         ///
160         friend class BufferView;
161
162         ///
163         ViewMetricsInfo metrics_info_;
164         ///
165         void updateMetrics(bool singlepar = false);
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         bool using_xterm_cursor;
180         ///
181         class Position {
182         public:
183                 /// Filename
184                 std::string filename;
185                 /// Cursor paragraph Id
186                 int par_id;
187                 /// Cursor position
188                 lyx::pos_type par_pos;
189                 ///
190                 Position() : par_id(0), par_pos(0) {}
191                 ///
192                 Position(std::string const & f, int id, lyx::pos_type pos)
193                         : filename(f), par_id(id), par_pos(pos) {}
194         };
195         ///
196         std::vector<Position> saved_positions;
197         ///
198         void menuInsertLyXFile(std::string const & filen);
199
200         /// this is used to handle XSelection events in the right manner
201         struct {
202                 CursorSlice cursor;
203                 CursorSlice anchor;
204                 bool set;
205         } xsel_cache_;
206         ///
207         LCursor cursor_;
208         ///
209         bool multiparsel_cache_;
210         ///
211         lyx::pit_type anchor_ref_;
212         ///
213         int offset_ref_;
214 };
215 #endif // BUFFERVIEW_PIMPL_H