]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
cosmetics
[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 <QTabWidget>
25 #include <QTimer>
26
27 class QDragEnterEvent;
28 class QDropEvent;
29 class QMenu;
30 class QToolBar;
31
32 namespace lyx {
33 namespace frontend {
34
35 class GuiToolbar;
36 class GuiWorkArea;
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: a 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 GuiViewBase : public QMainWindow, public LyXView
50 {
51         Q_OBJECT
52 public:
53         /// create a main window of the given dimensions
54         GuiViewBase(int id);
55
56         ~GuiViewBase();
57
58         virtual void init();
59         virtual void close();
60         virtual void setFocus();
61         virtual void setGeometry(
62                 unsigned int width,
63                 unsigned int height,
64                 int posx, int posy,
65                 int maximized,
66                 unsigned int iconSizeXY,
67                 const std::string & geometryArg);
68         virtual void saveGeometry();
69         virtual void setBusy(bool);
70         /// add toolbar, if newline==true, add a toolbar break before the toolbar
71         GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
72         virtual void updateStatusBar();
73         virtual void message(docstring const & str);
74         virtual void clearMessage();
75         virtual bool hasFocus() const;
76         void showMiniBuffer(bool);
77         void openMenu(docstring const &);
78         void openLayoutList();
79         void updateLayoutChoice();
80         bool isToolbarVisible(std::string const & id);
81         void updateToolbars();
82         ToolbarInfo * getToolbarInfo(std::string const & name);
83         void toggleToolbarState(std::string const & name, bool allowauto);
84
85         /// show - display the top-level window
86         void showView();
87
88         /// menu item has been selected
89         void activated(FuncRequest const &);
90
91         QMenu* createPopupMenu();
92
93 Q_SIGNALS:
94         void closing(int);
95
96 public Q_SLOTS:
97         /// idle timeout
98         void update_view_state_qt();
99
100         ///
101         void on_currentWorkAreaChanged(GuiWorkArea *);
102
103         /// slots to change the icon size
104         void smallSizedIcons();
105         void normalSizedIcons();
106         void bigSizedIcons();
107
108 protected:
109         /// make sure we quit cleanly
110         virtual void closeEvent(QCloseEvent * e);
111         ///
112         virtual void resizeEvent(QResizeEvent * e);
113         ///
114         virtual void moveEvent(QMoveEvent * e);
115
116         /// \return the \c Workarea associated to \p  Buffer
117         /// \retval 0 if no \c WorkArea is found.
118         WorkArea * workArea(Buffer & buffer);
119
120         /// Add a \c WorkArea 
121         /// \return the \c Workarea associated to \p  Buffer
122         /// \retval 0 if no \c WorkArea is found.
123         WorkArea * addWorkArea(Buffer & buffer);
124         void setCurrentWorkArea(WorkArea * work_area);
125         void removeWorkArea(WorkArea * work_area);
126         WorkArea const * currentWorkArea() const;
127         WorkArea * currentWorkArea();
128
129 private:
130         ///
131         void dragEnterEvent(QDragEnterEvent * ev);
132         ///
133         void dropEvent(QDropEvent * ev);
134
135         /**
136          * setWindowTitle - set title of window
137          * @param t main window title
138          * @param it iconified (short) title
139          */
140         virtual void setWindowTitle(docstring const & t, docstring const & it);
141
142         /// in order to catch Tab key press.
143         bool event(QEvent * e);
144         bool focusNextPrevChild(bool);
145
146         QTimer statusbar_timer_;
147
148         /// are we quitting by the menu?
149         bool quitting_by_menu_;
150
151         ///
152         QRect updateFloatingGeometry();
153         ///
154         QRect floatingGeometry_;
155
156         void setIconSize(unsigned int size);
157
158         struct ToolbarSize {
159                 int top_width;
160                 int bottom_width;
161                 int left_height;
162                 int right_height;
163         };
164
165         ToolbarSize toolbarSize_;
166
167         struct GuiViewPrivate;
168         GuiViewPrivate& d;
169 };
170
171
172 } // namespace frontend
173 } // namespace lyx
174
175 #endif // GUIVIEW_H