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 void scheduleRedraw();
64 BufferView & bufferView();
66 BufferView const & bufferView() const;
68 void redraw(bool update_metrics);
70 /// return true if the key is part of a shortcut
71 bool queryKeySym(KeySymbol const & key, KeyModifier mod) const;
72 /// Process Key pressed event.
73 /// This needs to be public because it is accessed externally by GuiView.
74 void processKeySym(KeySymbol const & key, KeyModifier mod);
76 bool inDialogMode() const;
77 void setDialogMode(bool mode);
80 GuiCompleter & completer();
82 /// Return the GuiView this workArea belongs to
83 GuiView const & view() const;
86 /// Current ratio between physical pixels and device-independent pixels
87 double pixelRatio() const;
91 void stopBlinkingCaret();
93 void startBlinkingCaret();
97 void titleChanged(GuiWorkArea *);
101 void bufferViewChanged();
104 /// Scroll the BufferView.
106 * This is a slot for the valueChanged() signal of the vertical scrollbar.
107 * \p value value of the scrollbar.
109 void scrollTo(int value);
110 /// timer to limit triple clicks
111 void doubleClickTimeout();
112 /// toggle the caret's visibility
114 /// close this work area.
115 /// Slot for Buffer::closing signal.
117 /// Slot to restore proper scrollbar behaviour.
118 void fixVerticalScrollBar();
121 /// Update window titles of all users.
122 void updateWindowTitle();
124 bool event(QEvent *);
126 void contextMenuEvent(QContextMenuEvent *);
128 void focusInEvent(QFocusEvent *);
130 void focusOutEvent(QFocusEvent *);
131 /// repaint part of the widget
132 void paintEvent(QPaintEvent * ev);
133 /// widget has been resized
134 void resizeEvent(QResizeEvent * ev);
135 /// mouse button press
136 void mousePressEvent(QMouseEvent * ev);
137 /// mouse button release
138 void mouseReleaseEvent(QMouseEvent * ev);
139 /// mouse double click of button
140 void mouseDoubleClickEvent(QMouseEvent * ev);
142 void mouseMoveEvent(QMouseEvent * ev);
144 void wheelEvent(QWheelEvent * ev);
145 /// key press event. It also knows how to handle ShortcutOverride events to
146 /// avoid code duplication.
147 void keyPressEvent(QKeyEvent * ev);
149 void inputMethodEvent(QInputMethodEvent * ev);
151 QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
153 /// The slot connected to SyntheticMouseEvent::timeout.
154 void generateSyntheticMouseEvent();
156 friend class GuiCompleter;
162 class EmbeddedWorkArea : public GuiWorkArea
167 EmbeddedWorkArea(QWidget *);
170 /// Dummy methods for Designer.
171 void setWidgetResizable(bool) {}
172 void setWidget(QWidget *) {}
174 QSize sizeHint () const;
180 void closeEvent(QCloseEvent * ev);
182 void hideEvent(QHideEvent *ev);
187 }; // EmbeddedWorkArea
190 class GuiWorkAreaContainer;
192 /// A tabbed set of GuiWorkAreas.
193 class TabWorkArea : public QTabWidget
197 TabWorkArea(QWidget * parent = 0);
199 /// hide QTabWidget methods
200 GuiWorkAreaContainer * currentWidget() const;
201 GuiWorkAreaContainer * widget(int index) const;
204 void setFullScreen(bool full_screen);
205 void showBar(bool show);
207 bool setCurrentWorkArea(GuiWorkArea *);
208 GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
209 bool removeWorkArea(GuiWorkArea *);
210 GuiWorkArea * currentWorkArea() const;
211 GuiWorkArea * workArea(Buffer & buffer) const;
212 GuiWorkArea * workArea(int index) const;
213 void paintEvent(QPaintEvent *);
217 void currentWorkAreaChanged(GuiWorkArea *);
219 void lastWorkAreaRemoved();
222 /// close current buffer, or the one given by \c clicked_tab_
223 void closeCurrentBuffer();
224 /// hide current tab, or the one given by \c clicked_tab_
225 void hideCurrentTab();
226 /// close the tab given by \c index
227 void closeTab(int index);
229 void moveTab(int fromIndex, int toIndex);
231 void updateTabTexts();
235 void on_currentTabChanged(int index);
237 void showContextMenu(const QPoint & pos);
238 /// enable closing tab on middle-click
239 void mousePressEvent(QMouseEvent * me);
240 void mouseReleaseEvent(QMouseEvent * me);
242 void mouseDoubleClickEvent(QMouseEvent * event);
244 int indexOfWorkArea(GuiWorkArea * w) const;
247 using QTabWidget::addTab;
248 using QTabWidget::insertTab;
250 /// true if position is a tab (rather than the blank space in tab bar)
251 bool posIsTab(QPoint position);
257 QToolButton * closeBufferButton;
261 class DragTabBar : public QTabBar
266 DragTabBar(QWidget * parent = 0);
270 void mousePressEvent(QMouseEvent * event);
272 void mouseMoveEvent(QMouseEvent * event);
274 void dragEnterEvent(QDragEnterEvent * event);
276 void dropEvent(QDropEvent * event);
280 QPoint dragStartPos_;
284 void tabMoveRequested(int fromIndex, int toIndex);
288 class GuiWorkAreaContainer : public QWidget, public Ui::WorkAreaUi
292 GuiWorkArea * const wa_;
293 void dispatch(FuncRequest f) const;
296 void updateDisplay();
301 void mouseDoubleClickEvent(QMouseEvent * event); //override
305 GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent = 0);
307 GuiWorkArea * workArea() const { return wa_; }
312 } // namespace frontend