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