]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
Get rid of extraneous whitespace.
[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 class ViewMetricsInfo;
45
46
47 ///
48 struct BufferView::Pimpl : public boost::signals::trackable {
49         ///
50         Pimpl(BufferView & bv, LyXView * owner, 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         ///
58         void resizeCurrentBuffer();
59         //
60         bool fitCursor();
61         ///
62         void update(bool fitcursor = false, bool forceupdate = true);
63         ///
64         void newFile(std::string const &, std::string const &, bool);
65         ///
66         bool loadLyXFile(std::string const &, bool);
67         ///
68         void workAreaResize();
69         ///
70         void updateScrollbar();
71         ///
72         void scrollDocView(int value);
73         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
74         void scroll(int lines);
75         ///
76         typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
77         ///
78         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
79         ///
80         void selectionRequested();
81         ///
82         void selectionLost();
83         ///
84         void cursorToggle();
85         ///
86         bool available() const;
87         /// get the change at the cursor position
88         Change const getCurrentChange();
89         ///
90         void savePosition(unsigned int i);
91         ///
92         void restorePosition(unsigned int i);
93         ///
94         bool isSavedPosition(unsigned int i);
95         ///
96         void switchKeyMap();
97         ///
98         void center();
99         /// a function should be executed from the workarea
100         bool workAreaDispatch(FuncRequest const & ev);
101         /// return true for events that will handle
102         FuncStatus getStatus(FuncRequest const & cmd);
103         /// a function should be executed
104         bool dispatch(FuncRequest const & ev);
105 private:
106         /// An error list (replaces the error insets)
107         ErrorList errorlist_;
108         /// add an error to the list
109         void addError(ErrorItem const &);
110         /// buffer errors signal connection
111         boost::signals::connection errorConnection_;
112         /// buffer messages signal connection
113         boost::signals::connection messageConnection_;
114         /// buffer busy status signal connection
115         boost::signals::connection busyConnection_;
116         /// buffer title changed signal connection
117         boost::signals::connection titleConnection_;
118         /// buffer reset timers signal connection
119         boost::signals::connection timerConnection_;
120         /// buffer readonly status changed signal connection
121         boost::signals::connection readonlyConnection_;
122         /// buffer closing signal connection
123         boost::signals::connection closingConnection_;
124         /// connect to signals in the given buffer
125         void connectBuffer(Buffer & buf);
126         /// disconnect from signals in the given buffer
127         void disconnectBuffer();
128         /// track changes for the document
129         void trackChanges();
130         /// notify readonly status
131         void showReadonly(bool);
132
133
134         ///
135         friend class BufferView;
136
137         ///
138         BufferView * bv_;
139         ///
140         LyXView * owner_;
141         ///
142         Buffer * buffer_;
143         ///
144         boost::scoped_ptr<LyXScreen> screen_;
145         ///
146         boost::scoped_ptr<WorkArea> workarea_;
147         ///
148         Timeout cursor_timeout;
149         ///
150         void stuffClipboard(std::string const &) const;
151         ///
152         bool using_xterm_cursor;
153         ///
154         struct Position {
155                 /// Filename
156                 std::string filename;
157                 /// Cursor paragraph Id
158                 int par_id;
159                 /// Cursor position
160                 lyx::pos_type par_pos;
161                 ///
162                 Position() : par_id(0), par_pos(0) {}
163                 ///
164                 Position(std::string const & f, int id, lyx::pos_type pos)
165                         : filename(f), par_id(id), par_pos(pos) {}
166         };
167         ///
168         std::vector<Position> saved_positions;
169         ///
170         void MenuInsertLyXFile(std::string const & filen);
171         /// our workarea
172         WorkArea & workarea() const;
173         /// this is used to handle XSelection events in the right manner
174         struct {
175                 CursorSlice cursor;
176                 CursorSlice anchor;
177                 bool set;
178         } xsel_cache_;
179         ///
180         LCursor cursor_;
181         ///
182         ///
183         lyx::pit_type anchor_ref_;
184         ///
185         int offset_ref_;
186         ///
187         ViewMetricsInfo metrics();
188
189
190 };
191 #endif // BUFFERVIEW_PIMPL_H