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