4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS.
16 #include "frontends/Application.h"
17 #include "support/docstring.h"
19 #include <boost/signal.hpp>
20 #include <boost/signals/trackable.hpp>
21 #include <boost/utility.hpp>
27 namespace support { class FileName; }
45 * LyXView - main LyX window
47 * This class represents the main LyX window and provides
48 * accessor functions to its content.
50 * The eventual intention is that LyX will support a number
51 * of containing LyXViews. Currently a lot of code still
52 * relies on there being a single top-level view.
54 * Additionally we would like to support multiple views
55 * in a single LyXView.
57 class LyXView : public boost::signals::trackable, boost::noncopyable {
64 int id() const { return id_; }
66 virtual void close() = 0;
68 virtual void setFocus() = 0;
71 virtual WorkArea * workArea(Buffer & buffer) = 0;
73 virtual WorkArea * addWorkArea(Buffer & buffer) = 0;
75 virtual void setCurrentWorkArea(WorkArea * work_area) = 0;
77 virtual void removeWorkArea(WorkArea * work_area) = 0;
78 /// return the current WorkArea (the one that has the focus).
79 virtual WorkArea const * currentWorkArea() const = 0;
80 /// FIXME: This non-const access is needed because of
81 /// a mis-designed \c ControlSpellchecker.
82 virtual WorkArea * currentWorkArea() = 0;
85 * This is called after the concrete view has been created.
86 * We have to have the toolbar and the other stuff created
87 * before we can populate it with this call.
89 virtual void init() = 0;
94 HorizontallyMaximized,
99 virtual void setGeometry(
104 unsigned int iconSizeXY,
105 const std::string & geometryArg) = 0;
107 /// save the geometry state in the session manager.
108 virtual void saveGeometry() = 0;
111 virtual void busy(bool) = 0;
113 virtual Toolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline) = 0;
115 //@{ generic accessor functions
117 /// \return the current buffer view.
120 /// \return the buffer currently shown in this window
122 Buffer const * buffer() const;
125 void openLayoutList();
127 bool isToolbarVisible(std::string const & id);
129 virtual void showMiniBuffer(bool visible) = 0;
130 virtual void openMenu(docstring const & name) = 0;
132 /// get access to the dialogs
133 Dialogs & getDialogs() { return *dialogs_; }
135 Dialogs const & getDialogs() const { return *dialogs_; }
139 /// load a buffer into the current workarea.
140 Buffer * loadLyXFile(support::FileName const & name, ///< File to load.
141 bool tolastfiles = true); ///< append to the "Open recent" menu?
143 /// set a buffer to the current workarea.
144 void setBuffer(Buffer * b); ///< \c Buffer to set.
146 /// updates the possible layouts selectable
147 void updateLayoutChoice();
149 /// update the toolbar
150 void updateToolbars();
152 ToolbarInfo * getToolbarInfo(std::string const & name);
153 /// toggle toolbar state
154 void toggleToolbarState(std::string const & name, bool allowauto);
155 /// update the status bar
156 virtual void updateStatusBar() = 0;
158 /// display a message in the view
159 virtual void message(docstring const &) = 0;
161 /// clear any temporary message and replace with current status
162 virtual void clearMessage() = 0;
164 /// updates the title of the window
165 void updateWindowTitle();
167 /// reset autosave timer
168 void resetAutosaveTimer();
170 /// dispatch to current BufferView
171 void dispatch(FuncRequest const & cmd);
173 /** redraw \c inset in all the BufferViews in which it is currently
174 * visible. If successful return a pointer to the owning Buffer.
176 Buffer const * updateInset(Inset const *);
178 /// returns true if this view has the focus.
179 virtual bool hasFocus() const = 0;
181 /// show the error list to the user
182 void showErrorList(std::string const &);
185 /// connect to signals in the given BufferView
186 void connectBufferView(BufferView & bv);
187 /// disconnect from signals in the given BufferView
188 void disconnectBufferView();
189 /// connect to signals in the given buffer
190 void connectBuffer(Buffer & buf);
191 /// disconnect from signals in the given buffer
192 void disconnectBuffer();
195 Toolbars * toolbars_;
199 * setWindowTitle - set title of window
200 * @param t main window title
201 * @param it iconified (short) title
203 virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
205 /// called on timeout
208 /// auto-saving of buffers
209 Timeout * const autosave_timeout_;
210 /// dialogs for this view
213 /// buffer structure changed signal connection
214 boost::signals::connection bufferStructureChangedConnection_;
215 /// embedded file change signal connection
216 boost::signals::connection bufferEmbeddingChangedConnection_;
217 /// buffer errors signal connection
218 boost::signals::connection errorsConnection_;
219 /// buffer messages signal connection
220 boost::signals::connection messageConnection_;
221 /// buffer busy status signal connection
222 boost::signals::connection busyConnection_;
223 /// buffer title changed signal connection
224 boost::signals::connection titleConnection_;
225 /// buffer reset timers signal connection
226 boost::signals::connection timerConnection_;
227 /// buffer readonly status changed signal connection
228 boost::signals::connection readonlyConnection_;
230 /// BufferView messages signal connection
232 boost::signals::connection message_connection_;
233 boost::signals::connection show_dialog_connection_;
234 boost::signals::connection show_dialog_with_data_connection_;
235 boost::signals::connection show_inset_dialog_connection_;
236 boost::signals::connection update_dialog_connection_;
237 boost::signals::connection layout_changed_connection_;
240 /// Bind methods for BufferView messages signal connection
242 void showDialog(std::string const & name);
243 void showDialogWithData(std::string const & name,
244 std::string const & data);
245 void showInsetDialog(std::string const & name,
246 std::string const & data, Inset * inset);
247 void updateDialog(std::string const & name,
248 std::string const & data);
251 /// notify readonly status
252 void showReadonly(bool);
258 void updateEmbeddedFiles();
264 } // namespace frontend