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 <boost/scoped_ptr.hpp>
17 #include <boost/shared_ptr.hpp>
18 #include <boost/signal.hpp>
19 #include <boost/signals/trackable.hpp>
20 #include <boost/utility.hpp>
39 class ControlCommandBuffer;
40 } // namespace frontend
45 * LyXView - main LyX window
47 * This class represents the main LyX window and provides
48 * accessor functions to its content.
50 * The eventual intention is that LyX will support a number
51 * of containing LyXViews. Currently a lot of code still
52 * relies on there being a single top-level view.
54 * Additionally we would like to support multiple views
55 * in a single LyXView.
57 class LyXView : public boost::signals::trackable, boost::noncopyable {
60 LyXView(lyx::frontend::Gui & owner);
64 void setWorkArea(lyx::frontend::WorkArea * work_area);
67 * This is called after the concrete view has been created.
68 * We have to have the toolbar and the other stuff created
69 * before we can populate it with this call.
74 virtual void busy(bool) const = 0;
76 //@{ generic accessor functions
78 /** return the current buffer view
79 Returned as a shared_ptr so that anything wanting to cache the
80 buffer view can do so safely using a boost::weak_ptr.
82 BufferView * view() const;
84 /// return the buffer currently shown in this window
85 Buffer * buffer() const;
87 /// return the LyX function handler for this view
88 LyXFunc & getLyXFunc() { return *lyxfunc_.get(); }
90 LyXFunc const & getLyXFunc() const { return *lyxfunc_.get(); }
92 /// return the toolbar for this view
93 Toolbars & getToolbars() { return *toolbars_.get(); }
95 Toolbars const & getToolbars() const { return *toolbars_.get(); }
97 /// return the menubar for this view
98 Menubar & getMenubar() { return *menubar_.get(); }
100 Menubar const & getMenubar() const { return *menubar_.get(); }
102 /// get access to the dialogs
103 Dialogs & getDialogs() { return *dialogs_.get(); }
105 Dialogs const & getDialogs() const { return *dialogs_.get(); }
107 /// get this view's keyboard map handler
108 Intl & getIntl() { return *intl_.get(); }
110 Intl const & getIntl() const { return *intl_.get(); }
114 /// load a buffer into the current workarea
115 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
117 /// set a buffer to the current workarea
118 void setBuffer(Buffer * b);
120 /// sets the layout in the toolbar layout selection
121 void setLayout(std::string const & layout);
122 /// updates the possible layouts selectable
123 void updateLayoutChoice();
125 /// update the toolbar
126 void updateToolbars();
127 /// update the menubar
128 void updateMenubar();
129 /// update the status bar
130 virtual void updateStatusBar() = 0;
132 /// focus the command buffer (minibuffer)
133 boost::signal<void()> focus_command_buffer;
135 /// display a message in the view
136 virtual void message(std::string const &) = 0;
138 /// clear any temporary message and replace with current status
139 virtual void clearMessage() = 0;
141 /// updates the title of the window
142 void updateWindowTitle();
144 /// reset autosave timer
145 void resetAutosaveTimer();
147 /// dispatch to current BufferView
148 void dispatch(FuncRequest const & cmd);
150 /** redraw \c inset in all the BufferViews in which it is currently
151 * visible. If successful return a pointer to the owning Buffer.
153 Buffer const * const updateInset(InsetBase const *) const;
155 /// returns true if this view has the focus.
156 virtual bool hasFocus() const = 0;
159 virtual lyx::frontend::Gui & gui();
161 /// Temporary method used by the kernel to redraw the work area.
162 virtual void redrawWorkArea();
164 /// Temporary method to access the current workArea.
165 /// This is needed for the qt3 and gtk frontend.
166 lyx::frontend::WorkArea * workArea();
168 /// show the error list to the user
169 void showErrorList(std::string const &);
172 /// current work area (screen view of a BufferView).
174 \todo FIXME: there is only one workArea per LyXView for now.
176 lyx::frontend::WorkArea * work_area_;
179 boost::scoped_ptr<Menubar> menubar_;
182 lyx::frontend::Gui & owner_;
184 * setWindowTitle - set title of window
185 * @param t main window title
186 * @param it iconified (short) title
188 virtual void setWindowTitle(std::string const & t, std::string const & it) = 0;
190 /// called on timeout
194 boost::scoped_ptr<Toolbars> toolbars_;
195 /// keyboard mapping object
196 boost::scoped_ptr<Intl> const intl_;
197 /// auto-saving of buffers
198 boost::scoped_ptr<Timeout> const autosave_timeout_;
199 /// our function handler
200 boost::scoped_ptr<LyXFunc> lyxfunc_;
201 /// dialogs for this view
202 boost::scoped_ptr<Dialogs> dialogs_;
204 /// buffer errors signal connection
205 boost::signals::connection errorsConnection_;
206 /// buffer messages signal connection
207 boost::signals::connection messageConnection_;
208 /// buffer busy status signal connection
209 boost::signals::connection busyConnection_;
210 /// buffer title changed signal connection
211 boost::signals::connection titleConnection_;
212 /// buffer reset timers signal connection
213 boost::signals::connection timerConnection_;
214 /// buffer readonly status changed signal connection
215 boost::signals::connection readonlyConnection_;
216 /// buffer closing signal connection
217 boost::signals::connection closingConnection_;
218 /// connect to signals in the given buffer
219 void connectBuffer(Buffer & buf);
220 /// disconnect from signals in the given buffer
221 void disconnectBuffer();
222 /// notify readonly status
223 void showReadonly(bool);
226 /// view's command buffer controller
227 // this has to be declared _after_ lyxfunc_ as its initialization depends
229 typedef boost::scoped_ptr<lyx::frontend::ControlCommandBuffer>
232 CommandBufferPtr const controlcommand_;