]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
3082d41b8a36d38a9da07baf6cce0da1a72893fb
[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 // Must be here because of moc.
19 #include <config.h>
20
21 #include "frontends/LyXView.h"
22 #include "FuncRequest.h"
23
24 #include <QAction>
25 #include <QCloseEvent>
26 #include <QMainWindow>
27 #include <QTimer>
28
29 class QDragEnterEvent;
30 class QDropEvent;
31 class QMenu;
32 class QToolBar;
33
34
35 namespace lyx {
36 namespace frontend {
37
38 class QCommandBuffer;
39
40 QWidget* mainWindow();
41
42 /**
43  * GuiView - Qt4 implementation of LyXView
44  *
45  * qt4-private implementation of the main LyX window.
46  *
47  * Note: any 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.
50  */
51 class GuiView : public QMainWindow, public LyXView {
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         virtual void setGeometry(
63                 unsigned int width,
64                 unsigned int height,
65                 int posx, int posy,
66                 int maximized,
67                 unsigned int iconSizeXY,
68                 const std::string & geometryArg);
69         virtual void saveGeometry();
70         virtual void busy(bool);
71         /// add toolbar, if newline==true, add a toolbar break before the toolbar
72         Toolbars::ToolbarPtr 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
78         virtual void updateTab();
79
80         /// show - display the top-level window
81         void show();
82
83         /// add the command buffer
84         void addCommandBuffer(QToolBar * toolbar);
85
86         /// menu item has been selected
87         void activated(FuncRequest const &);
88
89         void initTab(QWidget* workArea);
90
91         QMenu* createPopupMenu();
92
93 Q_SIGNALS:
94         void closing(int);
95
96 public Q_SLOTS:
97         /// idle timeout
98         void update_view_state_qt();
99
100         /// populate a toplevel menu and all its children on demand
101         void updateMenu(QAction *);
102
103         void currentTabChanged(int index);
104         void closeCurrentTab();
105
106         /// slots to change the icon size
107         void smallSizedIcons();
108         void normalSizedIcons();
109         void bigSizedIcons();
110
111 protected:
112         /// make sure we quit cleanly
113         virtual void closeEvent(QCloseEvent * e);
114
115         ///
116         virtual void resizeEvent(QResizeEvent * e);
117
118         ///
119         virtual void moveEvent(QMoveEvent * e);
120
121 private:
122         ///
123         void dragEnterEvent(QDragEnterEvent * ev);
124         ///
125         void dropEvent(QDropEvent * ev);
126
127         /// focus the command buffer widget
128         void focus_command_widget();
129
130         /**
131          * setWindowTitle - set title of window
132          * @param t main window title
133          * @param it iconified (short) title
134          */
135         virtual void setWindowTitle(docstring const & t, docstring const & it);
136
137         /// in order to catch Tab key press.
138         bool event(QEvent * e);
139         bool focusNextPrevChild(bool);
140
141         QTimer statusbar_timer_;
142
143         /// command buffer
144         QCommandBuffer * commandbuffer_;
145
146         /// are we quitting by the menu?
147         bool quitting_by_menu_;
148
149         ///
150         QRect updateFloatingGeometry();
151         ///
152         QRect floatingGeometry_;
153
154         void setIconSize(unsigned int size);
155
156         struct ToolbarSize {
157                 int top_width;
158                 int bottom_width;
159                 int left_height;
160                 int right_height;
161         };
162
163         ToolbarSize toolbarSize_;
164
165         struct GuiViewPrivate;
166         GuiViewPrivate& d;
167 };
168
169 } // namespace frontend
170 } // namespace lyx
171
172 #endif // GUIVIEW_H