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