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>
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 {
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.
72 virtual void init() = 0;
74 virtual void setGeometry(
81 virtual void busy(bool) const = 0;
83 virtual Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb) = 0;
85 //@{ generic accessor functions
87 /** return the current buffer view
88 Returned as a shared_ptr so that anything wanting to cache the
89 buffer view can do so safely using a boost::weak_ptr.
91 BufferView * view() const;
93 /// return the buffer currently shown in this window
94 Buffer * buffer() const;
96 /* FIXME: Abdel 22/09/71
97 there is only one lyxFunc() for now but there is maybe a need
98 for more in the feature. Something like that:
100 LyXFunc & getLyXFunc() { return theApp->lyxFunc(id_); }
102 where id_ would be the this LyXView ID.
103 That's the reason why I didn't remove these methods for now.
105 /// return the LyX function handler for this view
106 LyXFunc & getLyXFunc() { return theApp->lyxFunc(); }
108 LyXFunc const & getLyXFunc() const { return theApp->lyxFunc(); }
110 /// return the toolbar for this view
111 Toolbars & getToolbars() { return *toolbars_.get(); }
113 Toolbars const & getToolbars() const { return *toolbars_.get(); }
115 /// return the menubar for this view
116 Menubar & getMenubar() { return *menubar_.get(); }
118 Menubar const & getMenubar() const { return *menubar_.get(); }
120 /// get access to the dialogs
121 Dialogs & getDialogs() { return *dialogs_.get(); }
123 Dialogs const & getDialogs() const { return *dialogs_.get(); }
127 /// load a buffer into the current workarea
128 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
130 /// set a buffer to the current workarea
131 void setBuffer(Buffer * b);
133 /// updates the possible layouts selectable
134 void updateLayoutChoice();
136 /// update the toolbar
137 void updateToolbars();
138 /// update the menubar
139 void updateMenubar();
140 /// update the status bar
141 virtual void updateStatusBar() = 0;
143 /// focus the command buffer (minibuffer)
144 boost::signal<void()> focus_command_buffer;
146 /// display a message in the view
147 virtual void message(lyx::docstring const &) = 0;
149 /// clear any temporary message and replace with current status
150 virtual void clearMessage() = 0;
152 /// updates the title of the window
153 void updateWindowTitle();
155 /// reset autosave timer
156 void resetAutosaveTimer();
158 /// dispatch to current BufferView
159 void dispatch(FuncRequest const & cmd);
161 /** redraw \c inset in all the BufferViews in which it is currently
162 * visible. If successful return a pointer to the owning Buffer.
164 Buffer const * const updateInset(InsetBase const *) const;
166 /// returns true if this view has the focus.
167 virtual bool hasFocus() const = 0;
169 /// Temporary method used by the kernel to redraw the work area.
170 virtual void redrawWorkArea();
172 /// Temporary method to access the current workArea.
173 /// This is needed for the qt3 and gtk frontend.
174 lyx::frontend::WorkArea * workArea();
176 /// show the error list to the user
177 void showErrorList(std::string const &);
179 /// connect to signals in the given BufferView
180 void connectBufferView(BufferView & bv);
181 /// disconnect from signals in the given BufferView
182 void disconnectBufferView();
185 /// current work area (screen view of a BufferView).
187 \todo FIXME: there is only one workArea per LyXView for now.
189 lyx::frontend::WorkArea * work_area_;
192 boost::scoped_ptr<Menubar> menubar_;
196 * setWindowTitle - set title of window
197 * @param t main window title
198 * @param it iconified (short) title
200 virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it) = 0;
202 /// called on timeout
206 boost::scoped_ptr<Toolbars> toolbars_;
207 /// auto-saving of buffers
208 boost::scoped_ptr<Timeout> const autosave_timeout_;
209 /// our function handler
210 boost::scoped_ptr<LyXFunc> lyxfunc_;
211 /// dialogs for this view
212 boost::scoped_ptr<Dialogs> dialogs_;
214 /// buffer errors signal connection
215 boost::signals::connection errorsConnection_;
216 /// buffer messages signal connection
217 boost::signals::connection messageConnection_;
218 /// buffer busy status signal connection
219 boost::signals::connection busyConnection_;
220 /// buffer title changed signal connection
221 boost::signals::connection titleConnection_;
222 /// buffer reset timers signal connection
223 boost::signals::connection timerConnection_;
224 /// buffer readonly status changed signal connection
225 boost::signals::connection readonlyConnection_;
226 /// buffer closing signal connection
227 boost::signals::connection closingConnection_;
228 /// connect to signals in the given buffer
229 void connectBuffer(Buffer & buf);
230 /// disconnect from signals in the given buffer
231 void disconnectBuffer();
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, InsetBase * inset);
250 void updateDialog(std::string const & name,
251 std::string const & data);
254 /// notify readonly status
255 void showReadonly(bool);
258 /// view's command buffer controller
259 // this has to be declared _after_ lyxfunc_ as its initialization depends
261 typedef boost::scoped_ptr<lyx::frontend::ControlCommandBuffer>
264 CommandBufferPtr const controlcommand_;