]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
223a3e58b5e7d3713f547a5864cf12eb52d00211
[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 "errorlist.h"
23
24 #include "insets/inset.h"
25
26 #include "frontends/key_state.h"
27 #include "frontends/Timeout.h"
28
29 #include "support/types.h"
30
31 #include <boost/scoped_ptr.hpp>
32 #include <boost/shared_ptr.hpp>
33 #include <boost/signals/trackable.hpp>
34
35
36 class Change;
37 class LyXKeySym;
38 class LyXView;
39 class WorkArea;
40 class LyXScreen;
41 class FuncRequest;
42
43 ///
44 struct BufferView::Pimpl : public boost::signals::trackable {
45         ///
46         Pimpl(BufferView * i, LyXView * o,
47               int xpos, int ypos, int width, int height);
48         ///
49         Painter & painter() const;
50         /// return the screen for this bview
51         LyXScreen & screen() const;
52         ///
53         void buffer(Buffer *);
54         /// Return true if the cursor was fitted.
55         bool fitCursor();
56         ///
57         void redoCurrentBuffer();
58         ///
59         void resizeCurrentBuffer();
60         ///
61         void update();
62         /**
63          * Repaint pixmap. Used for when we've made a visible
64          * change but don't need the full update() logic
65          */
66         ///
67         bool newFile(string const &, string const &, bool);
68         ///
69         bool loadLyXFile(string const &, bool);
70         ///
71         void workAreaResize();
72         ///
73         void updateScrollbar();
74         ///
75         void scrollDocView(int value);
76         /**
77          * Wheel mouse scroll, move by multiples of text->defaultRowHeight().
78          */
79         void scroll(int lines);
80         ///
81         typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
82         ///
83         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
84         ///
85         void selectionRequested();
86         ///
87         void selectionLost();
88         ///
89         void cursorToggle();
90         ///
91         bool available() const;
92         /// get the change at the cursor position
93         Change const getCurrentChange();
94         ///
95         void beforeChange(LyXText *);
96         ///
97         void savePosition(unsigned int i);
98         ///
99         void restorePosition(unsigned int i);
100         ///
101         bool isSavedPosition(unsigned int i);
102         ///
103         void switchKeyMap();
104         ///
105         void insetUnlock();
106         ///
107         void center();
108         ///
109         bool insertInset(InsetOld * inset, string const & lout = string());
110         ///
111         void updateInset(InsetOld const * inset);
112         /// a function should be executed from the workarea
113         bool workAreaDispatch(FuncRequest const & ev);
114         /// a function should be executed
115         bool dispatch(FuncRequest const & ev);
116         ///
117         int top_y() const;
118         ///
119         void top_y(int y);
120 private:
121         /// the y coordinate of the top of the screen
122         int top_y_;
123         /// An error list (replaces the error insets)
124         ErrorList errorlist_;
125         /// add an error to the list
126         void addError(ErrorItem const &);
127         /// buffer errors signal connection
128         boost::signals::connection errorConnection_;
129         /// buffer messages signal connection
130         boost::signals::connection messageConnection_;
131         /// buffer busy status signal connection
132         boost::signals::connection busyConnection_;
133         /// buffer title changed signal connection
134         boost::signals::connection titleConnection_;
135         /// buffer reset timers signal connection
136         boost::signals::connection timerConnection_;
137         /// buffer readonly status changed signal connection
138         boost::signals::connection readonlyConnection_;
139         /// buffer closing signal connection
140         boost::signals::connection closingConnection_;
141         /// connect to signals in the given buffer
142         void connectBuffer(Buffer & buf);
143         /// disconnect from signals in the given buffer
144         void disconnectBuffer();
145         /// track changes for the document
146         void trackChanges();
147         /// notify readonly status
148         void showReadonly(bool);
149
150         /**
151          * Change all insets with the given code's contents to a new
152          * string. May only be used with InsetCommand-derived insets
153          * Returns true if a screen update is needed.
154          */
155         bool ChangeInsets(InsetOld::Code code, string const & from,
156                           string const & to);
157
158         ///
159         friend class BufferView;
160
161         ///
162         BufferView * bv_;
163         ///
164         LyXView * owner_;
165         ///
166         Buffer * buffer_;
167         ///
168         boost::scoped_ptr<LyXScreen> screen_;
169         ///
170         boost::scoped_ptr<WorkArea> workarea_;
171         ///
172         Timeout cursor_timeout;
173         ///
174         void stuffClipboard(string const &) const;
175         ///
176         bool using_xterm_cursor;
177         ///
178         struct Position {
179                 /// Filename
180                 string filename;
181                 /// Cursor paragraph Id
182                 int par_id;
183                 /// Cursor position
184                 lyx::pos_type par_pos;
185                 ///
186                 Position() : par_id(0), par_pos(0) {}
187                 ///
188                 Position(string const & f, int id, lyx::pos_type pos)
189                         : filename(f), par_id(id), par_pos(pos) {}
190         };
191         ///
192         std::vector<Position> saved_positions;
193         /// Get next inset of this class from current cursor position
194         InsetOld * getInsetByCode(InsetOld::Code code);
195         ///
196         void MenuInsertLyXFile(string const & filen);
197         /// our workarea
198         WorkArea & workarea() const;
199 };
200 #endif // BUFFERVIEW_PIMPL_H