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