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>
41 class ControlCommandBuffer;
42 } // 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(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.
72 virtual void init() = 0;
74 virtual void setGeometry(
81 virtual void busy(bool) const = 0;
83 virtual Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb) = 0;
85 //@{ generic accessor functions
87 /** return the current buffer view
88 Returned as a shared_ptr so that anything wanting to cache the
89 buffer view can do so safely using a boost::weak_ptr.
91 BufferView * view() const;
93 /// return the buffer currently shown in this window
94 Buffer * buffer() const;
96 /// return the toolbar for this view
97 Toolbars & getToolbars() { return *toolbars_.get(); }
99 Toolbars const & getToolbars() const { return *toolbars_.get(); }
101 /// return the menubar for this view
102 Menubar & getMenubar() { return *menubar_.get(); }
104 Menubar const & getMenubar() const { return *menubar_.get(); }
106 /// get access to the dialogs
107 Dialogs & getDialogs() { return *dialogs_.get(); }
109 Dialogs const & getDialogs() const { return *dialogs_.get(); }
113 /// load a buffer into the current workarea
114 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
116 /// set a buffer to the current workarea
117 void setBuffer(Buffer * b);
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(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;
155 /// show the error list to the user
156 void showErrorList(std::string const &);
158 /// connect to signals in the given BufferView
159 void connectBufferView(BufferView & bv);
160 /// disconnect from signals in the given BufferView
161 void disconnectBufferView();
164 /// current work area (screen view of a BufferView).
166 \todo FIXME: there is only one workArea per LyXView for now.
168 frontend::WorkArea * work_area_;
171 boost::scoped_ptr<Menubar> menubar_;
175 * setWindowTitle - set title of window
176 * @param t main window title
177 * @param it iconified (short) title
179 virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
181 /// called on timeout
185 boost::scoped_ptr<Toolbars> toolbars_;
186 /// auto-saving of buffers
187 boost::scoped_ptr<Timeout> const autosave_timeout_;
188 /// our function handler
189 boost::scoped_ptr<LyXFunc> lyxfunc_;
190 /// dialogs for this view
191 boost::scoped_ptr<Dialogs> dialogs_;
193 /// buffer changed signal connection
194 boost::signals::connection bufferChangedConnection_;
195 /// buffer errors signal connection
196 boost::signals::connection errorsConnection_;
197 /// buffer messages signal connection
198 boost::signals::connection messageConnection_;
199 /// buffer busy status signal connection
200 boost::signals::connection busyConnection_;
201 /// buffer title changed signal connection
202 boost::signals::connection titleConnection_;
203 /// buffer reset timers signal connection
204 boost::signals::connection timerConnection_;
205 /// buffer readonly status changed signal connection
206 boost::signals::connection readonlyConnection_;
207 /// buffer closing signal connection
208 boost::signals::connection closingConnection_;
209 /// connect to signals in the given buffer
210 void connectBuffer(Buffer & buf);
211 /// disconnect from signals in the given buffer
212 void disconnectBuffer();
214 /// BufferView messages signal connection
216 boost::signals::connection message_connection_;
217 boost::signals::connection show_dialog_connection_;
218 boost::signals::connection show_dialog_with_data_connection_;
219 boost::signals::connection show_inset_dialog_connection_;
220 boost::signals::connection update_dialog_connection_;
221 boost::signals::connection layout_changed_connection_;
224 /// Bind methods for BufferView messages signal connection
226 void showDialog(std::string const & name);
227 void showDialogWithData(std::string const & name,
228 std::string const & data);
229 void showInsetDialog(std::string const & name,
230 std::string const & data, InsetBase * inset);
231 void updateDialog(std::string const & name,
232 std::string const & data);
235 /// notify readonly status
236 void showReadonly(bool);
239 /// view's command buffer controller
240 // this has to be declared _after_ lyxfunc_ as its initialization depends
242 typedef boost::scoped_ptr<frontend::ControlCommandBuffer>
245 CommandBufferPtr const controlcommand_;