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>
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 *lyxfunc_.get(); }
93 LyXFunc const & getLyXFunc() const { return *lyxfunc_.get(); }
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(); }
110 /// get this view's keyboard map handler
111 Intl & getIntl() { return *intl_.get(); }
113 Intl const & getIntl() const { return *intl_.get(); }
117 /// load a buffer into the current workarea
118 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
120 /// set a buffer to the current workarea
121 void setBuffer(Buffer * b);
123 /// sets the layout in the toolbar layout selection
124 void setLayout(std::string const & layout);
125 /// updates the possible layouts selectable
126 void updateLayoutChoice();
128 /// update the toolbar
129 void updateToolbars();
130 /// update the menubar
131 void updateMenubar();
132 /// update the status bar
133 virtual void updateStatusBar() = 0;
135 /// focus the command buffer (minibuffer)
136 boost::signal<void()> focus_command_buffer;
138 /// display a message in the view
139 virtual void message(std::string const &) = 0;
141 /// clear any temporary message and replace with current status
142 virtual void clearMessage() = 0;
144 /// updates the title of the window
145 void updateWindowTitle();
147 /// reset autosave timer
148 void resetAutosaveTimer();
150 /// dispatch to current BufferView
151 void dispatch(FuncRequest const & cmd);
153 /** redraw \c inset in all the BufferViews in which it is currently
154 * visible. If successful return a pointer to the owning Buffer.
156 Buffer const * const updateInset(InsetBase const *) const;
158 /// returns true if this view has the focus.
159 virtual bool hasFocus() const = 0;
162 virtual lyx::frontend::Gui & gui();
164 /// Temporary method used by the kernel to redraw the work area.
165 virtual void redrawWorkArea();
167 /// Temporary method to access the current workArea.
168 /// This is needed for the qt3 and gtk frontend.
169 lyx::frontend::WorkArea * workArea();
171 /// show the error list to the user
172 void showErrorList(std::string const &);
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(std::string const & t, std::string const & it) = 0;
193 /// called on timeout
197 boost::scoped_ptr<Toolbars> toolbars_;
198 /// keyboard mapping object
199 boost::scoped_ptr<Intl> const intl_;
200 /// auto-saving of buffers
201 boost::scoped_ptr<Timeout> const autosave_timeout_;
202 /// our function handler
203 boost::scoped_ptr<LyXFunc> lyxfunc_;
204 /// dialogs for this view
205 boost::scoped_ptr<Dialogs> dialogs_;
207 /// buffer errors signal connection
208 boost::signals::connection errorsConnection_;
209 /// buffer messages signal connection
210 boost::signals::connection messageConnection_;
211 /// buffer busy status signal connection
212 boost::signals::connection busyConnection_;
213 /// buffer title changed signal connection
214 boost::signals::connection titleConnection_;
215 /// buffer reset timers signal connection
216 boost::signals::connection timerConnection_;
217 /// buffer readonly status changed signal connection
218 boost::signals::connection readonlyConnection_;
219 /// buffer closing signal connection
220 boost::signals::connection closingConnection_;
221 /// connect to signals in the given buffer
222 void connectBuffer(Buffer & buf);
223 /// disconnect from signals in the given buffer
224 void disconnectBuffer();
225 /// notify readonly status
226 void showReadonly(bool);
229 /// view's command buffer controller
230 // this has to be declared _after_ lyxfunc_ as its initialization depends
232 typedef boost::scoped_ptr<lyx::frontend::ControlCommandBuffer>
235 CommandBufferPtr const controlcommand_;