4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS.
16 #include "frontends/Delegates.h"
17 #include "support/strfwd.h"
23 namespace support { class FileName; }
35 * LyXView - main LyX window
37 * This class represents the main LyX window and provides
38 * accessor functions to its content.
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.
44 * Additionally we would like to support multiple views
45 * in a single LyXView.
48 : public GuiBufferViewDelegate, public GuiBufferDelegate
52 LyXView(int id) : id_(id) {}
56 int id() const { return id_; }
58 virtual void close() = 0;
60 virtual void setFocus() = 0;
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.
67 virtual void init() = 0;
70 virtual void setBusy(bool) = 0;
72 //@{ generic accessor functions
74 /// \return the current buffer view.
75 virtual BufferView * view() = 0;
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.
84 virtual bool isToolbarVisible(std::string const & id) = 0;
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?
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;
101 /// dispatch to current BufferView
102 virtual void dispatch(FuncRequest const & cmd) = 0;
104 /** redraw \c inset in all the BufferViews in which it is currently
105 * visible. If successful return a pointer to the owning Buffer.
107 virtual Buffer const * updateInset(Inset const *) = 0;
109 /// returns true if this view has the focus.
110 virtual bool hasFocus() const = 0;
113 virtual void restartCursor() = 0;
118 virtual void errors(std::string const &) = 0;
122 // This View's Dialogs
125 /** Check the status of all visible dialogs and disable or reenable
126 * them as appropriate.
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
132 virtual void checkStatus() = 0;
134 /// Are the tooltips on or off?
135 virtual bool tooltipsEnabled() = 0;
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.
145 virtual void updateBufferDependent(bool) const = 0;
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?
160 virtual void showDialog(std::string const & name,
161 std::string const & data = std::string(), Inset * inset = 0) = 0;
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.
167 virtual void updateDialog(std::string const & name, std::string const & data) = 0;
169 /// Is the dialog currently visible?
170 virtual bool isDialogVisible(std::string const & name) const = 0;
172 /** All Dialogs of the given \param name will be closed if they are
173 connected to the given \param inset.
175 virtual void hideDialog(std::string const & name, Inset * inset) = 0;
177 virtual void disconnectDialog(std::string const & name) = 0;
179 virtual Inset * getOpenInset(std::string const & name) const = 0;
183 LyXView(LyXView const &);
184 void operator=(LyXView const &);
190 } // namespace frontend