]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
Put LyXView on a diet, step 1: get rid of toolbars direct access from the core. Toolb...
[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 class QCommandBuffer;
36
37 QWidget* mainWindow();
38
39 /**
40  * GuiView - Qt4 implementation of LyXView
41  *
42  * qt4-private implementation of the main LyX window.
43  *
44  * Note: any QObject emits a destroyed(QObject *) Qt signal when it
45  *       is deleted.This might be useful for closing other dialogs
46  *       depending on a given GuiView.
47  */
48 class GuiView : public QMainWindow, public LyXView {
49         Q_OBJECT
50 public:
51         /// create a main window of the given dimensions
52         GuiView(int id);
53
54         ~GuiView();
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         Toolbars::ToolbarPtr 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
76         /// show - display the top-level window
77         void show();
78
79         /// add the command buffer
80         void addCommandBuffer(QToolBar * toolbar);
81
82         /// menu item has been selected
83         void activated(FuncRequest const &);
84
85         QMenu* createPopupMenu();
86
87 Q_SIGNALS:
88         void closing(int);
89
90 public Q_SLOTS:
91         /// idle timeout
92         void update_view_state_qt();
93
94         /// populate a toplevel menu and all its children on demand
95         void updateMenu(QAction *);
96
97         void currentTabChanged(int index);
98         void closeCurrentTab();
99
100         /// slots to change the icon size
101         void smallSizedIcons();
102         void normalSizedIcons();
103         void bigSizedIcons();
104
105 protected:
106         /// make sure we quit cleanly
107         virtual void closeEvent(QCloseEvent * e);
108
109         ///
110         virtual void resizeEvent(QResizeEvent * e);
111
112         ///
113         virtual void moveEvent(QMoveEvent * e);
114
115         /// \return the \c Workarea associated to \p  Buffer
116         /// \retval 0 if no \c WorkArea is found.
117         WorkArea * workArea(Buffer & buffer);
118
119         /// Add a \c WorkArea 
120         /// \return the \c Workarea associated to \p  Buffer
121         /// \retval 0 if no \c WorkArea is found.
122         WorkArea * addWorkArea(Buffer & buffer);
123         void setCurrentWorkArea(WorkArea * work_area);
124         void removeWorkArea(WorkArea * work_area);
125         WorkArea const * currentWorkArea() const;
126         WorkArea * currentWorkArea();
127
128 private:
129         ///
130         void dragEnterEvent(QDragEnterEvent * ev);
131         ///
132         void dropEvent(QDropEvent * ev);
133
134         /**
135          * setWindowTitle - set title of window
136          * @param t main window title
137          * @param it iconified (short) title
138          */
139         virtual void setWindowTitle(docstring const & t, docstring const & it);
140
141         /// in order to catch Tab key press.
142         bool event(QEvent * e);
143         bool focusNextPrevChild(bool);
144
145         QTimer statusbar_timer_;
146
147         /// command buffer
148         QCommandBuffer * commandbuffer_;
149
150         /// are we quitting by the menu?
151         bool quitting_by_menu_;
152
153         ///
154         QRect updateFloatingGeometry();
155         ///
156         QRect floatingGeometry_;
157
158         void setIconSize(unsigned int size);
159
160         struct ToolbarSize {
161                 int top_width;
162                 int bottom_width;
163                 int left_height;
164                 int right_height;
165         };
166
167         ToolbarSize toolbarSize_;
168
169         struct GuiViewPrivate;
170         GuiViewPrivate& d;
171 };
172
173 } // namespace frontend
174 } // namespace lyx
175
176 #endif // GUIVIEW_H