]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
* src/frontends/qt4/GuiView.[Ch]:
[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                 bool maximize,
65                 unsigned int iconSizeXY,
66                 const std::string & geometryArg);
67         virtual void saveGeometry();
68         virtual void busy(bool);
69         Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
70         virtual void updateStatusBar();
71         virtual void message(lyx::docstring const & str);
72         virtual void clearMessage();
73         virtual bool hasFocus() const;
74
75         virtual void updateTab();
76
77         /// show - display the top-level window
78         void show();
79
80         /// add the command buffer
81         void addCommandBuffer(QToolBar * toolbar);
82
83         /// menu item has been selected
84         void activated(FuncRequest const &);
85
86         void initTab(QWidget* workArea);
87
88         QMenu* createPopupMenu();
89
90 Q_SIGNALS:
91         void closing(int);
92
93 public Q_SLOTS:
94         /// idle timeout
95         void update_view_state_qt();
96
97         /// populate a toplevel menu and all its children on demand
98         void updateMenu(QAction *);
99
100         void currentTabChanged (int index); 
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 private:
118         /// focus the command buffer widget
119         void focus_command_widget();
120
121         /**
122          * setWindowTitle - set title of window
123          * @param t main window title
124          * @param it iconified (short) title
125          */
126         virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it);
127
128         /// in order to catch Tab key press.
129         bool event(QEvent * e);
130         bool focusNextPrevChild(bool);
131
132         QTimer statusbar_timer_;
133
134         /// command buffer
135         QCommandBuffer * commandbuffer_;
136
137         /// are we quitting by the menu?
138         bool quitting_by_menu_;
139
140         ///
141         void updateFloatingGeometry();
142         ///
143         QRect floatingGeometry_;
144
145         void setIconSize(unsigned int size);
146
147         struct ToolbarSize {
148                 int top_width;
149                 int bottom_width;
150                 int left_height;
151                 int right_height;
152         };
153
154         ToolbarSize toolbarSize_;
155
156         struct GuiViewPrivate;
157         GuiViewPrivate& d;
158 };
159
160 } // namespace frontend
161 } // namespace lyx
162
163 #endif // GUIVIEW_H