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