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;
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
56 /// 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 void 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
184 /** Check the status of all visible dialogs and disable or reenable
185 * them as appropriate.
187 * Disabling is needed for example when a dialog is open and the
188 * cursor moves to a position where the corresponding inset is not
193 /// Hide all visible dialogs
194 void hideAll() const;
195 /// Hide any dialogs that require a buffer for them to operate
196 void hideBufferDependent() const;
197 /** Update visible, buffer-dependent dialogs
198 If the bool is true then a buffer change has occurred
199 else it is still the same buffer.
201 void updateBufferDependent(bool) const;
203 /** \param name == "bibtex", "citation" etc; an identifier used to
204 launch a particular dialog.
205 \param data is a string representation of the Inset contents.
206 It is often little more than the output from Inset::write.
207 It is passed to, and parsed by, the frontend dialog.
208 Several of these dialogs do not need any data,
209 so it defaults to string().
210 \param inset ownership is _not_ passed to the frontend dialog.
211 It is stored internally and used by the kernel to ascertain
212 what to do with the FuncRequest dispatched from the frontend
213 dialog on 'Apply'; should it be used to create a new inset at
214 the current cursor position or modify an existing, 'open' inset?
216 void showDialog(std::string const & name,
217 std::string const & data, Inset * inset = 0);
219 /** \param name == "citation", "bibtex" etc; an identifier used
220 to update the contents of a particular dialog with \param data.
221 See the comments to 'show', above.
223 void updateDialog(std::string const & name, std::string const & data);
225 /** All Dialogs of the given \param name will be closed if they are
226 connected to the given \param inset.
228 void hideDialog(std::string const & name, Inset * inset);
230 void disconnectDialog(std::string const & name);
232 Inset * getOpenInset(std::string const & name) const;
235 /// Is the dialog currently visible?
236 bool isDialogVisible(std::string const & name) const;
238 Dialog * find_or_build(std::string const & name);
240 Dialog * build(std::string const & name);
246 } // namespace frontend