]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
revert recent change to development/FORMAT (don't change history)
[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 "metricsinfo.h"
24
25 #include "frontends/LyXKeySym.h"
26
27 #include "support/types.h"
28
29 class Change;
30 class LyXView;
31
32 class FuncRequest;
33 class FuncStatus;
34
35 namespace lyx {
36 namespace frontend {
37 class Gui;
38 }
39 }
40
41
42 ///
43 class BufferView::Pimpl {
44 public:
45         ///
46         Pimpl(BufferView & bv, LyXView * owner);
47         ///
48         void setBuffer(Buffer * buf);
49         /// return the first layout of the Buffer.
50         std::string firstLayout();
51         ///
52         void resizeCurrentBuffer();
53         //
54         bool fitCursor();
55         //
56         bool multiParSel();
57         ///
58         bool update(Update::flags flags = Update::Force);
59         /// load a buffer into the view
60         bool loadLyXFile(std::string const &, bool);
61         ///
62         void workAreaResize(int width, int height);
63         ///
64         void updateScrollbar();
65         ///
66         ScrollbarParameters const & scrollbarParameters() const;
67         ///
68         void scrollDocView(int value);
69         ///
70         void setCursorFromScrollbar();
71         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
72         void scroll(int lines);
73         ///
74         void selectionRequested();
75         ///
76         void selectionLost();
77         ///
78         bool available() const;
79         /// get the change at the cursor position
80         Change const getCurrentChange();
81         ///
82         void savePosition(unsigned int i);
83         ///
84         void restorePosition(unsigned int i);
85         ///
86         bool isSavedPosition(unsigned int i);
87         /// save bookmarks to .lyx/session
88         void saveSavedPositions();
89         ///
90         void switchKeyMap();
91         ///
92         void center();
93         /// a function should be executed from the workarea
94         bool workAreaDispatch(FuncRequest const & ev);
95         /// return true for events that will handle
96         FuncStatus getStatus(FuncRequest const & cmd);
97         /// a function should be executed
98         bool dispatch(FuncRequest const & ev);
99
100         /// Width and height of the BufferView in Pixels
101         /**
102         This is set externally by the workAreaResize method.
103         */
104         int width() const;
105         /// Height of the BufferView in Pixels
106         /**
107         This is set externally by the workAreaResize method.
108         */
109         int height() const;
110
111         ///
112         ViewMetricsInfo const & viewMetricsInfo();
113         ///
114         void updateMetrics(bool singlepar = false);
115
116 private:
117         ///
118         int width_;
119         ///
120         int height_;
121         ///
122         ScrollbarParameters scrollbarParameters_;
123
124         /// track changes for the document
125         void trackChanges();
126
127         ///
128         ViewMetricsInfo metrics_info_;
129
130         ///
131         friend class BufferView;
132
133         ///
134         BufferView * bv_;
135         ///
136         LyXView * owner_;
137         ///
138         Buffer * buffer_;
139
140         /// Estimated average par height for scrollbar
141         int wh_;
142         ///
143         class Position {
144         public:
145                 /// Filename
146                 std::string filename;
147                 /// Cursor paragraph Id
148                 int par_id;
149                 /// Cursor position
150                 lyx::pos_type par_pos;
151                 ///
152                 Position() : par_id(0), par_pos(0) {}
153                 ///
154                 Position(std::string const & f, int id, lyx::pos_type pos)
155                         : filename(f), par_id(id), par_pos(pos) {}
156         };
157         ///
158         std::vector<Position> saved_positions;
159         ///
160         void menuInsertLyXFile(std::string const & filen);
161
162         /// this is used to handle XSelection events in the right manner
163         struct {
164                 CursorSlice cursor;
165                 CursorSlice anchor;
166                 bool set;
167         } xsel_cache_;
168         ///
169         LCursor cursor_;
170         ///
171         bool multiparsel_cache_;
172         ///
173         lyx::pit_type anchor_ref_;
174         ///
175         int offset_ref_;
176
177 };
178 #endif // BUFFERVIEW_PIMPL_H