]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
Create a grfx::Loader class and so move large chunks of code out of
[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 Bjornes <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/signals/trackable.hpp>
25
26 class Buffer;
27 class Toolbar;
28 class MiniBuffer;
29 class Intl;
30 class Menubar;
31
32 class BufferView;
33 class Dialogs;
34 class LyXFunc;
35 class LyXFont;
36 class Timeout;
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         /// start modal operation
66         virtual void prohibitInput() const = 0;
67         /// end modal operation
68         virtual void allowInput() const = 0;
69
70         //@{ generic accessor functions
71
72         /// return the current buffer view
73         BufferView * view() const;
74
75         /// return the LyX function handler for this view
76         LyXFunc * getLyXFunc() const;
77
78         /// return the buffer currently shown in this window
79         Buffer * buffer() const;
80
81         /// return the toolbar for this view
82         Toolbar * getToolbar() const;
83
84         /// return the menubar for this view
85         Menubar * getMenubar() const;
86
87         /// return the minibuffer for this view
88         /// FIXME: I'm not at all sure that LyXFunc should be
89         /// aware of a mini buffer as such
90         MiniBuffer * getMiniBuffer() const;
91
92         /// get access to the dialogs
93         Dialogs * getDialogs() { return dialogs_.get(); }
94
95         /// get this view's keyboard map handler
96         Intl * getIntl() const;
97
98         //@}
99
100         /// sets the layout in the toolbar layout selection
101         void setLayout(string const & layout);
102         /// updates the possible layouts selectable
103         void updateLayoutChoice();
104
105         /// update the toolbar
106         void updateToolbar();
107         /// update the menubar
108         void updateMenubar();
109
110         /// display a message in the view
111         void message(string const &);
112         /// push a message onto the history, and show it
113         void messagePush(string const & str);
114         /// pop the last message pushed
115         void messagePop();
116         /// show state (font etc.) in minibuffer
117         void showState();
118
119         /// updates the title of the window
120         void updateWindowTitle();
121
122         /// reset autosave timer
123         void resetAutosaveTimer();
124
125 protected:
126         /// view of a buffer. Eventually there will be several.
127         boost::scoped_ptr<BufferView> bufferview_;
128
129         /// view's menubar
130         boost::scoped_ptr<Menubar> menubar_;
131         /// view's toolbar
132         boost::scoped_ptr<Toolbar> toolbar_;
133         /// view's minibuffer
134         boost::scoped_ptr<MiniBuffer> minibuffer_;
135
136         /// keyboard mapping object
137         boost::scoped_ptr<Intl> intl_;
138
139         /// auto-saving of buffers
140         boost::scoped_ptr<Timeout> autosave_timeout_;
141
142         /// called on timeout
143         void autoSave();
144
145 private:
146         /**
147          * setWindowTitle - set title of window
148          * @param t main window title
149          * @param it iconified (short) title
150          */
151         virtual void setWindowTitle(string const & t, string const & it) = 0;
152
153         /// our function handler
154         boost::scoped_ptr<LyXFunc> lyxfunc_;
155         /// dialogs for this view
156         boost::scoped_ptr<Dialogs> dialogs_;
157 };
158
159 #endif // LYXVIEW_H