]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
Use 'assign' as the name for the operation that opens/closes branch
[lyx.git] / src / BufferView_pimpl.h
1 // -*- C++ -*-
2 /**
3  * \file BufferView_pimpl.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Asger Alstrup
8  * \author Alfredo Braustein
9  * \author Lars Gullik Bjønnes
10  * \author John Levon
11  * \author André Pönitz
12  * \author Dekel Tsur
13  * \author Jürgen Vigna
14  *
15  * Full author contact details are available in file CREDITS.
16  */
17
18 #ifndef BUFFERVIEW_PIMPL_H
19 #define BUFFERVIEW_PIMPL_H
20
21 #include "BufferView.h"
22 #include "cursor.h"
23 #include "errorlist.h"
24
25 #include "insets/inset.h"
26
27 #include "frontends/key_state.h"
28 #include "frontends/Timeout.h"
29
30 #include "support/types.h"
31
32 #include <boost/scoped_ptr.hpp>
33 #include <boost/shared_ptr.hpp>
34 #include <boost/signals/trackable.hpp>
35
36
37 class Change;
38 class LyXKeySym;
39 class LyXView;
40 class WorkArea;
41 class LyXScreen;
42 class FuncRequest;
43 class FuncStatus;
44
45
46 ///
47 struct BufferView::Pimpl : public boost::signals::trackable {
48         ///
49         Pimpl(BufferView & bv, LyXView * owner,
50               int xpos, int ypos, int width, int height);
51         ///
52         Painter & painter() const;
53         /// return the screen for this bview
54         LyXScreen & screen() const;
55         ///
56         void setBuffer(Buffer * buf);
57         /// Return true if the cursor was fitted.
58         bool fitCursor();
59         ///
60         void redoCurrentBuffer();
61         ///
62         void resizeCurrentBuffer();
63         ///
64         void update();
65         ///
66         void newFile(std::string const &, std::string const &, bool);
67         ///
68         bool loadLyXFile(std::string const &, bool);
69         ///
70         void workAreaResize();
71         ///
72         void updateScrollbar();
73         ///
74         void scrollDocView(int value);
75         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
76         void scroll(int lines);
77         ///
78         typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
79         ///
80         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
81         ///
82         void selectionRequested();
83         ///
84         void selectionLost();
85         ///
86         void cursorToggle();
87         ///
88         bool available() const;
89         /// get the change at the cursor position
90         Change const getCurrentChange();
91         ///
92         void savePosition(unsigned int i);
93         ///
94         void restorePosition(unsigned int i);
95         ///
96         bool isSavedPosition(unsigned int i);
97         ///
98         void switchKeyMap();
99         ///
100         void center();
101         /// a function should be executed from the workarea
102         bool workAreaDispatch(FuncRequest const & ev);
103         /// return true for events that will handle
104         FuncStatus getStatus(FuncRequest const & cmd);
105         /// a function should be executed
106         bool dispatch(FuncRequest const & ev);
107         ///
108         int top_y() const;
109         ///
110         void top_y(int y);
111 private:
112         /// the y coordinate of the top of the screen
113         int top_y_;
114         /// An error list (replaces the error insets)
115         ErrorList errorlist_;
116         /// add an error to the list
117         void addError(ErrorItem const &);
118         /// buffer errors signal connection
119         boost::signals::connection errorConnection_;
120         /// buffer messages signal connection
121         boost::signals::connection messageConnection_;
122         /// buffer busy status signal connection
123         boost::signals::connection busyConnection_;
124         /// buffer title changed signal connection
125         boost::signals::connection titleConnection_;
126         /// buffer reset timers signal connection
127         boost::signals::connection timerConnection_;
128         /// buffer readonly status changed signal connection
129         boost::signals::connection readonlyConnection_;
130         /// buffer closing signal connection
131         boost::signals::connection closingConnection_;
132         /// connect to signals in the given buffer
133         void connectBuffer(Buffer & buf);
134         /// disconnect from signals in the given buffer
135         void disconnectBuffer();
136         /// track changes for the document
137         void trackChanges();
138         /// notify readonly status
139         void showReadonly(bool);
140
141
142         ///
143         friend class BufferView;
144
145         ///
146         BufferView * bv_;
147         ///
148         LyXView * owner_;
149         ///
150         Buffer * buffer_;
151         ///
152         boost::scoped_ptr<LyXScreen> screen_;
153         ///
154         boost::scoped_ptr<WorkArea> workarea_;
155         ///
156         Timeout cursor_timeout;
157         ///
158         void stuffClipboard(std::string const &) const;
159         ///
160         bool using_xterm_cursor;
161         ///
162         struct Position {
163                 /// Filename
164                 std::string filename;
165                 /// Cursor paragraph Id
166                 int par_id;
167                 /// Cursor position
168                 lyx::pos_type par_pos;
169                 ///
170                 Position() : par_id(0), par_pos(0) {}
171                 ///
172                 Position(std::string const & f, int id, lyx::pos_type pos)
173                         : filename(f), par_id(id), par_pos(pos) {}
174         };
175         ///
176         std::vector<Position> saved_positions;
177         /// Get next inset of this class from current cursor position
178         InsetBase * getInsetByCode(InsetBase::Code code);
179         ///
180         void MenuInsertLyXFile(std::string const & filen);
181         /// our workarea
182         WorkArea & workarea() const;
183         /// this is used to handle XSelection events in the right manner
184         struct {
185                 CursorSlice cursor;
186                 CursorSlice anchor;
187                 bool set;
188         } xsel_cache_;
189         ///
190         LCursor cursor_;
191 };
192 #endif // BUFFERVIEW_PIMPL_H