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.
7 * \author Asger Alstrup
8 * \author Alfredo Braustein
9 * \author Lars Gullik Bjønnes
11 * \author André Pönitz
13 * \author Jürgen Vigna
15 * Full author contact details are available in file CREDITS.
18 #ifndef BUFFERVIEW_PIMPL_H
19 #define BUFFERVIEW_PIMPL_H
21 #include "BufferView.h"
23 #include "errorlist.h"
25 #include "insets/inset.h"
27 #include "frontends/key_state.h"
28 #include "frontends/LyXKeySym.h"
29 #include "frontends/Timeout.h"
31 #include "support/types.h"
33 #include <boost/scoped_ptr.hpp>
34 #include <boost/shared_ptr.hpp>
35 #include <boost/signals/trackable.hpp>
45 class ViewMetricsInfo;
49 class BufferView::Pimpl : public boost::signals::trackable {
52 Pimpl(BufferView & bv, LyXView * owner, int width, int height);
54 Painter & painter() const;
55 /// return the screen for this bview
56 LyXScreen & screen() const;
58 void setBuffer(Buffer * buf);
60 void resizeCurrentBuffer();
66 void update(Update::flags flags = Update::Force);
68 void newFile(std::string const &, std::string const &, bool);
70 bool loadLyXFile(std::string const &, bool);
72 void workAreaResize();
74 void updateScrollbar();
76 void scrollDocView(int value);
77 /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
78 void scroll(int lines);
80 void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
82 void selectionRequested();
88 bool available() const;
89 /// get the change at the cursor position
90 Change const getCurrentChange();
92 void savePosition(unsigned int i);
94 void restorePosition(unsigned int i);
96 bool isSavedPosition(unsigned int i);
97 /// save bookmarks to .lyx/session
98 void saveSavedPositions();
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_; }
112 void repaintAll(bool r) {refresh_inside_ = r; }
114 /// An error list (replaces the error insets)
115 ErrorList errorlist_;
116 /// add an error to the list
117 void addError(ErrorItem const &);
118 /// buffer errors signal connection
119 boost::signals::connection errorConnection_;
120 /// buffer messages signal connection
121 boost::signals::connection messageConnection_;
122 /// buffer busy status signal connection
123 boost::signals::connection busyConnection_;
124 /// buffer title changed signal connection
125 boost::signals::connection titleConnection_;
126 /// buffer reset timers signal connection
127 boost::signals::connection timerConnection_;
128 /// buffer readonly status changed signal connection
129 boost::signals::connection readonlyConnection_;
130 /// buffer closing signal connection
131 boost::signals::connection closingConnection_;
132 /// connect to signals in the given buffer
133 void connectBuffer(Buffer & buf);
134 /// disconnect from signals in the given buffer
135 void disconnectBuffer();
136 /// track changes for the document
138 /// notify readonly status
139 void showReadonly(bool);
143 friend class BufferView;
152 boost::scoped_ptr<LyXScreen> screen_;
154 boost::scoped_ptr<WorkArea> workarea_;
155 /// Estimated average par height for scrollbar
158 Timeout cursor_timeout;
160 void stuffClipboard(std::string const &) const;
162 bool using_xterm_cursor;
167 std::string filename;
168 /// Cursor paragraph Id
171 lyx::pos_type par_pos;
173 Position() : par_id(0), par_pos(0) {}
175 Position(std::string const & f, int id, lyx::pos_type pos)
176 : filename(f), par_id(id), par_pos(pos) {}
179 std::vector<Position> saved_positions;
181 void menuInsertLyXFile(std::string const & filen);
183 WorkArea & workarea() const;
184 /// this is used to handle XSelection events in the right manner
193 bool multiparsel_cache_;
195 lyx::pit_type anchor_ref_;
199 ViewMetricsInfo metrics(bool singlepar = false);
200 /// Working variable indicating a full screen refresh
201 mutable bool refresh_inside_;
204 #endif // BUFFERVIEW_PIMPL_H