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>
30 namespace support { class FileName; }
45 class ControlCommandBuffer;
46 } // namespace frontend
50 * LyXView - main LyX window
52 * This class represents the main LyX window and provides
53 * accessor functions to its content.
55 * The eventual intention is that LyX will support a number
56 * of containing LyXViews. Currently a lot of code still
57 * relies on there being a single top-level view.
59 * Additionally we would like to support multiple views
60 * in a single LyXView.
62 class LyXView : public boost::signals::trackable, boost::noncopyable {
69 int const id() const { return id_; }
71 virtual void close() = 0;
73 std::vector<int> const & workAreaIds() const { return work_area_ids_; }
75 void setWorkArea(frontend::WorkArea * work_area);
78 * This is called after the concrete view has been created.
79 * We have to have the toolbar and the other stuff created
80 * before we can populate it with this call.
82 virtual void init() = 0;
85 virtual void setGeometry(
90 unsigned int iconSizeXY,
91 const std::string & geometryArg) = 0;
93 /// save the geometry state in the session manager.
94 virtual void saveGeometry() = 0;
97 virtual void busy(bool) = 0;
99 virtual Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb) = 0;
101 //@{ generic accessor functions
103 /** return the current buffer view
104 Returned as a shared_ptr so that anything wanting to cache the
105 buffer view can do so safely using a boost::weak_ptr.
107 BufferView * view() const;
109 /// return the buffer currently shown in this window
110 Buffer * buffer() const;
112 /// return the toolbar for this view
113 Toolbars & getToolbars() { return *toolbars_.get(); }
115 Toolbars const & getToolbars() const { return *toolbars_.get(); }
117 /// return the menubar for this view
118 Menubar & getMenubar() { return *menubar_.get(); }
120 Menubar const & getMenubar() const { return *menubar_.get(); }
122 /// get access to the dialogs
123 Dialogs & getDialogs() { return *dialogs_.get(); }
125 Dialogs const & getDialogs() const { return *dialogs_.get(); }
129 /// load a buffer into the current workarea
130 bool loadLyXFile(support::FileName const & name, bool tolastfiles = true);
132 /// set a buffer to the current workarea
133 void setBuffer(Buffer * b);
135 /// updates the possible layouts selectable
136 void updateLayoutChoice();
138 /// update the toolbar
139 void updateToolbars();
140 /// get toolbar state
141 ToolbarBackend::Flags getToolbarState(std::string const & name);
142 /// toggle toolbar state
143 void toggleToolbarState(std::string const & name);
144 /// update the menubar
145 void updateMenubar();
146 /// update the status bar
147 virtual void updateStatusBar() = 0;
149 /// focus the command buffer (minibuffer)
150 boost::signal<void()> focus_command_buffer;
152 /// display a message in the view
153 virtual void message(docstring const &) = 0;
155 /// clear any temporary message and replace with current status
156 virtual void clearMessage() = 0;
158 /// updates the title of the window
159 void updateWindowTitle();
161 /// updates the tab view
162 virtual void updateTab() = 0;
164 /// reset autosave timer
165 void resetAutosaveTimer();
167 /// dispatch to current BufferView
168 void dispatch(FuncRequest const & cmd);
170 /** redraw \c inset in all the BufferViews in which it is currently
171 * visible. If successful return a pointer to the owning Buffer.
173 Buffer const * const updateInset(InsetBase const *) const;
175 /// returns true if this view has the focus.
176 virtual bool hasFocus() const = 0;
178 /// show the error list to the user
179 void showErrorList(std::string const &);
181 /// connect to signals in the given BufferView
182 void connectBufferView(BufferView & bv);
183 /// disconnect from signals in the given BufferView
184 void disconnectBufferView();
187 /// current work area (screen view of a BufferView).
189 \todo FIXME: there is only one workArea per LyXView for now.
191 frontend::WorkArea * work_area_;
194 boost::scoped_ptr<Menubar> menubar_;
198 * setWindowTitle - set title of window
199 * @param t main window title
200 * @param it iconified (short) title
202 virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
204 /// called on timeout
208 boost::scoped_ptr<Toolbars> toolbars_;
209 /// auto-saving of buffers
210 boost::scoped_ptr<Timeout> const autosave_timeout_;
211 /// our function handler
212 boost::scoped_ptr<LyXFunc> lyxfunc_;
213 /// dialogs for this view
214 boost::scoped_ptr<Dialogs> dialogs_;
216 /// buffer changed signal connection
217 boost::signals::connection bufferChangedConnection_;
218 /// buffer errors signal connection
219 boost::signals::connection errorsConnection_;
220 /// buffer messages signal connection
221 boost::signals::connection messageConnection_;
222 /// buffer busy status signal connection
223 boost::signals::connection busyConnection_;
224 /// buffer title changed signal connection
225 boost::signals::connection titleConnection_;
226 /// buffer reset timers signal connection
227 boost::signals::connection timerConnection_;
228 /// buffer readonly status changed signal connection
229 boost::signals::connection readonlyConnection_;
230 /// buffer closing signal connection
231 boost::signals::connection closingConnection_;
232 /// connect to signals in the given buffer
233 void connectBuffer(Buffer & buf);
234 /// disconnect from signals in the given buffer
235 void disconnectBuffer();
237 /// BufferView messages signal connection
239 boost::signals::connection message_connection_;
240 boost::signals::connection show_dialog_connection_;
241 boost::signals::connection show_dialog_with_data_connection_;
242 boost::signals::connection show_inset_dialog_connection_;
243 boost::signals::connection update_dialog_connection_;
244 boost::signals::connection layout_changed_connection_;
247 /// Bind methods for BufferView messages signal connection
249 void showDialog(std::string const & name);
250 void showDialogWithData(std::string const & name,
251 std::string const & data);
252 void showInsetDialog(std::string const & name,
253 std::string const & data, InsetBase * inset);
254 void updateDialog(std::string const & name,
255 std::string const & data);
258 /// notify readonly status
259 void showReadonly(bool);
262 /// view's command buffer controller
263 // this has to be declared _after_ lyxfunc_ as its initialization depends
265 typedef boost::scoped_ptr<frontend::ControlCommandBuffer>
268 CommandBufferPtr const controlcommand_;
272 std::vector<int> work_area_ids_;