4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Abdelrazak Younes
10 * Full author contact details are available in file CREDITS.
16 #include "ui_WorkAreaUi.h"
18 #include "frontends/WorkArea.h"
20 #include <QAbstractScrollArea>
24 class QDragEnterEvent;
39 class GuiWorkArea : public QAbstractScrollArea, public WorkArea
45 GuiWorkArea(QWidget *);
47 GuiWorkArea(Buffer & buffer, GuiView & gv);
54 void setBuffer(Buffer &);
56 void setGuiView(GuiView &);
58 void setFullScreen(bool full_screen);
59 /// is GuiView in fullscreen mode?
60 bool isFullScreen() const;
62 BufferView & bufferView();
64 BufferView const & bufferView() const;
66 void scheduleRedraw(bool update_metrics);
68 /// return true if the key is part of a shortcut
69 bool queryKeySym(KeySymbol const & key, KeyModifier mod) const;
70 /// Process Key pressed event.
71 /// This needs to be public because it is accessed externally by GuiView.
72 void processKeySym(KeySymbol const & key, KeyModifier mod);
74 bool inDialogMode() const;
75 void setDialogMode(bool mode);
78 GuiCompleter & completer();
80 /// Return the GuiView this workArea belongs to
81 GuiView const & view() const;
84 /// Current ratio between physical pixels and device-independent pixels
85 double pixelRatio() const;
89 void stopBlinkingCaret();
91 void startBlinkingCaret();
95 void titleChanged(GuiWorkArea *);
99 void bufferViewChanged();
102 /// Scroll the BufferView.
104 * This is a slot for the valueChanged() signal of the vertical scrollbar.
105 * \p value value of the scrollbar.
107 void scrollTo(int value);
108 /// timer to limit triple clicks
109 void doubleClickTimeout();
110 /// toggle the caret's visibility
112 /// close this work area.
113 /// Slot for Buffer::closing signal.
115 /// Slot to restore proper scrollbar behaviour.
116 void fixVerticalScrollBar();
119 /// Update window titles of all users.
120 void updateWindowTitle();
122 bool event(QEvent *);
124 void contextMenuEvent(QContextMenuEvent *);
126 void focusInEvent(QFocusEvent *);
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);
140 void mouseMoveEvent(QMouseEvent * ev);
142 void wheelEvent(QWheelEvent * ev);
143 /// key press event. It also knows how to handle ShortcutOverride events to
144 /// avoid code duplication.
145 void keyPressEvent(QKeyEvent * ev);
147 void inputMethodEvent(QInputMethodEvent * ev);
149 QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
151 /// The slot connected to SyntheticMouseEvent::timeout.
152 void generateSyntheticMouseEvent();
154 friend class GuiCompleter;
160 class EmbeddedWorkArea : public GuiWorkArea
165 EmbeddedWorkArea(QWidget *);
168 /// Dummy methods for Designer.
169 void setWidgetResizable(bool) {}
170 void setWidget(QWidget *) {}
172 QSize sizeHint () const;
178 void closeEvent(QCloseEvent * ev);
180 void hideEvent(QHideEvent *ev);
185 }; // EmbeddedWorkArea
188 class GuiWorkAreaContainer;
190 /// A tabbed set of GuiWorkAreas.
191 class TabWorkArea : public QTabWidget
195 TabWorkArea(QWidget * parent = 0);
197 /// hide QTabWidget methods
198 GuiWorkAreaContainer * currentWidget() const;
199 GuiWorkAreaContainer * widget(int index) const;
202 void setFullScreen(bool full_screen);
203 void showBar(bool show);
205 bool setCurrentWorkArea(GuiWorkArea *);
206 GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
207 bool removeWorkArea(GuiWorkArea *);
208 GuiWorkArea * currentWorkArea() const;
209 GuiWorkArea * workArea(Buffer & buffer) const;
210 GuiWorkArea * workArea(int index) const;
211 void paintEvent(QPaintEvent *);
215 void currentWorkAreaChanged(GuiWorkArea *);
217 void lastWorkAreaRemoved();
220 /// close current buffer, or the one given by \c clicked_tab_
221 void closeCurrentBuffer();
222 /// hide current tab, or the one given by \c clicked_tab_
223 void hideCurrentTab();
224 /// close the tab given by \c index
225 void closeTab(int index);
227 void moveTab(int fromIndex, int toIndex);
229 void updateTabTexts();
233 void on_currentTabChanged(int index);
235 void showContextMenu(const QPoint & pos);
236 /// enable closing tab on middle-click
237 void mousePressEvent(QMouseEvent * me);
238 void mouseReleaseEvent(QMouseEvent * me);
240 void mouseDoubleClickEvent(QMouseEvent * event);
242 int indexOfWorkArea(GuiWorkArea * w) const;
245 using QTabWidget::addTab;
246 using QTabWidget::insertTab;
248 /// true if position is a tab (rather than the blank space in tab bar)
249 bool posIsTab(QPoint position);
255 QToolButton * closeBufferButton;
259 class DragTabBar : public QTabBar
264 DragTabBar(QWidget * parent = 0);
268 void mousePressEvent(QMouseEvent * event);
270 void mouseMoveEvent(QMouseEvent * event);
272 void dragEnterEvent(QDragEnterEvent * event);
274 void dropEvent(QDropEvent * event);
278 QPoint dragStartPos_;
282 void tabMoveRequested(int fromIndex, int toIndex);
286 class GuiWorkAreaContainer : public QWidget, public Ui::WorkAreaUi
290 GuiWorkArea * const wa_;
291 void dispatch(FuncRequest f) const;
294 void updateDisplay();
299 void mouseDoubleClickEvent(QMouseEvent * event); //override
303 GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent = 0);
305 GuiWorkArea * workArea() const { return wa_; }
310 } // namespace frontend