]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
* LyXView: the accessor methods now return a reference to the member
[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
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         /// start modal operation
68         virtual void prohibitInput() const = 0;
69         /// end modal operation
70         virtual void allowInput() const = 0;
71
72         //@{ generic accessor functions
73
74         /** return the current buffer view
75             Returned as a shared_ptr so that anything wanting to cache the
76             buffer view can do so safely using a boost::weak_ptr.
77          */
78         boost::shared_ptr<BufferView> const & view() const;
79
80         /// return the buffer currently shown in this window
81         Buffer * buffer() const;
82
83         /// return the LyX function handler for this view
84         LyXFunc & getLyXFunc() { return *lyxfunc_.get(); }
85         ///
86         LyXFunc const & getLyXFunc() const { return *lyxfunc_.get(); }
87
88         /// return the toolbar for this view
89         Toolbar & getToolbar() { return *toolbar_.get(); }
90         ///
91         Toolbar const & getToolbar() const { return *toolbar_.get(); }
92
93         /// return the menubar for this view
94         Menubar & getMenubar() { return *menubar_.get(); }
95         ///
96         Menubar const & getMenubar() const { return *menubar_.get(); }
97
98         /// get access to the dialogs
99         Dialogs & getDialogs() { return *dialogs_.get(); }
100         ///
101         Dialogs const & getDialogs() const { return *dialogs_.get(); }
102
103         /// get this view's keyboard map handler
104         Intl & getIntl() { return *intl_.get(); }
105         ///
106         Intl const & getIntl() const { return *intl_.get(); }
107
108         //@}
109
110         /// sets the layout in the toolbar layout selection
111         void setLayout(string const & layout);
112         /// updates the possible layouts selectable
113         void updateLayoutChoice();
114
115         /// update the toolbar
116         void updateToolbar();
117         /// update the menubar
118         void updateMenubar();
119
120         /// focus the command buffer (minibuffer)
121         boost::signal0<void> focus_command_buffer;
122  
123         /// view state string changed
124         boost::signal0<void> view_state_changed;
125
126         /// display a message in the view
127         virtual void message(string const &) = 0;
128
129         /// updates the title of the window
130         void updateWindowTitle();
131
132         /// reset autosave timer
133         void resetAutosaveTimer();
134
135 protected:
136         /// view of a buffer. Eventtually there will be several.
137         boost::shared_ptr<BufferView> bufferview_;
138
139         /// view's menubar
140         boost::scoped_ptr<Menubar> menubar_;
141         /// view's toolbar
142         boost::scoped_ptr<Toolbar> toolbar_;
143         /// view's command buffer controller
144         boost::scoped_ptr<ControlCommandBuffer> const controlcommand_;
145
146 private:
147         /**
148          * setWindowTitle - set title of window
149          * @param t main window title
150          * @param it iconified (short) title
151          */
152         virtual void setWindowTitle(string const & t, string const & it) = 0;
153
154         /// called on timeout
155         void autoSave();
156
157         /// keyboard mapping object
158         boost::scoped_ptr<Intl> const intl_;
159         /// auto-saving of buffers
160         boost::scoped_ptr<Timeout> const autosave_timeout_;
161         /// our function handler
162         boost::scoped_ptr<LyXFunc> lyxfunc_;
163         /// dialogs for this view
164         boost::scoped_ptr<Dialogs> dialogs_;
165 };
166
167 #endif // LYXVIEW_H