]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
namespace grfx -> lyx::graphics
[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
17 #include "LString.h"
18
19 #include "support/types.h"
20
21 #include <boost/utility.hpp>
22 #include <boost/scoped_ptr.hpp>
23 #include <boost/shared_ptr.hpp>
24 #include <boost/signals/trackable.hpp>
25 #include <boost/signals/signal0.hpp>
26
27 class Buffer;
28 class Toolbar;
29 class Intl;
30 class Menubar;
31 class ControlCommandBuffer;
32
33 class BufferView;
34 class Dialogs;
35 class LyXFunc;
36 class LyXFont;
37 class Timeout;
38 class FuncRequest;
39
40 /**
41  * LyXView - main LyX window
42  *
43  * This class represents the main LyX window and provides
44  * accessor functions to its content.
45  *
46  * The eventual intention is that LyX will support a number
47  * of containing LyXViews. Currently a lot of code still
48  * relies on there being a single top-level view.
49  *
50  * Additionally we would like to support multiple views
51  * in a single LyXView.
52  */
53 class LyXView : public boost::signals::trackable, boost::noncopyable {
54 public:
55
56         LyXView();
57
58         virtual ~LyXView();
59
60         /**
61          * This is called after the concrete view has been created.
62          * We have to have the toolbar and the other stuff created
63          * before we can populate it with this call.
64          */
65         void init();
66
67         /// show busy cursor
68         virtual void busy(bool) const = 0;
69
70         //@{ generic accessor functions
71
72         /** return the current buffer view
73             Returned as a shared_ptr so that anything wanting to cache the
74             buffer view can do so safely using a boost::weak_ptr.
75          */
76         boost::shared_ptr<BufferView> const & view() const;
77
78         /// return the buffer currently shown in this window
79         Buffer * buffer() const;
80
81         /// return the LyX function handler for this view
82         LyXFunc & getLyXFunc() { return *lyxfunc_.get(); }
83         ///
84         LyXFunc const & getLyXFunc() const { return *lyxfunc_.get(); }
85
86         /// return the toolbar for this view
87         Toolbar & getToolbar() { return *toolbar_.get(); }
88         ///
89         Toolbar const & getToolbar() const { return *toolbar_.get(); }
90
91         /// return the menubar for this view
92         Menubar & getMenubar() { return *menubar_.get(); }
93         ///
94         Menubar const & getMenubar() const { return *menubar_.get(); }
95
96         /// get access to the dialogs
97         Dialogs & getDialogs() { return *dialogs_.get(); }
98         ///
99         Dialogs const & getDialogs() const { return *dialogs_.get(); }
100
101         /// get this view's keyboard map handler
102         Intl & getIntl() { return *intl_.get(); }
103         ///
104         Intl const & getIntl() const { return *intl_.get(); }
105
106         //@}
107
108         /// sets the layout in the toolbar layout selection
109         void setLayout(string const & layout);
110         /// updates the possible layouts selectable
111         void updateLayoutChoice();
112
113         /// update the toolbar
114         void updateToolbar();
115         /// update the menubar
116         void updateMenubar();
117
118         /// focus the command buffer (minibuffer)
119         boost::signal0<void> focus_command_buffer;
120
121         /// view state string changed
122         boost::signal0<void> view_state_changed;
123
124         /// display a message in the view
125         virtual void message(string const &) = 0;
126
127         /// clear any temporary message and replace with current status
128         virtual void clearMessage() = 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