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