]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
de-boostification
[lyx.git] / src / frontends / LyXView.h
1 // -*- C++ -*-
2 /**
3  * \file LyXView.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef LYXVIEW_H
14 #define LYXVIEW_H
15
16 #include "frontends/Application.h"
17 #include "frontends/Delegates.h"
18 #include "support/docstring.h"
19
20 #include <vector>
21
22 namespace lyx {
23
24 namespace support { class FileName; }
25
26 class Font;
27 class Buffer;
28 class BufferView;
29 class FuncRequest;
30 class Inset;
31 class Timeout;
32 class ToolbarInfo;
33
34 namespace frontend {
35
36 class Dialogs;
37 class WorkArea;
38
39 /**
40  * LyXView - main LyX window
41  *
42  * This class represents the main LyX window and provides
43  * accessor functions to its content.
44  *
45  * The eventual intention is that LyX will support a number
46  * of containing LyXViews. Currently a lot of code still
47  * relies on there being a single top-level view.
48  *
49  * Additionally we would like to support multiple views
50  * in a single LyXView.
51  */
52 class LyXView
53         : public GuiBufferViewDelegate, public GuiBufferDelegate
54 {
55 public:
56         ///
57         LyXView(int id);
58         ///
59         virtual ~LyXView();
60         ///
61         int id() const { return id_; }
62         ///
63         virtual void close() = 0;
64         ///
65         virtual void setFocus() = 0;
66
67         ///
68         virtual WorkArea * workArea(Buffer & buffer) = 0;
69         ///
70         virtual WorkArea * addWorkArea(Buffer & buffer) = 0;
71         ///
72         virtual void setCurrentWorkArea(WorkArea * work_area) = 0;
73         ///
74         virtual void removeWorkArea(WorkArea * work_area) = 0;
75         /// return the current WorkArea (the one that has the focus).
76         virtual WorkArea const * currentWorkArea() const = 0;
77         /// FIXME: This non-const access is needed because of
78         /// a mis-designed \c ControlSpellchecker.
79         virtual WorkArea * currentWorkArea() = 0;
80
81         /**
82          * This is called after the concrete view has been created.
83          * We have to have the toolbar and the other stuff created
84          * before we can populate it with this call.
85          */
86         virtual void init() = 0;
87
88         enum Maximized {
89                 NotMaximized,
90                 VerticallyMaximized,
91                 HorizontallyMaximized,
92                 CompletelyMaximized
93         };
94
95         ///
96         virtual void setGeometry(
97                 unsigned int width,
98                 unsigned int height,
99                 int posx, int posy,
100                 int maximize,
101                 unsigned int iconSizeXY,
102                 const std::string & geometryArg) = 0;
103
104         /// save the geometry state in the session manager.
105         virtual void saveGeometry() = 0;
106
107         /// show busy cursor
108         virtual void setBusy(bool) = 0;
109
110         //@{ generic accessor functions
111
112         /// \return the current buffer view.
113         BufferView * view();
114
115         /// \return the buffer currently shown in this window
116         Buffer * buffer();
117         Buffer const * buffer() const;
118
119         ///
120         virtual void openLayoutList() = 0;
121         ///
122         virtual bool isToolbarVisible(std::string const & id) = 0;
123         ///
124         virtual void showMiniBuffer(bool visible) = 0;
125         virtual void openMenu(docstring const & name) = 0;
126
127         /// get access to the dialogs
128         Dialogs & getDialogs() { return *dialogs_; }
129         ///
130         Dialogs const & getDialogs() const { return *dialogs_; }
131
132         //@}
133
134         /// load a buffer into the current workarea.
135         Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
136                 bool tolastfiles = true);  ///< append to the "Open recent" menu?
137
138         /// set a buffer to the current workarea.
139         void setBuffer(Buffer * b); ///< \c Buffer to set.
140
141         /// updates the possible layouts selectable
142         virtual void updateLayoutChoice(bool force) = 0;
143
144         /// update the toolbar
145         virtual void updateToolbars() = 0;
146         /// get toolbar info
147         virtual ToolbarInfo * getToolbarInfo(std::string const & name) = 0;
148         /// toggle toolbar state
149         virtual void toggleToolbarState(std::string const & name, bool allowauto) = 0;
150         /// update the status bar
151         virtual void updateStatusBar() = 0;
152
153         /// display a message in the view
154         virtual void message(docstring const &) = 0;
155
156         /// clear any temporary message and replace with current status
157         virtual void clearMessage() = 0;
158
159         /// reset autosave timer
160         void resetAutosaveTimer();
161
162         /// dispatch to current BufferView
163         void dispatch(FuncRequest const & cmd);
164
165         /** redraw \c inset in all the BufferViews in which it is currently
166          *  visible. If successful return a pointer to the owning Buffer.
167          */
168         Buffer const * updateInset(Inset const *);
169
170         /// returns true if this view has the focus.
171         virtual bool hasFocus() const = 0;
172
173         /// show the error list to the user
174         void showErrorList(std::string const &);
175
176         
177         //
178         // GuiBufferDelegate
179         //
180         /// This function is called when the buffer structure is changed.
181         void structureChanged() { updateToc(); }
182         /// This function is called when some parsing error shows up.
183         void errors(std::string const & err) { showErrorList(err); }
184         /// Reset autosave timers for all users.
185         void resetAutosaveTimers() { resetAutosaveTimer(); }
186
187         /// connect to signals in the given BufferView
188         void connectBufferView(BufferView & bv);
189         /// disconnect from signals in the given BufferView
190         void disconnectBufferView();
191         /// connect to signals in the given buffer
192         void connectBuffer(Buffer & buf);
193         /// disconnect from signals in the given buffer
194         void disconnectBuffer();
195
196 private:
197         /// noncopyable
198         LyXView(LyXView const &);
199         void operator=(LyXView const &);
200
201         /// called on timeout
202         void autoSave();
203
204         /// auto-saving of buffers
205         Timeout * const autosave_timeout_;
206         /// dialogs for this view
207         Dialogs * dialogs_;
208
209         /// Bind methods for BufferView messages signal connection
210         //@{
211         void showDialog(std::string const & name);
212         void showDialogWithData(std::string const & name,
213                 std::string const & data);
214         void showInsetDialog(std::string const & name,
215                 std::string const & data, Inset * inset);
216         void updateDialog(std::string const & name,
217                 std::string const & data);
218         //@}
219
220 protected:
221         ///
222         void updateToc();
223         ///
224         void updateEmbeddedFiles();
225
226 private:
227         int id_;
228 };
229
230 } // namespace frontend
231 } // namespace lyx
232
233 #endif // LYXVIEW_H