]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
Some minor cleanup + use of scoped_ptr instead of raw pointer,
[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         virtual void init() = 0;
59         ///
60         virtual void setPosition(int, int) = 0;
61         ///
62         virtual void show(int, int, string const &) = 0;
63         /// Redraw the main form.
64         virtual void redraw() = 0;
65
66         /// Resize all BufferViews in this LyXView (because the width changed)
67         void resize();
68
69         /// returns the buffer currently shown in the main form.
70         Buffer * buffer() const;
71
72         ///
73         BufferView * view() const;
74
75         /// return the toolbar for this view
76         Toolbar * getToolbar() const;
77
78         /// sets the layout in the toolbar layout combox
79         void setLayout(string const & layout);
80         /// update the toolbar
81         void updateToolbar();
82
83         /// return a pointer to the lyxfunc
84         LyXFunc * getLyXFunc() const;
85
86         /// return a pointer to the minibuffer
87         MiniBuffer * getMiniBuffer() const;
88
89         ///
90         void message(string const &);
91         ///
92         void messagePush(string const & str);
93         ///
94         void messagePop();
95
96         /// return the menubar for this view
97         Menubar * getMenubar() const;
98
99         ///
100         void updateMenubar();
101
102         ///
103         Intl * getIntl() const;
104
105         /// get access to the dialogs
106         Dialogs * getDialogs() { return dialogs_.get(); }
107
108         ///
109         void updateLayoutChoice();
110
111         /// Updates the title of the window
112         void updateWindowTitle();
113
114         /// Show state (toolbar and font in minibuffer)
115         void showState();
116
117         /// Reset autosave timer
118         void resetAutosaveTimer();
119         ///
120         virtual void prohibitInput() const = 0;
121         ///
122         virtual void allowInput() const = 0;
123  
124 protected:
125         /// view of a buffer. Eventually there will be several.
126         boost::scoped_ptr<BufferView> bufferview_;
127
128         /// view's menubar
129         boost::scoped_ptr<Menubar> menubar_;
130         /// view's toolbar
131         boost::scoped_ptr<Toolbar> toolbar_;
132         /// view's minibuffer
133         boost::scoped_ptr<MiniBuffer> minibuffer_;
134
135         /// keyboard mapping object
136         boost::scoped_ptr<Intl> intl_;
137
138         /// auto-saving of buffers
139         boost::scoped_ptr<Timeout> autosave_timeout_;
140
141         /// called on timeout
142         void AutoSave();
143
144         /// FIXME: GUII - toolbar property
145         void invalidateLayoutChoice();
146
147 private:
148         /**
149          * setWindowTitle - set title of window
150          * @param t main window title
151          * @param it iconified (short) title
152          */
153         virtual void setWindowTitle(string const & t, string const & it) = 0;
154
155         /// our function handler
156         boost::scoped_ptr<LyXFunc> lyxfunc_;
157         /// dialogs for this view
158         boost::scoped_ptr<Dialogs> dialogs_;
159
160         /**
161          * The last textclass layout list in the layout choice selector
162          * This should probably be moved to the toolbar, but for now it's
163          * here. (Asger)
164          *
165          * FIXME: GUII
166          */
167         int last_textclass_;
168 };
169
170 #endif // LYXVIEW_H