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"
19 #include "frontends/KeySymbol.h"
21 #include <QAbstractScrollArea>
25 class QDragEnterEvent;
40 class GuiWorkArea : public QAbstractScrollArea, public WorkArea
46 GuiWorkArea(QWidget *);
48 GuiWorkArea(Buffer & buffer, GuiView & gv);
55 void setBuffer(Buffer &);
57 void setGuiView(GuiView &);
59 void setFullScreen(bool full_screen);
60 /// is GuiView in fullscreen mode?
61 bool isFullScreen() const;
63 BufferView & bufferView();
65 BufferView const & bufferView() const;
67 void scheduleRedraw(bool update_metrics);
69 /// return true if the key is part of a shortcut
70 bool queryKeySym(KeySymbol const & key, KeyModifier mod) const;
72 bool inDialogMode() const;
73 void setDialogMode(bool mode);
76 GuiCompleter & completer();
78 /// Return the GuiView this workArea belongs to
79 GuiView const & view() const;
82 /// Current ratio between physical pixels and device-independent pixels
83 double pixelRatio() const;
86 /// Process Key pressed event.
87 /// This needs to be public because it is accessed externally by GuiView.
88 void processKeySym(KeySymbol const & key, KeyModifier mod);
90 void stopBlinkingCaret();
92 void startBlinkingCaret();
96 void titleChanged(GuiWorkArea *);
100 void bufferViewChanged();
101 /// send key event to CompressorProxy
102 void compressKeySym(KeySymbol sym, KeyModifier mod, bool isAutoRepeat);
105 /// Scroll the BufferView.
107 * This is a slot for the valueChanged() signal of the vertical scrollbar.
108 * \p value value of the scrollbar.
110 void scrollTo(int value);
111 /// timer to limit triple clicks
112 void doubleClickTimeout();
113 /// toggle the caret's visibility
115 /// close this work area.
116 /// Slot for Buffer::closing signal.
118 /// Slot to restore proper scrollbar behaviour.
119 void fixVerticalScrollBar();
122 /// Update window titles of all users.
123 void updateWindowTitle();
125 bool event(QEvent *);
127 void contextMenuEvent(QContextMenuEvent *);
129 void focusInEvent(QFocusEvent *);
131 void focusOutEvent(QFocusEvent *);
132 /// repaint part of the widget
133 void paintEvent(QPaintEvent * ev);
134 /// widget has been resized
135 void resizeEvent(QResizeEvent * ev);
136 /// mouse button press
137 void mousePressEvent(QMouseEvent * ev);
138 /// mouse button release
139 void mouseReleaseEvent(QMouseEvent * ev);
140 /// mouse double click of button
141 void mouseDoubleClickEvent(QMouseEvent * ev);
143 void mouseMoveEvent(QMouseEvent * ev);
145 void wheelEvent(QWheelEvent * ev);
146 /// key press event. It also knows how to handle ShortcutOverride events to
147 /// avoid code duplication.
148 void keyPressEvent(QKeyEvent * ev);
150 void inputMethodEvent(QInputMethodEvent * ev);
152 QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
154 /// The slot connected to SyntheticMouseEvent::timeout.
155 void generateSyntheticMouseEvent();
157 friend class GuiCompleter;
163 /// CompressorProxy adapted from Kuba Ober https://stackoverflow.com/a/21006207
164 class CompressorProxy : public QObject
167 bool emitCheck(bool isAutoRepeat);
169 // input: event to compress
170 Q_SLOT void slot(KeySymbol sym, KeyModifier mod, bool isAutoRepeat);
171 // output: compressed event
172 Q_SIGNAL void signal(KeySymbol sym, KeyModifier mod);
174 // No default constructor, since the proxy must be a child of the
176 explicit CompressorProxy(GuiWorkArea * wa);
180 class EmbeddedWorkArea : public GuiWorkArea
185 EmbeddedWorkArea(QWidget *);
188 /// Dummy methods for Designer.
189 void setWidgetResizable(bool) {}
190 void setWidget(QWidget *) {}
192 QSize sizeHint () const;
198 void closeEvent(QCloseEvent * ev);
200 void hideEvent(QHideEvent *ev);
205 }; // EmbeddedWorkArea
208 class GuiWorkAreaContainer;
210 /// A tabbed set of GuiWorkAreas.
211 class TabWorkArea : public QTabWidget
215 TabWorkArea(QWidget * parent = 0);
217 /// hide QTabWidget methods
218 GuiWorkAreaContainer * currentWidget() const;
219 GuiWorkAreaContainer * widget(int index) const;
222 void setFullScreen(bool full_screen);
223 void showBar(bool show);
225 bool setCurrentWorkArea(GuiWorkArea *);
226 GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
227 bool removeWorkArea(GuiWorkArea *);
228 GuiWorkArea * currentWorkArea() const;
229 GuiWorkArea * workArea(Buffer & buffer) const;
230 GuiWorkArea * workArea(int index) const;
231 void paintEvent(QPaintEvent *);
235 void currentWorkAreaChanged(GuiWorkArea *);
237 void lastWorkAreaRemoved();
240 /// close current buffer, or the one given by \c clicked_tab_
241 void closeCurrentBuffer();
242 /// hide current tab, or the one given by \c clicked_tab_
243 void hideCurrentTab();
244 /// close the tab given by \c index
245 void closeTab(int index);
247 void moveTab(int fromIndex, int toIndex);
249 void updateTabTexts();
253 void on_currentTabChanged(int index);
255 void showContextMenu(const QPoint & pos);
256 /// enable closing tab on middle-click
257 void mousePressEvent(QMouseEvent * me);
258 void mouseReleaseEvent(QMouseEvent * me);
260 void mouseDoubleClickEvent(QMouseEvent * event);
262 int indexOfWorkArea(GuiWorkArea * w) const;
265 using QTabWidget::addTab;
266 using QTabWidget::insertTab;
268 /// true if position is a tab (rather than the blank space in tab bar)
269 bool posIsTab(QPoint position);
275 QToolButton * closeBufferButton;
279 class GuiWorkAreaContainer : public QWidget, public Ui::WorkAreaUi
283 GuiWorkArea * const wa_;
284 void dispatch(FuncRequest f) const;
287 void updateDisplay();
292 void mouseDoubleClickEvent(QMouseEvent * event); //override
296 GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent = 0);
298 GuiWorkArea * workArea() const { return wa_; }
303 } // namespace frontend