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