]> git.lyx.org Git - features.git/blob - src/frontends/LyXView.h
Remove warnings reported with gcc 4.3:
[features.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/Toolbars.h"
18
19 #include "LyXFunc.h"
20
21 #include <boost/scoped_ptr.hpp>
22 #include <boost/signal.hpp>
23 #include <boost/signals/trackable.hpp>
24 #include <boost/utility.hpp>
25
26 #include <vector>
27
28 namespace lyx {
29
30 namespace support { class FileName; }
31
32 class Font;
33 class Buffer;
34 class BufferView;
35 class FuncRequest;
36 class Inset;
37 class LyXFunc;
38 class Timeout;
39
40 namespace frontend {
41
42 class Dialogs;
43 class WorkArea;
44
45 /**
46  * LyXView - main LyX window
47  *
48  * This class represents the main LyX window and provides
49  * accessor functions to its content.
50  *
51  * The eventual intention is that LyX will support a number
52  * of containing LyXViews. Currently a lot of code still
53  * relies on there being a single top-level view.
54  *
55  * Additionally we would like to support multiple views
56  * in a single LyXView.
57  */
58 class LyXView : public boost::signals::trackable, boost::noncopyable {
59 public:
60
61         LyXView(int id);
62
63         virtual ~LyXView();
64
65         int id() const { return id_; }
66
67         virtual void close() = 0;
68
69         virtual void setFocus() = 0;
70
71         ///
72         virtual WorkArea * workArea(Buffer & buffer) = 0;
73         ///
74         virtual WorkArea * addWorkArea(Buffer & buffer) = 0;
75         ///
76         virtual void setCurrentWorkArea(WorkArea * work_area) = 0;
77         ///
78         virtual void removeWorkArea(WorkArea * work_area) = 0;
79         /// return the current WorkArea (the one that has the focus).
80         virtual WorkArea const * currentWorkArea() const = 0;
81         /// FIXME: This non-const access is needed because of
82         /// a mis-designed \c ControlSpellchecker.
83         virtual WorkArea * currentWorkArea() = 0;
84
85         /**
86          * This is called after the concrete view has been created.
87          * We have to have the toolbar and the other stuff created
88          * before we can populate it with this call.
89          */
90         virtual void init() = 0;
91
92         enum Maximized {
93                 NotMaximized,
94                 VerticallyMaximized,
95                 HorizontallyMaximized,
96                 CompletelyMaximized
97         };
98
99         ///
100         virtual void setGeometry(
101                 unsigned int width,
102                 unsigned int height,
103                 int posx, int posy,
104                 int maximize,
105                 unsigned int iconSizeXY,
106                 const std::string & geometryArg) = 0;
107
108         /// save the geometry state in the session manager.
109         virtual void saveGeometry() = 0;
110
111         /// show busy cursor
112         virtual void busy(bool) = 0;
113
114         virtual Toolbars::ToolbarPtr makeToolbar(ToolbarInfo const & tbinfo, bool newline) = 0;
115
116         //@{ generic accessor functions
117
118         /// \return the current buffer view.
119         BufferView * view();
120
121         /// \return the buffer currently shown in this window
122         Buffer * buffer();
123         Buffer const * buffer() const;
124
125         ///
126         void openLayoutList();
127         ///
128         bool isToolbarVisible(std::string const & id);
129         ///
130         virtual void showMiniBuffer(bool visible) = 0;
131         virtual void openMenu(docstring const & name) = 0;
132
133         /// get access to the dialogs
134         Dialogs & getDialogs() { return *dialogs_.get(); }
135         ///
136         Dialogs const & getDialogs() const { return *dialogs_.get(); }
137
138         //@}
139
140         /// load a buffer into the current workarea.
141         Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
142                 bool tolastfiles = true);  ///< append to the "Open recent" menu?
143
144         /// set a buffer to the current workarea.
145         void setBuffer(Buffer * b); ///< \c Buffer to set.
146
147         /// updates the possible layouts selectable
148         void updateLayoutChoice();
149
150         /// update the toolbar
151         void updateToolbars();
152         /// get toolbar info
153         ToolbarInfo * getToolbarInfo(std::string const & name);
154         /// toggle toolbar state
155         void toggleToolbarState(std::string const & name, bool allowauto);
156         /// update the status bar
157         virtual void updateStatusBar() = 0;
158
159         /// display a message in the view
160         virtual void message(docstring const &) = 0;
161
162         /// clear any temporary message and replace with current status
163         virtual void clearMessage() = 0;
164
165         /// updates the title of the window
166         void updateWindowTitle();
167
168         /// reset autosave timer
169         void resetAutosaveTimer();
170
171         /// dispatch to current BufferView
172         void dispatch(FuncRequest const & cmd);
173
174         /** redraw \c inset in all the BufferViews in which it is currently
175          *  visible. If successful return a pointer to the owning Buffer.
176          */
177         Buffer const * updateInset(Inset const *);
178
179         /// returns true if this view has the focus.
180         virtual bool hasFocus() const = 0;
181
182         /// show the error list to the user
183         void showErrorList(std::string const &);
184
185 protected:
186         /// connect to signals in the given BufferView
187         void connectBufferView(BufferView & bv);
188         /// disconnect from signals in the given BufferView
189         void disconnectBufferView();
190         /// connect to signals in the given buffer
191         void connectBuffer(Buffer & buf);
192         /// disconnect from signals in the given buffer
193         void disconnectBuffer();
194
195         /// view's toolbar
196         boost::scoped_ptr<Toolbars> toolbars_;
197
198 private:
199         /**
200          * setWindowTitle - set title of window
201          * @param t main window title
202          * @param it iconified (short) title
203          */
204         virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
205
206         /// called on timeout
207         void autoSave();
208
209         /// auto-saving of buffers
210         boost::scoped_ptr<Timeout> const autosave_timeout_;
211         /// our function handler
212         boost::scoped_ptr<LyXFunc> lyxfunc_;
213         /// dialogs for this view
214         boost::scoped_ptr<Dialogs> dialogs_;
215
216         /// buffer structure changed signal connection
217         boost::signals::connection bufferStructureChangedConnection_;
218         /// embedded file change signal connection
219         boost::signals::connection bufferEmbeddingChangedConnection_;
220         /// buffer errors signal connection
221         boost::signals::connection errorsConnection_;
222         /// buffer messages signal connection
223         boost::signals::connection messageConnection_;
224         /// buffer busy status signal connection
225         boost::signals::connection busyConnection_;
226         /// buffer title changed signal connection
227         boost::signals::connection titleConnection_;
228         /// buffer reset timers signal connection
229         boost::signals::connection timerConnection_;
230         /// buffer readonly status changed signal connection
231         boost::signals::connection readonlyConnection_;
232
233         /// BufferView messages signal connection
234         //@{
235         boost::signals::connection message_connection_;
236         boost::signals::connection show_dialog_connection_;
237         boost::signals::connection show_dialog_with_data_connection_;
238         boost::signals::connection show_inset_dialog_connection_;
239         boost::signals::connection update_dialog_connection_;
240         boost::signals::connection layout_changed_connection_;
241         //@}
242
243         /// Bind methods for BufferView messages signal connection
244         //@{
245         void showDialog(std::string const & name);
246         void showDialogWithData(std::string const & name,
247                 std::string const & data);
248         void showInsetDialog(std::string const & name,
249                 std::string const & data, Inset * inset);
250         void updateDialog(std::string const & name,
251                 std::string const & data);
252         //@}
253
254         /// notify readonly status
255         void showReadonly(bool);
256
257 protected:
258         ///
259         void updateToc();
260         ///
261         void updateEmbeddedFiles();
262
263 private:
264         int id_;
265 };
266
267 } // namespace frontend
268 } // namespace lyx
269
270 #endif // LYXVIEW_H