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