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