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"
20 #include "support/strfwd.h"
22 #include <QMainWindow>
25 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, public GuiBufferViewDelegate,
52 public GuiBufferDelegate
56 /// create a main window of the given dimensions
62 int id() const { return id_; }
66 /// returns true if this view has the focus.
67 bool hasFocus() const;
69 /// add toolbar, if newline==true, add a toolbar break before the toolbar
70 GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
71 virtual void updateStatusBar();
72 virtual void message(docstring const & str);
74 /// updates the possible layouts selectable
75 void updateLayoutList();
76 void updateToolbars();
77 QMenu * createPopupMenu();
78 FuncStatus getStatus(FuncRequest const & cmd);
79 bool dispatch(FuncRequest const & cmd);
82 void setLayoutDialog(GuiLayoutBox *);
84 /// \return the buffer currently shown in this window
86 Buffer const * buffer() const;
87 /// set a buffer to the current workarea.
88 void setBuffer(Buffer * b); ///< \c Buffer to set.
90 /// GuiBufferDelegate.
92 void resetAutosaveTimers();
93 void errors(std::string const &);
94 void structureChanged() { updateToc(); }
100 void updateEmbeddedFiles();
102 /// \return the current buffer view.
105 /** redraw \c inset in all the BufferViews in which it is currently
106 * visible. If successful return a pointer to the owning Buffer.
108 Buffer const * updateInset(Inset const *);
110 void restartCursor();
112 /// \return the \c Workarea associated to \p Buffer
113 /// \retval 0 if no \c WorkArea is found.
114 GuiWorkArea * workArea(Buffer & buffer);
116 /// Add a \c WorkArea
117 /// \return the \c Workarea associated to \p Buffer
118 /// \retval 0 if no \c WorkArea is found.
119 GuiWorkArea * addWorkArea(Buffer & buffer);
121 void setCurrentWorkArea(GuiWorkArea * work_area);
123 void removeWorkArea(GuiWorkArea * work_area);
124 /// return the current WorkArea (the one that has the focus).
125 GuiWorkArea const * currentWorkArea() const;
132 /// clear any temporary message and replace with current status.
137 void updateWindowTitle(GuiWorkArea * wa);
140 void on_currentWorkAreaChanged(GuiWorkArea *);
142 /// slots to change the icon size
143 void smallSizedIcons();
144 void normalSizedIcons();
145 void bigSizedIcons();
149 void addTabWorkArea();
151 /// connect to signals in the given BufferView
152 void connectBufferView(BufferView & bv);
153 /// disconnect from signals in the given BufferView
154 void disconnectBufferView();
155 /// connect to signals in the given buffer
156 void connectBuffer(Buffer & buf);
157 /// disconnect from signals in the given buffer
158 void disconnectBuffer();
162 void dragEnterEvent(QDragEnterEvent * ev);
164 void dropEvent(QDropEvent * ev);
165 /// make sure we quit cleanly
166 void closeEvent(QCloseEvent * e);
168 void showEvent(QShowEvent *);
170 /// in order to catch Tab key press.
171 bool event(QEvent * e);
172 bool focusNextPrevChild(bool);
175 struct GuiViewPrivate;
180 /// dialogs for this view
186 /** Check the status of all visible dialogs and disable or reenable
187 * them as appropriate.
189 * Disabling is needed for example when a dialog is open and the
190 * cursor moves to a position where the corresponding inset is not
195 /// Hide all visible dialogs
196 void hideAll() const;
197 /// Hide any dialogs that require a buffer for them to operate
198 void hideBufferDependent() const;
199 /** Update visible, buffer-dependent dialogs
200 If the bool is true then a buffer change has occurred
201 else it is still the same buffer.
203 void updateBufferDependent(bool) const;
205 /** \param name == "bibtex", "citation" etc; an identifier used to
206 launch a particular dialog.
207 \param data is a string representation of the Inset contents.
208 It is often little more than the output from Inset::write.
209 It is passed to, and parsed by, the frontend dialog.
210 Several of these dialogs do not need any data,
211 so it defaults to string().
212 \param inset ownership is _not_ passed to the frontend dialog.
213 It is stored internally and used by the kernel to ascertain
214 what to do with the FuncRequest dispatched from the frontend
215 dialog on 'Apply'; should it be used to create a new inset at
216 the current cursor position or modify an existing, 'open' inset?
218 void showDialog(std::string const & name,
219 std::string const & data, Inset * inset = 0);
221 /** \param name == "citation", "bibtex" etc; an identifier used
222 to update the contents of a particular dialog with \param data.
223 See the comments to 'show', above.
225 void updateDialog(std::string const & name, std::string const & data);
227 /** All Dialogs of the given \param name will be closed if they are
228 connected to the given \param inset.
230 void hideDialog(std::string const & name, Inset * inset);
232 void disconnectDialog(std::string const & name);
236 Inset * getOpenInset(std::string const & name) const;
238 /// Is the dialog currently visible?
239 bool isDialogVisible(std::string const & name) const;
241 Dialog * find_or_build(std::string const & name);
243 Dialog * build(std::string const & name);
249 } // namespace frontend