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 "errorlist.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>
41 class ControlCommandBuffer;
42 } // namespace frontend
47 * LyXView - main LyX window
49 * This class represents the main LyX window and provides
50 * accessor functions to its content.
52 * The eventual intention is that LyX will support a number
53 * of containing LyXViews. Currently a lot of code still
54 * relies on there being a single top-level view.
56 * Additionally we would like to support multiple views
57 * in a single LyXView.
59 class LyXView : public boost::signals::trackable, boost::noncopyable {
62 LyXView(lyx::frontend::Gui & owner);
66 void setWorkArea(lyx::frontend::WorkArea * work_area);
69 * This is called after the concrete view has been created.
70 * We have to have the toolbar and the other stuff created
71 * before we can populate it with this call.
76 virtual void busy(bool) const = 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(); }
109 /// get this view's keyboard map handler
110 Intl & getIntl() { return *intl_.get(); }
112 Intl const & getIntl() const { return *intl_.get(); }
116 /// load a buffer into the current workarea
117 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
119 /// set a buffer to the current workarea
120 void setBuffer(Buffer * b);
122 /// sets the layout in the toolbar layout selection
123 void setLayout(std::string const & layout);
124 /// updates the possible layouts selectable
125 void updateLayoutChoice();
127 /// update the toolbar
128 void updateToolbars();
129 /// update the menubar
130 void updateMenubar();
131 /// update the status bar
132 virtual void updateStatusBar() = 0;
134 /// focus the command buffer (minibuffer)
135 boost::signal<void()> focus_command_buffer;
137 /// display a message in the view
138 virtual void message(std::string const &) = 0;
140 /// clear any temporary message and replace with current status
141 virtual void clearMessage() = 0;
143 /// updates the title of the window
144 void updateWindowTitle();
146 /// reset autosave timer
147 void resetAutosaveTimer();
149 /// dispatch to current BufferView
150 void dispatch(FuncRequest const & cmd);
152 /** redraw \c inset in all the BufferViews in which it is currently
153 * visible. If successful return a pointer to the owning Buffer.
155 Buffer const * const updateInset(InsetBase const *) const;
157 /// returns true if this view has the focus.
158 virtual bool hasFocus() const = 0;
161 virtual lyx::frontend::Gui & gui();
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 /// get the stored error list
171 ErrorList const & getErrorList() const;
172 /// show the error list to the user
173 void showErrorList(std::string const &);
174 /// add an error to the list
175 /** FIXME: public method until the signal connection in
176 * BufferView::menuInsertLyXFile() is removed.
178 void addError(ErrorItem const &);
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_;
191 lyx::frontend::Gui & owner_;
193 * setWindowTitle - set title of window
194 * @param t main window title
195 * @param it iconified (short) title
197 virtual void setWindowTitle(std::string const & t, std::string const & it) = 0;
199 /// called on timeout
203 boost::scoped_ptr<Toolbars> toolbars_;
204 /// keyboard mapping object
205 boost::scoped_ptr<Intl> const intl_;
206 /// auto-saving of buffers
207 boost::scoped_ptr<Timeout> const autosave_timeout_;
208 /// our function handler
209 boost::scoped_ptr<LyXFunc> lyxfunc_;
210 /// dialogs for this view
211 boost::scoped_ptr<Dialogs> dialogs_;
213 /// An error list (replaces the error insets)
214 ErrorList errorlist_;
216 /// buffer errors signal connection
217 boost::signals::connection errorConnection_;
218 /// buffer messages signal connection
219 boost::signals::connection messageConnection_;
220 /// buffer busy status signal connection
221 boost::signals::connection busyConnection_;
222 /// buffer title changed signal connection
223 boost::signals::connection titleConnection_;
224 /// buffer reset timers signal connection
225 boost::signals::connection timerConnection_;
226 /// buffer readonly status changed signal connection
227 boost::signals::connection readonlyConnection_;
228 /// buffer closing signal connection
229 boost::signals::connection closingConnection_;
230 /// connect to signals in the given buffer
231 void connectBuffer(Buffer & buf);
232 /// disconnect from signals in the given buffer
233 void disconnectBuffer();
234 /// notify readonly status
235 void showReadonly(bool);
238 /// view's command buffer controller
239 // this has to be declared _after_ lyxfunc_ as its initialization depends
241 typedef boost::scoped_ptr<lyx::frontend::ControlCommandBuffer>
244 CommandBufferPtr const controlcommand_;