]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiWorkArea.h
Also display the info about BibTeX databases in the TeX info panel.
[lyx.git] / src / frontends / qt4 / GuiWorkArea.h
1 // -*- C++ -*-
2 /**
3  * \file GuiWorkArea.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef WORKAREA_H
14 #define WORKAREA_H
15
16 #include "frontends/WorkArea.h"
17
18 #include "support/docstring.h"
19
20 #include <QAbstractScrollArea>
21 #include <QTabBar>
22 #include <QTabWidget>
23
24 class QDragEnterEvent;
25 class QDropEvent;
26 class QToolButton;
27 class QWidget;
28
29 #ifdef CursorShape
30 #undef CursorShape
31 #endif
32
33 namespace lyx {
34
35 class Buffer;
36
37 namespace frontend {
38
39 class GuiCompleter;
40 class GuiView;
41
42 class GuiWorkArea : public QAbstractScrollArea, public WorkArea
43 {
44         Q_OBJECT
45
46 public:
47         ///
48         GuiWorkArea(QWidget *);
49         ///
50         GuiWorkArea(Buffer & buffer, GuiView & gv);
51         ///
52         ~GuiWorkArea();
53
54         ///
55         void init();
56         ///
57         void setBuffer(Buffer &);
58         ///
59         void setGuiView(GuiView &);
60         ///
61         void setFullScreen(bool full_screen);
62         /// is GuiView in fullscreen mode?
63         bool isFullScreen() const;
64         ///
65         void scheduleRedraw();
66         ///
67         BufferView & bufferView();
68         ///
69         BufferView const & bufferView() const;
70         ///
71         void redraw(bool update_metrics);
72
73         /// Process Key pressed event.
74         /// This needs to be public because it is accessed externally by GuiView.
75         void processKeySym(KeySymbol const & key, KeyModifier mod);
76
77         bool inDialogMode() const;
78         void setDialogMode(bool mode);
79
80         ///
81         GuiCompleter & completer();
82
83         Qt::CursorShape cursorShape() const;
84
85         /// Return the GuiView this workArea belongs to
86         GuiView const & view() const;
87         GuiView & view();
88
89 public Q_SLOTS:
90         ///
91         void stopBlinkingCursor();
92         ///
93         void startBlinkingCursor();
94
95 Q_SIGNALS:
96         ///
97         void titleChanged(GuiWorkArea *);
98         ///
99         void busy(bool);
100
101 private Q_SLOTS:
102         /// Scroll the BufferView.
103         /**
104           * This is a slot for the valueChanged() signal of the vertical scrollbar.
105           * \p value value of the scrollbar.
106         */
107         void scrollTo(int value);
108         /// timer to limit triple clicks
109         void doubleClickTimeout();
110         /// toggle the cursor's visibility
111         void toggleCursor();
112         /// close this work area.
113         /// Slot for Buffer::closing signal.
114         void close();
115         /// Slot to restore proper scrollbar behaviour.
116         void fixVerticalScrollBar();
117
118 private:
119         /// Update window titles of all users.
120         void updateWindowTitle();
121         ///
122         bool event(QEvent *);
123         ///
124         void contextMenuEvent(QContextMenuEvent *);
125         ///
126         void focusInEvent(QFocusEvent *);
127         ///
128         void focusOutEvent(QFocusEvent *);
129         /// repaint part of the widget
130         void paintEvent(QPaintEvent * ev);
131         /// widget has been resized
132         void resizeEvent(QResizeEvent * ev);
133         /// mouse button press
134         void mousePressEvent(QMouseEvent * ev);
135         /// mouse button release
136         void mouseReleaseEvent(QMouseEvent * ev);
137         /// mouse double click of button
138         void mouseDoubleClickEvent(QMouseEvent * ev);
139         /// mouse motion
140         void mouseMoveEvent(QMouseEvent * ev);
141         /// wheel event
142         void wheelEvent(QWheelEvent * ev);
143         /// key press
144         void keyPressEvent(QKeyEvent * ev);
145         /// IM events
146         void inputMethodEvent(QInputMethodEvent * ev);
147         /// IM query
148         QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
149
150         /// The slot connected to SyntheticMouseEvent::timeout.
151         void generateSyntheticMouseEvent();
152
153         friend class GuiCompleter;
154         struct Private;
155         Private * const d;
156 }; // GuiWorkArea
157
158
159 class EmbeddedWorkArea : public GuiWorkArea
160 {
161         Q_OBJECT
162 public:
163         ///
164         EmbeddedWorkArea(QWidget *);
165         ~EmbeddedWorkArea();
166
167         /// Dummy methods for Designer.
168         void setWidgetResizable(bool) {}
169         void setWidget(QWidget *) {}
170
171         QSize sizeHint () const;
172         ///
173         void disable();
174
175 protected:
176         ///
177         void closeEvent(QCloseEvent * ev);
178         ///
179         void hideEvent(QHideEvent *ev);
180
181 private:
182         /// Embedded Buffer.
183         Buffer * buffer_;
184 }; // EmbeddedWorkArea
185
186
187 /// A tabbed set of GuiWorkAreas.
188 class TabWorkArea : public QTabWidget
189 {
190         Q_OBJECT
191 public:
192         TabWorkArea(QWidget * parent = 0);
193
194         ///
195         void setFullScreen(bool full_screen);
196         void showBar(bool show);
197         void closeAll();
198         bool setCurrentWorkArea(GuiWorkArea *);
199         GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
200         bool removeWorkArea(GuiWorkArea *);
201         GuiWorkArea * currentWorkArea();
202         GuiWorkArea * workArea(Buffer & buffer);
203         GuiWorkArea * workArea(int index);
204
205 Q_SIGNALS:
206         ///
207         void currentWorkAreaChanged(GuiWorkArea *);
208         ///
209         void lastWorkAreaRemoved();
210
211 public Q_SLOTS:
212         /// close current buffer, or the one given by \c clicked_tab_
213         void closeCurrentBuffer();
214         /// hide current tab, or the one given by \c clicked_tab_
215         void hideCurrentTab();
216         /// close the tab given by \c index
217         void closeTab(int index);
218         ///
219         void updateTabTexts();
220         
221 private Q_SLOTS:
222         ///
223         void on_currentTabChanged(int index);
224         ///
225         void showContextMenu(const QPoint & pos);
226         ///
227         void moveTab(int fromIndex, int toIndex);
228         ///
229         void mouseDoubleClickEvent(QMouseEvent * event);
230
231 private:
232         ///
233         int clicked_tab_;
234         ///
235         QToolButton * closeBufferButton;
236 }; // TabWorkArea
237
238
239 class DragTabBar : public QTabBar
240 {
241         Q_OBJECT
242 public:
243         ///
244         DragTabBar(QWidget * parent = 0);
245
246 #if QT_VERSION < 0x040300
247         ///
248         int tabAt(QPoint const & position) const;
249 #endif
250
251 protected:
252         ///
253         void mousePressEvent(QMouseEvent * event);
254         ///
255         void mouseMoveEvent(QMouseEvent * event);
256         ///
257         void dragEnterEvent(QDragEnterEvent * event);
258         ///
259         void dropEvent(QDropEvent * event);
260
261 private:
262         ///
263         QPoint dragStartPos_;
264         ///
265         int dragCurrentIndex_;
266
267 Q_SIGNALS:
268         ///
269         void tabMoveRequested(int fromIndex, int toIndex);
270 };
271
272 } // namespace frontend
273 } // namespace lyx
274
275 #endif // WORKAREA_H