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