]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
some tabular fixes for the problems reported by Helge
[lyx.git] / src / frontends / LyXView.h
1 // -*- C++ -*-
2 /**
3  * \file LyXView.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef LYXVIEW_H
14 #define LYXVIEW_H
15
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>
21
22 class Buffer;
23 class Toolbars;
24 class InsetBase;
25 class Intl;
26 class Menubar;
27
28 class BufferView;
29 class Dialogs;
30 class LyXFunc;
31 class LyXFont;
32 class Timeout;
33 class FuncRequest;
34
35 namespace lyx {
36 namespace frontend {
37 class ControlCommandBuffer;
38 } // namespace frontend
39 } // namespace lyx
40
41 /**
42  * LyXView - main LyX window
43  *
44  * This class represents the main LyX window and provides
45  * accessor functions to its content.
46  *
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.
50  *
51  * Additionally we would like to support multiple views
52  * in a single LyXView.
53  */
54 class LyXView : public boost::signals::trackable, boost::noncopyable {
55 public:
56
57         LyXView();
58
59         virtual ~LyXView();
60
61         /**
62          * This is called after the concrete view has been created.
63          * We have to have the toolbar and the other stuff created
64          * before we can populate it with this call.
65          */
66         void init();
67
68         /// show busy cursor
69         virtual void busy(bool) const = 0;
70
71         //@{ generic accessor functions
72
73         /** return the current buffer view
74             Returned as a shared_ptr so that anything wanting to cache the
75             buffer view can do so safely using a boost::weak_ptr.
76          */
77         boost::shared_ptr<BufferView> const & view() const;
78
79         /// return the buffer currently shown in this window
80         Buffer * buffer() const;
81
82         /// return the LyX function handler for this view
83         LyXFunc & getLyXFunc() { return *lyxfunc_.get(); }
84         ///
85         LyXFunc const & getLyXFunc() const { return *lyxfunc_.get(); }
86
87         /// return the toolbar for this view
88         Toolbars & getToolbars() { return *toolbars_.get(); }
89         ///
90         Toolbars const & getToolbars() const { return *toolbars_.get(); }
91
92         /// return the menubar for this view
93         Menubar & getMenubar() { return *menubar_.get(); }
94         ///
95         Menubar const & getMenubar() const { return *menubar_.get(); }
96
97         /// get access to the dialogs
98         Dialogs & getDialogs() { return *dialogs_.get(); }
99         ///
100         Dialogs const & getDialogs() const { return *dialogs_.get(); }
101
102         /// get this view's keyboard map handler
103         Intl & getIntl() { return *intl_.get(); }
104         ///
105         Intl const & getIntl() const { return *intl_.get(); }
106
107         //@}
108
109         /// sets the layout in the toolbar layout selection
110         void setLayout(std::string const & layout);
111         /// updates the possible layouts selectable
112         void updateLayoutChoice();
113
114         /// update the toolbar
115         void updateToolbars();
116         /// update the menubar
117         void updateMenubar();
118
119         /// focus the command buffer (minibuffer)
120         boost::signal<void()> focus_command_buffer;
121
122         /// view state string changed
123         boost::signal<void()> view_state_changed;
124
125         /// display a message in the view
126         virtual void message(std::string const &) = 0;
127
128         /// clear any temporary message and replace with current status
129         virtual void clearMessage() = 0;
130
131         /// updates the title of the window
132         void updateWindowTitle();
133
134         /// reset autosave timer
135         void resetAutosaveTimer();
136
137         /// dispatch to current BufferView
138         void dispatch(FuncRequest const & cmd);
139
140         /** redraw \c inset in all the BufferViews in which it is currently
141          *  visible. If successful return a pointer to the owning Buffer.
142          */
143         Buffer const * const updateInset(InsetBase const *) const;
144
145         // returns true if this view has the focus.
146         virtual bool hasFocus() const = 0;
147
148 protected:
149         /// view of a buffer. Eventually there will be several.
150         boost::shared_ptr<BufferView> bufferview_;
151
152         /// view's menubar
153         boost::scoped_ptr<Menubar> menubar_;
154
155 private:
156         /**
157          * setWindowTitle - set title of window
158          * @param t main window title
159          * @param it iconified (short) title
160          */
161         virtual void setWindowTitle(std::string const & t, std::string const & it) = 0;
162
163         /// called on timeout
164         void autoSave();
165
166         /// view's toolbar
167         boost::scoped_ptr<Toolbars> toolbars_;
168         /// keyboard mapping object
169         boost::scoped_ptr<Intl> const intl_;
170         /// auto-saving of buffers
171         boost::scoped_ptr<Timeout> const autosave_timeout_;
172         /// our function handler
173         boost::scoped_ptr<LyXFunc> lyxfunc_;
174         /// dialogs for this view
175         boost::scoped_ptr<Dialogs> dialogs_;
176
177 protected:
178         /// view's command buffer controller
179         // this has to be declared _after_ lyxfunc_ as its initialization depends
180         // on it!
181         typedef boost::scoped_ptr<lyx::frontend::ControlCommandBuffer>
182         CommandBufferPtr;
183
184         CommandBufferPtr const controlcommand_;
185 };
186
187 #endif // LYXVIEW_H