OpenWalnut
1.5.0dev
|
Base class for all the widget abstraction the core UI provides. More...
#include <WUIWidgetBase.h>
Public Types | |
typedef std::shared_ptr< WUIWidgetBase > | SPtr |
Convenience typedef for a std::shared_ptr< WUIWidgetBase >. More... | |
typedef std::shared_ptr< const WUIWidgetBase > | ConstSPtr |
Convenience typedef for a std::shared_ptr< const WUIWidgetBase >. More... | |
Public Member Functions | |
virtual | ~WUIWidgetBase () |
Destructor. More... | |
virtual std::string | getTitle () const |
Get the title of the widget. More... | |
virtual void | show ()=0 |
Show this widget if not yet visible. More... | |
virtual void | setVisible (bool visible=true)=0 |
Hide/show this widget. More... | |
virtual bool | isVisible () const =0 |
Check if the widget is hidden or not. More... | |
void | close () |
Close the widget. More... | |
bool | isClosed () const |
Checks whether the widget was closed already. More... | |
WCondition::SPtr | getCloseCondition () const |
Return the condition that fires when the widgets closes. More... | |
virtual WUIWidgetBase::SPtr | getParent () const |
Get the parent widget of this widget if any. More... | |
virtual bool | allowNesting () const |
Tell the user whether this kind of widget can be used as parent. More... | |
virtual void | addAction (WPropGroup group, WGEImage::SPtr icon=WGEImage::SPtr())=0 |
Define a property as action. More... | |
virtual void | addAction (WPropTrigger trigger, WGEImage::SPtr icon=WGEImage::SPtr())=0 |
Define a property as action. More... | |
virtual void | addAction (WPropBool toggle, WGEImage::SPtr icon=WGEImage::SPtr())=0 |
Define a property as action. More... | |
Protected Types | |
typedef WSharedSequenceContainer< std::vector< WUIWidgetBase::SPtr > > | ChildContainer |
Keep track of our child widgets. More... | |
Protected Member Functions | |
WUIWidgetBase (std::string title) | |
Default constructor. More... | |
virtual void | closeImpl ()=0 |
Close the widget. More... | |
virtual void | setParent (WUIWidgetBase::SPtr parent) |
Set the parent of this WUI widget. More... | |
virtual void | registerChild (WUIWidgetBase::SPtr child) |
Register widget as child. More... | |
ChildContainer & | getChildren () |
Return the list of children. More... | |
const ChildContainer & | getChildren () const |
Return the list of children. More... | |
void | closeChildren () |
Comfortable function to recurse a close call. More... | |
Private Attributes | |
std::string | m_title |
The widget's title string. More... | |
WCondition::SPtr | m_closeCondition |
Close condition. More... | |
WUIWidgetBase::SPtr | m_parent |
The parent. More... | |
ChildContainer | m_childs |
Child widgets. More... | |
bool | m_closed |
Flag denotes whether the widget was closed already. More... | |
Friends | |
class | WUIWidgetFactory |
The factory needs to be able to call the constructor. More... | |
Base class for all the widget abstraction the core UI provides.
All the abstract widgets use the bridge pattern to let the UI/GUI implementor actually handle everything.
Definition at line 44 of file WUIWidgetBase.h.
|
protected |
Keep track of our child widgets.
Please note that we store shared_ptr here. This means, no widget ever gets deleted by the shared_ptr accidentally in a module. All widgets keeps reference of their parent, and each widget keeps reference to its childs. Only a call to close will recursively free the widgets.
Definition at line 191 of file WUIWidgetBase.h.
typedef std::shared_ptr< const WUIWidgetBase > WUIWidgetBase::ConstSPtr |
Convenience typedef for a std::shared_ptr< const WUIWidgetBase >.
Definition at line 56 of file WUIWidgetBase.h.
typedef std::shared_ptr< WUIWidgetBase > WUIWidgetBase::SPtr |
Convenience typedef for a std::shared_ptr< WUIWidgetBase >.
Definition at line 51 of file WUIWidgetBase.h.
|
virtual |
Destructor.
Definition at line 40 of file WUIWidgetBase.cpp.
|
explicitprotected |
Default constructor.
title | the title of the widget |
Definition at line 32 of file WUIWidgetBase.cpp.
|
pure virtual |
Define a property as action.
Depending on the UI implementing this, adding actions to a nested widget can be useless. View the corresponding WUI*Widget doc for details. Order of adding is order of appearance in the UI/GUI.
toggle | the property to use |
icon | the icon to use. Consider a minimum size of 32x32. |
Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.
|
pure virtual |
Define a property as action.
Depending on the UI implementing this, adding actions to a nested widget can be useless. View the corresponding WUI*Widget doc for details. Order of adding is order of appearance in the UI/GUI.
group | the property to use. |
icon | the icon to use. Consider a minimum size of 32x32. |
Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.
|
pure virtual |
Define a property as action.
Depending on the UI implementing this, adding actions to a nested widget can be useless. View the corresponding WUI*Widget doc for details. Order of adding is order of appearance in the UI/GUI.
trigger | the property to use |
icon | the icon to use. Consider a minimum size of 32x32. |
Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.
|
virtual |
Tell the user whether this kind of widget can be used as parent.
In other word, whether it is allowed to nest other widgets into this one.
Reimplemented in WUITabbedWidget, and WUIGridWidget.
Definition at line 94 of file WUIWidgetBase.cpp.
void WUIWidgetBase::close | ( | ) |
Close the widget.
When done, the widget can be safely deleted. You cannot re-open the widget with show(). If you want to hide widget, use setVisible( false ) instead. This function cascades to all child widgets if any. So it is enough to use this for the top-level (parent-less) widget only. This ensures proper close for all nested widgets.
Definition at line 50 of file WUIWidgetBase.cpp.
References WSharedSequenceContainer< S >::clear(), closeChildren(), closeImpl(), isClosed(), m_childs, m_closeCondition, and m_closed.
Referenced by WUIQtGridWidget::close(), WUIQtPropertyGroupWidget::close(), WUIQtTabbedWidget::close(), and WUIQtViewWidget::close().
|
protected |
Comfortable function to recurse a close call.
This iterates the children and closes them.
Definition at line 120 of file WUIWidgetBase.cpp.
References WSharedObject< T >::getWriteTicket(), and m_childs.
Referenced by close().
|
protectedpure virtual |
Close the widget.
When done, the widget can be safely deleted. You cannot re-open the widget with show(). If you want to hide widget, use setVisible( false ) instead.
Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.
Referenced by close().
|
protected |
Return the list of children.
Definition at line 100 of file WUIWidgetBase.cpp.
References m_childs.
|
protected |
Return the list of children.
Definition at line 105 of file WUIWidgetBase.cpp.
References m_childs.
WCondition::SPtr WUIWidgetBase::getCloseCondition | ( | ) | const |
Return the condition that fires when the widgets closes.
Definition at line 73 of file WUIWidgetBase.cpp.
References m_closeCondition.
|
virtual |
Get the parent widget of this widget if any.
Can be NULL.
Definition at line 83 of file WUIWidgetBase.cpp.
References m_parent.
|
virtual |
Get the title of the widget.
Definition at line 45 of file WUIWidgetBase.cpp.
References m_title.
Referenced by WUIQtGridWidget::getTitleQString(), WUIQtPropertyGroupWidget::getTitleQString(), WUIQtTabbedWidget::getTitleQString(), WUIQtViewWidget::getTitleQString(), and WUIQtViewWidget::realizeImpl().
bool WUIWidgetBase::isClosed | ( | ) | const |
Checks whether the widget was closed already.
Definition at line 126 of file WUIWidgetBase.cpp.
References m_closed.
Referenced by close().
|
pure virtual |
Check if the widget is hidden or not.
Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.
|
protectedvirtual |
Register widget as child.
Called by the widget factory.
child | the child. |
Definition at line 88 of file WUIWidgetBase.cpp.
References m_childs, and WSharedSequenceContainer< S >::unique_push_back().
|
protectedvirtual |
Set the parent of this WUI widget.
Do never call this after the widget was realized by the factory. This method is used by the factory. Do not manually call it.
parent | the parent. Can be NULL if none. |
Definition at line 78 of file WUIWidgetBase.cpp.
References m_parent.
|
pure virtual |
Hide/show this widget.
Unlike close(), you can show the widget again using show().
visible | false to hide widget |
Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.
|
pure virtual |
Show this widget if not yet visible.
Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.
|
friend |
The factory needs to be able to call the constructor.
Definition at line 46 of file WUIWidgetBase.h.
|
private |
Child widgets.
Definition at line 231 of file WUIWidgetBase.h.
Referenced by close(), closeChildren(), getChildren(), and registerChild().
|
private |
Close condition.
Notified when widget closes.
Definition at line 221 of file WUIWidgetBase.h.
Referenced by close(), and getCloseCondition().
|
private |
Flag denotes whether the widget was closed already.
Definition at line 236 of file WUIWidgetBase.h.
Referenced by close(), and isClosed().
|
private |
The parent.
Can be NULL.
Definition at line 226 of file WUIWidgetBase.h.
Referenced by getParent(), and setParent().
|
private |
The widget's title string.
Definition at line 216 of file WUIWidgetBase.h.
Referenced by getTitle().