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"
20 #include <boost/scoped_ptr.hpp>
21 #include <boost/shared_ptr.hpp>
22 #include <boost/signal.hpp>
23 #include <boost/signals/trackable.hpp>
24 #include <boost/utility.hpp>
30 namespace support { class FileName; }
42 class ControlCommandBuffer;
47 * LyXView - main LyX window
49 * This class represents the main LyX window and provides
50 * accessor functions to its content.
52 * The eventual intention is that LyX will support a number
53 * of containing LyXViews. Currently a lot of code still
54 * relies on there being a single top-level view.
56 * Additionally we would like to support multiple views
57 * in a single LyXView.
59 class LyXView : public boost::signals::trackable, boost::noncopyable {
66 int const id() const { return id_; }
68 virtual void close() = 0;
70 virtual void setFocus() = 0;
73 virtual WorkArea * workArea(Buffer & buffer) = 0;
75 virtual WorkArea * addWorkArea(Buffer & buffer) = 0;
77 virtual void setCurrentWorkArea(WorkArea * work_area) = 0;
79 virtual void removeWorkArea(WorkArea * work_area) = 0;
80 /// return the current WorkArea (the one that has the focus).
81 virtual WorkArea const * currentWorkArea() const = 0;
82 /// FIXME: This non-const access is needed because of
83 /// a mis-designed \c ControlSpellchecker.
84 virtual WorkArea * currentWorkArea() = 0;
87 * This is called after the concrete view has been created.
88 * We have to have the toolbar and the other stuff created
89 * before we can populate it with this call.
91 virtual void init() = 0;
96 HorizontallyMaximized,
101 virtual void setGeometry(
106 unsigned int iconSizeXY,
107 const std::string & geometryArg) = 0;
109 /// save the geometry state in the session manager.
110 virtual void saveGeometry() = 0;
113 virtual void busy(bool) = 0;
115 virtual Toolbars::ToolbarPtr makeToolbar(ToolbarInfo const & tbinfo, bool newline) = 0;
117 //@{ generic accessor functions
119 /// \return the current buffer view.
122 /// \return the buffer currently shown in this window
124 Buffer const * buffer() const;
127 void openLayoutList();
129 bool isToolbarVisible(std::string const & id);
131 virtual void showMiniBuffer(bool visible) = 0;
132 virtual void openMenu(docstring const & name) = 0;
134 /// get access to the dialogs
135 Dialogs & getDialogs() { return *dialogs_.get(); }
137 Dialogs const & getDialogs() const { return *dialogs_.get(); }
141 /// load a buffer into the current workarea.
142 Buffer * loadLyXFile(support::FileName const & name, ///< File to load.
143 bool tolastfiles = true); ///< append to the "Open recent" menu?
145 /// set a buffer to the current workarea.
146 void setBuffer(Buffer * b); ///< \c Buffer to set.
148 /// updates the possible layouts selectable
149 void updateLayoutChoice();
151 /// update the toolbar
152 void updateToolbars();
154 ToolbarInfo * getToolbarInfo(std::string const & name);
155 /// toggle toolbar state
156 void toggleToolbarState(std::string const & name, bool allowauto);
157 /// update the status bar
158 virtual void updateStatusBar() = 0;
160 /// display a message in the view
161 virtual void message(docstring const &) = 0;
163 /// clear any temporary message and replace with current status
164 virtual void clearMessage() = 0;
166 /// updates the title of the window
167 void updateWindowTitle();
169 /// reset autosave timer
170 void resetAutosaveTimer();
172 /// dispatch to current BufferView
173 void dispatch(FuncRequest const & cmd);
175 /** redraw \c inset in all the BufferViews in which it is currently
176 * visible. If successful return a pointer to the owning Buffer.
178 Buffer const * const updateInset(Inset const *);
180 /// returns true if this view has the focus.
181 virtual bool hasFocus() const = 0;
183 /// show the error list to the user
184 void showErrorList(std::string const &);
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();
197 boost::scoped_ptr<Toolbars> toolbars_;
201 * setWindowTitle - set title of window
202 * @param t main window title
203 * @param it iconified (short) title
205 virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
207 /// called on timeout
210 /// auto-saving of buffers
211 boost::scoped_ptr<Timeout> const autosave_timeout_;
212 /// our function handler
213 boost::scoped_ptr<LyXFunc> lyxfunc_;
214 /// dialogs for this view
215 boost::scoped_ptr<Dialogs> dialogs_;
217 /// buffer structure changed signal connection
218 boost::signals::connection bufferStructureChangedConnection_;
219 /// buffer errors signal connection
220 boost::signals::connection errorsConnection_;
221 /// buffer messages signal connection
222 boost::signals::connection messageConnection_;
223 /// buffer busy status signal connection
224 boost::signals::connection busyConnection_;
225 /// buffer title changed signal connection
226 boost::signals::connection titleConnection_;
227 /// buffer reset timers signal connection
228 boost::signals::connection timerConnection_;
229 /// buffer readonly status changed signal connection
230 boost::signals::connection readonlyConnection_;
232 /// BufferView messages signal connection
234 boost::signals::connection message_connection_;
235 boost::signals::connection show_dialog_connection_;
236 boost::signals::connection show_dialog_with_data_connection_;
237 boost::signals::connection show_inset_dialog_connection_;
238 boost::signals::connection update_dialog_connection_;
239 boost::signals::connection layout_changed_connection_;
242 /// Bind methods for BufferView messages signal connection
244 void showDialog(std::string const & name);
245 void showDialogWithData(std::string const & name,
246 std::string const & data);
247 void showInsetDialog(std::string const & name,
248 std::string const & data, Inset * inset);
249 void updateDialog(std::string const & name,
250 std::string const & data);
253 /// notify readonly status
254 void showReadonly(bool);
260 /// view's command buffer controller
261 // this has to be declared _after_ lyxfunc_ as its initialization depends
263 typedef boost::scoped_ptr<ControlCommandBuffer>
266 CommandBufferPtr const controlcommand_;
272 } // namespace frontend