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