]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
bug fix. reorder initialization
[lyx.git] / src / frontends / LyXView.h
1 // -*- C++ -*-
2 /**
3  * \file LyXView.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author Lars Gullik Bjønnes <larsbj@lyx.org>
8  * \author John Levon <moz@compsoc.man.ac.uk>
9  */
10
11 #ifndef LYXVIEW_H
12 #define LYXVIEW_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "LString.h"
19
20 #include "support/types.h"
21
22 #include <boost/utility.hpp>
23 #include <boost/scoped_ptr.hpp>
24 #include <boost/shared_ptr.hpp>
25 #include <boost/signals/trackable.hpp>
26 #include <boost/signals/signal0.hpp>
27
28 class Buffer;
29 class Toolbar;
30 class Intl;
31 class Menubar;
32 class ControlCommandBuffer;
33
34 class BufferView;
35 class Dialogs;
36 class LyXFunc;
37 class LyXFont;
38 class Timeout;
39 class FuncRequest;
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         /// start modal operation
69         virtual void prohibitInput() const = 0;
70         /// end modal operation
71         virtual void allowInput() const = 0;
72
73         //@{ generic accessor functions
74
75         /** return the current buffer view
76             Returned as a shared_ptr so that anything wanting to cache the
77             buffer view can do so safely using a boost::weak_ptr.
78          */
79         boost::shared_ptr<BufferView> const & view() const;
80
81         /// return the buffer currently shown in this window
82         Buffer * buffer() const;
83
84         /// return the LyX function handler for this view
85         LyXFunc & getLyXFunc() { return *lyxfunc_.get(); }
86         ///
87         LyXFunc const & getLyXFunc() const { return *lyxfunc_.get(); }
88
89         /// return the toolbar for this view
90         Toolbar & getToolbar() { return *toolbar_.get(); }
91         ///
92         Toolbar const & getToolbar() const { return *toolbar_.get(); }
93
94         /// return the menubar for this view
95         Menubar & getMenubar() { return *menubar_.get(); }
96         ///
97         Menubar const & getMenubar() const { return *menubar_.get(); }
98
99         /// get access to the dialogs
100         Dialogs & getDialogs() { return *dialogs_.get(); }
101         ///
102         Dialogs const & getDialogs() const { return *dialogs_.get(); }
103
104         /// get this view's keyboard map handler
105         Intl & getIntl() { return *intl_.get(); }
106         ///
107         Intl const & getIntl() const { return *intl_.get(); }
108
109         //@}
110
111         /// sets the layout in the toolbar layout selection
112         void setLayout(string const & layout);
113         /// updates the possible layouts selectable
114         void updateLayoutChoice();
115
116         /// update the toolbar
117         void updateToolbar();
118         /// update the menubar
119         void updateMenubar();
120
121         /// focus the command buffer (minibuffer)
122         boost::signal0<void> focus_command_buffer;
123  
124         /// view state string changed
125         boost::signal0<void> view_state_changed;
126
127         /// display a message in the view
128         virtual void message(string const &) = 0;
129
130         /// updates the title of the window
131         void updateWindowTitle();
132
133         /// reset autosave timer
134         void resetAutosaveTimer();
135
136         /// dispatch to current BufferView
137         void dispatch(FuncRequest const & req);
138  
139 protected:
140         /// view of a buffer. Eventually there will be several.
141         boost::shared_ptr<BufferView> bufferview_;
142
143         /// view's menubar
144         boost::scoped_ptr<Menubar> menubar_;
145         /// view's toolbar
146         boost::scoped_ptr<Toolbar> toolbar_;
147
148 private:
149         /**
150          * setWindowTitle - set title of window
151          * @param t main window title
152          * @param it iconified (short) title
153          */
154         virtual void setWindowTitle(string const & t, string const & it) = 0;
155
156         /// called on timeout
157         void autoSave();
158
159         /// keyboard mapping object
160         boost::scoped_ptr<Intl> const intl_;
161         /// auto-saving of buffers
162         boost::scoped_ptr<Timeout> const autosave_timeout_;
163         /// our function handler
164         boost::scoped_ptr<LyXFunc> lyxfunc_;
165         /// dialogs for this view
166         boost::scoped_ptr<Dialogs> dialogs_;
167
168 protected:
169         /// view's command buffer controller
170         // this has to be declared _after_ lyxfunc_ as its initialization depends
171         // on it!
172         boost::scoped_ptr<ControlCommandBuffer> const controlcommand_;
173 };
174
175 #endif // LYXVIEW_H