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;
128 void openLayoutList();
130 bool isToolbarVisible(std::string const & id);
132 virtual void showMiniBuffer(bool visible) = 0;
134 /// return the menubar for this view
135 Menubar & getMenubar() { return *menubar_.get(); }
137 Menubar const & getMenubar() const { return *menubar_.get(); }
139 /// get access to the dialogs
140 Dialogs & getDialogs() { return *dialogs_.get(); }
142 Dialogs const & getDialogs() const { return *dialogs_.get(); }
146 /// load a buffer into the current workarea.
147 Buffer * loadLyXFile(support::FileName const & name, ///< File to load.
148 bool tolastfiles = true); ///< append to the "Open recent" menu?
150 /// set a buffer to the current workarea.
151 void setBuffer(Buffer * b); ///< \c Buffer to set.
153 /// updates the possible layouts selectable
154 void updateLayoutChoice();
156 /// update the toolbar
157 void updateToolbars();
159 ToolbarInfo * getToolbarInfo(std::string const & name);
160 /// toggle toolbar state
161 void toggleToolbarState(std::string const & name, bool allowauto);
162 /// update the menubar
163 void updateMenubar();
164 /// update the status bar
165 virtual void updateStatusBar() = 0;
167 /// display a message in the view
168 virtual void message(docstring const &) = 0;
170 /// clear any temporary message and replace with current status
171 virtual void clearMessage() = 0;
173 /// updates the title of the window
174 void updateWindowTitle();
176 /// reset autosave timer
177 void resetAutosaveTimer();
179 /// dispatch to current BufferView
180 void dispatch(FuncRequest const & cmd);
182 /** redraw \c inset in all the BufferViews in which it is currently
183 * visible. If successful return a pointer to the owning Buffer.
185 Buffer const * const updateInset(Inset const *);
187 /// returns true if this view has the focus.
188 virtual bool hasFocus() const = 0;
190 /// show the error list to the user
191 void showErrorList(std::string const &);
194 /// connect to signals in the given BufferView
195 void connectBufferView(BufferView & bv);
196 /// disconnect from signals in the given BufferView
197 void disconnectBufferView();
198 /// connect to signals in the given buffer
199 void connectBuffer(Buffer & buf);
200 /// disconnect from signals in the given buffer
201 void disconnectBuffer();
204 boost::scoped_ptr<Menubar> menubar_;
206 boost::scoped_ptr<Toolbars> toolbars_;
210 * setWindowTitle - set title of window
211 * @param t main window title
212 * @param it iconified (short) title
214 virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
216 /// called on timeout
219 /// auto-saving of buffers
220 boost::scoped_ptr<Timeout> const autosave_timeout_;
221 /// our function handler
222 boost::scoped_ptr<LyXFunc> lyxfunc_;
223 /// dialogs for this view
224 boost::scoped_ptr<Dialogs> dialogs_;
226 /// buffer structure changed signal connection
227 boost::signals::connection bufferStructureChangedConnection_;
228 /// buffer errors signal connection
229 boost::signals::connection errorsConnection_;
230 /// buffer messages signal connection
231 boost::signals::connection messageConnection_;
232 /// buffer busy status signal connection
233 boost::signals::connection busyConnection_;
234 /// buffer title changed signal connection
235 boost::signals::connection titleConnection_;
236 /// buffer reset timers signal connection
237 boost::signals::connection timerConnection_;
238 /// buffer readonly status changed signal connection
239 boost::signals::connection readonlyConnection_;
241 /// BufferView messages signal connection
243 boost::signals::connection message_connection_;
244 boost::signals::connection show_dialog_connection_;
245 boost::signals::connection show_dialog_with_data_connection_;
246 boost::signals::connection show_inset_dialog_connection_;
247 boost::signals::connection update_dialog_connection_;
248 boost::signals::connection layout_changed_connection_;
251 /// Bind methods for BufferView messages signal connection
253 void showDialog(std::string const & name);
254 void showDialogWithData(std::string const & name,
255 std::string const & data);
256 void showInsetDialog(std::string const & name,
257 std::string const & data, Inset * inset);
258 void updateDialog(std::string const & name,
259 std::string const & data);
262 /// notify readonly status
263 void showReadonly(bool);
269 /// view's command buffer controller
270 // this has to be declared _after_ lyxfunc_ as its initialization depends
272 typedef boost::scoped_ptr<ControlCommandBuffer>
275 CommandBufferPtr const controlcommand_;
281 } // namespace frontend