]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiWorkArea.h
Amend 8add88ee4995: Show Biblatex files in the TeXInfo dialog
[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 <QAbstractScrollArea>
19 #include <QTabBar>
20 #include <QTabWidget>
21
22 class QDragEnterEvent;
23 class QDropEvent;
24 class QToolButton;
25 class QWidget;
26
27 #ifdef CursorShape
28 #undef CursorShape
29 #endif
30
31 namespace lyx {
32
33 class Buffer;
34
35 namespace frontend {
36
37 class GuiCompleter;
38 class GuiView;
39
40 class GuiWorkArea : public QAbstractScrollArea, public WorkArea
41 {
42         Q_OBJECT
43
44 public:
45         ///
46         GuiWorkArea(QWidget *);
47         ///
48         GuiWorkArea(Buffer & buffer, GuiView & gv);
49         ///
50         ~GuiWorkArea();
51
52         ///
53         void init();
54         ///
55         void setBuffer(Buffer &);
56         ///
57         void setGuiView(GuiView &);
58         ///
59         void setFullScreen(bool full_screen);
60         /// is GuiView in fullscreen mode?
61         bool isFullScreen() const;
62         ///
63         void scheduleRedraw();
64         ///
65         BufferView & bufferView();
66         ///
67         BufferView const & bufferView() const;
68         ///
69         void redraw(bool update_metrics);
70
71         /// return true if the key is part of a shortcut
72         bool queryKeySym(KeySymbol const & key, KeyModifier mod) const;
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         /// Current ratio between physical pixels and device-independent pixels
90         double pixelRatio() const;
91
92 public Q_SLOTS:
93         ///
94         void stopBlinkingCursor();
95         ///
96         void startBlinkingCursor();
97
98 Q_SIGNALS:
99         ///
100         void titleChanged(GuiWorkArea *);
101         ///
102         void busy(bool);
103         ///
104         void bufferViewChanged();
105
106 private Q_SLOTS:
107         /// Scroll the BufferView.
108         /**
109           * This is a slot for the valueChanged() signal of the vertical scrollbar.
110           * \p value value of the scrollbar.
111         */
112         void scrollTo(int value);
113         /// timer to limit triple clicks
114         void doubleClickTimeout();
115         /// toggle the cursor's visibility
116         void toggleCursor();
117         /// close this work area.
118         /// Slot for Buffer::closing signal.
119         void close();
120         /// Slot to restore proper scrollbar behaviour.
121         void fixVerticalScrollBar();
122
123 private:
124         /// Update window titles of all users.
125         void updateWindowTitle();
126         ///
127         bool event(QEvent *);
128         ///
129         void contextMenuEvent(QContextMenuEvent *);
130         ///
131         void focusInEvent(QFocusEvent *);
132         ///
133         void focusOutEvent(QFocusEvent *);
134         /// repaint part of the widget
135         void paintEvent(QPaintEvent * ev);
136         /// widget has been resized
137         void resizeEvent(QResizeEvent * ev);
138         /// mouse button press
139         void mousePressEvent(QMouseEvent * ev);
140         /// mouse button release
141         void mouseReleaseEvent(QMouseEvent * ev);
142         /// mouse double click of button
143         void mouseDoubleClickEvent(QMouseEvent * ev);
144         /// mouse motion
145         void mouseMoveEvent(QMouseEvent * ev);
146         /// wheel event
147         void wheelEvent(QWheelEvent * ev);
148         /// key press event. It also knows how to handle ShortcutOverride events to
149         /// avoid code duplication.
150         void keyPressEvent(QKeyEvent * ev);
151         /// IM events
152         void inputMethodEvent(QInputMethodEvent * ev);
153         /// IM query
154         QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
155
156         /// The slot connected to SyntheticMouseEvent::timeout.
157         void generateSyntheticMouseEvent();
158
159         friend class GuiCompleter;
160         struct Private;
161         Private * const d;
162 }; // GuiWorkArea
163
164
165 class EmbeddedWorkArea : public GuiWorkArea
166 {
167         Q_OBJECT
168 public:
169         ///
170         EmbeddedWorkArea(QWidget *);
171         ~EmbeddedWorkArea();
172
173         /// Dummy methods for Designer.
174         void setWidgetResizable(bool) {}
175         void setWidget(QWidget *) {}
176
177         QSize sizeHint () const;
178         ///
179         void disable();
180
181 protected:
182         ///
183         void closeEvent(QCloseEvent * ev);
184         ///
185         void hideEvent(QHideEvent *ev);
186
187 private:
188         /// Embedded Buffer.
189         Buffer * buffer_;
190 }; // EmbeddedWorkArea
191
192
193 /// A tabbed set of GuiWorkAreas.
194 class TabWorkArea : public QTabWidget
195 {
196         Q_OBJECT
197 public:
198         TabWorkArea(QWidget * parent = 0);
199
200         ///
201         void setFullScreen(bool full_screen);
202         void showBar(bool show);
203         void closeAll();
204         bool setCurrentWorkArea(GuiWorkArea *);
205         GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
206         bool removeWorkArea(GuiWorkArea *);
207         GuiWorkArea * currentWorkArea();
208         GuiWorkArea * workArea(Buffer & buffer);
209         GuiWorkArea * workArea(int index);
210         void paintEvent(QPaintEvent *);
211
212 Q_SIGNALS:
213         ///
214         void currentWorkAreaChanged(GuiWorkArea *);
215         ///
216         void lastWorkAreaRemoved();
217
218 public Q_SLOTS:
219         /// close current buffer, or the one given by \c clicked_tab_
220         void closeCurrentBuffer();
221         /// hide current tab, or the one given by \c clicked_tab_
222         void hideCurrentTab();
223         /// close the tab given by \c index
224         void closeTab(int index);
225         ///
226         void moveTab(int fromIndex, int toIndex);
227         ///
228         void updateTabTexts();
229         
230 private Q_SLOTS:
231         ///
232         void on_currentTabChanged(int index);
233         ///
234         void showContextMenu(const QPoint & pos);
235         /// enable closing tab on middle-click
236         void mousePressEvent(QMouseEvent * me);
237         void mouseReleaseEvent(QMouseEvent * me);
238         ///
239         void mouseDoubleClickEvent(QMouseEvent * event);
240
241 private:
242         /// true if position is a tab (rather than the blank space in tab bar)
243         bool posIsTab(QPoint position);
244
245         int clicked_tab_;
246         ///
247         int midpressed_tab_;
248         ///
249         QToolButton * closeBufferButton;
250 }; // TabWorkArea
251
252
253 class DragTabBar : public QTabBar
254 {
255         Q_OBJECT
256 public:
257         ///
258         DragTabBar(QWidget * parent = 0);
259
260 protected:
261         ///
262         void mousePressEvent(QMouseEvent * event);
263         ///
264         void mouseMoveEvent(QMouseEvent * event);
265         ///
266         void dragEnterEvent(QDragEnterEvent * event);
267         ///
268         void dropEvent(QDropEvent * event);
269
270 private:
271         ///
272         QPoint dragStartPos_;
273
274 Q_SIGNALS:
275         ///
276         void tabMoveRequested(int fromIndex, int toIndex);
277 };
278
279 } // namespace frontend
280 } // namespace lyx
281
282 #endif // WORKAREA_H