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