ACF $AcfVersion:0$
CMultiPageWidget.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QSize>
7#include <QtCore/QMap>
8#include <QtCore/QtGlobal>
9#include <QtGui/QIcon>
10
11#if QT_VERSION >= 0x050000
12#include <QtWidgets/QWidget>
13#else
14#include <QtGui/QWidget>
15#endif
16
17// ACF includes
18#include <istd/TSmartPtr.h>
19#include <istd/TDelPtr.h>
22
23
24namespace iwidgets
25{
26
27
32class CMultiPageWidget: public QWidget
33{
34 Q_OBJECT
35public:
36 typedef QWidget BaseClass;
38
81
88 QWidget* parentWidgetPtr = NULL,
89 int designMode = DT_SIMPLE,
90 int containerGuiFlags = IMultiPageWidgetDelegate::CGF_NONE,
91 Qt::Orientation orientation = Qt::Vertical);
92
96 virtual QWidget* GetContainerWidgetPtr() const;
97
103 void SetDesignMode(int designMode);
104
110 void SetContainerGuiFlags(int containerGuiFlags);
111
117 void SetLayoutOrientation(Qt::Orientation orientation);
118
122 virtual void ResetPages();
123
127 virtual void SetPageHeaderPosition(PageHeaderPosition pageHeaderPosition);
128
134 virtual int InsertPage(
135 QWidget* pageWidgetPtr,
136 const QString& pageTitle,
137 int pageIndex = -1);
138
142 virtual void RemovePage(int pageIndex);
143
147 virtual int GetPagesCount() const;
148
152 virtual QWidget* GetPageWidgetPtr(int pageIndex) const;
153
157 virtual int GetCurrentPage() const;
158
162 virtual bool SetCurrentPage(int pageIndex);
163
167 virtual QString GetPageTitle(int pageIndex) const;
168
172 virtual void SetPageTitle(int pageIndex, const QString& pageTitle);
173
177 virtual QIcon GetPageIcon(int pageIndex) const;
178
182 virtual void SetPageIcon(int pageIndex, const QIcon& pageIcon);
183
187 virtual QString GetPageToolTip(int pageIndex) const;
188
192 virtual void SetPageToolTip(int pageIndex, const QString& pageToolTip);
193
197 virtual bool IsPageEnabled(int pageIndex) const;
198
202 virtual bool SetPageEnabled(int pageIndex, bool isPageEnabled = true);
203
207 virtual bool IsPageVisible(int pageIndex) const;
208
212 virtual bool SetPageVisible(int pageIndex, bool isPageVisible = true);
213
217 virtual QSize GetPageIconSize() const;
218
222 virtual bool SetPageIconSize(const QSize& pageIconSize);
223
227 template<class DelegateImpl>
228 void RegisterMultiPageWidgetDelegate(int uiMode);
229
230 // static methods
234 static bool IsPageIndexChangeSupported(int designMode);
235
236Q_SIGNALS:
240 void EmitPageIndexChanged(int pageIndex);
241
242protected Q_SLOTS:
243 void OnPageIndexChanged(int pageIndex);
244
245private:
247
251 bool CreateContainerGui();
252
256 MultiPageWidgetDelegatePtr GetCurrentDelegate() const;
257
258private:
259 typedef QMap<int, MultiPageWidgetDelegatePtr> ContainerWidgetDelegateMap;
260
261 ContainerWidgetDelegateMap m_containerWidgetDelegateMap;
262
266 istd::TDelPtr<QWidget> m_guiContainerPtr;
267
268 int m_designMode;
269
270 int m_containerGuiFlags;
271
272 Qt::Orientation m_orientation;
273
274 QSize m_pageIconSize;
275
279 bool m_pageSwitchingBlocked;
280
281 istd::TDelPtr<CWidgetWheelEventBlocker> m_widgetWheelEventBlockerPtr;
282
283};
284
285
286template<class DelegateImpl>
288{
289 MultiPageWidgetDelegatePtr delegatePtr = MultiPageWidgetDelegatePtr(new DelegateImpl);
290
291 m_containerWidgetDelegateMap[uiMode] = delegatePtr;
292}
293
294
295} // namespace iwidgets
296
297
298
299
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition TDelPtr.h:21
Implementation of the widget, which is represented as a set of pages.
virtual QIcon GetPageIcon(int pageIndex) const
Get the page icon.
void OnPageIndexChanged(int pageIndex)
void SetLayoutOrientation(Qt::Orientation orientation)
Set layout orientation for the pages in the container UI.
virtual bool SetPageVisible(int pageIndex, bool isPageVisible=true)
Set page visible/hidden.
virtual bool IsPageVisible(int pageIndex) const
Get if the page visible/hidden.
virtual QSize GetPageIconSize() const
Get the size page icon.
void SetContainerGuiFlags(int containerGuiFlags)
Set flags for container behavior.
IMultiPageWidgetDelegate::PageHeaderPosition PageHeaderPosition
void RegisterMultiPageWidgetDelegate(int uiMode)
Register your own page widget delegate objects for the given UI mode.
virtual bool SetCurrentPage(int pageIndex)
Set active page in the container.
virtual bool SetPageEnabled(int pageIndex, bool isPageEnabled=true)
Set page enabled/disabled.
virtual QWidget * GetPageWidgetPtr(int pageIndex) const
Get page's widget from the container.
virtual bool IsPageEnabled(int pageIndex) const
Get if the page enabled/disabled.
CMultiPageWidget(QWidget *parentWidgetPtr=NULL, int designMode=DT_SIMPLE, int containerGuiFlags=IMultiPageWidgetDelegate::CGF_NONE, Qt::Orientation orientation=Qt::Vertical)
Construct the multi page widget.
virtual void SetPageTitle(int pageIndex, const QString &pageTitle)
Set the page title.
void EmitPageIndexChanged(int pageIndex)
Signal will be emitted whenever the currently selected page will be changed.
virtual QString GetPageTitle(int pageIndex) const
Get the title of the given page.
void SetDesignMode(int designMode)
Set design mode.
virtual void SetPageHeaderPosition(PageHeaderPosition pageHeaderPosition)
Set the position of the page header on the container UI.
virtual void ResetPages()
Remove all pages from the container widget.
virtual void SetPageToolTip(int pageIndex, const QString &pageToolTip)
Set the page tool tip.
virtual bool SetPageIconSize(const QSize &pageIconSize)
Set the size of the icon for all pages in the container.
virtual int GetCurrentPage() const
Get currently active page in the container.
virtual QString GetPageToolTip(int pageIndex) const
Get the page tool tip.
virtual void SetPageIcon(int pageIndex, const QIcon &pageIcon)
Set the page icon.
virtual int InsertPage(QWidget *pageWidgetPtr, const QString &pageTitle, int pageIndex=-1)
Add a new page to the container.
virtual void RemovePage(int pageIndex)
Remove the page from the container.
@ DT_SIMPLE
The pages will be placed simple beside each other.
@ DT_TOOL_BOX
The pages are grouped in a tool box.
@ DT_TAB_WIDGET
The pages are grouped in a tab widget.
@ DT_STACK
The pages are grouped in a stack layout.
@ DT_COLLAPSIBLE_GROUPS
The pages will be placed into collapsible panels.
@ DT_USER
User defined container implementation.
@ DT_MINI_WIDGETS
The pages will be placed into a mini-widget container.
@ DT_SPLITTER
The same as DT_SIMPLE but a splitter manager is used for lay-outing of the pages.
virtual int GetPagesCount() const
Get the number of the pages in the container.
static bool IsPageIndexChangeSupported(int designMode)
Check if switching of pages is supported for this UI mode.
virtual QWidget * GetContainerWidgetPtr() const
Get page container widget.
@ CGF_NONE
Default behavior of the UI container.
PageHeaderPosition
Enum for describing of page header bar position on the container widget.
#define NULL
Definition istd.h:74
Namespace contains implementation of Qt widget extensions.