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