]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
* src/bufferlist.C
[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         /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
70         void scroll(int lines);
71         ///
72         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
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         /// the frontend
101         lyx::frontend::Gui & gui() const;
102
103         /// Width and height of the BufferView in Pixels
104         /**
105         This is set externally by the workAreaResize method.
106         */
107         int width() const;
108         /// Height of the BufferView in Pixels
109         /**
110         This is set externally by the workAreaResize method.
111         */
112         int height() const;
113
114         ///
115         ViewMetricsInfo const & viewMetricsInfo();
116         ///
117         void updateMetrics(bool singlepar = false);
118
119 private:
120         ///
121         int width_;
122         ///
123         int height_;
124         ///
125         ScrollbarParameters scrollbarParameters_;
126
127         /// track changes for the document
128         void trackChanges();
129
130         ///
131         ViewMetricsInfo metrics_info_;
132
133         ///
134         friend class BufferView;
135
136         ///
137         BufferView * bv_;
138         ///
139         LyXView * owner_;
140         ///
141         Buffer * buffer_;
142
143         /// Estimated average par height for scrollbar
144         int wh_;
145         ///
146         class Position {
147         public:
148                 /// Filename
149                 std::string filename;
150                 /// Cursor paragraph Id
151                 int par_id;
152                 /// Cursor position
153                 lyx::pos_type par_pos;
154                 ///
155                 Position() : par_id(0), par_pos(0) {}
156                 ///
157                 Position(std::string const & f, int id, lyx::pos_type pos)
158                         : filename(f), par_id(id), par_pos(pos) {}
159         };
160         ///
161         std::vector<Position> saved_positions;
162         ///
163         void menuInsertLyXFile(std::string const & filen);
164
165         /// this is used to handle XSelection events in the right manner
166         struct {
167                 CursorSlice cursor;
168                 CursorSlice anchor;
169                 bool set;
170         } xsel_cache_;
171         ///
172         LCursor cursor_;
173         ///
174         bool multiparsel_cache_;
175         ///
176         lyx::pit_type anchor_ref_;
177         ///
178         int offset_ref_;
179
180 };
181 #endif // BUFFERVIEW_PIMPL_H