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"
21 namespace support { class FileName; }
33 * LyXView - main LyX window
35 * This class represents the main LyX window and provides
36 * accessor functions to its content.
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.
42 * Additionally we would like to support multiple views
43 * in a single LyXView.
46 : public GuiBufferViewDelegate, public GuiBufferDelegate
50 LyXView(int id) : id_(id) {}
54 int id() const { return id_; }
56 virtual void close() = 0;
58 virtual void setFocus() = 0;
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.
65 virtual void init() = 0;
68 virtual void setBusy(bool) = 0;
70 //@{ generic accessor functions
72 /// \return the current buffer view.
73 virtual BufferView * view() = 0;
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.
82 virtual bool isToolbarVisible(std::string const & id) = 0;
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?
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;
99 /// dispatch to current BufferView
100 virtual void dispatch(FuncRequest const & cmd) = 0;
102 /** redraw \c inset in all the BufferViews in which it is currently
103 * visible. If successful return a pointer to the owning Buffer.
105 virtual Buffer const * updateInset(Inset const *) = 0;
107 /// returns true if this view has the focus.
108 virtual bool hasFocus() const = 0;
111 virtual void restartCursor() = 0;
116 virtual void errors(std::string const &) = 0;
120 // This View's Dialogs
123 /** Check the status of all visible dialogs and disable or reenable
124 * them as appropriate.
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
130 virtual void checkStatus() = 0;
132 /// Are the tooltips on or off?
133 virtual bool tooltipsEnabled() = 0;
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.
143 virtual void updateBufferDependent(bool) const = 0;
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?
158 virtual void showDialog(std::string const & name,
159 std::string const & data, Inset * inset = 0) = 0;
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.
165 virtual void updateDialog(std::string const & name, std::string const & data) = 0;
167 /// Is the dialog currently visible?
168 virtual bool isDialogVisible(std::string const & name) const = 0;
170 /** All Dialogs of the given \param name will be closed if they are
171 connected to the given \param inset.
173 virtual void hideDialog(std::string const & name, Inset * inset) = 0;
175 virtual void disconnectDialog(std::string const & name) = 0;
177 virtual Inset * getOpenInset(std::string const & name) const = 0;
181 LyXView(LyXView const &);
182 void operator=(LyXView const &);
188 } // namespace frontend