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