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 /// A tabbed set of GuiWorkAreas.
197 class TabWorkArea : public QTabWidget
201 TabWorkArea(QWidget * parent = 0);
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();
211 GuiWorkArea * workArea(Buffer & buffer);
212 GuiWorkArea const * workArea(int index) const;
213 GuiWorkArea * workArea(int index);
214 void paintEvent(QPaintEvent *);
218 void currentWorkAreaChanged(GuiWorkArea *);
220 void lastWorkAreaRemoved();
223 /// close current buffer, or the one given by \c clicked_tab_
224 void closeCurrentBuffer();
225 /// hide current tab, or the one given by \c clicked_tab_
226 void hideCurrentTab();
227 /// close the tab given by \c index
228 void closeTab(int index);
230 void moveTab(int fromIndex, int toIndex);
232 void updateTabTexts();
236 void on_currentTabChanged(int index);
238 void showContextMenu(const QPoint & pos);
239 /// enable closing tab on middle-click
240 void mousePressEvent(QMouseEvent * me);
241 void mouseReleaseEvent(QMouseEvent * me);
243 void mouseDoubleClickEvent(QMouseEvent * event);
245 int indexOfWorkArea(GuiWorkArea * w) const;
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
289 GuiWorkArea * const wa_;
290 void dispatch(FuncRequest f) const;
293 void updateDisplay();
298 void mouseDoubleClickEvent(QMouseEvent * event); //override
302 GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent = 0);
303 GuiWorkArea * workArea() const { return wa_; }
308 } // namespace frontend