]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
reduce #includes
[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 namespace lyx {
32 namespace frontend {
33
34 QWidget * mainWindow();
35
36 /**
37  * GuiView - Qt4 implementation of LyXView
38  *
39  * qt4-private implementation of the main LyX window.
40  *
41  * Note: a QObject emits a destroyed(QObject *) Qt signal when it
42  * is deleted. This might be useful for closing other dialogs
43  * depending on a given GuiView.
44  */
45 class GuiViewBase : public QMainWindow, public LyXView
46 {
47         Q_OBJECT
48 public:
49         /// create a main window of the given dimensions
50         GuiViewBase(int id);
51
52         ~GuiViewBase();
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         Toolbar * 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 showView();
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         virtual void resizeEvent(QResizeEvent * e);
103         ///
104         virtual void moveEvent(QMoveEvent * e);
105
106         /// \return the \c Workarea associated to \p  Buffer
107         /// \retval 0 if no \c WorkArea is found.
108         WorkArea * workArea(Buffer & buffer);
109
110         /// Add a \c WorkArea 
111         /// \return the \c Workarea associated to \p  Buffer
112         /// \retval 0 if no \c WorkArea is found.
113         WorkArea * addWorkArea(Buffer & buffer);
114         void setCurrentWorkArea(WorkArea * work_area);
115         void removeWorkArea(WorkArea * work_area);
116         WorkArea const * currentWorkArea() const;
117         WorkArea * currentWorkArea();
118
119 private:
120         ///
121         void dragEnterEvent(QDragEnterEvent * ev);
122         ///
123         void dropEvent(QDropEvent * ev);
124
125         /**
126          * setWindowTitle - set title of window
127          * @param t main window title
128          * @param it iconified (short) title
129          */
130         virtual void setWindowTitle(docstring const & t, docstring const & it);
131
132         /// in order to catch Tab key press.
133         bool event(QEvent * e);
134         bool focusNextPrevChild(bool);
135
136         QTimer statusbar_timer_;
137
138         /// are we quitting by the menu?
139         bool quitting_by_menu_;
140
141         ///
142         QRect updateFloatingGeometry();
143         ///
144         QRect floatingGeometry_;
145
146         void setIconSize(unsigned int size);
147
148         struct ToolbarSize {
149                 int top_width;
150                 int bottom_width;
151                 int left_height;
152                 int right_height;
153         };
154
155         ToolbarSize toolbarSize_;
156
157         struct GuiViewPrivate;
158         GuiViewPrivate& d;
159 };
160
161 } // namespace frontend
162 } // namespace lyx
163
164 #endif // GUIVIEW_H