]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
1f67c8eb930c8106d86771ef7a2136bfe9887523
[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         /// show - display the top-level window
79         void show();
80
81         /// add the command buffer
82         void addCommandBuffer(QToolBar * toolbar);
83
84         /// menu item has been selected
85         void activated(FuncRequest const &);
86
87         QMenu* createPopupMenu();
88
89 Q_SIGNALS:
90         void closing(int);
91
92 public Q_SLOTS:
93         /// idle timeout
94         void update_view_state_qt();
95
96         /// populate a toplevel menu and all its children on demand
97         void updateMenu(QAction *);
98
99         void currentTabChanged(int index);
100         void closeCurrentTab();
101
102         /// slots to change the icon size
103         void smallSizedIcons();
104         void normalSizedIcons();
105         void bigSizedIcons();
106
107 protected:
108         /// make sure we quit cleanly
109         virtual void closeEvent(QCloseEvent * e);
110
111         ///
112         virtual void resizeEvent(QResizeEvent * e);
113
114         ///
115         virtual void moveEvent(QMoveEvent * e);
116
117         /// \return the \c Workarea associated to \p  Buffer
118         /// \retval 0 if no \c WorkArea is found.
119         WorkArea * workArea(Buffer & buffer);
120
121         /// Add a \c WorkArea 
122         /// \return the \c Workarea associated to \p  Buffer
123         /// \retval 0 if no \c WorkArea is found.
124         WorkArea * addWorkArea(Buffer & buffer);
125         void setCurrentWorkArea(WorkArea * work_area);
126         void removeWorkArea(WorkArea * work_area);
127         WorkArea const * currentWorkArea() const;
128         WorkArea * currentWorkArea();
129
130 private:
131         ///
132         void dragEnterEvent(QDragEnterEvent * ev);
133         ///
134         void dropEvent(QDropEvent * ev);
135
136         /// focus the command buffer widget
137         void focus_command_widget();
138
139         /**
140          * setWindowTitle - set title of window
141          * @param t main window title
142          * @param it iconified (short) title
143          */
144         virtual void setWindowTitle(docstring const & t, docstring const & it);
145
146         /// in order to catch Tab key press.
147         bool event(QEvent * e);
148         bool focusNextPrevChild(bool);
149
150         QTimer statusbar_timer_;
151
152         /// command buffer
153         QCommandBuffer * commandbuffer_;
154
155         /// are we quitting by the menu?
156         bool quitting_by_menu_;
157
158         ///
159         QRect updateFloatingGeometry();
160         ///
161         QRect floatingGeometry_;
162
163         void setIconSize(unsigned int size);
164
165         struct ToolbarSize {
166                 int top_width;
167                 int bottom_width;
168                 int left_height;
169                 int right_height;
170         };
171
172         ToolbarSize toolbarSize_;
173
174         struct GuiViewPrivate;
175         GuiViewPrivate& d;
176 };
177
178 } // namespace frontend
179 } // namespace lyx
180
181 #endif // GUIVIEW_H