]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
bug 2298: cursorTop/Bottom/Home/End does not redraw after dEPM
[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 class BufferView::Pimpl : public boost::signals::trackable {
49 public:
50         ///
51         Pimpl(BufferView & bv, LyXView * owner, int width, int height);
52         ///
53         Painter & painter() const;
54         /// return the screen for this bview
55         LyXScreen & screen() const;
56         ///
57         void setBuffer(Buffer * buf);
58         ///
59         void resizeCurrentBuffer();
60         //
61         bool fitCursor();
62         //
63         bool multiParSel();
64         ///
65         void update(Update::flags flags = Update::Force);
66         ///
67         void newFile(std::string const &, std::string const &, bool);
68         ///
69         bool loadLyXFile(std::string const &, bool);
70         ///
71         void workAreaResize();
72         ///
73         void updateScrollbar();
74         ///
75         void scrollDocView(int value);
76         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
77         void scroll(int lines);
78         ///
79         typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
80         ///
81         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
82         ///
83         void selectionRequested();
84         ///
85         void selectionLost();
86         ///
87         void cursorToggle();
88         ///
89         bool available() const;
90         /// get the change at the cursor position
91         Change const getCurrentChange();
92         ///
93         void savePosition(unsigned int i);
94         ///
95         void restorePosition(unsigned int i);
96         ///
97         bool isSavedPosition(unsigned int i);
98         ///
99         void switchKeyMap();
100         ///
101         void center();
102         /// a function should be executed from the workarea
103         bool workAreaDispatch(FuncRequest const & ev);
104         /// return true for events that will handle
105         FuncStatus getStatus(FuncRequest const & cmd);
106         /// a function should be executed
107         bool dispatch(FuncRequest const & ev);
108         /// Flag: do a full redraw of inside text of inset
109         bool repaintAll() { return refresh_inside_; }
110         ///
111         void repaintAll(bool r) {refresh_inside_ = r; }
112 private:
113         /// An error list (replaces the error insets)
114         ErrorList errorlist_;
115         /// add an error to the list
116         void addError(ErrorItem const &);
117         /// buffer errors signal connection
118         boost::signals::connection errorConnection_;
119         /// buffer messages signal connection
120         boost::signals::connection messageConnection_;
121         /// buffer busy status signal connection
122         boost::signals::connection busyConnection_;
123         /// buffer title changed signal connection
124         boost::signals::connection titleConnection_;
125         /// buffer reset timers signal connection
126         boost::signals::connection timerConnection_;
127         /// buffer readonly status changed signal connection
128         boost::signals::connection readonlyConnection_;
129         /// buffer closing signal connection
130         boost::signals::connection closingConnection_;
131         /// connect to signals in the given buffer
132         void connectBuffer(Buffer & buf);
133         /// disconnect from signals in the given buffer
134         void disconnectBuffer();
135         /// track changes for the document
136         void trackChanges();
137         /// notify readonly status
138         void showReadonly(bool);
139
140
141         ///
142         friend class BufferView;
143
144         ///
145         BufferView * bv_;
146         ///
147         LyXView * owner_;
148         ///
149         Buffer * buffer_;
150         ///
151         boost::scoped_ptr<LyXScreen> screen_;
152         ///
153         boost::scoped_ptr<WorkArea> workarea_;
154         /// Estimated average par height for scrollbar
155         int wh_;
156         ///
157         Timeout cursor_timeout;
158         ///
159         void stuffClipboard(std::string const &) const;
160         ///
161         bool using_xterm_cursor;
162         ///
163         class Position {
164         public:
165                 /// Filename
166                 std::string filename;
167                 /// Cursor paragraph Id
168                 int par_id;
169                 /// Cursor position
170                 lyx::pos_type par_pos;
171                 ///
172                 Position() : par_id(0), par_pos(0) {}
173                 ///
174                 Position(std::string const & f, int id, lyx::pos_type pos)
175                         : filename(f), par_id(id), par_pos(pos) {}
176         };
177         ///
178         std::vector<Position> saved_positions;
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         bool multiparsel_cache_;
193         ///
194         lyx::pit_type anchor_ref_;
195         ///
196         int offset_ref_;
197         ///
198         ViewMetricsInfo metrics(bool singlepar = false);
199         /// Working variable indicating a full screen refresh
200         mutable bool refresh_inside_;
201         
202 };
203 #endif // BUFFERVIEW_PIMPL_H