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