]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
compile fix.
[lyx.git] / src / frontends / qt4 / GuiView.h
1 // -*- C++ -*-
2 /**
3  * \file GuiView.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjornes
8  * \author John Levon
9  * \author Abdelrazak Younes
10  * \author Peter Kümmel
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef GUI_VIEW_H
16 #define GUI_VIEW_H
17
18 #include "frontends/LyXView.h"
19
20 #include <QMainWindow>
21 #include <QTimer>
22
23 class QCloseEvent;
24 class QDragEnterEvent;
25 class QDropEvent;
26 class QMenu;
27
28
29 namespace lyx {
30
31 class Timeout;
32
33 namespace frontend {
34
35 class GuiToolbar;
36 class GuiWorkArea;
37
38 QWidget * mainWindow();
39
40 /**
41  * GuiView - Qt4 implementation of LyXView
42  *
43  * qt4-private implementation of the main LyX window.
44  *
45  * Note: a QObject emits a destroyed(QObject *) Qt signal when it
46  * is deleted. This might be useful for closing other dialogs
47  * depending on a given GuiView.
48  */
49 class GuiView : public QMainWindow, public LyXView
50 {
51         Q_OBJECT
52 public:
53         /// create a main window of the given dimensions
54         GuiView(int id);
55
56         ~GuiView();
57
58         virtual void init();
59         virtual void close();
60         virtual void setFocus();
61         virtual void setGeometry(
62                 unsigned int width,
63                 unsigned int height,
64                 int posx, int posy,
65                 Maximized maximized,
66                 unsigned int iconSizeXY,
67                 const std::string & geometryArg);
68         /// save the geometry state in the session manager.
69         virtual void saveGeometry();
70         virtual void setBusy(bool);
71         /// add toolbar, if newline==true, add a toolbar break before the toolbar
72         GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
73         virtual void updateStatusBar();
74         virtual void message(docstring const & str);
75         virtual void clearMessage();
76         virtual bool hasFocus() const;
77         void showMiniBuffer(bool);
78         void openMenu(docstring const &);
79         void openLayoutList();
80         void updateLayoutChoice(bool force);
81         bool isToolbarVisible(std::string const & id);
82         void updateToolbars();
83         ToolbarInfo * getToolbarInfo(std::string const & name);
84         void toggleToolbarState(std::string const & name, bool allowauto);
85
86         /// show - display the top-level window
87         void showView();
88
89         /// menu item has been selected
90         void activated(FuncRequest const &);
91
92         ///
93         QMenu * createPopupMenu();
94
95         ///
96         void addTabWorkArea();
97
98         /// dispatch to current BufferView
99         void dispatch(FuncRequest const & cmd);
100
101         /// \return the buffer currently shown in this window
102         Buffer * buffer();
103         Buffer const * buffer() const;
104         /// set a buffer to the current workarea.
105         void setBuffer(Buffer * b); ///< \c Buffer to set.
106
107 Q_SIGNALS:
108         void closing(int);
109
110 public Q_SLOTS:
111         /// idle timeout
112         void update_view_state_qt();
113
114         ///
115         void updateWindowTitle(GuiWorkArea * wa);
116
117         ///
118         void on_currentWorkAreaChanged(GuiWorkArea *);
119
120         /// slots to change the icon size
121         void smallSizedIcons();
122         void normalSizedIcons();
123         void bigSizedIcons();
124
125 private:
126         friend GuiWorkArea;
127
128         /// make sure we quit cleanly
129         virtual void closeEvent(QCloseEvent * e);
130         ///
131         virtual void resizeEvent(QResizeEvent * e);
132         ///
133         virtual void moveEvent(QMoveEvent * e);
134
135         /// \return the \c Workarea associated to \p  Buffer
136         /// \retval 0 if no \c WorkArea is found.
137         GuiWorkArea * workArea(Buffer & buffer);
138
139         /// Add a \c WorkArea 
140         /// \return the \c Workarea associated to \p  Buffer
141         /// \retval 0 if no \c WorkArea is found.
142         GuiWorkArea * addWorkArea(Buffer & buffer);
143         ///
144         void setCurrentWorkArea(GuiWorkArea * work_area);
145         ///
146         void removeWorkArea(GuiWorkArea * work_area);
147         /// return the current WorkArea (the one that has the focus).
148         GuiWorkArea const * currentWorkArea() const;
149         /// FIXME: This non-const access is needed because of
150         /// a mis-designed \c ControlSpellchecker.
151         GuiWorkArea * currentWorkArea();
152
153         /// GuiBufferDelegate.
154         ///@{
155         void resetAutosaveTimers();
156         void errors(std::string const &);
157         void structureChanged() { updateToc(); }
158         ///@}
159
160
161         /// connect to signals in the given BufferView
162         void connectBufferView(BufferView & bv);
163         /// disconnect from signals in the given BufferView
164         void disconnectBufferView();
165         /// connect to signals in the given buffer
166         void connectBuffer(Buffer & buf);
167         /// disconnect from signals in the given buffer
168         void disconnectBuffer();
169
170         ////
171         void showDialog(std::string const & name);
172         void showDialogWithData(std::string const & name,
173                 std::string const & data);
174         void showInsetDialog(std::string const & name,
175                 std::string const & data, Inset * inset);
176         void updateDialog(std::string const & name,
177                 std::string const & data);
178         
179         ///
180         void updateToc();
181
182         ///
183         void dragEnterEvent(QDragEnterEvent * ev);
184         ///
185         void dropEvent(QDropEvent * ev);
186
187         /// in order to catch Tab key press.
188         bool event(QEvent * e);
189         bool focusNextPrevChild(bool);
190         ///
191         QRect updateFloatingGeometry();
192         /// called on timeout
193         void autoSave();
194         ///
195         void updateEmbeddedFiles();
196
197         /// \return the current buffer view.
198         BufferView * view();
199
200         /// get access to the dialogs
201         Dialogs & getDialogs() { return *dialogs_; }
202         ///
203         Dialogs const & getDialogs() const { return *dialogs_; }
204
205         //@}
206
207         /// load a buffer into the current workarea.
208         Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
209                 bool tolastfiles = true);  ///< append to the "Open recent" menu?
210
211         /** redraw \c inset in all the BufferViews in which it is currently
212          *  visible. If successful return a pointer to the owning Buffer.
213          */
214         Buffer const * updateInset(Inset const *);
215         ///
216         void restartCursor();
217
218
219 private:
220         ///
221         struct GuiViewPrivate;
222         GuiViewPrivate & d;
223
224         ///
225         QTimer statusbar_timer_;
226
227         /// are we quitting by the menu?
228         bool quitting_by_menu_;
229
230         ///
231         QRect floatingGeometry_;
232
233         void setIconSize(unsigned int size);
234
235         struct ToolbarSize {
236                 int top_width;
237                 int bottom_width;
238                 int left_height;
239                 int right_height;
240         };
241
242         ToolbarSize toolbarSize_;
243
244         /// auto-saving of buffers
245         Timeout * const autosave_timeout_;
246         /// dialogs for this view
247         Dialogs * dialogs_;
248 };
249
250
251 } // namespace frontend
252 } // namespace lyx
253
254 #endif // GUIVIEW_H