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