]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
some more changes
[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         /// Return true if the cursor was fitted.
48         bool fitCursor();
49         ///
50         void redoCurrentBuffer();
51         ///
52         int resizeCurrentBuffer();
53         ///
54         void update();
55         //
56         void update(LyXText *, BufferView::UpdateCodes);
57         /**
58          * Repaint pixmap. Used for when we've made a visible
59          * change but don't need the full update() logic
60          */
61         void repaint();
62         ///
63         void workAreaResize();
64         ///
65         void updateScrollbar();
66         ///
67         void scrollDocView(int value);
68         /**
69          * Returns an inset if inset was hit, or 0 if not.
70          *
71          * If hit, the coordinates are changed relative to the inset.
72          */
73         Inset * checkInsetHit(LyXText *, int & x, int & y);
74         /// wheel mouse scroll
75         int scroll(long time);
76         ///
77         void workAreaKeyPress(LyXKeySymPtr key,
78                               key_modifier::state state);
79         ///
80         void workAreaMotionNotify(int x, int y, mouse_button::state state);
81         ///
82         void workAreaButtonPress(int x, int y, mouse_button::state button);
83         ///
84         void workAreaButtonRelease(int x, int y, mouse_button::state button);
85         ///
86         void doubleClick(int x, int y, mouse_button::state button);
87         ///
88         void tripleClick(int x, int y, mouse_button::state button);
89         ///
90         void selectionRequested();
91         ///
92         void selectionLost();
93         ///
94         void cursorToggle();
95         ///
96         void cursorPrevious(LyXText *);
97         ///
98         void cursorNext(LyXText *);
99         ///
100         bool available() const;
101         ///
102         void beforeChange(LyXText *);
103         ///
104         void savePosition(unsigned int i);
105         ///
106         void restorePosition(unsigned int i);
107         ///
108         bool isSavedPosition(unsigned int i);
109         ///
110         void setState();
111         ///
112         void insetUnlock();
113         ///
114         void showCursor();
115         ///
116         void hideCursor();
117         ///
118         void toggleSelection(bool = true);
119         ///
120         void toggleToggle();
121         ///
122         void center();
123         ///
124         bool insertInset(Inset * inset, string const & lout = string());
125         ///
126         void updateInset(Inset * inset, bool mark_dirty);
127         ///
128         bool Dispatch(kb_action action, string const & argument);
129 private:
130         /**
131          * Return the on-screen dimensions of the inset at the cursor.
132          * Pre-condition: the cursor must be at an inset.
133          */
134         Box insetDimensions(LyXText const & text, LyXCursor const & cursor) const;
135         /**
136          * check if the given co-ordinates are inside an inset at the given cursor,
137          * if one exists. If so, the inset is returned, and the co-ordinates are
138          * made relative. Otherwise, 0 is returned.
139          */
140         Inset * checkInset(LyXText const & text, LyXCursor const & cursor, int & x, int & y) const;
141         ///
142         friend class BufferView;
143         /// open and lock an updatable inset
144         bool open_new_inset(UpdatableInset * new_inset, bool behind = false);
145         ///
146         void specialChar(InsetSpecialChar::Kind);
147         ///
148         void newline();
149         ///
150         void hfill();
151         ///
152         void smartQuote();
153         ///
154         void insertAndEditInset(Inset *);
155         ///
156         void gotoInset(std::vector<Inset::Code> const & codes,
157                        bool same_content);
158         ///
159         void gotoInset(Inset::Code codes, bool same_content);
160         ///
161         BufferView * bv_;
162         ///
163         LyXView * owner_;
164         ///
165         Buffer * buffer_;
166         ///
167         boost::scoped_ptr<LyXScreen> screen_;
168         ///
169         boost::scoped_ptr<WorkArea> workarea_;
170         ///
171         Timeout cursor_timeout;
172         ///
173         void pasteClipboard(bool asPara);
174         ///
175         void stuffClipboard(string const &) const;
176         ///
177         bool using_xterm_cursor;
178         ///
179         struct Position {
180                 /// Filename
181                 string filename;
182                 /// Cursor paragraph Id
183                 int par_id;
184                 /// Cursor position
185                 lyx::pos_type par_pos;
186                 ///
187                 Position() : par_id(0), par_pos(0) {}
188                 ///
189                 Position(string const & f, int id, lyx::pos_type pos)
190                         : filename(f), par_id(id), par_pos(pos) {}
191         };
192         ///
193         std::vector<Position> saved_positions;
194         ///
195         void moveCursorUpdate(bool selecting, bool fitcur = true);
196         /// Get next inset of this class from current cursor position
197         Inset * getInsetByCode(Inset::Code code);
198         ///
199         void MenuInsertLyXFile(string const & filen);
200 };
201 #endif // BUFFERVIEW_PIMPL_H