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/Toolbars.h"
18 #include <boost/scoped_ptr.hpp>
19 #include <boost/shared_ptr.hpp>
20 #include <boost/signal.hpp>
21 #include <boost/signals/trackable.hpp>
22 #include <boost/utility.hpp>
39 class ControlCommandBuffer;
40 } // namespace frontend
45 * LyXView - main LyX window
47 * This class represents the main LyX window and provides
48 * accessor functions to its content.
50 * The eventual intention is that LyX will support a number
51 * of containing LyXViews. Currently a lot of code still
52 * relies on there being a single top-level view.
54 * Additionally we would like to support multiple views
55 * in a single LyXView.
57 class LyXView : public boost::signals::trackable, boost::noncopyable {
60 LyXView(lyx::frontend::Gui & owner);
64 void setWorkArea(lyx::frontend::WorkArea * work_area);
67 * This is called after the concrete view has been created.
68 * We have to have the toolbar and the other stuff created
69 * before we can populate it with this call.
74 virtual void busy(bool) const = 0;
76 virtual Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb) = 0;
78 //@{ generic accessor functions
80 /** return the current buffer view
81 Returned as a shared_ptr so that anything wanting to cache the
82 buffer view can do so safely using a boost::weak_ptr.
84 BufferView * view() const;
86 /// return the buffer currently shown in this window
87 Buffer * buffer() const;
89 /// return the LyX function handler for this view
90 LyXFunc & getLyXFunc() { return *lyxfunc_.get(); }
92 LyXFunc const & getLyXFunc() const { return *lyxfunc_.get(); }
94 /// return the toolbar for this view
95 Toolbars & getToolbars() { return *toolbars_.get(); }
97 Toolbars const & getToolbars() const { return *toolbars_.get(); }
99 /// return the menubar for this view
100 Menubar & getMenubar() { return *menubar_.get(); }
102 Menubar const & getMenubar() const { return *menubar_.get(); }
104 /// get access to the dialogs
105 Dialogs & getDialogs() { return *dialogs_.get(); }
107 Dialogs const & getDialogs() const { return *dialogs_.get(); }
111 /// load a buffer into the current workarea
112 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
114 /// set a buffer to the current workarea
115 void setBuffer(Buffer * b);
117 /// sets the layout in the toolbar layout selection
118 void setLayout(std::string const & layout);
119 /// updates the possible layouts selectable
120 void updateLayoutChoice();
122 /// update the toolbar
123 void updateToolbars();
124 /// update the menubar
125 void updateMenubar();
126 /// update the status bar
127 virtual void updateStatusBar() = 0;
129 /// focus the command buffer (minibuffer)
130 boost::signal<void()> focus_command_buffer;
132 /// display a message in the view
133 virtual void message(lyx::docstring const &) = 0;
135 /// clear any temporary message and replace with current status
136 virtual void clearMessage() = 0;
138 /// updates the title of the window
139 void updateWindowTitle();
141 /// reset autosave timer
142 void resetAutosaveTimer();
144 /// dispatch to current BufferView
145 void dispatch(FuncRequest const & cmd);
147 /** redraw \c inset in all the BufferViews in which it is currently
148 * visible. If successful return a pointer to the owning Buffer.
150 Buffer const * const updateInset(InsetBase const *) const;
152 /// returns true if this view has the focus.
153 virtual bool hasFocus() const = 0;
156 virtual lyx::frontend::Gui & gui();
158 /// Temporary method used by the kernel to redraw the work area.
159 virtual void redrawWorkArea();
161 /// Temporary method to access the current workArea.
162 /// This is needed for the qt3 and gtk frontend.
163 lyx::frontend::WorkArea * workArea();
165 /// show the error list to the user
166 void showErrorList(std::string const &);
168 /// connect to signals in the given BufferView
169 void connectBufferView(BufferView & bv);
170 /// disconnect from signals in the given BufferView
171 void disconnectBufferView();
174 /// current work area (screen view of a BufferView).
176 \todo FIXME: there is only one workArea per LyXView for now.
178 lyx::frontend::WorkArea * work_area_;
181 boost::scoped_ptr<Menubar> menubar_;
184 lyx::frontend::Gui & owner_;
186 * setWindowTitle - set title of window
187 * @param t main window title
188 * @param it iconified (short) title
190 virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it) = 0;
192 /// called on timeout
196 boost::scoped_ptr<Toolbars> toolbars_;
197 /// auto-saving of buffers
198 boost::scoped_ptr<Timeout> const autosave_timeout_;
199 /// our function handler
200 boost::scoped_ptr<LyXFunc> lyxfunc_;
201 /// dialogs for this view
202 boost::scoped_ptr<Dialogs> dialogs_;
204 /// buffer errors signal connection
205 boost::signals::connection errorsConnection_;
206 /// buffer messages signal connection
207 boost::signals::connection messageConnection_;
208 /// buffer busy status signal connection
209 boost::signals::connection busyConnection_;
210 /// buffer title changed signal connection
211 boost::signals::connection titleConnection_;
212 /// buffer reset timers signal connection
213 boost::signals::connection timerConnection_;
214 /// buffer readonly status changed signal connection
215 boost::signals::connection readonlyConnection_;
216 /// buffer closing signal connection
217 boost::signals::connection closingConnection_;
218 /// connect to signals in the given buffer
219 void connectBuffer(Buffer & buf);
220 /// disconnect from signals in the given buffer
221 void disconnectBuffer();
223 /// BufferView messages signal connection
225 boost::signals::connection message_connection_;
226 boost::signals::connection show_dialog_connection_;
227 boost::signals::connection show_dialog_with_data_connection_;
228 boost::signals::connection show_inset_dialog_connection_;
229 boost::signals::connection update_dialog_connection_;
232 /// Bind methods for BufferView messages signal connection
234 void showDialog(std::string const & name);
235 void showDialogWithData(std::string const & name,
236 std::string const & data);
237 void showInsetDialog(std::string const & name,
238 std::string const & data, InsetBase * inset);
239 void updateDialog(std::string const & name,
240 std::string const & data);
243 /// notify readonly status
244 void showReadonly(bool);
247 /// view's command buffer controller
248 // this has to be declared _after_ lyxfunc_ as its initialization depends
250 typedef boost::scoped_ptr<lyx::frontend::ControlCommandBuffer>
253 CommandBufferPtr const controlcommand_;