]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
Move init() back to LyXView
[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         /// FIXME: what is the requirement for this be to separate from the ctor ?
59         void init();
60
61         /// start modal operation
62         virtual void prohibitInput() const = 0;
63         /// end modal operation
64         virtual void allowInput() const = 0;
65
66         //@{ generic accessor functions
67
68         /// return the current buffer view
69         BufferView * view() const;
70
71         /// return the LyX function handler for this view
72         LyXFunc * getLyXFunc() const;
73
74         /// return the buffer currently shown in this window
75         Buffer * buffer() const;
76
77         /// return the toolbar for this view
78         Toolbar * getToolbar() const;
79
80         /// return the menubar for this view
81         Menubar * getMenubar() const;
82
83         /// return the minibuffer for this view
84         /// FIXME: I'm not at all sure that LyXFunc should be
85         /// aware of a mini buffer as such
86         MiniBuffer * getMiniBuffer() const;
87
88         /// get access to the dialogs
89         Dialogs * getDialogs() { return dialogs_.get(); }
90
91         /// get this view's keyboard map handler
92         Intl * getIntl() const;
93
94         //@}
95
96         /// sets the layout in the toolbar layout selection
97         void setLayout(string const & layout);
98         /// updates the possible layouts selectable
99         void updateLayoutChoice();
100
101         /// update the toolbar
102         void updateToolbar();
103         /// update the menubar
104         void updateMenubar();
105
106         /// display a message in the view
107         void message(string const &);
108         /// push a message onto the history, and show it
109         void messagePush(string const & str);
110         /// pop the last message pushed
111         void messagePop();
112         /// show state (font etc.) in minibuffer
113         void showState();
114         
115         /// updates the title of the window
116         void updateWindowTitle();
117
118         /// reset autosave timer
119         void resetAutosaveTimer();
120
121 protected:
122         /// view of a buffer. Eventually there will be several.
123         boost::scoped_ptr<BufferView> bufferview_;
124
125         /// view's menubar
126         boost::scoped_ptr<Menubar> menubar_;
127         /// view's toolbar
128         boost::scoped_ptr<Toolbar> toolbar_;
129         /// view's minibuffer
130         boost::scoped_ptr<MiniBuffer> minibuffer_;
131
132         /// keyboard mapping object
133         boost::scoped_ptr<Intl> intl_;
134
135         /// auto-saving of buffers
136         boost::scoped_ptr<Timeout> autosave_timeout_;
137
138         /// called on timeout
139         void autoSave();
140
141         /// FIXME: GUII - toolbar property
142         void invalidateLayoutChoice();
143
144 private:
145         /**
146          * setWindowTitle - set title of window
147          * @param t main window title
148          * @param it iconified (short) title
149          */
150         virtual void setWindowTitle(string const & t, string const & it) = 0;
151
152         /// our function handler
153         boost::scoped_ptr<LyXFunc> lyxfunc_;
154         /// dialogs for this view
155         boost::scoped_ptr<Dialogs> dialogs_;
156
157         /**
158          * The last textclass layout list in the layout choice selector
159          * This should probably be moved to the toolbar, but for now it's
160          * here. (Asger)
161          *
162          * FIXME: GUII
163          */
164         int last_textclass_;
165 };
166
167 #endif // LYXVIEW_H