]> git.lyx.org Git - lyx.git/blob - src/frontends/LyXView.h
Transfer LyXView::loadLyXFile() to lyxFunc::loadAndViewFile(). This enables to get...
[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         /// updates the possible layouts selectable
76         virtual void updateLayoutChoice(bool force) = 0;
77         /// update the toolbar
78         virtual void updateToolbars() = 0;
79         /// update the status bar
80         virtual void updateStatusBar() = 0;
81         /// display a message in the view
82         virtual void message(docstring const &) = 0;
83
84         /// dispatch to current BufferView
85         virtual void dispatch(FuncRequest const & cmd) = 0;
86
87         /** redraw \c inset in all the BufferViews in which it is currently
88          *  visible. If successful return a pointer to the owning Buffer.
89          */
90         virtual Buffer const * updateInset(Inset const *) = 0;
91
92         /// returns true if this view has the focus.
93         virtual bool hasFocus() const = 0;
94
95         ///
96         virtual void restartCursor() = 0;
97         
98         //
99         // GuiBufferDelegate
100         //
101         virtual void errors(std::string const &) = 0;
102
103
104         //
105         // This View's Dialogs
106         //
107         
108         /// Hide all visible dialogs
109         virtual void hideAll() const = 0;
110
111         /** \param name == "bibtex", "citation" etc; an identifier used to
112             launch a particular dialog.
113             \param data is a string representation of the Inset contents.
114             It is often little more than the output from Inset::write.
115             It is passed to, and parsed by, the frontend dialog.
116             Several of these dialogs do not need any data,
117             so it defaults to string().
118             \param inset ownership is _not_ passed to the frontend dialog.
119             It is stored internally and used by the kernel to ascertain
120             what to do with the FuncRequest dispatched from the frontend
121             dialog on 'Apply'; should it be used to create a new inset at
122             the current cursor position or modify an existing, 'open' inset?
123         */
124         virtual void showDialog(std::string const & name,
125                 std::string const & data, Inset * inset = 0) = 0;
126
127         /** \param name == "citation", "bibtex" etc; an identifier used
128             to update the contents of a particular dialog with \param data.
129             See the comments to 'show', above.
130         */
131         virtual void updateDialog(std::string const & name, std::string const & data) = 0;
132
133         /// Is the dialog currently visible?
134         virtual bool isDialogVisible(std::string const & name) const = 0;
135
136         /** All Dialogs of the given \param name will be closed if they are
137             connected to the given \param inset.
138         */
139         virtual void hideDialog(std::string const & name, Inset * inset) = 0;
140         ///
141         virtual void disconnectDialog(std::string const & name) = 0;
142         ///
143         virtual Inset * getOpenInset(std::string const & name) const = 0;
144
145 private:
146         /// noncopyable
147         LyXView(LyXView const &);
148         void operator=(LyXView const &);
149 };
150
151 } // namespace frontend
152 } // namespace lyx
153
154 #endif // LYXVIEW_H