]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
merge GuiView/Dialogs
[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 <string>
20
21 namespace lyx {
22
23 namespace support { class FileName; }
24
25 class Buffer;
26 class BufferView;
27 class FuncRequest;
28 class Inset;
29
30 namespace frontend {
31
32 class Dialogs;
33
34 /**
35  * LyXView - main LyX window
36  *
37  * This class represents the main LyX window and provides
38  * accessor functions to its content.
39  *
40  * The eventual intention is that LyX will support a number
41  * of containing LyXViews. Currently a lot of code still
42  * relies on there being a single top-level view.
43  *
44  * Additionally we would like to support multiple views
45  * in a single LyXView.
46  */
47 class LyXView
48         : public GuiBufferViewDelegate, public GuiBufferDelegate
49 {
50 public:
51         ///
52         LyXView(int id) : id_(id) {}
53         ///
54         virtual ~LyXView() {}
55         ///
56         int id() const { return id_; }
57         ///
58         virtual void close() = 0;
59         ///
60         virtual void setFocus() = 0;
61
62         /**
63          * This is called after the concrete view has been created.
64          * We have to have the toolbar and the other stuff created
65          * before we can populate it with this call.
66          */
67         virtual void init() = 0;
68
69         /// show busy cursor
70         virtual void setBusy(bool) = 0;
71
72         //@{ generic accessor functions
73
74         /// \return the current buffer view.
75         virtual BufferView * view() = 0;
76
77         /// \return the buffer currently shown in this window
78         virtual Buffer * buffer() = 0;
79         virtual Buffer const * buffer() const = 0;
80         /// set a buffer to the current workarea.
81         virtual void setBuffer(Buffer * b) = 0; ///< \c Buffer to set.
82
83         ///
84         virtual bool isToolbarVisible(std::string const & id) = 0;
85
86         //@}
87
88         /// load a buffer into the current workarea.
89         virtual Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
90                 bool tolastfiles = true) = 0;  ///< append to the "Open recent" menu?
91
92         /// updates the possible layouts selectable
93         virtual void updateLayoutChoice(bool force) = 0;
94         /// update the toolbar
95         virtual void updateToolbars() = 0;
96         /// update the status bar
97         virtual void updateStatusBar() = 0;
98         /// display a message in the view
99         virtual void message(docstring const &) = 0;
100
101         /// dispatch to current BufferView
102         virtual void dispatch(FuncRequest const & cmd) = 0;
103
104         /** redraw \c inset in all the BufferViews in which it is currently
105          *  visible. If successful return a pointer to the owning Buffer.
106          */
107         virtual Buffer const * updateInset(Inset const *) = 0;
108
109         /// returns true if this view has the focus.
110         virtual bool hasFocus() const = 0;
111
112         ///
113         virtual void restartCursor() = 0;
114         
115         //
116         // GuiBufferDelegate
117         //
118         virtual void errors(std::string const &) = 0;
119
120
121         //
122         // This View's Dialogs
123         //
124         
125         /** Check the status of all visible dialogs and disable or reenable
126          *  them as appropriate.
127          *
128          *  Disabling is needed for example when a dialog is open and the
129          *  cursor moves to a position where the corresponding inset is not
130          *  allowed.
131          */
132         virtual void checkStatus() = 0;
133
134         /// Are the tooltips on or off?
135         virtual bool tooltipsEnabled() = 0;
136
137         /// Hide all visible dialogs
138         virtual void hideAll() const = 0;
139         /// Hide any dialogs that require a buffer for them to operate
140         virtual void hideBufferDependent() const = 0;
141         /** Update visible, buffer-dependent dialogs
142             If the bool is true then a buffer change has occurred
143             else it is still the same buffer.
144          */
145         virtual void updateBufferDependent(bool) const = 0;
146
147         /** \param name == "bibtex", "citation" etc; an identifier used to
148             launch a particular dialog.
149             \param data is a string representation of the Inset contents.
150             It is often little more than the output from Inset::write.
151             It is passed to, and parsed by, the frontend dialog.
152             Several of these dialogs do not need any data,
153             so it defaults to string().
154             \param inset ownership is _not_ passed to the frontend dialog.
155             It is stored internally and used by the kernel to ascertain
156             what to do with the FuncRequest dispatched from the frontend
157             dialog on 'Apply'; should it be used to create a new inset at
158             the current cursor position or modify an existing, 'open' inset?
159         */
160         virtual void showDialog(std::string const & name,
161                 std::string const & data = std::string(), Inset * inset = 0) = 0;
162
163         /** \param name == "citation", "bibtex" etc; an identifier used
164             to update the contents of a particular dialog with \param data.
165             See the comments to 'show', above.
166         */
167         virtual void updateDialog(std::string const & name, std::string const & data) = 0;
168
169         /// Is the dialog currently visible?
170         virtual bool isDialogVisible(std::string const & name) const = 0;
171
172         /** All Dialogs of the given \param name will be closed if they are
173             connected to the given \param inset.
174         */
175         virtual void hideDialog(std::string const & name, Inset * inset) = 0;
176         ///
177         virtual void disconnectDialog(std::string const & name) = 0;
178         ///
179         virtual Inset * getOpenInset(std::string const & name) const = 0;
180
181 private:
182         /// noncopyable
183         LyXView(LyXView const &);
184         void operator=(LyXView const &);
185
186         ///
187         int id_;
188 };
189
190 } // namespace frontend
191 } // namespace lyx
192
193 #endif // LYXVIEW_H