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