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>
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 {
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 /* FIXME: Abdel 22/09/71
90 there is only one lyxFunc() for now but there is maybe a need
91 for more in the feature. Something like that:
93 LyXFunc & getLyXFunc() { return theApp->lyxFunc(id_); }
95 where id_ would be the this LyXView ID.
96 That's the reason why I didn't remove these methods for now.
98 /// return the LyX function handler for this view
99 LyXFunc & getLyXFunc() { return theApp->lyxFunc(); }
101 LyXFunc const & getLyXFunc() const { return theApp->lyxFunc(); }
103 /// return the toolbar for this view
104 Toolbars & getToolbars() { return *toolbars_.get(); }
106 Toolbars const & getToolbars() const { return *toolbars_.get(); }
108 /// return the menubar for this view
109 Menubar & getMenubar() { return *menubar_.get(); }
111 Menubar const & getMenubar() const { return *menubar_.get(); }
113 /// get access to the dialogs
114 Dialogs & getDialogs() { return *dialogs_.get(); }
116 Dialogs const & getDialogs() const { return *dialogs_.get(); }
120 /// load a buffer into the current workarea
121 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
123 /// set a buffer to the current workarea
124 void setBuffer(Buffer * b);
126 /// sets the layout in the toolbar layout selection
127 void setLayout(std::string const & layout);
128 /// updates the possible layouts selectable
129 void updateLayoutChoice();
131 /// update the toolbar
132 void updateToolbars();
133 /// update the menubar
134 void updateMenubar();
135 /// update the status bar
136 virtual void updateStatusBar() = 0;
138 /// focus the command buffer (minibuffer)
139 boost::signal<void()> focus_command_buffer;
141 /// display a message in the view
142 virtual void message(lyx::docstring const &) = 0;
144 /// clear any temporary message and replace with current status
145 virtual void clearMessage() = 0;
147 /// updates the title of the window
148 void updateWindowTitle();
150 /// reset autosave timer
151 void resetAutosaveTimer();
153 /// dispatch to current BufferView
154 void dispatch(FuncRequest const & cmd);
156 /** redraw \c inset in all the BufferViews in which it is currently
157 * visible. If successful return a pointer to the owning Buffer.
159 Buffer const * const updateInset(InsetBase const *) const;
161 /// returns true if this view has the focus.
162 virtual bool hasFocus() const = 0;
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 &);
174 /// connect to signals in the given BufferView
175 void connectBufferView(BufferView & bv);
176 /// disconnect from signals in the given BufferView
177 void disconnectBufferView();
180 /// current work area (screen view of a BufferView).
182 \todo FIXME: there is only one workArea per LyXView for now.
184 lyx::frontend::WorkArea * work_area_;
187 boost::scoped_ptr<Menubar> menubar_;
191 * setWindowTitle - set title of window
192 * @param t main window title
193 * @param it iconified (short) title
195 virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it) = 0;
197 /// called on timeout
201 boost::scoped_ptr<Toolbars> toolbars_;
202 /// auto-saving of buffers
203 boost::scoped_ptr<Timeout> const autosave_timeout_;
204 /// our function handler
205 boost::scoped_ptr<LyXFunc> lyxfunc_;
206 /// dialogs for this view
207 boost::scoped_ptr<Dialogs> dialogs_;
209 /// buffer errors signal connection
210 boost::signals::connection errorsConnection_;
211 /// buffer messages signal connection
212 boost::signals::connection messageConnection_;
213 /// buffer busy status signal connection
214 boost::signals::connection busyConnection_;
215 /// buffer title changed signal connection
216 boost::signals::connection titleConnection_;
217 /// buffer reset timers signal connection
218 boost::signals::connection timerConnection_;
219 /// buffer readonly status changed signal connection
220 boost::signals::connection readonlyConnection_;
221 /// buffer closing signal connection
222 boost::signals::connection closingConnection_;
223 /// connect to signals in the given buffer
224 void connectBuffer(Buffer & buf);
225 /// disconnect from signals in the given buffer
226 void disconnectBuffer();
228 /// BufferView messages signal connection
230 boost::signals::connection message_connection_;
231 boost::signals::connection show_dialog_connection_;
232 boost::signals::connection show_dialog_with_data_connection_;
233 boost::signals::connection show_inset_dialog_connection_;
234 boost::signals::connection update_dialog_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_;