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