]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
313e6c459b5d18622f2460c1cbea79f80c3cb138
[lyx.git] / src / BufferView_pimpl.h
1 // -*- C++ -*-
2
3 #ifndef BUFFERVIEW_PIMPL_H
4 #define BUFFERVIEW_PIMPL_H
5
6 #include "BufferView.h"
7 #include "commandtags.h"
8 #include "frontends/mouse_state.h"
9 #include "frontends/Timeout.h"
10 // FIXME remove me 
11 #include "frontends/WorkArea.h"
12 #include "box.h"
13 #include "insets/insetspecialchar.h"
14 #include "support/types.h"
15
16 #include <boost/scoped_ptr.hpp>
17
18 #ifdef __GNUG__
19 #pragma interface
20 #endif
21
22 class LyXView;
23 class WorkArea;
24 class LyXScreen;
25
26 ///
27 struct BufferView::Pimpl : public SigC::Object {
28         ///
29         Pimpl(BufferView * i, LyXView * o,
30               int xpos, int ypos, int width, int height);
31         ///
32         Painter & painter();
33         ///
34         void buffer(Buffer *);
35         ///
36         void resize(int xpos, int ypos, int width, int height);
37         ///
38         void resize();
39         ///
40         void redraw();
41         /// Return true if the cursor was fitted.
42         bool fitCursor();
43         ///
44         void redoCurrentBuffer();
45         ///
46         int resizeCurrentBuffer();
47         ///
48         void update();
49         //
50         void update(LyXText *, BufferView::UpdateCodes);
51         /// Update pixmap of screen
52         void updateScreen();
53         ///
54         void workAreaExpose();
55         ///
56         void updateScrollbar();
57         ///
58         void scrollCB(double value);
59         /**
60          * Returns an inset if inset was hit, or 0 if not.
61          *
62          * If hit, the coordinates are changed relative to the inset.
63          */
64         Inset * checkInsetHit(LyXText *, int & x, int & y);
65         ///
66         int scrollUp(long time);
67         ///
68         int scrollDown(long time);
69         ///
70         void workAreaKeyPress(KeySym, key_modifier::state state);
71         ///
72         void workAreaMotionNotify(int x, int y, mouse_button::state state);
73         ///
74         void workAreaButtonPress(int x, int y, mouse_button::state button);
75         ///
76         void workAreaButtonRelease(int x, int y, mouse_button::state button);
77         ///
78         void doubleClick(int x, int y, mouse_button::state button);
79         ///
80         void tripleClick(int x, int y, mouse_button::state button);
81         ///
82         void selectionRequested();
83         ///
84         void selectionLost();
85         ///
86         void enterView();
87         ///
88         void leaveView();
89         ///
90         void cursorToggle();
91         ///
92         void cursorPrevious(LyXText *);
93         ///
94         void cursorNext(LyXText *);
95         ///
96         bool available() const;
97         ///
98         void beforeChange(LyXText *);
99         ///
100         void savePosition(unsigned int i);
101         ///
102         void restorePosition(unsigned int i);
103         ///
104         bool isSavedPosition(unsigned int i);
105         ///
106         void setState();
107 #if 0
108         ///
109         void insetSleep();
110         ///
111         void insetWakeup();
112 #endif
113         ///
114         void insetUnlock();
115         ///
116         bool focus() const;
117         ///
118         void focus(bool);
119         ///
120         bool active() const;
121         ///
122         bool belowMouse() const;
123         ///
124         void showCursor();
125         ///
126         void hideCursor();
127         ///
128         void toggleSelection(bool = true);
129         ///
130         void toggleToggle();
131         ///
132         void center();
133         ///
134         bool insertInset(Inset * inset, string const & lout = string());
135         ///
136         void updateInset(Inset * inset, bool mark_dirty);
137         ///
138         bool Dispatch(kb_action action, string const & argument);
139 private:
140         /**
141          * Return the on-screen dimensions of the inset at the cursor.
142          * Pre-condition: the cursor must be at an inset.
143          */
144         Box insetDimensions(LyXText const & text, LyXCursor const & cursor) const;
145         /**
146          * check if the given co-ordinates are inside an inset at the given cursor,
147          * if one exists. If so, the inset is returned, and the co-ordinates are
148          * made relative. Otherwise, 0 is returned.
149          */
150         Inset * checkInset(LyXText const & text, LyXCursor const & cursor, int & x, int & y) const;
151         ///
152         friend class BufferView;
153         /// open and lock an updatable inset
154         bool open_new_inset(UpdatableInset * new_inset, bool behind = false);
155         ///
156         void specialChar(InsetSpecialChar::Kind);
157         ///
158         void newline();
159         ///
160         void hfill();
161         ///
162         void smartQuote();
163         ///
164         void insertAndEditInset(Inset *);
165         ///
166         void gotoInset(std::vector<Inset::Code> const & codes,
167                        bool same_content);
168         ///
169         void gotoInset(Inset::Code codes, bool same_content);
170         ///
171         BufferView * bv_;
172         ///
173         LyXView * owner_;
174         ///
175         Buffer * buffer_;
176         ///
177         boost::scoped_ptr<LyXScreen> screen_;
178         ///
179         long current_scrollbar_value;
180         ///
181         Timeout cursor_timeout;
182         ///
183         WorkArea workarea_;
184         ///
185         void pasteClipboard(bool asPara);
186         ///
187         void stuffClipboard(string const &) const;
188         ///
189         bool using_xterm_cursor;
190         ///
191         struct Position {
192                 /// Filename
193                 string filename;
194                 /// Cursor paragraph Id
195                 int par_id;
196                 /// Cursor position
197                 lyx::pos_type par_pos;
198                 ///
199                 Position() : par_id(0), par_pos(0) {}
200                 ///
201                 Position(string const & f, int id, lyx::pos_type pos)
202                         : filename(f), par_id(id), par_pos(pos) {}
203         };
204         ///
205         std::vector<Position> saved_positions;
206         ///
207         void moveCursorUpdate(bool selecting, bool fitcur = true);
208         /// Get next inset of this class from current cursor position
209         Inset * getInsetByCode(Inset::Code code);
210         ///
211         void MenuInsertLyXFile(string const & filen);
212         ///
213         bool inset_slept;
214 };
215 #endif