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 {
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 /* FIXME: Abdel 22/09/71
91 there is only one lyxFunc() for now but there is maybe a need
92 for more in the feature. Something like that:
94 LyXFunc & getLyXFunc() { return theApp->lyxFunc(id_); }
96 where id_ would be the this LyXView ID.
97 That's the reason why I didn't remove these methods for now.
99 /// return the LyX function handler for this view
100 LyXFunc & getLyXFunc() { return theApp->lyxFunc(); }
102 LyXFunc const & getLyXFunc() const { return theApp->lyxFunc(); }
104 /// return the toolbar for this view
105 Toolbars & getToolbars() { return *toolbars_.get(); }
107 Toolbars const & getToolbars() const { return *toolbars_.get(); }
109 /// return the menubar for this view
110 Menubar & getMenubar() { return *menubar_.get(); }
112 Menubar const & getMenubar() const { return *menubar_.get(); }
114 /// get access to the dialogs
115 Dialogs & getDialogs() { return *dialogs_.get(); }
117 Dialogs const & getDialogs() const { return *dialogs_.get(); }
121 /// load a buffer into the current workarea
122 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
124 /// set a buffer to the current workarea
125 void setBuffer(Buffer * b);
127 /// sets the layout in the toolbar layout selection
128 void setLayout(std::string const & layout);
129 /// updates the possible layouts selectable
130 void updateLayoutChoice();
132 /// update the toolbar
133 void updateToolbars();
134 /// update the menubar
135 void updateMenubar();
136 /// update the status bar
137 virtual void updateStatusBar() = 0;
139 /// focus the command buffer (minibuffer)
140 boost::signal<void()> focus_command_buffer;
142 /// display a message in the view
143 virtual void message(lyx::docstring const &) = 0;
145 /// clear any temporary message and replace with current status
146 virtual void clearMessage() = 0;
148 /// updates the title of the window
149 void updateWindowTitle();
151 /// reset autosave timer
152 void resetAutosaveTimer();
154 /// dispatch to current BufferView
155 void dispatch(FuncRequest const & cmd);
157 /** redraw \c inset in all the BufferViews in which it is currently
158 * visible. If successful return a pointer to the owning Buffer.
160 Buffer const * const updateInset(InsetBase const *) const;
162 /// returns true if this view has the focus.
163 virtual bool hasFocus() const = 0;
165 /// Temporary method used by the kernel to redraw the work area.
166 virtual void redrawWorkArea();
168 /// Temporary method to access the current workArea.
169 /// This is needed for the qt3 and gtk frontend.
170 lyx::frontend::WorkArea * workArea();
172 /// show the error list to the user
173 void showErrorList(std::string const &);
175 /// connect to signals in the given BufferView
176 void connectBufferView(BufferView & bv);
177 /// disconnect from signals in the given BufferView
178 void disconnectBufferView();
181 /// current work area (screen view of a BufferView).
183 \todo FIXME: there is only one workArea per LyXView for now.
185 lyx::frontend::WorkArea * work_area_;
188 boost::scoped_ptr<Menubar> menubar_;
192 * setWindowTitle - set title of window
193 * @param t main window title
194 * @param it iconified (short) title
196 virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it) = 0;
198 /// called on timeout
202 boost::scoped_ptr<Toolbars> toolbars_;
203 /// auto-saving of buffers
204 boost::scoped_ptr<Timeout> const autosave_timeout_;
205 /// our function handler
206 boost::scoped_ptr<LyXFunc> lyxfunc_;
207 /// dialogs for this view
208 boost::scoped_ptr<Dialogs> dialogs_;
210 /// buffer errors signal connection
211 boost::signals::connection errorsConnection_;
212 /// buffer messages signal connection
213 boost::signals::connection messageConnection_;
214 /// buffer busy status signal connection
215 boost::signals::connection busyConnection_;
216 /// buffer title changed signal connection
217 boost::signals::connection titleConnection_;
218 /// buffer reset timers signal connection
219 boost::signals::connection timerConnection_;
220 /// buffer readonly status changed signal connection
221 boost::signals::connection readonlyConnection_;
222 /// buffer closing signal connection
223 boost::signals::connection closingConnection_;
224 /// connect to signals in the given buffer
225 void connectBuffer(Buffer & buf);
226 /// disconnect from signals in the given buffer
227 void disconnectBuffer();
229 /// BufferView messages signal connection
231 boost::signals::connection message_connection_;
232 boost::signals::connection show_dialog_connection_;
233 boost::signals::connection show_dialog_with_data_connection_;
234 boost::signals::connection show_inset_dialog_connection_;
235 boost::signals::connection update_dialog_connection_;
238 /// Bind methods for BufferView messages signal connection
240 void showDialog(std::string const & name);
241 void showDialogWithData(std::string const & name,
242 std::string const & data);
243 void showInsetDialog(std::string const & name,
244 std::string const & data, InsetBase * inset);
245 void updateDialog(std::string const & name,
246 std::string const & data);
249 /// notify readonly status
250 void showReadonly(bool);
253 /// view's command buffer controller
254 // this has to be declared _after_ lyxfunc_ as its initialization depends
256 typedef boost::scoped_ptr<lyx::frontend::ControlCommandBuffer>
259 CommandBufferPtr const controlcommand_;