]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
John's Layout Tabular UI improvements and Martins fixes to clearing the
[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 enterView();
82         ///
83         void leaveView();
84         ///
85         void cursorToggle();
86         ///
87         void cursorPrevious(LyXText *);
88         ///
89         void cursorNext(LyXText *);
90         ///
91         bool available() const;
92         ///
93         void beforeChange(LyXText *);
94         ///
95         void savePosition(unsigned int i);
96         ///
97         void restorePosition(unsigned int i);
98         ///
99         bool isSavedPosition(unsigned int i);
100         ///
101         void setState();
102         ///
103         void insetSleep();
104         ///
105         void insetWakeup();
106         ///
107         void insetUnlock();
108         ///
109         bool focus() const;
110         ///
111         void focus(bool);
112         ///
113         bool active() const;
114         ///
115         bool belowMouse() const;
116         ///
117         void showCursor();
118         ///
119         void hideCursor();
120         ///
121         void toggleSelection(bool = true);
122         ///
123         void toggleToggle();
124         ///
125         void center();
126         ///
127         bool insertInset(Inset * inset, string const & lout = string());
128         ///
129         void updateInset(Inset * inset, bool mark_dirty);
130         ///
131         bool Dispatch(kb_action action, string const & argument);
132 private:
133         /**
134          * Return the on-screen dimensions of the inset at the cursor.
135          * Pre-condition: the cursor must be at an inset.
136          */
137         Box insetDimensions(LyXText const & text, LyXCursor const & cursor) const;
138         /**
139          * check if the given co-ordinates are inside an inset at the given cursor,
140          * if one exists. If so, the inset is returned, and the co-ordinates are
141          * made relative. Otherwise, 0 is returned.
142          */
143         Inset * checkInset(LyXText const & text, LyXCursor const & cursor, int & x, int & y) const; 
144         ///
145         friend class BufferView;
146         /// open and lock an updatable inset
147         bool open_new_inset(UpdatableInset * new_inset, bool behind = false);
148         ///
149         void protectedBlank(LyXText * lt);
150         /// 
151         void specialChar(InsetSpecialChar::Kind);
152         ///
153         void newline();
154         ///
155         void hfill();
156         ///
157         void smartQuote();
158         ///
159         void insertAndEditInset(Inset *);
160         ///
161         void gotoInset(std::vector<Inset::Code> const & codes,
162                        bool same_content);
163         ///
164         void gotoInset(Inset::Code codes, bool same_content);
165         ///
166         BufferView * bv_;
167         ///
168         LyXView * owner_;
169         ///
170         Buffer * buffer_;
171         ///
172         boost::scoped_ptr<LyXScreen> screen_;
173         ///
174         long current_scrollbar_value;
175         ///
176         Timeout cursor_timeout;
177         ///
178         WorkArea workarea_;
179         ///
180         UpdateInset updatelist;
181         ///
182         void pasteClipboard(bool asPara);
183         ///
184         void stuffClipboard(string const &) const;
185         ///
186         bool using_xterm_cursor;
187         ///
188         struct Position {
189                 /// Filename
190                 string filename;
191                 /// Cursor paragraph Id
192                 int par_id;
193                 /// Cursor position
194                 lyx::pos_type par_pos;
195                 ///
196                 Position() : par_id(0), par_pos(0) {}
197                 ///
198                 Position(string const & f, int id, lyx::pos_type pos)
199                         : filename(f), par_id(id), par_pos(pos) {}
200         };
201         ///
202         std::vector<Position> saved_positions;
203         ///
204         void moveCursorUpdate(bool selecting);
205         /// Get next inset of this class from current cursor position  
206         Inset * getInsetByCode(Inset::Code code);
207         ///
208         void MenuInsertLyXFile(string const & filen);
209         ///
210         bool inset_slept;
211 };
212 #endif