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/Delegates.h"
19 #include "frontends/LyXView.h"
21 #include "support/strfwd.h"
23 #include <QMainWindow>
26 class QDragEnterEvent;
44 * GuiView - Qt4 implementation of LyXView
46 * qt4-private implementation of the main LyX window.
48 * Note: a QObject emits a destroyed(QObject *) Qt signal when it
49 * is deleted. This might be useful for closing other dialogs
50 * depending on a given GuiView.
52 class GuiView : public QMainWindow, public LyXView, public GuiBufferViewDelegate,
53 public GuiBufferDelegate
57 /// create a main window of the given dimensions
63 int id() const { return id_; }
67 /// returns true if this view has the focus.
68 bool hasFocus() const;
70 /// add toolbar, if newline==true, add a toolbar break before the toolbar
71 GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
72 virtual void updateStatusBar();
73 virtual void message(docstring const & str);
75 /// updates the possible layouts selectable
76 void updateLayoutList();
77 void updateToolbars();
78 QMenu * createPopupMenu();
79 FuncStatus getStatus(FuncRequest const & cmd);
80 bool dispatch(FuncRequest const & cmd);
83 void setLayoutDialog(GuiLayoutBox *);
85 /// \return the buffer currently shown in this window
87 Buffer const * buffer() const;
88 /// set a buffer to the current workarea.
89 void setBuffer(Buffer * b); ///< \c Buffer to set.
92 /// write all buffers, asking the user, returns false if cancelled
95 /// GuiBufferDelegate.
97 void resetAutosaveTimers();
98 void errors(std::string const &);
99 void structureChanged() { updateToc(); }
102 /// called on timeout
105 void updateEmbeddedFiles();
107 /// \return the current buffer view.
110 /** redraw \c inset in all the BufferViews in which it is currently
111 * visible. If successful return a pointer to the owning Buffer.
113 Buffer const * updateInset(Inset const *);
115 void restartCursor();
117 /// \return the \c Workarea associated to \p Buffer
118 /// \retval 0 if no \c WorkArea is found.
119 GuiWorkArea * workArea(Buffer & buffer);
121 /// Add a \c WorkArea
122 /// \return the \c Workarea associated to \p Buffer
123 /// \retval 0 if no \c WorkArea is found.
124 GuiWorkArea * addWorkArea(Buffer & buffer);
126 void setCurrentWorkArea(GuiWorkArea * work_area);
128 void removeWorkArea(GuiWorkArea * work_area);
129 /// return the current WorkArea (the one that has the focus).
130 GuiWorkArea const * currentWorkArea() const;
137 /// clear any temporary message and replace with current status.
142 void updateWindowTitle(GuiWorkArea * wa);
145 void on_currentWorkAreaChanged(GuiWorkArea *);
147 /// slots to change the icon size
148 void smallSizedIcons();
149 void normalSizedIcons();
150 void bigSizedIcons();
154 void addTabWorkArea();
156 /// connect to signals in the given BufferView
157 void connectBufferView(BufferView & bv);
158 /// disconnect from signals in the given BufferView
159 void disconnectBufferView();
160 /// connect to signals in the given buffer
161 void connectBuffer(Buffer & buf);
162 /// disconnect from signals in the given buffer
163 void disconnectBuffer();
167 void dragEnterEvent(QDragEnterEvent * ev);
169 void dropEvent(QDropEvent * ev);
170 /// make sure we quit cleanly
171 void closeEvent(QCloseEvent * e);
173 void showEvent(QShowEvent *);
175 /// in order to catch Tab key press.
176 bool event(QEvent * e);
177 bool focusNextPrevChild(bool);
180 struct GuiViewPrivate;
185 /// dialogs for this view
191 /** Check the status of all visible dialogs and disable or reenable
192 * them as appropriate.
194 * Disabling is needed for example when a dialog is open and the
195 * cursor moves to a position where the corresponding inset is not
200 /// Hide all visible dialogs
201 void hideAll() const;
202 /// Hide any dialogs that require a buffer for them to operate
203 void hideBufferDependent() const;
204 /** Update visible, buffer-dependent dialogs
205 If the bool is true then a buffer change has occurred
206 else it is still the same buffer.
208 void updateBufferDependent(bool) const;
210 /** \param name == "bibtex", "citation" etc; an identifier used to
211 launch a particular dialog.
212 \param data is a string representation of the Inset contents.
213 It is often little more than the output from Inset::write.
214 It is passed to, and parsed by, the frontend dialog.
215 Several of these dialogs do not need any data,
216 so it defaults to string().
217 \param inset ownership is _not_ passed to the frontend dialog.
218 It is stored internally and used by the kernel to ascertain
219 what to do with the FuncRequest dispatched from the frontend
220 dialog on 'Apply'; should it be used to create a new inset at
221 the current cursor position or modify an existing, 'open' inset?
223 void showDialog(std::string const & name,
224 std::string const & data, Inset * inset = 0);
226 /** \param name == "citation", "bibtex" etc; an identifier used
227 to update the contents of a particular dialog with \param data.
228 See the comments to 'show', above.
230 void updateDialog(std::string const & name, std::string const & data);
232 /** All Dialogs of the given \param name will be closed if they are
233 connected to the given \param inset.
235 void hideDialog(std::string const & name, Inset * inset);
237 void disconnectDialog(std::string const & name);
241 void insertLyXFile(docstring const & fname);
243 void insertPlaintextFile(docstring const & fname,
246 /// Save a buffer as a new file.
248 Write a buffer to a new file name and rename the buffer
249 according to the new file name.
251 This function is e.g. used by menu callbacks and
252 LFUN_BUFFER_WRITE_AS.
254 If 'newname' is empty, the user is asked via a
255 dialog for the buffer's new name and location.
257 If 'newname' is non-empty and has an absolute path, that is used.
258 Otherwise the base directory of the buffer is used as the base
259 for any relative path in 'newname'.
261 bool renameBuffer(Buffer & b, docstring const & newname);
263 bool saveBuffer(Buffer & b);
265 bool closeBuffer(Buffer & buf);
268 Inset * getOpenInset(std::string const & name) const;
270 /// Is the dialog currently visible?
271 bool isDialogVisible(std::string const & name) const;
273 Dialog * find_or_build(std::string const & name);
275 Dialog * build(std::string const & name);
281 } // namespace frontend