]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
make LyXView almost pure virtual. Merge implementation with GuiView
[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 "frontends/Delegates.h"
17 #include "support/strfwd.h"
18
19 #include <vector>
20
21 namespace lyx {
22
23 namespace support { class FileName; }
24
25 class Buffer;
26 class BufferView;
27 class FuncRequest;
28 class Inset;
29 class ToolbarInfo;
30
31 namespace frontend {
32
33 class Dialogs;
34 class WorkArea;
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
50         : public GuiBufferViewDelegate, public GuiBufferDelegate
51 {
52 public:
53         ///
54         LyXView(int id) : id_(id) {}
55         ///
56         virtual ~LyXView();
57         ///
58         int id() const { return id_; }
59         ///
60         virtual void close() = 0;
61         ///
62         virtual void setFocus() = 0;
63
64         ///
65         virtual WorkArea * workArea(Buffer & buffer) = 0;
66         ///
67         virtual WorkArea * addWorkArea(Buffer & buffer) = 0;
68         ///
69         virtual void setCurrentWorkArea(WorkArea * work_area) = 0;
70         ///
71         virtual void removeWorkArea(WorkArea * work_area) = 0;
72         /// return the current WorkArea (the one that has the focus).
73         virtual WorkArea const * currentWorkArea() const = 0;
74         /// FIXME: This non-const access is needed because of
75         /// a mis-designed \c ControlSpellchecker.
76         virtual WorkArea * currentWorkArea() = 0;
77
78         /**
79          * This is called after the concrete view has been created.
80          * We have to have the toolbar and the other stuff created
81          * before we can populate it with this call.
82          */
83         virtual void init() = 0;
84
85         enum Maximized {
86                 NotMaximized,
87                 VerticallyMaximized,
88                 HorizontallyMaximized,
89                 CompletelyMaximized
90         };
91
92         ///
93         virtual void setGeometry(
94                 unsigned int width,
95                 unsigned int height,
96                 int posx, int posy,
97                 int maximize,
98                 unsigned int iconSizeXY,
99                 const std::string & geometryArg) = 0;
100
101         /// save the geometry state in the session manager.
102         virtual void saveGeometry() = 0;
103
104         /// show busy cursor
105         virtual void setBusy(bool) = 0;
106
107         //@{ generic accessor functions
108
109         /// \return the current buffer view.
110         virtual BufferView * view() = 0;
111
112         /// \return the buffer currently shown in this window
113         virtual Buffer * buffer() = 0;
114         virtual Buffer const * buffer() const = 0;
115         /// set a buffer to the current workarea.
116         virtual void setBuffer(Buffer * b) = 0; ///< \c Buffer to set.
117
118         ///
119         virtual void openLayoutList() = 0;
120         ///
121         virtual bool isToolbarVisible(std::string const & id) = 0;
122         ///
123         virtual void showMiniBuffer(bool visible) = 0;
124         virtual void openMenu(docstring const & name) = 0;
125
126         /// get access to the dialogs
127         virtual Dialogs & getDialogs() = 0;
128         ///
129         virtual Dialogs const & getDialogs() const = 0;
130
131         //@}
132
133         /// load a buffer into the current workarea.
134         virtual Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
135                 bool tolastfiles = true) = 0;  ///< append to the "Open recent" menu?
136
137         /// updates the possible layouts selectable
138         virtual void updateLayoutChoice(bool force) = 0;
139
140         /// update the toolbar
141         virtual void updateToolbars() = 0;
142         /// get toolbar info
143         virtual ToolbarInfo * getToolbarInfo(std::string const & name) = 0;
144         /// toggle toolbar state
145         virtual void toggleToolbarState(std::string const & name, bool allowauto) = 0;
146         /// update the status bar
147         virtual void updateStatusBar() = 0;
148
149         /// display a message in the view
150         virtual void message(docstring const &) = 0;
151
152         /// clear any temporary message and replace with current status
153         virtual void clearMessage() = 0;
154
155         /// reset autosave timer
156         virtual void resetAutosaveTimer() = 0;
157
158         /// dispatch to current BufferView
159         virtual void dispatch(FuncRequest const & cmd) = 0;
160
161         /** redraw \c inset in all the BufferViews in which it is currently
162          *  visible. If successful return a pointer to the owning Buffer.
163          */
164         virtual Buffer const * updateInset(Inset const *) = 0;
165
166         /// returns true if this view has the focus.
167         virtual bool hasFocus() const = 0;
168
169         /// show the error list to the user
170         virtual void showErrorList(std::string const &) = 0;
171
172         
173         //
174         // GuiBufferDelegate
175         //
176         /// This function is called when the buffer structure is changed.
177         virtual void structureChanged() = 0;
178         /// This function is called when some parsing error shows up.
179         void errors(std::string const & err) { showErrorList(err); }
180         /// Reset autosave timers for all users.
181         void resetAutosaveTimers() { resetAutosaveTimer(); }
182
183         /// connect to signals in the given BufferView
184         virtual void connectBufferView(BufferView & bv) = 0;
185         /// disconnect from signals in the given BufferView
186         virtual void disconnectBufferView() = 0;
187         /// connect to signals in the given buffer
188         virtual void connectBuffer(Buffer & buf) = 0;
189         /// disconnect from signals in the given buffer
190         virtual void disconnectBuffer() = 0;
191
192 private:
193         /// noncopyable
194         LyXView(LyXView const &);
195         void operator=(LyXView const &);
196
197         /// Bind methods for BufferView messages signal connection
198         //@{
199         virtual void showDialog(std::string const & name) = 0;
200         virtual void showDialogWithData(std::string const & name,
201                 std::string const & data) = 0;
202         virtual void showInsetDialog(std::string const & name,
203                 std::string const & data, Inset * inset) = 0;
204         virtual void updateDialog(std::string const & name,
205                 std::string const & data) = 0;
206         //@}
207
208 private:
209         int id_;
210 };
211
212 } // namespace frontend
213 } // namespace lyx
214
215 #endif // LYXVIEW_H