4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjornes
9 * \author Abdelrazak Younes
10 * \author Peter Kümmel
12 * Full author contact details are available in file CREDITS.
18 #include "frontends/LyXView.h"
23 #include <QMainWindow>
26 class QDragEnterEvent;
43 * GuiView - Qt4 implementation of LyXView
45 * qt4-private implementation of the main LyX window.
47 * Note: a QObject emits a destroyed(QObject *) Qt signal when it
48 * is deleted. This might be useful for closing other dialogs
49 * depending on a given GuiView.
51 class GuiView : public QMainWindow, public LyXView
55 /// create a main window of the given dimensions
62 int id() const { return id_; }
67 /// add toolbar, if newline==true, add a toolbar break before the toolbar
68 GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
69 virtual void updateStatusBar();
70 virtual void message(docstring const & str);
71 virtual bool hasFocus() const;
72 void updateLayoutChoice(bool force);
73 bool isToolbarVisible(std::string const & id);
74 void updateToolbars();
76 QMenu * createPopupMenu();
78 /// dispatch to current BufferView
79 void dispatch(FuncRequest const & cmd);
81 /// \return the buffer currently shown in this window
83 Buffer const * buffer() const;
84 /// set a buffer to the current workarea.
85 void setBuffer(Buffer * b); ///< \c Buffer to set.
87 /// GuiBufferDelegate.
89 void resetAutosaveTimers();
90 void errors(std::string const &);
91 void structureChanged() { updateToc(); }
97 void updateEmbeddedFiles();
99 /// \return the current buffer view.
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 Buffer const * updateInset(Inset const *);
107 void restartCursor();
109 /// \return the \c Workarea associated to \p Buffer
110 /// \retval 0 if no \c WorkArea is found.
111 GuiWorkArea * workArea(Buffer & buffer);
113 /// Add a \c WorkArea
114 /// \return the \c Workarea associated to \p Buffer
115 /// \retval 0 if no \c WorkArea is found.
116 GuiWorkArea * addWorkArea(Buffer & buffer);
118 void setCurrentWorkArea(GuiWorkArea * work_area);
120 void removeWorkArea(GuiWorkArea * work_area);
121 /// return the current WorkArea (the one that has the focus).
122 GuiWorkArea const * currentWorkArea() const;
129 /// clear any temporary message and replace with current status.
134 void updateWindowTitle(GuiWorkArea * wa);
137 void on_currentWorkAreaChanged(GuiWorkArea *);
139 /// slots to change the icon size
140 void smallSizedIcons();
141 void normalSizedIcons();
142 void bigSizedIcons();
146 void addTabWorkArea();
148 /// connect to signals in the given BufferView
149 void connectBufferView(BufferView & bv);
150 /// disconnect from signals in the given BufferView
151 void disconnectBufferView();
152 /// connect to signals in the given buffer
153 void connectBuffer(Buffer & buf);
154 /// disconnect from signals in the given buffer
155 void disconnectBuffer();
159 void dragEnterEvent(QDragEnterEvent * ev);
161 void dropEvent(QDropEvent * ev);
162 /// make sure we quit cleanly
163 void closeEvent(QCloseEvent * e);
165 void showEvent(QShowEvent *);
167 /// in order to catch Tab key press.
168 bool event(QEvent * e);
169 bool focusNextPrevChild(bool);
172 struct GuiViewPrivate;
177 /// dialogs for this view
180 /** Check the status of all visible dialogs and disable or reenable
181 * them as appropriate.
183 * Disabling is needed for example when a dialog is open and the
184 * cursor moves to a position where the corresponding inset is not
189 /// Hide all visible dialogs
190 void hideAll() const;
191 /// Hide any dialogs that require a buffer for them to operate
192 void hideBufferDependent() const;
193 /** Update visible, buffer-dependent dialogs
194 If the bool is true then a buffer change has occurred
195 else it is still the same buffer.
197 void updateBufferDependent(bool) const;
199 /** \param name == "bibtex", "citation" etc; an identifier used to
200 launch a particular dialog.
201 \param data is a string representation of the Inset contents.
202 It is often little more than the output from Inset::write.
203 It is passed to, and parsed by, the frontend dialog.
204 Several of these dialogs do not need any data,
205 so it defaults to string().
206 \param inset ownership is _not_ passed to the frontend dialog.
207 It is stored internally and used by the kernel to ascertain
208 what to do with the FuncRequest dispatched from the frontend
209 dialog on 'Apply'; should it be used to create a new inset at
210 the current cursor position or modify an existing, 'open' inset?
212 void showDialog(std::string const & name,
213 std::string const & data, Inset * inset = 0);
215 /** \param name == "citation", "bibtex" etc; an identifier used
216 to update the contents of a particular dialog with \param data.
217 See the comments to 'show', above.
219 void updateDialog(std::string const & name, std::string const & data);
221 /// Is the dialog currently visible?
222 bool isDialogVisible(std::string const & name) const;
224 /** All Dialogs of the given \param name will be closed if they are
225 connected to the given \param inset.
227 void hideDialog(std::string const & name, Inset * inset);
229 void disconnectDialog(std::string const & name);
231 Inset * getOpenInset(std::string const & name) const;
235 Dialog * find_or_build(std::string const & name);
237 Dialog * build(std::string const & name);
243 } // namespace frontend