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