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.
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 /// updates the possible layouts selectable
128 void updateLayoutChoice();
130 /// update the toolbar
131 void updateToolbars();
132 /// update the menubar
133 void updateMenubar();
134 /// update the status bar
135 virtual void updateStatusBar() = 0;
137 /// focus the command buffer (minibuffer)
138 boost::signal<void()> focus_command_buffer;
140 /// display a message in the view
141 virtual void message(lyx::docstring const &) = 0;
143 /// clear any temporary message and replace with current status
144 virtual void clearMessage() = 0;
146 /// updates the title of the window
147 void updateWindowTitle();
149 /// reset autosave timer
150 void resetAutosaveTimer();
152 /// dispatch to current BufferView
153 void dispatch(FuncRequest const & cmd);
155 /** redraw \c inset in all the BufferViews in which it is currently
156 * visible. If successful return a pointer to the owning Buffer.
158 Buffer const * const updateInset(InsetBase const *) const;
160 /// returns true if this view has the focus.
161 virtual bool hasFocus() const = 0;
163 /// Temporary method used by the kernel to redraw the work area.
164 virtual void redrawWorkArea();
166 /// Temporary method to access the current workArea.
167 /// This is needed for the qt3 and gtk frontend.
168 lyx::frontend::WorkArea * workArea();
170 /// show the error list to the user
171 void showErrorList(std::string const &);
173 /// connect to signals in the given BufferView
174 void connectBufferView(BufferView & bv);
175 /// disconnect from signals in the given BufferView
176 void disconnectBufferView();
179 /// current work area (screen view of a BufferView).
181 \todo FIXME: there is only one workArea per LyXView for now.
183 lyx::frontend::WorkArea * work_area_;
186 boost::scoped_ptr<Menubar> menubar_;
190 * setWindowTitle - set title of window
191 * @param t main window title
192 * @param it iconified (short) title
194 virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it) = 0;
196 /// called on timeout
200 boost::scoped_ptr<Toolbars> toolbars_;
201 /// auto-saving of buffers
202 boost::scoped_ptr<Timeout> const autosave_timeout_;
203 /// our function handler
204 boost::scoped_ptr<LyXFunc> lyxfunc_;
205 /// dialogs for this view
206 boost::scoped_ptr<Dialogs> dialogs_;
208 /// buffer errors signal connection
209 boost::signals::connection errorsConnection_;
210 /// buffer messages signal connection
211 boost::signals::connection messageConnection_;
212 /// buffer busy status signal connection
213 boost::signals::connection busyConnection_;
214 /// buffer title changed signal connection
215 boost::signals::connection titleConnection_;
216 /// buffer reset timers signal connection
217 boost::signals::connection timerConnection_;
218 /// buffer readonly status changed signal connection
219 boost::signals::connection readonlyConnection_;
220 /// buffer closing signal connection
221 boost::signals::connection closingConnection_;
222 /// connect to signals in the given buffer
223 void connectBuffer(Buffer & buf);
224 /// disconnect from signals in the given buffer
225 void disconnectBuffer();
227 /// BufferView messages signal connection
229 boost::signals::connection message_connection_;
230 boost::signals::connection show_dialog_connection_;
231 boost::signals::connection show_dialog_with_data_connection_;
232 boost::signals::connection show_inset_dialog_connection_;
233 boost::signals::connection update_dialog_connection_;
234 boost::signals::connection layout_changed_connection_;
237 /// Bind methods for BufferView messages signal connection
239 void showDialog(std::string const & name);
240 void showDialogWithData(std::string const & name,
241 std::string const & data);
242 void showInsetDialog(std::string const & name,
243 std::string const & data, InsetBase * inset);
244 void updateDialog(std::string const & name,
245 std::string const & data);
248 /// notify readonly status
249 void showReadonly(bool);
252 /// view's command buffer controller
253 // this has to be declared _after_ lyxfunc_ as its initialization depends
255 typedef boost::scoped_ptr<lyx::frontend::ControlCommandBuffer>
258 CommandBufferPtr const controlcommand_;