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 "support/docstring.h"
19 #include <boost/signal.hpp>
20 #include <boost/signals/trackable.hpp>
21 #include <boost/noncopyable.hpp>
27 namespace support { class FileName; }
43 * LyXView - main LyX window
45 * This class represents the main LyX window and provides
46 * accessor functions to its content.
48 * The eventual intention is that LyX will support a number
49 * of containing LyXViews. Currently a lot of code still
50 * relies on there being a single top-level view.
52 * Additionally we would like to support multiple views
53 * in a single LyXView.
55 class LyXView : public boost::signals::trackable, boost::noncopyable {
62 int id() const { return id_; }
64 virtual void close() = 0;
66 virtual void setFocus() = 0;
69 virtual WorkArea * workArea(Buffer & buffer) = 0;
71 virtual WorkArea * addWorkArea(Buffer & buffer) = 0;
73 virtual void setCurrentWorkArea(WorkArea * work_area) = 0;
75 virtual void removeWorkArea(WorkArea * work_area) = 0;
76 /// return the current WorkArea (the one that has the focus).
77 virtual WorkArea const * currentWorkArea() const = 0;
78 /// FIXME: This non-const access is needed because of
79 /// a mis-designed \c ControlSpellchecker.
80 virtual WorkArea * currentWorkArea() = 0;
83 * This is called after the concrete view has been created.
84 * We have to have the toolbar and the other stuff created
85 * before we can populate it with this call.
87 virtual void init() = 0;
92 HorizontallyMaximized,
97 virtual void setGeometry(
102 unsigned int iconSizeXY,
103 const std::string & geometryArg) = 0;
105 /// save the geometry state in the session manager.
106 virtual void saveGeometry() = 0;
109 virtual void busy(bool) = 0;
111 //@{ generic accessor functions
113 /// \return the current buffer view.
116 /// \return the buffer currently shown in this window
118 Buffer const * buffer() const;
121 virtual void openLayoutList() = 0;
123 virtual bool isToolbarVisible(std::string const & id) = 0;
125 virtual void showMiniBuffer(bool visible) = 0;
126 virtual void openMenu(docstring const & name) = 0;
128 /// get access to the dialogs
129 Dialogs & getDialogs() { return *dialogs_; }
131 Dialogs const & getDialogs() const { return *dialogs_; }
135 /// load a buffer into the current workarea.
136 Buffer * loadLyXFile(support::FileName const & name, ///< File to load.
137 bool tolastfiles = true); ///< append to the "Open recent" menu?
139 /// set a buffer to the current workarea.
140 void setBuffer(Buffer * b); ///< \c Buffer to set.
142 /// updates the possible layouts selectable
143 virtual void updateLayoutChoice() = 0;
145 /// update the toolbar
146 virtual void updateToolbars() = 0;
148 virtual ToolbarInfo * getToolbarInfo(std::string const & name) = 0;
149 /// toggle toolbar state
150 virtual void toggleToolbarState(std::string const & name, bool allowauto) = 0;
151 /// update the status bar
152 virtual void updateStatusBar() = 0;
154 /// display a message in the view
155 virtual void message(docstring const &) = 0;
157 /// clear any temporary message and replace with current status
158 virtual void clearMessage() = 0;
160 /// updates the title of the window
161 void updateWindowTitle();
163 /// reset autosave timer
164 void resetAutosaveTimer();
166 /// dispatch to current BufferView
167 void dispatch(FuncRequest const & cmd);
169 /** redraw \c inset in all the BufferViews in which it is currently
170 * visible. If successful return a pointer to the owning Buffer.
172 Buffer const * updateInset(Inset const *);
174 /// returns true if this view has the focus.
175 virtual bool hasFocus() const = 0;
177 /// show the error list to the user
178 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();
185 /// connect to signals in the given buffer
186 void connectBuffer(Buffer & buf);
187 /// disconnect from signals in the given buffer
188 void disconnectBuffer();
192 * setWindowTitle - set title of window
193 * @param t main window title
194 * @param it iconified (short) title
196 virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
198 /// called on timeout
201 /// auto-saving of buffers
202 Timeout * const autosave_timeout_;
203 /// dialogs for this view
206 /// buffer structure changed signal connection
207 boost::signals::connection bufferStructureChangedConnection_;
208 /// embedded file change signal connection
209 boost::signals::connection bufferEmbeddingChangedConnection_;
210 /// buffer errors signal connection
211 boost::signals::connection errorsConnection_;
212 /// buffer messages signal connection
213 boost::signals::connection messageConnection_;
214 /// buffer busy status signal connection
215 boost::signals::connection busyConnection_;
216 /// buffer title changed signal connection
217 boost::signals::connection titleConnection_;
218 /// buffer reset timers signal connection
219 boost::signals::connection timerConnection_;
220 /// buffer readonly status changed signal connection
221 boost::signals::connection readonlyConnection_;
223 /// BufferView messages signal connection
225 boost::signals::connection message_connection_;
226 boost::signals::connection show_dialog_connection_;
227 boost::signals::connection show_dialog_with_data_connection_;
228 boost::signals::connection show_inset_dialog_connection_;
229 boost::signals::connection update_dialog_connection_;
232 /// Bind methods for BufferView messages signal connection
234 void showDialog(std::string const & name);
235 void showDialogWithData(std::string const & name,
236 std::string const & data);
237 void showInsetDialog(std::string const & name,
238 std::string const & data, Inset * inset);
239 void updateDialog(std::string const & name,
240 std::string const & data);
243 /// notify readonly status
244 void showReadonly(bool);
250 void updateEmbeddedFiles();
256 } // namespace frontend