]> git.lyx.org Git - lyx.git/blob - src/BufferView_pimpl.h
1371bcd2f8382e4cecc99456720e8f30fa1679fe
[lyx.git] / src / BufferView_pimpl.h
1 // -*- C++ -*-
2 /**
3  * \file BufferView_pimpl.h
4  * Copyright 2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author various
8  */
9
10 #ifndef BUFFERVIEW_PIMPL_H
11 #define BUFFERVIEW_PIMPL_H
12
13 #include "errorlist.h"
14 #include "BufferView.h"
15 #include "frontends/Timeout.h"
16 #include "frontends/key_state.h"
17 #include "frontends/LyXKeySym.h"
18 #include "support/types.h"
19
20 #include <boost/scoped_ptr.hpp>
21 #include <boost/signals/trackable.hpp>
22
23
24 class Change;
25 class LyXView;
26 class WorkArea;
27 class LyXScreen;
28 class FuncRequest;
29
30 ///
31 struct BufferView::Pimpl : public boost::signals::trackable {
32         ///
33         Pimpl(BufferView * i, LyXView * o,
34               int xpos, int ypos, int width, int height);
35         ///
36         Painter & painter() const;
37         /// return the screen for this bview
38         LyXScreen & screen() const;
39         ///
40         void buffer(Buffer *);
41         /// Return true if the cursor was fitted.
42         bool fitCursor();
43         ///
44         void redoCurrentBuffer();
45         ///
46         void resizeCurrentBuffer();
47         ///
48         void update();
49         /**
50          * Repaint pixmap. Used for when we've made a visible
51          * change but don't need the full update() logic
52          */
53         ///
54         bool newFile(string const &, string const &, bool);
55         ///
56         bool loadLyXFile(string const &, bool);
57         ///
58         void workAreaResize();
59         ///
60         void updateScrollbar();
61         ///
62         void scrollDocView(int value);
63         /**
64          * Wheel mouse scroll, move by multiples of text->defaultRowHeight().
65          */
66         void scroll(int lines);
67         ///
68         void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
69         ///
70         void selectionRequested();
71         ///
72         void selectionLost();
73         ///
74         void cursorToggle();
75         ///
76         bool available() const;
77         /// get the change at the cursor position
78         Change const getCurrentChange();
79         ///
80         void beforeChange(LyXText *);
81         ///
82         void savePosition(unsigned int i);
83         ///
84         void restorePosition(unsigned int i);
85         ///
86         bool isSavedPosition(unsigned int i);
87         ///
88         void switchKeyMap();
89         ///
90         void insetUnlock();
91         ///
92         void toggleSelection(bool = true);
93         ///
94         void center();
95         ///
96         bool insertInset(InsetOld * inset, string const & lout = string());
97         ///
98         void updateInset();
99         /// a function should be executed from the workarea
100         bool workAreaDispatch(FuncRequest const & ev);
101         /// a function should be executed
102         bool dispatch(FuncRequest const & ev);
103 private:
104         /// An error list (replaces the error insets)
105         ErrorList errorlist_;
106         /// add an error to the list
107         void addError(ErrorItem const &);
108         /// buffer errors signal connection
109         boost::signals::connection errorConnection_;
110         /// buffer messages signal connection
111         boost::signals::connection messageConnection_;
112         /// buffer busy status signal connection
113         boost::signals::connection busyConnection_;
114         /// buffer title changed signal connection
115         boost::signals::connection titleConnection_;
116         /// buffer reset timers signal connection
117         boost::signals::connection timerConnection_;
118         /// buffer readonly status changed signal connection
119         boost::signals::connection readonlyConnection_;
120         /// buffer closing signal connection
121         boost::signals::connection closingConnection_;
122         /// connect to signals in the given buffer
123         void connectBuffer(Buffer & buf);
124         /// disconnect from signals in the given buffer
125         void disconnectBuffer();
126         /// track changes for the document
127         void trackChanges();
128         /// notify readonly status
129         void showReadonly(bool);
130
131         ///
132         friend class BufferView;
133
134         ///
135         BufferView * bv_;
136         ///
137         LyXView * owner_;
138         ///
139         Buffer * buffer_;
140         ///
141         boost::scoped_ptr<LyXScreen> screen_;
142         ///
143         boost::scoped_ptr<WorkArea> workarea_;
144         ///
145         Timeout cursor_timeout;
146         ///
147         void stuffClipboard(string const &) const;
148         ///
149         bool using_xterm_cursor;
150         ///
151         struct Position {
152                 /// Filename
153                 string filename;
154                 /// Cursor paragraph Id
155                 int par_id;
156                 /// Cursor position
157                 lyx::pos_type par_pos;
158                 ///
159                 Position() : par_id(0), par_pos(0) {}
160                 ///
161                 Position(string const & f, int id, lyx::pos_type pos)
162                         : filename(f), par_id(id), par_pos(pos) {}
163         };
164         ///
165         std::vector<Position> saved_positions;
166         /// Get next inset of this class from current cursor position
167         InsetOld * getInsetByCode(InsetOld::Code code);
168         ///
169         void MenuInsertLyXFile(string const & filen);
170         /// our workarea
171         WorkArea & workarea() const;
172 };
173 #endif // BUFFERVIEW_PIMPL_H