]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
add tab close button
[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 <QMainWindow>
25 #include <QTimer>
26 #include <QAction>
27 #include <QCloseEvent>
28
29 class QToolBar;
30 class QMenu;
31
32
33 namespace lyx {
34 namespace frontend {
35
36 class QCommandBuffer;
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: any 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         Q_OBJECT
51 public:
52         /// create a main window of the given dimensions
53         GuiView(int id);
54
55         ~GuiView();
56
57         virtual void init();
58         virtual void close();
59         virtual void setFocus();
60         virtual void setGeometry(
61                 unsigned int width,
62                 unsigned int height,
63                 int posx, int posy,
64                 int maximized,
65                 unsigned int iconSizeXY,
66                 const std::string & geometryArg);
67         virtual void saveGeometry();
68         virtual void busy(bool);
69         /// add toolbar, if newline==true, add a toolbar break before the toolbar
70         Toolbars::ToolbarPtr makeToolbar(ToolbarInfo const & tbinfo, bool newline);
71         virtual void updateStatusBar();
72         virtual void message(docstring const & str);
73         virtual void clearMessage();
74         virtual bool hasFocus() const;
75
76         virtual void updateTab();
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         void initTab(QWidget* workArea);
88
89         QMenu* createPopupMenu();
90
91 Q_SIGNALS:
92         void closing(int);
93
94 public Q_SLOTS:
95         /// idle timeout
96         void update_view_state_qt();
97
98         /// populate a toplevel menu and all its children on demand
99         void updateMenu(QAction *);
100
101         void currentTabChanged(int index);
102         void closeCurrentTab();
103
104         /// slots to change the icon size
105         void smallSizedIcons();
106         void normalSizedIcons();
107         void bigSizedIcons();
108
109 protected:
110         /// make sure we quit cleanly
111         virtual void closeEvent(QCloseEvent * e);
112
113         ///
114         virtual void resizeEvent(QResizeEvent * e);
115
116         ///
117         virtual void moveEvent(QMoveEvent * e);
118
119 private:
120         /// focus the command buffer widget
121         void focus_command_widget();
122
123         /**
124          * setWindowTitle - set title of window
125          * @param t main window title
126          * @param it iconified (short) title
127          */
128         virtual void setWindowTitle(docstring const & t, docstring const & it);
129
130         /// in order to catch Tab key press.
131         bool event(QEvent * e);
132         bool focusNextPrevChild(bool);
133
134         QTimer statusbar_timer_;
135
136         /// command buffer
137         QCommandBuffer * commandbuffer_;
138
139         /// are we quitting by the menu?
140         bool quitting_by_menu_;
141
142         ///
143         QRect updateFloatingGeometry();
144         ///
145         QRect floatingGeometry_;
146
147         void setIconSize(unsigned int size);
148
149         struct ToolbarSize {
150                 int top_width;
151                 int bottom_width;
152                 int left_height;
153                 int right_height;
154         };
155
156         ToolbarSize toolbarSize_;
157
158         struct GuiViewPrivate;
159         GuiViewPrivate& d;
160 };
161
162 } // namespace frontend
163 } // namespace lyx
164
165 #endif // GUIVIEW_H