]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
e768918ac902a0d7335c70b888bd13a07a68f810
[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 cursorToggle();
94         ///
95         void cursorPrevious(LyXText *);
96         ///
97         void cursorNext(LyXText *);
98         ///
99         bool available() const;
100         ///
101         void beforeChange(LyXText *);
102         ///
103         void savePosition(unsigned int i);
104         ///
105         void restorePosition(unsigned int i);
106         ///
107         bool isSavedPosition(unsigned int i);
108         ///
109         void setState();
110 #if 0
111         ///
112         void insetSleep();
113         ///
114         void insetWakeup();
115 #endif
116         ///
117         void insetUnlock();
118         ///
119         bool focus() const;
120         ///
121         void focus(bool);
122         ///
123         void showCursor();
124         ///
125         void hideCursor();
126         ///
127         void toggleSelection(bool = true);
128         ///
129         void toggleToggle();
130         ///
131         void center();
132         ///
133         bool insertInset(Inset * inset, string const & lout = string());
134         ///
135         void updateInset(Inset * inset, bool mark_dirty);
136         ///
137         bool Dispatch(kb_action action, string const & argument);
138 private:
139         /**
140          * Return the on-screen dimensions of the inset at the cursor.
141          * Pre-condition: the cursor must be at an inset.
142          */
143         Box insetDimensions(LyXText const & text, LyXCursor const & cursor) const;
144         /**
145          * check if the given co-ordinates are inside an inset at the given cursor,
146          * if one exists. If so, the inset is returned, and the co-ordinates are
147          * made relative. Otherwise, 0 is returned.
148          */
149         Inset * checkInset(LyXText const & text, LyXCursor const & cursor, int & x, int & y) const;
150         ///
151         friend class BufferView;
152         /// open and lock an updatable inset
153         bool open_new_inset(UpdatableInset * new_inset, bool behind = false);
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<LScreen> screen_;
177         ///
178         boost::scoped_ptr<WorkArea> workarea_;
179         ///
180         long current_scrollbar_value;
181         ///
182         Timeout cursor_timeout;
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, bool fitcur = true);
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