OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Private Attributes | Friends | List of all members
WUIWidgetBase Class Referenceabstract

Base class for all the widget abstraction the core UI provides. More...

#include <WUIWidgetBase.h>

+ Inheritance diagram for WUIWidgetBase:
+ Collaboration diagram for WUIWidgetBase:

Public Types

typedef std::shared_ptr< WUIWidgetBaseSPtr
 Convenience typedef for a std::shared_ptr< WUIWidgetBase >. More...
 
typedef std::shared_ptr< const WUIWidgetBaseConstSPtr
 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...
 
ChildContainergetChildren ()
 Return the list of children. More...
 
const ChildContainergetChildren () 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...
 

Detailed Description

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.

Note
Please read documentation of WUIWidgetFactory for limitations, requirements and creation of these widgets.

Definition at line 44 of file WUIWidgetBase.h.

Member Typedef Documentation

◆ ChildContainer

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.

◆ ConstSPtr

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.

◆ SPtr

typedef std::shared_ptr< WUIWidgetBase > WUIWidgetBase::SPtr

Convenience typedef for a std::shared_ptr< WUIWidgetBase >.

Definition at line 51 of file WUIWidgetBase.h.

Constructor & Destructor Documentation

◆ ~WUIWidgetBase()

WUIWidgetBase::~WUIWidgetBase ( )
virtual

Destructor.

Definition at line 40 of file WUIWidgetBase.cpp.

◆ WUIWidgetBase()

WUIWidgetBase::WUIWidgetBase ( std::string  title)
explicitprotected

Default constructor.

Parameters
titlethe title of the widget

Definition at line 32 of file WUIWidgetBase.cpp.

Member Function Documentation

◆ addAction() [1/3]

virtual void WUIWidgetBase::addAction ( WPropBool  toggle,
WGEImage::SPtr  icon = WGEImage::SPtr() 
)
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.

Note
They might not be visible. Only top-level widgets guarantee to show these properly.
Parameters
togglethe property to use
iconthe icon to use. Consider a minimum size of 32x32.

Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.

◆ addAction() [2/3]

virtual void WUIWidgetBase::addAction ( WPropGroup  group,
WGEImage::SPtr  icon = WGEImage::SPtr() 
)
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.

Note
They might not be visible. Only top-level widgets guarantee to show these properly.
Parameters
groupthe property to use.
iconthe icon to use. Consider a minimum size of 32x32.

Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.

◆ addAction() [3/3]

virtual void WUIWidgetBase::addAction ( WPropTrigger  trigger,
WGEImage::SPtr  icon = WGEImage::SPtr() 
)
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.

Note
They might not be visible. Only top-level widgets guarantee to show these properly.
Parameters
triggerthe property to use
iconthe icon to use. Consider a minimum size of 32x32.

Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.

◆ allowNesting()

bool WUIWidgetBase::allowNesting ( ) const
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.

Returns
true if nesting other widgets INTO this one is allowed

Reimplemented in WUITabbedWidget, and WUIGridWidget.

Definition at line 94 of file WUIWidgetBase.cpp.

◆ close()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closeChildren()

void WUIWidgetBase::closeChildren ( )
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closeImpl()

virtual void WUIWidgetBase::closeImpl ( )
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().

+ Here is the caller graph for this function:

◆ getChildren() [1/2]

WUIWidgetBase::ChildContainer & WUIWidgetBase::getChildren ( )
protected

Return the list of children.

Returns
the children

Definition at line 100 of file WUIWidgetBase.cpp.

References m_childs.

◆ getChildren() [2/2]

const WUIWidgetBase::ChildContainer & WUIWidgetBase::getChildren ( ) const
protected

Return the list of children.

Returns
the children

Definition at line 105 of file WUIWidgetBase.cpp.

References m_childs.

◆ getCloseCondition()

WCondition::SPtr WUIWidgetBase::getCloseCondition ( ) const

Return the condition that fires when the widgets closes.

Returns
the condition fired whenever the widget closes

Definition at line 73 of file WUIWidgetBase.cpp.

References m_closeCondition.

◆ getParent()

WUIWidgetBase::SPtr WUIWidgetBase::getParent ( ) const
virtual

Get the parent widget of this widget if any.

Can be NULL.

Returns
the parent

Definition at line 83 of file WUIWidgetBase.cpp.

References m_parent.

◆ getTitle()

std::string WUIWidgetBase::getTitle ( ) const
virtual

Get the title of the widget.

Returns
title as string

Definition at line 45 of file WUIWidgetBase.cpp.

References m_title.

Referenced by WUIQtGridWidget::getTitleQString(), WUIQtPropertyGroupWidget::getTitleQString(), WUIQtTabbedWidget::getTitleQString(), WUIQtViewWidget::getTitleQString(), and WUIQtViewWidget::realizeImpl().

+ Here is the caller graph for this function:

◆ isClosed()

bool WUIWidgetBase::isClosed ( ) const

Checks whether the widget was closed already.

Returns
true if already closed

Definition at line 126 of file WUIWidgetBase.cpp.

References m_closed.

Referenced by close().

+ Here is the caller graph for this function:

◆ isVisible()

virtual bool WUIWidgetBase::isVisible ( ) const
pure virtual

Check if the widget is hidden or not.

Returns
true if visible.

Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.

◆ registerChild()

void WUIWidgetBase::registerChild ( WUIWidgetBase::SPtr  child)
protectedvirtual

Register widget as child.

Called by the widget factory.

Parameters
childthe child.

Definition at line 88 of file WUIWidgetBase.cpp.

References m_childs, and WSharedSequenceContainer< S >::unique_push_back().

+ Here is the call graph for this function:

◆ setParent()

void WUIWidgetBase::setParent ( WUIWidgetBase::SPtr  parent)
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.

Parameters
parentthe parent. Can be NULL if none.

Definition at line 78 of file WUIWidgetBase.cpp.

References m_parent.

◆ setVisible()

virtual void WUIWidgetBase::setVisible ( bool  visible = true)
pure virtual

Hide/show this widget.

Unlike close(), you can show the widget again using show().

Parameters
visiblefalse to hide widget

Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.

◆ show()

virtual void WUIWidgetBase::show ( )
pure virtual

Show this widget if not yet visible.

Implemented in WUIQtViewWidget, WUIQtTabbedWidget, WUIQtPropertyGroupWidget, and WUIQtGridWidget.

Friends And Related Function Documentation

◆ WUIWidgetFactory

friend class WUIWidgetFactory
friend

The factory needs to be able to call the constructor.

Definition at line 46 of file WUIWidgetBase.h.

Member Data Documentation

◆ m_childs

ChildContainer WUIWidgetBase::m_childs
private

Child widgets.

Definition at line 231 of file WUIWidgetBase.h.

Referenced by close(), closeChildren(), getChildren(), and registerChild().

◆ m_closeCondition

WCondition::SPtr WUIWidgetBase::m_closeCondition
private

Close condition.

Notified when widget closes.

Definition at line 221 of file WUIWidgetBase.h.

Referenced by close(), and getCloseCondition().

◆ m_closed

bool WUIWidgetBase::m_closed
private

Flag denotes whether the widget was closed already.

Definition at line 236 of file WUIWidgetBase.h.

Referenced by close(), and isClosed().

◆ m_parent

WUIWidgetBase::SPtr WUIWidgetBase::m_parent
private

The parent.

Can be NULL.

Definition at line 226 of file WUIWidgetBase.h.

Referenced by getParent(), and setParent().

◆ m_title

std::string WUIWidgetBase::m_title
private

The widget's title string.

Definition at line 216 of file WUIWidgetBase.h.

Referenced by getTitle().


The documentation for this class was generated from the following files: