CMultiPageWidget.h
Go to the documentation of this file.
1 #ifndef iwidgets_CMultiPageWidget_included
2 #define iwidgets_CMultiPageWidget_included
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>
21 
22 
23 namespace iwidgets
24 {
25 
26 
31 class CMultiPageWidget: public QWidget
32 {
33  Q_OBJECT
34 public:
35  typedef QWidget BaseClass;
37 
39  {
44 
49 
54 
59 
64 
69 
73  DT_USER = 1024
74  };
75 
82  QWidget* parentWidgetPtr = NULL,
83  int designMode = DT_SIMPLE,
84  int containerGuiFlags = IMultiPageWidgetDelegate::CGF_NONE,
85  Qt::Orientation orientation = Qt::Vertical);
86 
90  virtual QWidget* GetContainerWidgetPtr() const;
91 
97  void SetDesignMode(int designMode);
98 
104  void SetContainerGuiFlags(int containerGuiFlags);
105 
111  void SetLayoutOrientation(Qt::Orientation orientation);
112 
116  virtual void ResetPages();
117 
121  virtual void SetPageHeaderPosition(PageHeaderPosition pageHeaderPosition);
122 
128  virtual int InsertPage(
129  QWidget* pageWidgetPtr,
130  const QString& pageTitle,
131  int pageIndex = -1);
132 
136  virtual void RemovePage(int pageIndex);
137 
141  virtual int GetPagesCount() const;
142 
146  virtual QWidget* GetPageWidgetPtr(int pageIndex) const;
147 
151  virtual int GetCurrentPage() const;
152 
156  virtual bool SetCurrentPage(int pageIndex);
157 
161  virtual QString GetPageTitle(int pageIndex) const;
162 
166  virtual void SetPageTitle(int pageIndex, const QString& pageTitle);
167 
171  virtual QIcon GetPageIcon(int pageIndex) const;
172 
176  virtual void SetPageIcon(int pageIndex, const QIcon& pageIcon);
177 
181  virtual QString GetPageToolTip(int pageIndex) const;
182 
186  virtual void SetPageToolTip(int pageIndex, const QString& pageToolTip);
187 
191  virtual bool IsPageEnabled(int pageIndex) const;
192 
196  virtual bool SetPageEnabled(int pageIndex, bool isPageEnabled = true);
197 
201  virtual bool IsPageVisible(int pageIndex) const;
202 
206  virtual bool SetPageVisible(int pageIndex, bool isPageVisible = true);
207 
211  virtual QSize GetPageIconSize() const;
212 
216  virtual bool SetPageIconSize(const QSize& pageIconSize);
217 
221  template<class DelegateImpl>
222  void RegisterMultiPageWidgetDelegate(int uiMode);
223 
224  // static methods
228  static bool IsPageIndexChangeSupported(int designMode);
229 
230 Q_SIGNALS:
234  void EmitPageIndexChanged(int pageIndex);
235 
236 protected Q_SLOTS:
237  void OnPageIndexChanged(int pageIndex);
238 
239 private:
240  typedef istd::TSmartPtr<IMultiPageWidgetDelegate> MultiPageWidgetDelegatePtr;
241 
245  bool CreateContainerGui();
246 
250  MultiPageWidgetDelegatePtr GetCurrentDelegate() const;
251 
252 private:
253  typedef QMap<int, MultiPageWidgetDelegatePtr> ContainerWidgetDelegateMap;
254 
255  ContainerWidgetDelegateMap m_containerWidgetDelegateMap;
256 
260  istd::TDelPtr<QWidget> m_guiContainerPtr;
261 
262  int m_designMode;
263 
264  int m_containerGuiFlags;
265 
266  Qt::Orientation m_orientation;
267 
268  QSize m_pageIconSize;
269 
273  bool m_pageSwitchingBlocked;
274 };
275 
276 
277 template<class DelegateImpl>
279 {
280  MultiPageWidgetDelegatePtr delegatePtr = MultiPageWidgetDelegatePtr(new DelegateImpl);
281 
282  m_containerWidgetDelegateMap[uiMode] = delegatePtr;
283 }
284 
285 
286 } // namespace iwidgets
287 
288 
289 #endif // !iwidgets_CMultiPageWidget_included
290 
291 
virtual bool SetPageIconSize(const QSize &pageIconSize)
Set the size of the icon for all pages in the container.
virtual bool IsPageVisible(int pageIndex) const
Get if the page visible/hidden.
void SetDesignMode(int designMode)
Set design mode.
virtual void SetPageHeaderPosition(PageHeaderPosition pageHeaderPosition)
Set the position of the page header on the container UI.
Implementation of the widget, which is represented as a set of pages.
IMultiPageWidgetDelegate::PageHeaderPosition PageHeaderPosition
The pages will be placed into collapsible panels.
The pages are grouped in a tab widget.
virtual QString GetPageToolTip(int pageIndex) const
Get the page tool tip.
virtual QWidget * GetContainerWidgetPtr() const
Get page container widget.
void RegisterMultiPageWidgetDelegate(int uiMode)
Register your own page widget delegate objects for the given UI mode.
virtual QSize GetPageIconSize() const
Get the size page icon.
virtual QIcon GetPageIcon(int pageIndex) const
Get the page icon.
virtual bool IsPageEnabled(int pageIndex) const
Get if the page enabled/disabled.
User defined container implementation.
virtual void SetPageIcon(int pageIndex, const QIcon &pageIcon)
Set the page icon.
Implementation of a smart pointer.
Definition: TSmartPtr.h:24
virtual bool SetPageEnabled(int pageIndex, bool isPageEnabled=true)
Set page enabled/disabled.
void OnPageIndexChanged(int pageIndex)
The pages are grouped in a stack layout.
virtual QWidget * GetPageWidgetPtr(int pageIndex) const
Get page's widget from the container.
void SetLayoutOrientation(Qt::Orientation orientation)
Set layout orientation for the pages in the container UI.
void SetContainerGuiFlags(int containerGuiFlags)
Set flags for container behavior.
virtual QString GetPageTitle(int pageIndex) const
Get the title of the given page.
The pages are grouped in a tool box.
virtual void SetPageTitle(int pageIndex, const QString &pageTitle)
Set the page title.
virtual int GetCurrentPage() const
Get currently active page in the container.
virtual bool SetPageVisible(int pageIndex, bool isPageVisible=true)
Set page visible/hidden.
#define NULL
Definition: istd.h:64
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.
virtual void ResetPages()
Remove all pages from the container widget.
void EmitPageIndexChanged(int pageIndex)
Signal will be emitted whenever the currently selected page will be changed.
CMultiPageWidget(QWidget *parentWidgetPtr=NULL, int designMode=DT_SIMPLE, int containerGuiFlags=IMultiPageWidgetDelegate::CGF_NONE, Qt::Orientation orientation=Qt::Vertical)
Construct the multi page widget.
virtual bool SetCurrentPage(int pageIndex)
Set active page in the container.
PageHeaderPosition
Enum for describing of page header bar position on the container widget.
Default behavior of the UI container.
virtual int InsertPage(QWidget *pageWidgetPtr, const QString &pageTitle, int pageIndex=-1)
Add a new page to the container.
virtual void SetPageToolTip(int pageIndex, const QString &pageToolTip)
Set the page tool tip.
virtual void RemovePage(int pageIndex)
Remove the page from the container.
The pages will be placed simple beside each other.
static bool IsPageIndexChangeSupported(int designMode)
Check if switching of pages is supported for this UI mode.

© 2007-2017 Witold Gantzke and Kirill Lepskiy