]> git.lyx.org Git - features.git/blob - src/frontends/LyXView.h
Really dull and boring header shit
[features.git] / src / frontends / LyXView.h
1 // -*- C++ -*-
2 /**
3  * \file LyXView.h
4  * Read the file COPYING
5  *
6  * \author Lars Gullik Bjønnes 
7  * \author John Levon 
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef LYXVIEW_H
13 #define LYXVIEW_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "LString.h"
20
21 #include "support/types.h"
22
23 #include <boost/utility.hpp>
24 #include <boost/scoped_ptr.hpp>
25 #include <boost/shared_ptr.hpp>
26 #include <boost/signals/trackable.hpp>
27 #include <boost/signals/signal0.hpp>
28
29 class Buffer;
30 class Toolbar;
31 class Intl;
32 class Menubar;
33 class ControlCommandBuffer;
34
35 class BufferView;
36 class Dialogs;
37 class LyXFunc;
38 class LyXFont;
39 class Timeout;
40 class FuncRequest;
41
42 /**
43  * LyXView - main LyX window
44  *
45  * This class represents the main LyX window and provides
46  * accessor functions to its content.
47  *
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.
51  *
52  * Additionally we would like to support multiple views
53  * in a single LyXView.
54  */
55 class LyXView : public boost::signals::trackable, boost::noncopyable {
56 public:
57
58         LyXView();
59
60         virtual ~LyXView();
61
62         /**
63          * This is called after the concrete view has been created.
64          * We have to have the toolbar and the other stuff created
65          * before we can populate it with this call.
66          */
67         void init();
68
69         /// start modal operation
70         virtual void prohibitInput() const = 0;
71         /// end modal operation
72         virtual void allowInput() const = 0;
73
74         //@{ generic accessor functions
75
76         /** return the current buffer view
77             Returned as a shared_ptr so that anything wanting to cache the
78             buffer view can do so safely using a boost::weak_ptr.
79          */
80         boost::shared_ptr<BufferView> const & view() const;
81
82         /// return the buffer currently shown in this window
83         Buffer * buffer() const;
84
85         /// return the LyX function handler for this view
86         LyXFunc & getLyXFunc() { return *lyxfunc_.get(); }
87         ///
88         LyXFunc const & getLyXFunc() const { return *lyxfunc_.get(); }
89
90         /// return the toolbar for this view
91         Toolbar & getToolbar() { return *toolbar_.get(); }
92         ///
93         Toolbar const & getToolbar() const { return *toolbar_.get(); }
94
95         /// return the menubar for this view
96         Menubar & getMenubar() { return *menubar_.get(); }
97         ///
98         Menubar const & getMenubar() const { return *menubar_.get(); }
99
100         /// get access to the dialogs
101         Dialogs & getDialogs() { return *dialogs_.get(); }
102         ///
103         Dialogs const & getDialogs() const { return *dialogs_.get(); }
104
105         /// get this view's keyboard map handler
106         Intl & getIntl() { return *intl_.get(); }
107         ///
108         Intl const & getIntl() const { return *intl_.get(); }
109
110         //@}
111
112         /// sets the layout in the toolbar layout selection
113         void setLayout(string const & layout);
114         /// updates the possible layouts selectable
115         void updateLayoutChoice();
116
117         /// update the toolbar
118         void updateToolbar();
119         /// update the menubar
120         void updateMenubar();
121
122         /// focus the command buffer (minibuffer)
123         boost::signal0<void> focus_command_buffer;
124  
125         /// view state string changed
126         boost::signal0<void> view_state_changed;
127
128         /// display a message in the view
129         virtual void message(string const &) = 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 & req);
139  
140 protected:
141         /// view of a buffer. Eventually there will be several.
142         boost::shared_ptr<BufferView> bufferview_;
143
144         /// view's menubar
145         boost::scoped_ptr<Menubar> menubar_;
146         /// view's toolbar
147         boost::scoped_ptr<Toolbar> toolbar_;
148
149 private:
150         /**
151          * setWindowTitle - set title of window
152          * @param t main window title
153          * @param it iconified (short) title
154          */
155         virtual void setWindowTitle(string const & t, string const & it) = 0;
156
157         /// called on timeout
158         void autoSave();
159
160         /// keyboard mapping object
161         boost::scoped_ptr<Intl> const intl_;
162         /// auto-saving of buffers
163         boost::scoped_ptr<Timeout> const autosave_timeout_;
164         /// our function handler
165         boost::scoped_ptr<LyXFunc> lyxfunc_;
166         /// dialogs for this view
167         boost::scoped_ptr<Dialogs> dialogs_;
168
169 protected:
170         /// view's command buffer controller
171         // this has to be declared _after_ lyxfunc_ as its initialization depends
172         // on it!
173         boost::scoped_ptr<ControlCommandBuffer> const controlcommand_;
174 };
175
176 #endif // LYXVIEW_H