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 "frontends/Toolbars.h"
21 #include <boost/scoped_ptr.hpp>
22 #include <boost/signal.hpp>
23 #include <boost/signals/trackable.hpp>
24 #include <boost/utility.hpp>
30 namespace support { class FileName; }
46 * LyXView - main LyX window
48 * This class represents the main LyX window and provides
49 * accessor functions to its content.
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.
55 * Additionally we would like to support multiple views
56 * in a single LyXView.
58 class LyXView : public boost::signals::trackable, boost::noncopyable {
65 int id() const { return id_; }
67 virtual void close() = 0;
69 virtual void setFocus() = 0;
72 virtual WorkArea * workArea(Buffer & buffer) = 0;
74 virtual WorkArea * addWorkArea(Buffer & buffer) = 0;
76 virtual void setCurrentWorkArea(WorkArea * work_area) = 0;
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;
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.
90 virtual void init() = 0;
95 HorizontallyMaximized,
100 virtual void setGeometry(
105 unsigned int iconSizeXY,
106 const std::string & geometryArg) = 0;
108 /// save the geometry state in the session manager.
109 virtual void saveGeometry() = 0;
112 virtual void busy(bool) = 0;
114 virtual Toolbars::ToolbarPtr makeToolbar(ToolbarInfo const & tbinfo, bool newline) = 0;
116 //@{ generic accessor functions
118 /// \return the current buffer view.
121 /// \return the buffer currently shown in this window
123 Buffer const * buffer() const;
126 void openLayoutList();
128 bool isToolbarVisible(std::string const & id);
130 virtual void showMiniBuffer(bool visible) = 0;
131 virtual void openMenu(docstring const & name) = 0;
133 /// get access to the dialogs
134 Dialogs & getDialogs() { return *dialogs_.get(); }
136 Dialogs const & getDialogs() const { return *dialogs_.get(); }
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?
144 /// set a buffer to the current workarea.
145 void setBuffer(Buffer * b); ///< \c Buffer to set.
147 /// updates the possible layouts selectable
148 void updateLayoutChoice();
150 /// update the toolbar
151 void updateToolbars();
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;
159 /// display a message in the view
160 virtual void message(docstring const &) = 0;
162 /// clear any temporary message and replace with current status
163 virtual void clearMessage() = 0;
165 /// updates the title of the window
166 void updateWindowTitle();
168 /// reset autosave timer
169 void resetAutosaveTimer();
171 /// dispatch to current BufferView
172 void dispatch(FuncRequest const & cmd);
174 /** redraw \c inset in all the BufferViews in which it is currently
175 * visible. If successful return a pointer to the owning Buffer.
177 Buffer const * updateInset(Inset const *);
179 /// returns true if this view has the focus.
180 virtual bool hasFocus() const = 0;
182 /// show the error list to the user
183 void showErrorList(std::string const &);
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();
196 boost::scoped_ptr<Toolbars> toolbars_;
200 * setWindowTitle - set title of window
201 * @param t main window title
202 * @param it iconified (short) title
204 virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
206 /// called on timeout
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_;
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_;
233 /// BufferView messages signal connection
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_;
243 /// Bind methods for BufferView messages signal connection
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);
254 /// notify readonly status
255 void showReadonly(bool);
261 void updateEmbeddedFiles();
267 } // namespace frontend