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 "frontends/WorkArea.h"
18 #include <QAbstractScrollArea>
22 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 void scheduleRedraw();
65 BufferView & bufferView();
67 BufferView const & bufferView() const;
69 void redraw(bool update_metrics);
71 /// return true if the key is part of a shortcut
72 bool queryKeySym(KeySymbol const & key, KeyModifier mod) const;
73 /// Process Key pressed event.
74 /// This needs to be public because it is accessed externally by GuiView.
75 void processKeySym(KeySymbol const & key, KeyModifier mod);
77 bool inDialogMode() const;
78 void setDialogMode(bool mode);
81 GuiCompleter & completer();
83 Qt::CursorShape cursorShape() const;
85 /// Return the GuiView this workArea belongs to
86 GuiView const & view() const;
89 /// Current ratio between physical pixels and device-independent pixels
90 double pixelRatio() const;
94 void stopBlinkingCursor();
96 void startBlinkingCursor();
100 void titleChanged(GuiWorkArea *);
104 void bufferViewChanged();
107 /// Scroll the BufferView.
109 * This is a slot for the valueChanged() signal of the vertical scrollbar.
110 * \p value value of the scrollbar.
112 void scrollTo(int value);
113 /// timer to limit triple clicks
114 void doubleClickTimeout();
115 /// toggle the cursor's visibility
117 /// close this work area.
118 /// Slot for Buffer::closing signal.
120 /// Slot to restore proper scrollbar behaviour.
121 void fixVerticalScrollBar();
124 /// Update window titles of all users.
125 void updateWindowTitle();
127 bool event(QEvent *);
129 void contextMenuEvent(QContextMenuEvent *);
131 void focusInEvent(QFocusEvent *);
133 void focusOutEvent(QFocusEvent *);
134 /// repaint part of the widget
135 void paintEvent(QPaintEvent * ev);
136 /// widget has been resized
137 void resizeEvent(QResizeEvent * ev);
138 /// mouse button press
139 void mousePressEvent(QMouseEvent * ev);
140 /// mouse button release
141 void mouseReleaseEvent(QMouseEvent * ev);
142 /// mouse double click of button
143 void mouseDoubleClickEvent(QMouseEvent * ev);
145 void mouseMoveEvent(QMouseEvent * ev);
147 void wheelEvent(QWheelEvent * ev);
148 /// key press event. It also knows how to handle ShortcutOverride events to
149 /// avoid code duplication.
150 void keyPressEvent(QKeyEvent * ev);
152 void inputMethodEvent(QInputMethodEvent * ev);
154 QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
156 /// The slot connected to SyntheticMouseEvent::timeout.
157 void generateSyntheticMouseEvent();
159 friend class GuiCompleter;
165 class EmbeddedWorkArea : public GuiWorkArea
170 EmbeddedWorkArea(QWidget *);
173 /// Dummy methods for Designer.
174 void setWidgetResizable(bool) {}
175 void setWidget(QWidget *) {}
177 QSize sizeHint () const;
183 void closeEvent(QCloseEvent * ev);
185 void hideEvent(QHideEvent *ev);
190 }; // EmbeddedWorkArea
193 /// A tabbed set of GuiWorkAreas.
194 class TabWorkArea : public QTabWidget
198 TabWorkArea(QWidget * parent = 0);
201 void setFullScreen(bool full_screen);
202 void showBar(bool show);
204 bool setCurrentWorkArea(GuiWorkArea *);
205 GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
206 bool removeWorkArea(GuiWorkArea *);
207 GuiWorkArea * currentWorkArea();
208 GuiWorkArea * workArea(Buffer & buffer);
209 GuiWorkArea * workArea(int index);
210 void paintEvent(QPaintEvent *);
214 void currentWorkAreaChanged(GuiWorkArea *);
216 void lastWorkAreaRemoved();
219 /// close current buffer, or the one given by \c clicked_tab_
220 void closeCurrentBuffer();
221 /// hide current tab, or the one given by \c clicked_tab_
222 void hideCurrentTab();
223 /// close the tab given by \c index
224 void closeTab(int index);
226 void moveTab(int fromIndex, int toIndex);
228 void updateTabTexts();
232 void on_currentTabChanged(int index);
234 void showContextMenu(const QPoint & pos);
235 /// enable closing tab on middle-click
236 void mousePressEvent(QMouseEvent * me);
237 void mouseReleaseEvent(QMouseEvent * me);
239 void mouseDoubleClickEvent(QMouseEvent * event);
242 /// true if position is a tab (rather than the blank space in tab bar)
243 bool posIsTab(QPoint position);
249 QToolButton * closeBufferButton;
253 class DragTabBar : public QTabBar
258 DragTabBar(QWidget * parent = 0);
262 void mousePressEvent(QMouseEvent * event);
264 void mouseMoveEvent(QMouseEvent * event);
266 void dragEnterEvent(QDragEnterEvent * event);
268 void dropEvent(QDropEvent * event);
272 QPoint dragStartPos_;
276 void tabMoveRequested(int fromIndex, int toIndex);
279 } // namespace frontend