]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
Fix the disappearing minibuffer by don't pretending we are flexible.
[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 class ToolbarInfo;
33
34 namespace frontend {
35
36 class GuiToolbar;
37 class GuiWorkArea;
38
39 QWidget * mainWindow();
40
41 /**
42  * GuiView - Qt4 implementation of LyXView
43  *
44  * qt4-private implementation of the main LyX window.
45  *
46  * Note: a QObject emits a destroyed(QObject *) Qt signal when it
47  * is deleted. This might be useful for closing other dialogs
48  * depending on a given GuiView.
49  */
50 class GuiView : public QMainWindow, public LyXView
51 {
52         Q_OBJECT
53 public:
54         /// create a main window of the given dimensions
55         GuiView(int id);
56
57         ~GuiView();
58
59         virtual void init();
60         virtual void close();
61         virtual void setFocus();
62
63         enum Maximized {
64                 NotMaximized = 0, // LyX::newLyXView() relies on this to be zero!
65                 VerticallyMaximized,
66                 HorizontallyMaximized,
67                 CompletelyMaximized
68         };
69         ///
70         virtual void setGeometry(
71                 unsigned int width,
72                 unsigned int height,
73                 int posx, int posy,
74                 Maximized maximized,
75                 unsigned int iconSizeXY,
76                 const std::string & geometryArg);
77         /// save the geometry state in the session manager.
78         virtual void saveGeometry();
79         virtual void setBusy(bool);
80         /// add toolbar, if newline==true, add a toolbar break before the toolbar
81         GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
82         virtual void updateStatusBar();
83         virtual void message(docstring const & str);
84         virtual bool hasFocus() const;
85         void updateLayoutChoice(bool force);
86         bool isToolbarVisible(std::string const & id);
87         void updateToolbars();
88         ///
89         QMenu * createPopupMenu();
90
91         /// dispatch to current BufferView
92         void dispatch(FuncRequest const & cmd);
93
94         /// \return the buffer currently shown in this window
95         Buffer * buffer();
96         Buffer const * buffer() const;
97         /// set a buffer to the current workarea.
98         void setBuffer(Buffer * b); ///< \c Buffer to set.
99
100         /// GuiBufferDelegate.
101         ///@{
102         void resetAutosaveTimers();
103         void errors(std::string const &);
104         void structureChanged() { updateToc(); }
105         ///@}
106
107         ////
108         void showDialog(std::string const & name);
109         void showDialogWithData(std::string const & name,
110                 std::string const & data);
111         void showInsetDialog(std::string const & name,
112                 std::string const & data, Inset * inset);
113         void updateDialog(std::string const & name,
114                 std::string const & data);
115         
116         /// called on timeout
117         void autoSave();
118         ///
119         void updateEmbeddedFiles();
120
121         /// \return the current buffer view.
122         BufferView * view();
123
124         /// get access to the dialogs
125         Dialogs & getDialogs() { return *dialogs_; }
126         ///
127         Dialogs const & getDialogs() const { return *dialogs_; }
128
129         /// load a buffer into the current workarea.
130         Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
131                 bool tolastfiles = true);  ///< append to the "Open recent" menu?
132
133         /** redraw \c inset in all the BufferViews in which it is currently
134          *  visible. If successful return a pointer to the owning Buffer.
135          */
136         Buffer const * updateInset(Inset const *);
137         ///
138         void restartCursor();
139
140         /// \return the \c Workarea associated to \p  Buffer
141         /// \retval 0 if no \c WorkArea is found.
142         GuiWorkArea * workArea(Buffer & buffer);
143
144         /// Add a \c WorkArea 
145         /// \return the \c Workarea associated to \p  Buffer
146         /// \retval 0 if no \c WorkArea is found.
147         GuiWorkArea * addWorkArea(Buffer & buffer);
148         ///
149         void setCurrentWorkArea(GuiWorkArea * work_area);
150         ///
151         void removeWorkArea(GuiWorkArea * work_area);
152         /// return the current WorkArea (the one that has the focus).
153         GuiWorkArea const * currentWorkArea() const;
154
155 Q_SIGNALS:
156         void closing(int);
157
158 public Q_SLOTS:
159         /// idle timeout.
160         /// clear any temporary message and replace with current status.
161         void clearMessage();
162
163 private Q_SLOTS:
164         ///
165         void updateWindowTitle(GuiWorkArea * wa);
166
167         ///
168         void on_currentWorkAreaChanged(GuiWorkArea *);
169
170         /// slots to change the icon size
171         void smallSizedIcons();
172         void normalSizedIcons();
173         void bigSizedIcons();
174
175 private:
176         ///
177         void addTabWorkArea();
178
179         /// connect to signals in the given BufferView
180         void connectBufferView(BufferView & bv);
181         /// disconnect from signals in the given BufferView
182         void disconnectBufferView();
183         /// connect to signals in the given buffer
184         void connectBuffer(Buffer & buf);
185         /// disconnect from signals in the given buffer
186         void disconnectBuffer();
187         ///
188         void updateToc();
189         ///
190         void dragEnterEvent(QDragEnterEvent * ev);
191         ///
192         void dropEvent(QDropEvent * ev);
193         /// make sure we quit cleanly
194         virtual void closeEvent(QCloseEvent * e);
195         ///
196         virtual void resizeEvent(QResizeEvent * e);
197         ///
198         virtual void moveEvent(QMoveEvent * e);
199
200         /// in order to catch Tab key press.
201         bool event(QEvent * e);
202         bool focusNextPrevChild(bool);
203         ///
204         QRect updateFloatingGeometry();
205         ///
206         void setIconSize(unsigned int size);
207
208         ///
209         struct GuiViewPrivate;
210         GuiViewPrivate & d;
211
212         ///
213         QTimer statusbar_timer_;
214
215         /// are we quitting by the menu?
216         bool quitting_by_menu_;
217
218         ///
219         QRect floatingGeometry_;
220
221         struct ToolbarSize {
222                 int top_width;
223                 int bottom_width;
224                 int left_height;
225                 int right_height;
226         };
227
228         ToolbarSize toolbarSize_;
229
230         /// auto-saving of buffers
231         Timeout * const autosave_timeout_;
232         /// dialogs for this view
233         Dialogs * dialogs_;
234 };
235
236
237 } // namespace frontend
238 } // namespace lyx
239
240 #endif // GUIVIEW_H