]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
Delete include of config.h. This was needed only for the qt3 port.
[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 #include "FuncRequest.h"
20
21 #include <QAction>
22 #include <QCloseEvent>
23 #include <QMainWindow>
24 #include <QTimer>
25
26 class QDragEnterEvent;
27 class QDropEvent;
28 class QMenu;
29 class QToolBar;
30
31
32 namespace lyx {
33 namespace frontend {
34
35 class QCommandBuffer;
36
37 QWidget* mainWindow();
38
39 /**
40  * GuiView - Qt4 implementation of LyXView
41  *
42  * qt4-private implementation of the main LyX window.
43  *
44  * Note: any QObject emits a destroyed(QObject *) Qt signal when it
45  *       is deleted.This might be useful for closing other dialogs
46  *       depending on a given GuiView.
47  */
48 class GuiView : public QMainWindow, public LyXView {
49         Q_OBJECT
50 public:
51         /// create a main window of the given dimensions
52         GuiView(int id);
53
54         ~GuiView();
55
56         virtual void init();
57         virtual void close();
58         virtual void setFocus();
59         virtual void setGeometry(
60                 unsigned int width,
61                 unsigned int height,
62                 int posx, int posy,
63                 int maximized,
64                 unsigned int iconSizeXY,
65                 const std::string & geometryArg);
66         virtual void saveGeometry();
67         virtual void busy(bool);
68         /// add toolbar, if newline==true, add a toolbar break before the toolbar
69         Toolbars::ToolbarPtr makeToolbar(ToolbarInfo const & tbinfo, bool newline);
70         virtual void updateStatusBar();
71         virtual void message(docstring const & str);
72         virtual void clearMessage();
73         virtual bool hasFocus() const;
74
75         /// show - display the top-level window
76         void show();
77
78         /// add the command buffer
79         void addCommandBuffer(QToolBar * toolbar);
80
81         /// menu item has been selected
82         void activated(FuncRequest const &);
83
84         QMenu* createPopupMenu();
85
86 Q_SIGNALS:
87         void closing(int);
88
89 public Q_SLOTS:
90         /// idle timeout
91         void update_view_state_qt();
92
93         /// populate a toplevel menu and all its children on demand
94         void updateMenu(QAction *);
95
96         void currentTabChanged(int index);
97         void closeCurrentTab();
98
99         /// slots to change the icon size
100         void smallSizedIcons();
101         void normalSizedIcons();
102         void bigSizedIcons();
103
104 protected:
105         /// make sure we quit cleanly
106         virtual void closeEvent(QCloseEvent * e);
107
108         ///
109         virtual void resizeEvent(QResizeEvent * e);
110
111         ///
112         virtual void moveEvent(QMoveEvent * e);
113
114         /// \return the \c Workarea associated to \p  Buffer
115         /// \retval 0 if no \c WorkArea is found.
116         WorkArea * workArea(Buffer & buffer);
117
118         /// Add a \c WorkArea 
119         /// \return the \c Workarea associated to \p  Buffer
120         /// \retval 0 if no \c WorkArea is found.
121         WorkArea * addWorkArea(Buffer & buffer);
122         void setCurrentWorkArea(WorkArea * work_area);
123         void removeWorkArea(WorkArea * work_area);
124         WorkArea const * currentWorkArea() const;
125         WorkArea * currentWorkArea();
126
127 private:
128         ///
129         void dragEnterEvent(QDragEnterEvent * ev);
130         ///
131         void dropEvent(QDropEvent * ev);
132
133         /// focus the command buffer widget
134         void focus_command_widget();
135
136         /**
137          * setWindowTitle - set title of window
138          * @param t main window title
139          * @param it iconified (short) title
140          */
141         virtual void setWindowTitle(docstring const & t, docstring const & it);
142
143         /// in order to catch Tab key press.
144         bool event(QEvent * e);
145         bool focusNextPrevChild(bool);
146
147         QTimer statusbar_timer_;
148
149         /// command buffer
150         QCommandBuffer * commandbuffer_;
151
152         /// are we quitting by the menu?
153         bool quitting_by_menu_;
154
155         ///
156         QRect updateFloatingGeometry();
157         ///
158         QRect floatingGeometry_;
159
160         void setIconSize(unsigned int size);
161
162         struct ToolbarSize {
163                 int top_width;
164                 int bottom_width;
165                 int left_height;
166                 int right_height;
167         };
168
169         ToolbarSize toolbarSize_;
170
171         struct GuiViewPrivate;
172         GuiViewPrivate& d;
173 };
174
175 } // namespace frontend
176 } // namespace lyx
177
178 #endif // GUIVIEW_H