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;
48 * LyXView - main LyX window
50 * This class represents the main LyX window and provides
51 * accessor functions to its content.
53 * The eventual intention is that LyX will support a number
54 * of containing LyXViews. Currently a lot of code still
55 * relies on there being a single top-level view.
57 * Additionally we would like to support multiple views
58 * in a single LyXView.
60 class LyXView : public boost::signals::trackable, boost::noncopyable {
67 int const id() const { return id_; }
69 virtual void close() = 0;
71 virtual void setFocus() = 0;
74 virtual WorkArea * workArea(Buffer & buffer) = 0;
76 virtual WorkArea * addWorkArea(Buffer & buffer) = 0;
78 virtual void setCurrentWorkArea(WorkArea * work_area) = 0;
80 virtual void removeWorkArea(WorkArea * work_area) = 0;
81 /// return the current WorkArea (the one that has the focus).
82 virtual WorkArea const * currentWorkArea() const = 0;
83 /// FIXME: This non-const access is needed because of
84 /// a mis-designed \c ControlSpellchecker.
85 virtual WorkArea * currentWorkArea() = 0;
88 * This is called after the concrete view has been created.
89 * We have to have the toolbar and the other stuff created
90 * before we can populate it with this call.
92 virtual void init() = 0;
97 HorizontallyMaximized,
102 virtual void setGeometry(
107 unsigned int iconSizeXY,
108 const std::string & geometryArg) = 0;
110 /// save the geometry state in the session manager.
111 virtual void saveGeometry() = 0;
114 virtual void busy(bool) = 0;
116 virtual Toolbars::ToolbarPtr makeToolbar(ToolbarInfo const & tbinfo, bool newline) = 0;
118 //@{ generic accessor functions
120 /// \return the current buffer view.
123 /// \return the buffer currently shown in this window
125 Buffer const * buffer() const;
127 /// return the toolbar for this view
128 Toolbars & getToolbars() { return *toolbars_.get(); }
130 Toolbars const & getToolbars() const { return *toolbars_.get(); }
132 /// return the menubar for this view
133 Menubar & getMenubar() { return *menubar_.get(); }
135 Menubar const & getMenubar() const { return *menubar_.get(); }
137 /// get access to the dialogs
138 Dialogs & getDialogs() { return *dialogs_.get(); }
140 Dialogs const & getDialogs() const { return *dialogs_.get(); }
144 /// load a buffer into the current workarea.
145 Buffer * loadLyXFile(support::FileName const & name, ///< File to load.
146 bool tolastfiles = true); ///< append to the "Open recent" menu?
148 /// set a buffer to the current workarea.
149 void setBuffer(Buffer * b); ///< \c Buffer to set.
151 /// updates the possible layouts selectable
152 void updateLayoutChoice();
154 /// update the toolbar
155 void updateToolbars();
157 ToolbarInfo * getToolbarInfo(std::string const & name);
158 /// toggle toolbar state
159 void toggleToolbarState(std::string const & name, bool allowauto);
160 /// update the menubar
161 void updateMenubar();
162 /// update the status bar
163 virtual void updateStatusBar() = 0;
165 /// focus the command buffer (minibuffer)
166 boost::signal<void()> focus_command_buffer;
168 /// display a message in the view
169 virtual void message(docstring const &) = 0;
171 /// clear any temporary message and replace with current status
172 virtual void clearMessage() = 0;
174 /// updates the title of the window
175 void updateWindowTitle();
177 /// reset autosave timer
178 void resetAutosaveTimer();
180 /// dispatch to current BufferView
181 void dispatch(FuncRequest const & cmd);
183 /** redraw \c inset in all the BufferViews in which it is currently
184 * visible. If successful return a pointer to the owning Buffer.
186 Buffer const * const updateInset(Inset const *);
188 /// returns true if this view has the focus.
189 virtual bool hasFocus() const = 0;
191 /// show the error list to the user
192 void showErrorList(std::string const &);
195 /// connect to signals in the given BufferView
196 void connectBufferView(BufferView & bv);
197 /// disconnect from signals in the given BufferView
198 void disconnectBufferView();
199 /// connect to signals in the given buffer
200 void connectBuffer(Buffer & buf);
201 /// disconnect from signals in the given buffer
202 void disconnectBuffer();
205 boost::scoped_ptr<Menubar> menubar_;
209 * setWindowTitle - set title of window
210 * @param t main window title
211 * @param it iconified (short) title
213 virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
215 /// called on timeout
219 boost::scoped_ptr<Toolbars> toolbars_;
220 /// auto-saving of buffers
221 boost::scoped_ptr<Timeout> const autosave_timeout_;
222 /// our function handler
223 boost::scoped_ptr<LyXFunc> lyxfunc_;
224 /// dialogs for this view
225 boost::scoped_ptr<Dialogs> dialogs_;
227 /// buffer structure changed signal connection
228 boost::signals::connection bufferStructureChangedConnection_;
229 /// buffer errors signal connection
230 boost::signals::connection errorsConnection_;
231 /// buffer messages signal connection
232 boost::signals::connection messageConnection_;
233 /// buffer busy status signal connection
234 boost::signals::connection busyConnection_;
235 /// buffer title changed signal connection
236 boost::signals::connection titleConnection_;
237 /// buffer reset timers signal connection
238 boost::signals::connection timerConnection_;
239 /// buffer readonly status changed signal connection
240 boost::signals::connection readonlyConnection_;
242 /// BufferView messages signal connection
244 boost::signals::connection message_connection_;
245 boost::signals::connection show_dialog_connection_;
246 boost::signals::connection show_dialog_with_data_connection_;
247 boost::signals::connection show_inset_dialog_connection_;
248 boost::signals::connection update_dialog_connection_;
249 boost::signals::connection layout_changed_connection_;
252 /// Bind methods for BufferView messages signal connection
254 void showDialog(std::string const & name);
255 void showDialogWithData(std::string const & name,
256 std::string const & data);
257 void showInsetDialog(std::string const & name,
258 std::string const & data, Inset * inset);
259 void updateDialog(std::string const & name,
260 std::string const & data);
263 /// notify readonly status
264 void showReadonly(bool);
270 /// view's command buffer controller
271 // this has to be declared _after_ lyxfunc_ as its initialization depends
273 typedef boost::scoped_ptr<ControlCommandBuffer>
276 CommandBufferPtr const controlcommand_;
282 } // namespace frontend