KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
core/View.h
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: SĂ©rgio Martins <sergio.martins@kdab.com>
6
7 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8
9 Contact KDAB at <info@kdab.com> for commercial licensing options.
10*/
11
12#pragma once
13
14#include "kddockwidgets/docks_export.h"
15#include "kddockwidgets/KDDockWidgets.h"
16#include "Controller.h"
17
18#include <memory>
19
20QT_BEGIN_NAMESPACE
21class QPainter;
22QT_END_NAMESPACE
23
24namespace KDDockWidgets {
25
26namespace Core {
27
28using HANDLE = const void *;
29using WId = quintptr;
30
31class Item;
33class Controller;
34class Screen;
35class Window;
36class MDILayout;
37class DropArea;
38class DockWidget;
39class FloatingWindow;
40class Group;
41class Layout;
42class Stack;
43class TabBar;
44class TitleBar;
45class MainWindow;
46
47class DOCKS_EXPORT View
48{
49public:
50 explicit View(Controller *controller, ViewType);
51 virtual ~View();
52
55 virtual void init();
56
62 virtual HANDLE handle() const = 0;
63
69 virtual bool isNull() const;
70
71 virtual void setParent(View *) = 0;
72 virtual Size minSize() const = 0;
73 virtual void setMinimumSize(Size) = 0;
74
75 virtual Qt::FocusPolicy focusPolicy() const = 0;
76 virtual bool hasFocus() const = 0;
77 virtual Size maxSizeHint() const = 0;
78 virtual Rect geometry() const = 0;
79 virtual Rect normalGeometry() const = 0;
80 virtual void setGeometry(Rect) = 0;
81 virtual bool isVisible() const = 0;
82 virtual bool isExplicitlyHidden() const = 0;
83 virtual void setVisible(bool) = 0;
84 virtual void move(int x, int y) = 0;
85 virtual void setSize(int width, int height) = 0;
86 virtual void setWidth(int width) = 0;
87 virtual void setHeight(int height) = 0;
88 virtual void show() = 0;
89 virtual void hide() = 0;
90 virtual void update() = 0;
91 virtual void raiseAndActivate() = 0;
92
95 virtual void raise() = 0;
96
97 virtual void activateWindow() = 0;
98 virtual bool isRootView() const = 0;
99 virtual Point mapToGlobal(Point) const = 0;
100 virtual Point mapFromGlobal(Point) const = 0;
101 virtual Point mapTo(View *, Point) const = 0;
102 virtual bool close() = 0;
103 virtual void setFlag(Qt::WindowType, bool = true) = 0;
104 virtual Qt::WindowFlags flags() const = 0;
105 virtual void setWindowTitle(const QString &title) = 0;
106 virtual void setWindowIcon(const Icon &) = 0;
107
110 virtual void enableAttribute(Qt::WidgetAttribute, bool enable = true) = 0;
111 virtual bool hasAttribute(Qt::WidgetAttribute) const = 0;
112
116 void installViewEventFilter(EventFilterInterface *);
117
119 void removeViewEventFilter(EventFilterInterface *);
120
122 bool deliverViewEventToFilters(Event *e);
123
124 virtual void showNormal() = 0;
125 virtual void showMinimized() = 0;
126 virtual void showMaximized() = 0;
127 virtual bool isMinimized() const = 0;
128 virtual bool isMaximized() const = 0;
129
130 virtual void createPlatformWindow();
131 virtual void setMaximumSize(Size sz) = 0;
132 virtual bool isActiveWindow() const = 0;
133 virtual void setFixedWidth(int) = 0;
134 virtual void setFixedHeight(int) = 0;
135 virtual void grabMouse() = 0;
136 virtual void releaseMouse() = 0;
137 virtual void releaseKeyboard() = 0;
138 virtual void setFocus(Qt::FocusReason) = 0;
140 virtual void setWindowOpacity(double) = 0;
141 virtual void setCursor(Qt::CursorShape) = 0;
142 virtual void setMouseTracking(bool) = 0;
143
144 virtual bool onResize(int h, int w);
145 bool onResize(Size);
146
147 virtual bool onFocusInEvent(FocusEvent *)
148 {
149 return false;
150 }
151
153 virtual void setViewName(const QString &) = 0;
154 virtual QString viewName() const = 0;
155
156 virtual void render(QPainter *) = 0;
157
158 virtual std::shared_ptr<View> childViewAt(Point localPos) const = 0;
159
162 virtual std::shared_ptr<View> rootView() const = 0;
163
167 virtual std::shared_ptr<Core::Window> window() const = 0;
168
170 virtual std::shared_ptr<View> parentView() const = 0;
171
173 virtual std::shared_ptr<View> asWrapper() = 0;
174
178 virtual bool is(ViewType) const;
179
182 virtual void setZOrder(int);
183
186 virtual int zOrder() const;
187
190
193 bool inDtor() const;
194
196 bool equals(const View *other) const;
197 bool equals(const std::shared_ptr<View> &) const;
198 static bool equals(const View *one, const View *two);
199
200 Point pos() const;
201 Size size() const;
202 Rect rect() const;
203 int x() const;
204 int y() const;
205 int height() const;
206 int width() const;
207 void resize(Size);
208 void resize(int w, int h);
209 void move(Point);
210 void setSize(Size);
211 int minimumWidth() const;
212 int minimumHeight() const;
213
215 Size screenSize() const;
216
218 static Size hardcodedMinimumSize();
219
222 static Controller *firstParentOfType(View *view, ViewType);
223
225 Controller *controller() const;
226
228 template<typename T>
230 {
231 if (m_inDtor)
232 return nullptr;
233
234 return object_cast<T *>(m_controller);
235 }
236
238 Core::FloatingWindow *asFloatingWindowController() const;
239 Core::Group *asGroupController() const;
240 Core::TitleBar *asTitleBarController() const;
241 Core::TabBar *asTabBarController() const;
242 Core::Stack *asStackController() const;
243 Core::DockWidget *asDockWidgetController() const;
244 Core::MainWindow *asMainWindowController() const;
245 Core::DropArea *asDropAreaController() const;
246 Core::MDILayout *asMDILayoutController() const;
247 Core::Layout *asLayout() const;
248
250 void dumpDebug();
251
252 bool isFixedWidth() const;
253 bool isFixedHeight() const;
254
255public:
256 class Private;
257 Private *const d;
258
259protected:
261 bool m_inDtor = false;
262
263 View(const View &) = delete;
264 View &operator=(const View &) = delete;
265
266#ifdef KDDW_FRONTEND_FLUTTER
267 // Little workaround so flutter has the same deletion order as Qt.
268 // In Qt we have this order of deletion
269 // 1. ~Core::View() deletes the controller
270 // 2. ~QObject deletes children views
271 // But in Flutter, we don't have ~QObject, so we were deleting children views inside ~flutter::View
272 // which runs before ~Core::View() not after, causing different deletion ordering, thus different behaviour
273 // and different bugs. Let's keep both frontends consistent predictable.
274
275 // No shared pointers, as lifetime is managed by parent-children relationship (as in QObject)
276 Vector<Core::View *> m_childViews;
277#endif
278};
279
280}
281
282}
The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some...
The widget (QWidget or QQuickItem) which holds a layout of dock widgets.
Definition Layout.h:57
The MDILayout class implements a layout suitable for MDI style docking. Where dock widgets are free t...
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
virtual void update()=0
virtual void show()=0
virtual bool onFocusInEvent(FocusEvent *)
Definition core/View.h:147
virtual void setMaximumSize(Size sz)=0
virtual bool isExplicitlyHidden() const =0
virtual void setSize(int width, int height)=0
virtual void setFocus(Qt::FocusReason)=0
virtual void setFixedWidth(int)=0
Controller *const m_controller
Definition core/View.h:260
View(const View &)=delete
virtual Size minSize() const =0
virtual void setWindowIcon(const Icon &)=0
virtual Rect geometry() const =0
virtual void activateWindow()=0
virtual void setMouseTracking(bool)=0
virtual void setFocusPolicy(Qt::FocusPolicy)=0
virtual void raiseAndActivate()=0
virtual void setWindowTitle(const QString &title)=0
virtual std::shared_ptr< View > rootView() const =0
Returns the top-level gui element which this view is inside It's the root view of the window.
virtual bool hasFocus() const =0
virtual void setWidth(int width)=0
virtual void setHeight(int height)=0
virtual bool isRootView() const =0
virtual void grabMouse()=0
virtual Point mapFromGlobal(Point) const =0
virtual Size maxSizeHint() const =0
virtual std::shared_ptr< View > parentView() const =0
Returns the gui element's parent. Like QWidget::parentWidget()
virtual Rect normalGeometry() const =0
virtual Qt::FocusPolicy focusPolicy() const =0
virtual bool isVisible() const =0
virtual bool isMinimized() const =0
virtual void hide()=0
virtual void setFixedHeight(int)=0
virtual Qt::WindowFlags flags() const =0
virtual void enableAttribute(Qt::WidgetAttribute, bool enable=true)=0
virtual QString viewName() const =0
virtual bool isMaximized() const =0
virtual void setParent(View *)=0
virtual void move(int x, int y)=0
virtual std::shared_ptr< Core::Window > window() const =0
Returns the window this view is inside For the Qt frontend, this wraps a QWindow. Like QWidget::windo...
virtual Point mapToGlobal(Point) const =0
virtual void showMinimized()=0
virtual void raise()=0
virtual void releaseKeyboard()=0
T * asController()
Returns the View's controller, casted as T.
Definition core/View.h:229
virtual void releaseMouse()=0
virtual bool isActiveWindow() const =0
View & operator=(const View &)=delete
virtual void setViewName(const QString &)=0
Equivalent to Qt's QObject::objectName()
virtual void setMinimumSize(Size)=0
virtual bool close()=0
virtual void setFlag(Qt::WindowType, bool=true)=0
virtual std::shared_ptr< View > asWrapper()=0
Returns this view, but as a wrapper.
virtual void showMaximized()=0
virtual void render(QPainter *)=0
virtual Point mapTo(View *, Point) const =0
virtual void setCursor(Qt::CursorShape)=0
virtual void showNormal()=0
virtual HANDLE handle() const =0
Returns a handle for the GUI element This value only makes sense to the frontend. For example,...
virtual void setWindowOpacity(double)=0
virtual std::shared_ptr< View > childViewAt(Point localPos) const =0
virtual bool hasAttribute(Qt::WidgetAttribute) const =0
virtual void setVisible(bool)=0
virtual void setGeometry(Rect)=0
virtual Vector< std::shared_ptr< View > > childViews() const =0
@Returns a list of child views
ViewType
Each View type also has a specific Controller associated with, except for ViewType::None.
Definition Controller.h:26
const void * HANDLE
Definition core/View.h:28
Class to abstract QAction, so code still works with QtQuick and Flutter.
CursorShape
FocusPolicy
FocusReason
WidgetAttribute
WindowType

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated by doxygen 1.9.8