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/Delegates.h"
18 #include "support/docstring.h"
20 #include <boost/noncopyable.hpp>
26 namespace support { class FileName; }
42 * LyXView - main LyX window
44 * This class represents the main LyX window and provides
45 * accessor functions to its content.
47 * The eventual intention is that LyX will support a number
48 * of containing LyXViews. Currently a lot of code still
49 * relies on there being a single top-level view.
51 * Additionally we would like to support multiple views
52 * in a single LyXView.
54 class LyXView : boost::noncopyable,
55 public GuiBufferViewDelegate, public GuiBufferDelegate
63 int id() const { return id_; }
65 virtual void close() = 0;
67 virtual void setFocus() = 0;
70 virtual WorkArea * workArea(Buffer & buffer) = 0;
72 virtual WorkArea * addWorkArea(Buffer & buffer) = 0;
74 virtual void setCurrentWorkArea(WorkArea * work_area) = 0;
76 virtual void removeWorkArea(WorkArea * work_area) = 0;
77 /// return the current WorkArea (the one that has the focus).
78 virtual WorkArea const * currentWorkArea() const = 0;
79 /// FIXME: This non-const access is needed because of
80 /// a mis-designed \c ControlSpellchecker.
81 virtual WorkArea * currentWorkArea() = 0;
84 * This is called after the concrete view has been created.
85 * We have to have the toolbar and the other stuff created
86 * before we can populate it with this call.
88 virtual void init() = 0;
93 HorizontallyMaximized,
98 virtual void setGeometry(
103 unsigned int iconSizeXY,
104 const std::string & geometryArg) = 0;
106 /// save the geometry state in the session manager.
107 virtual void saveGeometry() = 0;
110 virtual void busy(bool) = 0;
112 //@{ generic accessor functions
114 /// \return the current buffer view.
117 /// \return the buffer currently shown in this window
119 Buffer const * buffer() const;
122 virtual void openLayoutList() = 0;
124 virtual bool isToolbarVisible(std::string const & id) = 0;
126 virtual void showMiniBuffer(bool visible) = 0;
127 virtual void openMenu(docstring const & name) = 0;
129 /// get access to the dialogs
130 Dialogs & getDialogs() { return *dialogs_; }
132 Dialogs const & getDialogs() const { return *dialogs_; }
136 /// load a buffer into the current workarea.
137 Buffer * loadLyXFile(support::FileName const & name, ///< File to load.
138 bool tolastfiles = true); ///< append to the "Open recent" menu?
140 /// set a buffer to the current workarea.
141 void setBuffer(Buffer * b); ///< \c Buffer to set.
143 /// updates the possible layouts selectable
144 virtual void updateLayoutChoice() = 0;
146 /// update the toolbar
147 virtual void updateToolbars() = 0;
149 virtual ToolbarInfo * getToolbarInfo(std::string const & name) = 0;
150 /// toggle toolbar state
151 virtual void toggleToolbarState(std::string const & name, bool allowauto) = 0;
152 /// update the status bar
153 virtual void updateStatusBar() = 0;
155 /// display a message in the view
156 virtual void message(docstring const &) = 0;
158 /// clear any temporary message and replace with current status
159 virtual void clearMessage() = 0;
161 /// updates the title of the window
162 void updateWindowTitle();
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 * updateInset(Inset 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 &);
185 /// This function is called when the buffer structure is changed.
186 void structureChanged() { updateToc(); }
187 /// This function is called when an embedded file is changed
188 void embeddingChanged() { updateEmbeddedFiles(); }
189 /// This function is called when some parsing error shows up.
190 void errors(std::string const & err) { showErrorList(err); }
191 /// This function is called when the buffer busy status change.
193 /// This function is called when the buffer readonly status change.
194 void readonly(bool on) { showReadonly(on); }
195 /// Update window titles of all users.
196 void updateTitles() { updateWindowTitle(); }
197 /// Reset autosave timers for all users.
198 void resetAutosaveTimers() { resetAutosaveTimer(); }
200 /// connect to signals in the given BufferView
201 void connectBufferView(BufferView & bv);
202 /// disconnect from signals in the given BufferView
203 void disconnectBufferView();
204 /// connect to signals in the given buffer
205 void connectBuffer(Buffer & buf);
206 /// disconnect from signals in the given buffer
207 void disconnectBuffer();
211 * setWindowTitle - set title of window
212 * @param t main window title
213 * @param it iconified (short) title
215 virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
217 /// called on timeout
220 /// auto-saving of buffers
221 Timeout * const autosave_timeout_;
222 /// dialogs for this view
225 /// Bind methods for BufferView messages signal connection
227 void showDialog(std::string const & name);
228 void showDialogWithData(std::string const & name,
229 std::string const & data);
230 void showInsetDialog(std::string const & name,
231 std::string const & data, Inset * inset);
232 void updateDialog(std::string const & name,
233 std::string const & data);
236 /// notify readonly status
237 void showReadonly(bool);
243 void updateEmbeddedFiles();
249 } // namespace frontend