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"
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/shared_ptr.hpp>
21 #include <boost/signal.hpp>
22 #include <boost/signals/trackable.hpp>
23 #include <boost/utility.hpp>
40 class ControlCommandBuffer;
41 } // namespace frontend
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 {
61 LyXView(lyx::frontend::Gui & owner);
65 void setWorkArea(lyx::frontend::WorkArea * work_area);
68 * This is called after the concrete view has been created.
69 * We have to have the toolbar and the other stuff created
70 * before we can populate it with this call.
75 virtual void busy(bool) const = 0;
77 virtual Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb) = 0;
79 //@{ generic accessor functions
81 /** return the current buffer view
82 Returned as a shared_ptr so that anything wanting to cache the
83 buffer view can do so safely using a boost::weak_ptr.
85 BufferView * view() const;
87 /// return the buffer currently shown in this window
88 Buffer * buffer() const;
90 /// return the LyX function handler for this view
91 LyXFunc & getLyXFunc() { return theApp->lyxFunc(); }
93 LyXFunc const & getLyXFunc() const { return theApp->lyxFunc(); }
95 /// return the toolbar for this view
96 Toolbars & getToolbars() { return *toolbars_.get(); }
98 Toolbars const & getToolbars() const { return *toolbars_.get(); }
100 /// return the menubar for this view
101 Menubar & getMenubar() { return *menubar_.get(); }
103 Menubar const & getMenubar() const { return *menubar_.get(); }
105 /// get access to the dialogs
106 Dialogs & getDialogs() { return *dialogs_.get(); }
108 Dialogs const & getDialogs() const { return *dialogs_.get(); }
112 /// load a buffer into the current workarea
113 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
115 /// set a buffer to the current workarea
116 void setBuffer(Buffer * b);
118 /// sets the layout in the toolbar layout selection
119 void setLayout(std::string const & layout);
120 /// updates the possible layouts selectable
121 void updateLayoutChoice();
123 /// update the toolbar
124 void updateToolbars();
125 /// update the menubar
126 void updateMenubar();
127 /// update the status bar
128 virtual void updateStatusBar() = 0;
130 /// focus the command buffer (minibuffer)
131 boost::signal<void()> focus_command_buffer;
133 /// display a message in the view
134 virtual void message(lyx::docstring const &) = 0;
136 /// clear any temporary message and replace with current status
137 virtual void clearMessage() = 0;
139 /// updates the title of the window
140 void updateWindowTitle();
142 /// reset autosave timer
143 void resetAutosaveTimer();
145 /// dispatch to current BufferView
146 void dispatch(FuncRequest const & cmd);
148 /** redraw \c inset in all the BufferViews in which it is currently
149 * visible. If successful return a pointer to the owning Buffer.
151 Buffer const * const updateInset(InsetBase const *) const;
153 /// returns true if this view has the focus.
154 virtual bool hasFocus() const = 0;
157 virtual lyx::frontend::Gui & gui();
159 /// Temporary method used by the kernel to redraw the work area.
160 virtual void redrawWorkArea();
162 /// Temporary method to access the current workArea.
163 /// This is needed for the qt3 and gtk frontend.
164 lyx::frontend::WorkArea * workArea();
166 /// show the error list to the user
167 void showErrorList(std::string const &);
169 /// connect to signals in the given BufferView
170 void connectBufferView(BufferView & bv);
171 /// disconnect from signals in the given BufferView
172 void disconnectBufferView();
175 /// current work area (screen view of a BufferView).
177 \todo FIXME: there is only one workArea per LyXView for now.
179 lyx::frontend::WorkArea * work_area_;
182 boost::scoped_ptr<Menubar> menubar_;
185 lyx::frontend::Gui & owner_;
187 * setWindowTitle - set title of window
188 * @param t main window title
189 * @param it iconified (short) title
191 virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it) = 0;
193 /// called on timeout
197 boost::scoped_ptr<Toolbars> toolbars_;
198 /// auto-saving of buffers
199 boost::scoped_ptr<Timeout> const autosave_timeout_;
200 /// our function handler
201 boost::scoped_ptr<LyXFunc> lyxfunc_;
202 /// dialogs for this view
203 boost::scoped_ptr<Dialogs> dialogs_;
205 /// buffer errors signal connection
206 boost::signals::connection errorsConnection_;
207 /// buffer messages signal connection
208 boost::signals::connection messageConnection_;
209 /// buffer busy status signal connection
210 boost::signals::connection busyConnection_;
211 /// buffer title changed signal connection
212 boost::signals::connection titleConnection_;
213 /// buffer reset timers signal connection
214 boost::signals::connection timerConnection_;
215 /// buffer readonly status changed signal connection
216 boost::signals::connection readonlyConnection_;
217 /// buffer closing signal connection
218 boost::signals::connection closingConnection_;
219 /// connect to signals in the given buffer
220 void connectBuffer(Buffer & buf);
221 /// disconnect from signals in the given buffer
222 void disconnectBuffer();
224 /// BufferView messages signal connection
226 boost::signals::connection message_connection_;
227 boost::signals::connection show_dialog_connection_;
228 boost::signals::connection show_dialog_with_data_connection_;
229 boost::signals::connection show_inset_dialog_connection_;
230 boost::signals::connection update_dialog_connection_;
233 /// Bind methods for BufferView messages signal connection
235 void showDialog(std::string const & name);
236 void showDialogWithData(std::string const & name,
237 std::string const & data);
238 void showInsetDialog(std::string const & name,
239 std::string const & data, InsetBase * inset);
240 void updateDialog(std::string const & name,
241 std::string const & data);
244 /// notify readonly status
245 void showReadonly(bool);
248 /// view's command buffer controller
249 // this has to be declared _after_ lyxfunc_ as its initialization depends
251 typedef boost::scoped_ptr<lyx::frontend::ControlCommandBuffer>
254 CommandBufferPtr const controlcommand_;