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.
91 /// GuiBufferDelegate.
93 void resetAutosaveTimers();
94 void errors(std::string const &);
95 void structureChanged() { updateToc(); }
101 void updateEmbeddedFiles();
103 /// \return the current buffer view.
106 /** redraw \c inset in all the BufferViews in which it is currently
107 * visible. If successful return a pointer to the owning Buffer.
109 Buffer const * updateInset(Inset const *);
111 void restartCursor();
113 /// \return the \c Workarea associated to \p Buffer
114 /// \retval 0 if no \c WorkArea is found.
115 GuiWorkArea * workArea(Buffer & buffer);
117 /// Add a \c WorkArea
118 /// \return the \c Workarea associated to \p Buffer
119 /// \retval 0 if no \c WorkArea is found.
120 GuiWorkArea * addWorkArea(Buffer & buffer);
122 void setCurrentWorkArea(GuiWorkArea * work_area);
124 void removeWorkArea(GuiWorkArea * work_area);
125 /// return the current WorkArea (the one that has the focus).
126 GuiWorkArea const * currentWorkArea() const;
133 /// clear any temporary message and replace with current status.
138 void updateWindowTitle(GuiWorkArea * wa);
141 void on_currentWorkAreaChanged(GuiWorkArea *);
143 /// slots to change the icon size
144 void smallSizedIcons();
145 void normalSizedIcons();
146 void bigSizedIcons();
150 void addTabWorkArea();
152 /// connect to signals in the given BufferView
153 void connectBufferView(BufferView & bv);
154 /// disconnect from signals in the given BufferView
155 void disconnectBufferView();
156 /// connect to signals in the given buffer
157 void connectBuffer(Buffer & buf);
158 /// disconnect from signals in the given buffer
159 void disconnectBuffer();
163 void dragEnterEvent(QDragEnterEvent * ev);
165 void dropEvent(QDropEvent * ev);
166 /// make sure we quit cleanly
167 void closeEvent(QCloseEvent * e);
169 void showEvent(QShowEvent *);
171 /// in order to catch Tab key press.
172 bool event(QEvent * e);
173 bool focusNextPrevChild(bool);
176 struct GuiViewPrivate;
181 /// dialogs for this view
187 /** Check the status of all visible dialogs and disable or reenable
188 * them as appropriate.
190 * Disabling is needed for example when a dialog is open and the
191 * cursor moves to a position where the corresponding inset is not
196 /// Hide all visible dialogs
197 void hideAll() const;
198 /// Hide any dialogs that require a buffer for them to operate
199 void hideBufferDependent() const;
200 /** Update visible, buffer-dependent dialogs
201 If the bool is true then a buffer change has occurred
202 else it is still the same buffer.
204 void updateBufferDependent(bool) const;
206 /** \param name == "bibtex", "citation" etc; an identifier used to
207 launch a particular dialog.
208 \param data is a string representation of the Inset contents.
209 It is often little more than the output from Inset::write.
210 It is passed to, and parsed by, the frontend dialog.
211 Several of these dialogs do not need any data,
212 so it defaults to string().
213 \param inset ownership is _not_ passed to the frontend dialog.
214 It is stored internally and used by the kernel to ascertain
215 what to do with the FuncRequest dispatched from the frontend
216 dialog on 'Apply'; should it be used to create a new inset at
217 the current cursor position or modify an existing, 'open' inset?
219 void showDialog(std::string const & name,
220 std::string const & data, Inset * inset = 0);
222 /** \param name == "citation", "bibtex" etc; an identifier used
223 to update the contents of a particular dialog with \param data.
224 See the comments to 'show', above.
226 void updateDialog(std::string const & name, std::string const & data);
228 /** All Dialogs of the given \param name will be closed if they are
229 connected to the given \param inset.
231 void hideDialog(std::string const & name, Inset * inset);
233 void disconnectDialog(std::string const & name);
237 void insertLyXFile(docstring const & fname);
239 Inset * getOpenInset(std::string const & name) const;
241 /// Is the dialog currently visible?
242 bool isDialogVisible(std::string const & name) const;
244 Dialog * find_or_build(std::string const & name);
246 Dialog * build(std::string const & name);
252 } // namespace frontend