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