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