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;
43 class GuiWorkArea : public QAbstractScrollArea, public WorkArea
49 GuiWorkArea(QWidget *);
51 GuiWorkArea(Buffer & buffer, GuiView & gv);
58 void setBuffer(Buffer &);
60 void setGuiView(GuiView &);
62 void setFullScreen(bool full_screen);
63 /// is GuiView in fullscreen mode?
64 bool isFullScreen() const;
66 void scheduleRedraw();
68 BufferView & bufferView();
70 BufferView const & bufferView() const;
72 void redraw(bool update_metrics);
74 /// return true if the key is part of a shortcut
75 bool queryKeySym(KeySymbol const & key, KeyModifier mod) const;
76 /// Process Key pressed event.
77 /// This needs to be public because it is accessed externally by GuiView.
78 void processKeySym(KeySymbol const & key, KeyModifier mod);
80 bool inDialogMode() const;
81 void setDialogMode(bool mode);
84 GuiCompleter & completer();
86 Qt::CursorShape cursorShape() const;
88 /// Return the GuiView this workArea belongs to
89 GuiView const & view() const;
92 /// Current ratio between physical pixels and device-independent pixels
93 double pixelRatio() const;
97 void stopBlinkingCursor();
99 void startBlinkingCursor();
103 void titleChanged(GuiWorkArea *);
107 void bufferViewChanged();
110 /// Scroll the BufferView.
112 * This is a slot for the valueChanged() signal of the vertical scrollbar.
113 * \p value value of the scrollbar.
115 void scrollTo(int value);
116 /// timer to limit triple clicks
117 void doubleClickTimeout();
118 /// toggle the cursor's visibility
120 /// close this work area.
121 /// Slot for Buffer::closing signal.
123 /// Slot to restore proper scrollbar behaviour.
124 void fixVerticalScrollBar();
127 /// Update window titles of all users.
128 void updateWindowTitle();
130 bool event(QEvent *);
132 void contextMenuEvent(QContextMenuEvent *);
134 void focusInEvent(QFocusEvent *);
136 void focusOutEvent(QFocusEvent *);
137 /// repaint part of the widget
138 void paintEvent(QPaintEvent * ev);
139 /// widget has been resized
140 void resizeEvent(QResizeEvent * ev);
141 /// mouse button press
142 void mousePressEvent(QMouseEvent * ev);
143 /// mouse button release
144 void mouseReleaseEvent(QMouseEvent * ev);
145 /// mouse double click of button
146 void mouseDoubleClickEvent(QMouseEvent * ev);
148 void mouseMoveEvent(QMouseEvent * ev);
150 void wheelEvent(QWheelEvent * ev);
151 /// key press event. It also knows how to handle ShortcutOverride events to
152 /// avoid code duplication.
153 void keyPressEvent(QKeyEvent * ev);
155 void inputMethodEvent(QInputMethodEvent * ev);
157 QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
159 /// The slot connected to SyntheticMouseEvent::timeout.
160 void generateSyntheticMouseEvent();
162 friend class GuiCompleter;
168 class EmbeddedWorkArea : public GuiWorkArea
173 EmbeddedWorkArea(QWidget *);
176 /// Dummy methods for Designer.
177 void setWidgetResizable(bool) {}
178 void setWidget(QWidget *) {}
180 QSize sizeHint () const;
186 void closeEvent(QCloseEvent * ev);
188 void hideEvent(QHideEvent *ev);
193 }; // EmbeddedWorkArea
196 class GuiWorkAreaContainer;
198 /// A tabbed set of GuiWorkAreas.
199 class TabWorkArea : public QTabWidget
203 TabWorkArea(QWidget * parent = 0);
205 /// hide QTabWidget methods
206 GuiWorkAreaContainer * currentWidget() const;
207 GuiWorkAreaContainer * widget(int index) const;
210 void setFullScreen(bool full_screen);
211 void showBar(bool show);
213 bool setCurrentWorkArea(GuiWorkArea *);
214 GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
215 bool removeWorkArea(GuiWorkArea *);
216 GuiWorkArea * currentWorkArea() const;
217 GuiWorkArea * workArea(Buffer & buffer) const;
218 GuiWorkArea * workArea(int index) const;
219 void paintEvent(QPaintEvent *);
223 void currentWorkAreaChanged(GuiWorkArea *);
225 void lastWorkAreaRemoved();
228 /// close current buffer, or the one given by \c clicked_tab_
229 void closeCurrentBuffer();
230 /// hide current tab, or the one given by \c clicked_tab_
231 void hideCurrentTab();
232 /// close the tab given by \c index
233 void closeTab(int index);
235 void moveTab(int fromIndex, int toIndex);
237 void updateTabTexts();
241 void on_currentTabChanged(int index);
243 void showContextMenu(const QPoint & pos);
244 /// enable closing tab on middle-click
245 void mousePressEvent(QMouseEvent * me);
246 void mouseReleaseEvent(QMouseEvent * me);
248 void mouseDoubleClickEvent(QMouseEvent * event);
250 int indexOfWorkArea(GuiWorkArea * w) const;
253 using QTabWidget::addTab;
254 using QTabWidget::insertTab;
256 /// true if position is a tab (rather than the blank space in tab bar)
257 bool posIsTab(QPoint position);
263 QToolButton * closeBufferButton;
267 class DragTabBar : public QTabBar
272 DragTabBar(QWidget * parent = 0);
276 void mousePressEvent(QMouseEvent * event);
278 void mouseMoveEvent(QMouseEvent * event);
280 void dragEnterEvent(QDragEnterEvent * event);
282 void dropEvent(QDropEvent * event);
286 QPoint dragStartPos_;
290 void tabMoveRequested(int fromIndex, int toIndex);
294 class GuiWorkAreaContainer : public QWidget, public Ui::WorkAreaUi
298 GuiWorkArea * const wa_;
299 void dispatch(FuncRequest f) const;
302 void updateDisplay();
307 void mouseDoubleClickEvent(QMouseEvent * event); //override
311 GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent = 0);
313 GuiWorkArea * workArea() const { return wa_; }
318 } // namespace frontend