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 setBusy(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(bool force) = 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 /// reset autosave timer
162 void resetAutosaveTimer();
164 /// dispatch to current BufferView
165 void dispatch(FuncRequest const & cmd);
167 /** redraw \c inset in all the BufferViews in which it is currently
168 * visible. If successful return a pointer to the owning Buffer.
170 Buffer const * updateInset(Inset const *);
172 /// returns true if this view has the focus.
173 virtual bool hasFocus() const = 0;
175 /// show the error list to the user
176 void showErrorList(std::string const &);
182 /// This function is called when the buffer structure is changed.
183 void structureChanged() { updateToc(); }
184 /// This function is called when some parsing error shows up.
185 void errors(std::string const & err) { showErrorList(err); }
186 /// Reset autosave timers for all users.
187 void resetAutosaveTimers() { resetAutosaveTimer(); }
189 /// connect to signals in the given BufferView
190 void connectBufferView(BufferView & bv);
191 /// disconnect from signals in the given BufferView
192 void disconnectBufferView();
193 /// connect to signals in the given buffer
194 void connectBuffer(Buffer & buf);
195 /// disconnect from signals in the given buffer
196 void disconnectBuffer();
199 /// called on timeout
202 /// auto-saving of buffers
203 Timeout * const autosave_timeout_;
204 /// dialogs for this view
207 /// Bind methods for BufferView messages signal connection
209 void showDialog(std::string const & name);
210 void showDialogWithData(std::string const & name,
211 std::string const & data);
212 void showInsetDialog(std::string const & name,
213 std::string const & data, Inset * inset);
214 void updateDialog(std::string const & name,
215 std::string const & data);
222 void updateEmbeddedFiles();
228 } // namespace frontend