]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
0a50076a715d23ff89abf574c524aefe62f686d2
[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 "errorlist.h"
14 #include "BufferView.h"
15 #include "frontends/Timeout.h"
16 #include "frontends/key_state.h"
17 #include "frontends/LyXKeySym.h"
18 #include "support/types.h"
19
20 #include <boost/scoped_ptr.hpp>
21 #include <boost/signals/trackable.hpp>
22
23
24 class Change;
25 class LyXView;
26 class WorkArea;
27 class LyXScreen;
28 class FuncRequest;
29
30 ///
31 struct BufferView::Pimpl : public boost::signals::trackable {
32         ///
33         Pimpl(BufferView * i, LyXView * o,
34               int xpos, int ypos, int width, int height);
35         ///
36         Painter & painter() const;
37         /// return the screen for this bview
38         LyXScreen & screen() const;
39         ///
40         void buffer(Buffer *);
41         /// Return true if the cursor was fitted.
42         bool fitCursor();
43         ///
44         void redoCurrentBuffer();
45         ///
46         int resizeCurrentBuffer();
47         ///
48         void update();
49         //
50         void update(LyXText *, BufferView::UpdateCodes);
51         /// update the toplevel lyx text
52         void update(BufferView::UpdateCodes);
53         /**
54          * Repaint pixmap. Used for when we've made a visible
55          * change but don't need the full update() logic
56          */
57         ///
58         bool newFile(string const &, string const &, bool);
59         ///
60         bool loadLyXFile(string const &, bool);
61         ///
62         void repaint();
63         ///
64         void workAreaResize();
65         ///
66         void updateScrollbar();
67         ///
68         void scrollDocView(int value);
69         /**
70          * Wheel mouse scroll, move by multiples of text->defaultRowHeight().
71          */
72         void scroll(int lines);
73         ///
74         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
75         ///
76         void selectionRequested();
77         ///
78         void selectionLost();
79         ///
80         void cursorToggle();
81         ///
82         bool available() const;
83         /// get the change at the cursor position
84         Change const getCurrentChange();
85         ///
86         void beforeChange(LyXText *);
87         ///
88         void savePosition(unsigned int i);
89         ///
90         void restorePosition(unsigned int i);
91         ///
92         bool isSavedPosition(unsigned int i);
93         ///
94         void switchKeyMap();
95         ///
96         void insetUnlock();
97         ///
98         void toggleSelection(bool = true);
99         ///
100         void toggleToggle();
101         ///
102         void center();
103         ///
104         bool insertInset(Inset * inset, string const & lout = string());
105         ///
106         void updateInset(Inset * inset);
107         /// a function should be executed from the workarea
108         bool workAreaDispatch(FuncRequest const & ev);
109         /// a function should be executed
110         bool dispatch(FuncRequest const & ev);
111 private:
112         /// An error list (replaces the error insets)
113         ErrorList errorlist_;
114         /// add an error to the list
115         void addError(ErrorItem const &);
116         /// buffer errors signal connection
117         boost::signals::connection errorConnection_;
118         /// buffer messages signal connection
119         boost::signals::connection messageConnection_;
120         /// buffer busy status signal connection
121         boost::signals::connection busyConnection_;
122         /// connect to signals in the given buffer
123         void connectBuffer(Buffer & buf);
124         /// disconnect from signals in the given buffer
125         void disconnectBuffer();
126         /// track changes for the document
127         void trackChanges();
128
129         ///
130         friend class BufferView;
131
132         ///
133         BufferView * bv_;
134         ///
135         LyXView * owner_;
136         ///
137         Buffer * buffer_;
138         ///
139         boost::scoped_ptr<LyXScreen> screen_;
140         ///
141         boost::scoped_ptr<WorkArea> workarea_;
142         ///
143         Timeout cursor_timeout;
144         ///
145         void stuffClipboard(string const &) const;
146         ///
147         bool using_xterm_cursor;
148         ///
149         struct Position {
150                 /// Filename
151                 string filename;
152                 /// Cursor paragraph Id
153                 int par_id;
154                 /// Cursor position
155                 lyx::pos_type par_pos;
156                 ///
157                 Position() : par_id(0), par_pos(0) {}
158                 ///
159                 Position(string const & f, int id, lyx::pos_type pos)
160                         : filename(f), par_id(id), par_pos(pos) {}
161         };
162         ///
163         std::vector<Position> saved_positions;
164         /// Get next inset of this class from current cursor position
165         Inset * getInsetByCode(Inset::Code code);
166         ///
167         void MenuInsertLyXFile(string const & filen);
168         /// our workarea
169         WorkArea & workarea() const;
170 };
171 #endif // BUFFERVIEW_PIMPL_H