]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
cleanup and reorder initialisation code of GuiView and GuiToolbars. Move some things...
[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 /**
31  * LyXView - main LyX window
32  *
33  * This class represents the main LyX window and provides
34  * accessor functions to its content.
35  *
36  * The eventual intention is that LyX will support a number
37  * of containing LyXViews. Currently a lot of code still
38  * relies on there being a single top-level view.
39  *
40  * Additionally we would like to support multiple views
41  * in a single LyXView.
42  */
43 class LyXView
44         : public GuiBufferViewDelegate, public GuiBufferDelegate
45 {
46 public:
47         ///
48         LyXView() {}
49         ///
50         virtual ~LyXView() {}
51         ///
52         virtual int id() const = 0;
53         ///
54         virtual void close() = 0;
55
56         /// show busy cursor
57         virtual void setBusy(bool) = 0;
58
59         //@{ generic accessor functions
60
61         /// \return the current buffer view.
62         virtual BufferView * view() = 0;
63
64         /// \return the buffer currently shown in this window
65         virtual Buffer * buffer() = 0;
66         virtual Buffer const * buffer() const = 0;
67         /// set a buffer to the current workarea.
68         virtual void setBuffer(Buffer * b) = 0; ///< \c Buffer to set.
69
70         ///
71         virtual bool isToolbarVisible(std::string const & id) = 0;
72
73         //@}
74
75         /// load a buffer into the current workarea.
76         virtual Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
77                 bool tolastfiles = true) = 0;  ///< append to the "Open recent" menu?
78
79         /// updates the possible layouts selectable
80         virtual void updateLayoutChoice(bool force) = 0;
81         /// update the toolbar
82         virtual void updateToolbars() = 0;
83         /// update the status bar
84         virtual void updateStatusBar() = 0;
85         /// display a message in the view
86         virtual void message(docstring const &) = 0;
87
88         /// dispatch to current BufferView
89         virtual void dispatch(FuncRequest const & cmd) = 0;
90
91         /** redraw \c inset in all the BufferViews in which it is currently
92          *  visible. If successful return a pointer to the owning Buffer.
93          */
94         virtual Buffer const * updateInset(Inset const *) = 0;
95
96         /// returns true if this view has the focus.
97         virtual bool hasFocus() const = 0;
98
99         ///
100         virtual void restartCursor() = 0;
101         
102         //
103         // GuiBufferDelegate
104         //
105         virtual void errors(std::string const &) = 0;
106
107
108         //
109         // This View's Dialogs
110         //
111         
112         /// Hide all visible dialogs
113         virtual void hideAll() const = 0;
114
115         /** \param name == "bibtex", "citation" etc; an identifier used to
116             launch a particular dialog.
117             \param data is a string representation of the Inset contents.
118             It is often little more than the output from Inset::write.
119             It is passed to, and parsed by, the frontend dialog.
120             Several of these dialogs do not need any data,
121             so it defaults to string().
122             \param inset ownership is _not_ passed to the frontend dialog.
123             It is stored internally and used by the kernel to ascertain
124             what to do with the FuncRequest dispatched from the frontend
125             dialog on 'Apply'; should it be used to create a new inset at
126             the current cursor position or modify an existing, 'open' inset?
127         */
128         virtual void showDialog(std::string const & name,
129                 std::string const & data, Inset * inset = 0) = 0;
130
131         /** \param name == "citation", "bibtex" etc; an identifier used
132             to update the contents of a particular dialog with \param data.
133             See the comments to 'show', above.
134         */
135         virtual void updateDialog(std::string const & name, std::string const & data) = 0;
136
137         /// Is the dialog currently visible?
138         virtual bool isDialogVisible(std::string const & name) const = 0;
139
140         /** All Dialogs of the given \param name will be closed if they are
141             connected to the given \param inset.
142         */
143         virtual void hideDialog(std::string const & name, Inset * inset) = 0;
144         ///
145         virtual void disconnectDialog(std::string const & name) = 0;
146         ///
147         virtual Inset * getOpenInset(std::string const & name) const = 0;
148
149 private:
150         /// noncopyable
151         LyXView(LyXView const &);
152         void operator=(LyXView const &);
153 };
154
155 } // namespace frontend
156 } // namespace lyx
157
158 #endif // LYXVIEW_H