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