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 } // namespace frontend
42 class ControlCommandBuffer;
43 } // namespace frontend
48 * LyXView - main LyX window
50 * This class represents the main LyX window and provides
51 * accessor functions to its content.
53 * The eventual intention is that LyX will support a number
54 * of containing LyXViews. Currently a lot of code still
55 * relies on there being a single top-level view.
57 * Additionally we would like to support multiple views
58 * in a single LyXView.
60 class LyXView : public boost::signals::trackable, boost::noncopyable {
68 * This is called after the concrete view has been created.
69 * We have to have the toolbar and the other stuff created
70 * before we can populate it with this call.
75 virtual void busy(bool) const = 0;
77 //@{ generic accessor functions
79 /** return the current buffer view
80 Returned as a shared_ptr so that anything wanting to cache the
81 buffer view can do so safely using a boost::weak_ptr.
83 boost::shared_ptr<BufferView> const & view() const;
85 /// return the buffer currently shown in this window
86 Buffer * buffer() const;
88 /// return the LyX function handler for this view
89 LyXFunc & getLyXFunc() { return *lyxfunc_.get(); }
91 LyXFunc const & getLyXFunc() const { return *lyxfunc_.get(); }
93 /// return the toolbar for this view
94 Toolbars & getToolbars() { return *toolbars_.get(); }
96 Toolbars const & getToolbars() const { return *toolbars_.get(); }
98 /// return the menubar for this view
99 Menubar & getMenubar() { return *menubar_.get(); }
101 Menubar const & getMenubar() const { return *menubar_.get(); }
103 /// get access to the dialogs
104 Dialogs & getDialogs() { return *dialogs_.get(); }
106 Dialogs const & getDialogs() const { return *dialogs_.get(); }
108 /// get this view's keyboard map handler
109 Intl & getIntl() { return *intl_.get(); }
111 Intl const & getIntl() const { return *intl_.get(); }
115 /// sets the layout in the toolbar layout selection
116 void setLayout(std::string const & layout);
117 /// updates the possible layouts selectable
118 void updateLayoutChoice();
120 /// update the toolbar
121 void updateToolbars();
122 /// update the menubar
123 void updateMenubar();
125 /// focus the command buffer (minibuffer)
126 boost::signal<void()> focus_command_buffer;
128 /// view state string changed
129 boost::signal<void()> view_state_changed;
131 /// display a message in the view
132 virtual void message(std::string const &) = 0;
134 /// clear any temporary message and replace with current status
135 virtual void clearMessage() = 0;
137 /// updates the title of the window
138 void updateWindowTitle();
140 /// reset autosave timer
141 void resetAutosaveTimer();
143 /// dispatch to current BufferView
144 void dispatch(FuncRequest const & cmd);
146 /** redraw \c inset in all the BufferViews in which it is currently
147 * visible. If successful return a pointer to the owning Buffer.
149 Buffer const * const updateInset(InsetBase const *) const;
151 // returns true if this view has the focus.
152 virtual bool hasFocus() const = 0;
154 virtual lyx::frontend::Gui & gui() = 0;
157 /// view of a buffer. Eventually there will be several.
158 boost::shared_ptr<BufferView> bufferview_;
161 boost::scoped_ptr<Menubar> menubar_;
165 * setWindowTitle - set title of window
166 * @param t main window title
167 * @param it iconified (short) title
169 virtual void setWindowTitle(std::string const & t, std::string const & it) = 0;
171 /// called on timeout
175 boost::scoped_ptr<Toolbars> toolbars_;
176 /// keyboard mapping object
177 boost::scoped_ptr<Intl> const intl_;
178 /// auto-saving of buffers
179 boost::scoped_ptr<Timeout> const autosave_timeout_;
180 /// our function handler
181 boost::scoped_ptr<LyXFunc> lyxfunc_;
182 /// dialogs for this view
183 boost::scoped_ptr<Dialogs> dialogs_;
186 /// view's command buffer controller
187 // this has to be declared _after_ lyxfunc_ as its initialization depends
189 typedef boost::scoped_ptr<lyx::frontend::ControlCommandBuffer>
192 CommandBufferPtr const controlcommand_;