]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
* src/buffer_funcs.[Ch]
[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/LyXKeySym.h"
29 #include "frontends/Timeout.h"
30
31 #include "support/types.h"
32
33 #include <boost/scoped_ptr.hpp>
34 #include <boost/shared_ptr.hpp>
35 #include <boost/signals/trackable.hpp>
36
37
38 class Change;
39 class LyXKeySym;
40 class LyXView;
41 class WorkArea;
42 class LyXScreen;
43 class FuncRequest;
44 class FuncStatus;
45 class ViewMetricsInfo;
46
47
48 ///
49 class BufferView::Pimpl : public boost::signals::trackable {
50 public:
51         ///
52         Pimpl(BufferView & bv, LyXView * owner, int width, int height);
53         ///
54         Painter & painter() const;
55         /// return the screen for this bview
56         LyXScreen & screen() const;
57         ///
58         void setBuffer(Buffer * buf);
59         ///
60         void resizeCurrentBuffer();
61         //
62         bool fitCursor();
63         //
64         bool multiParSel();
65         ///
66         void update(Update::flags flags = Update::Force);
67         ///
68         void newFile(std::string const &, std::string const &, bool);
69         ///
70         bool loadLyXFile(std::string const &, bool);
71         ///
72         void workAreaResize();
73         ///
74         void updateScrollbar();
75         ///
76         void scrollDocView(int value);
77         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
78         void scroll(int lines);
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         /// save bookmarks to .lyx/session
98         void saveSavedPositions();
99         ///
100         void switchKeyMap();
101         ///
102         void center();
103         /// a function should be executed from the workarea
104         bool workAreaDispatch(FuncRequest const & ev);
105         /// return true for events that will handle
106         FuncStatus getStatus(FuncRequest const & cmd);
107         /// a function should be executed
108         bool dispatch(FuncRequest const & ev);
109         /// Flag: do a full redraw of inside text of inset
110         bool repaintAll() { return refresh_inside_; }
111         ///
112         void repaintAll(bool r) {refresh_inside_ = r; }
113 private:
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         /// Estimated average par height for scrollbar
156         int wh_;
157         ///
158         Timeout cursor_timeout;
159         ///
160         void stuffClipboard(std::string const &) const;
161         ///
162         bool using_xterm_cursor;
163         ///
164         class Position {
165         public:
166                 /// Filename
167                 std::string filename;
168                 /// Cursor paragraph Id
169                 int par_id;
170                 /// Cursor position
171                 lyx::pos_type par_pos;
172                 ///
173                 Position() : par_id(0), par_pos(0) {}
174                 ///
175                 Position(std::string const & f, int id, lyx::pos_type pos)
176                         : filename(f), par_id(id), par_pos(pos) {}
177         };
178         ///
179         std::vector<Position> saved_positions;
180         ///
181         void menuInsertLyXFile(std::string const & filen);
182         /// our workarea
183         WorkArea & workarea() const;
184         /// this is used to handle XSelection events in the right manner
185         struct {
186                 CursorSlice cursor;
187                 CursorSlice anchor;
188                 bool set;
189         } xsel_cache_;
190         ///
191         LCursor cursor_;
192         ///
193         bool multiparsel_cache_;
194         ///
195         lyx::pit_type anchor_ref_;
196         ///
197         int offset_ref_;
198         ///
199         ViewMetricsInfo metrics(bool singlepar = false);
200         /// Working variable indicating a full screen refresh
201         mutable bool refresh_inside_;
202
203 };
204 #endif // BUFFERVIEW_PIMPL_H