cocos2d-x  2.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
UIWidget Class Reference

#include <UIWidget.h>

Inheritance diagram for UIWidget:
CCObject CCCopying Layout UIButton UICheckBox UIImageView UILabel UILabelAtlas UILabelBMFont UILoadingBar UISlider UISwitch UITextField

Public Member Functions

 UIWidget (void)
virtual ~UIWidget ()
 Default destructor. More...
 
virtual void setEnabled (bool enabled)
 Sets whether the widget is enabled. More...
 
bool isEnabled () const
 Determines if the widget is enabled. More...
 
void setVisible (bool visible)
 Sets whether the widget is visible. More...
 
bool isVisible () const
 Determines if the widget is visible. More...
 
void setBright (bool bright)
 Sets whether the widget is bright. More...
 
bool isBright () const
 Determines if the widget is bright. More...
 
virtual void setTouchEnabled (bool enabled)
 Sets whether the widget is touch enabled. More...
 
void setBrightStyle (BrightStyle style)
 To set the bright style of widget. More...
 
bool isTouchEnabled () const
 Determines if the widget is touch enabled. More...
 
bool isFocused () const
 Determines if the widget is on focused. More...
 
void setFocused (bool fucosed)
 Sets whether the widget is on focused. More...
 
void setZOrder (int z)
 Sets the Z order which stands for the drawing order, and reorder this widget in its parent's children array. More...
 
int getZOrder ()
 Gets the Z order of this widget. More...
 
float getLeftInParent ()
 Gets the left boundary position of this widget. More...
 
float getBottomInParent ()
 Gets the bottom boundary position of this widget. More...
 
float getRightInParent ()
 Gets the right boundary position of this widget. More...
 
float getTopInParent ()
 Gets the top boundary position of this widget. More...
 
virtual bool addChild (UIWidget *child)
 Adds a child to the container. More...
 
virtual bool removeChild (UIWidget *child)
 Removes a child from the container with a cleanup. More...
 
virtual void removeFromParent ()
 Removes this widget itself from its parent widget. More...
 
virtual void removeAllChildren ()
 Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. More...
 
void disableUpdate ()
 Unschedules the "update" method. More...
 
virtual void reorderChild (UIWidget *child)
 Reorders a child according to a new z value. More...
 
UIWidgetgetChildByName (const char *name)
 Gets a child from the container with its name. More...
 
UIWidgetgetChildByTag (int tag)
 Gets a child from the container with its tag. More...
 
virtual CCArraygetChildren ()
 Return an array of children. More...
 
CCNodegetRenderer ()
 Gets the renderer of widget. More...
 
void addRenderer (CCNode *renderer, int zOrder)
 Add a CCNode for rendering. More...
 
void removeRenderer (CCNode *renderer, bool cleanup)
 Remove a CCNode from widget. More...
 
void setParent (UIWidget *parent)
 Sets the parent widget. More...
 
UIWidgetgetParent ()
 Returns a pointer to the parent widget. More...
 
void addTouchEventListener (CCObject *target, SEL_TouchEvent selector)
 Sets the touch event target/selector of the menu item. More...
 
void setPosition (const CCPoint &pos)
 Changes the position (x,y) of the widget in OpenGL coordinates. More...
 
void setPositionPercent (const CCPoint &percent)
 Changes the position (x,y) of the widget in OpenGL coordinates. More...
 
const CCPointgetPosition ()
 Gets the position (x,y) of the widget in OpenGL coordinates. More...
 
const CCPointgetPositionPercent ()
 Gets the percent (x,y) of the widget in OpenGL coordinates. More...
 
void setPositionType (PositionType type)
 Changes the position type of the widget. More...
 
PositionType getPositionType () const
 Gets the position type of the widget. More...
 
virtual void setAnchorPoint (const CCPoint &pt)
 Sets the anchor point in percent. More...
 
const CCPointgetAnchorPoint ()
 Returns the anchor point in percent. More...
 
virtual void setScale (float fScale)
 Changes both X and Y scale factor of the widget. More...
 
float getScale ()
 Gets the scale factor of the widget, when X and Y have the same scale factor. More...
 
virtual void setScaleX (float fScaleX)
 Changes the scale factor on X axis of this widget. More...
 
float getScaleX ()
 Returns the scale factor on X axis of this widget. More...
 
virtual void setScaleY (float fScaleY)
 Changes the scale factor on Y axis of this widget. More...
 
float getScaleY ()
 Returns the scale factor on Y axis of this widget. More...
 
void setRotation (float rotation)
 Sets the rotation (angle) of the widget in degrees. More...
 
float getRotation ()
 Returns the rotation of the widget in degrees. More...
 
void setRotationX (float rotationX)
 Sets the X rotation (angle) of the widget in degrees which performs a horizontal rotational skew. More...
 
float getRotationX ()
 Gets the X rotation (angle) of the widget in degrees which performs a horizontal rotation skew. More...
 
void setRotationY (float rotationY)
 Sets the Y rotation (angle) of the widget in degrees which performs a vertical rotational skew. More...
 
float getRotationY ()
 Gets the Y rotation (angle) of the widget in degrees which performs a vertical rotational skew. More...
 
virtual void setFlipX (bool flipX)
 Sets whether the widget should be flipped horizontally or not. More...
 
virtual bool isFlipX ()
 Returns the flag which indicates whether the widget is flipped horizontally or not. More...
 
virtual void setFlipY (bool flipY)
 Sets whether the widget should be flipped vertically or not. More...
 
virtual bool isFlipY ()
 Return the flag which indicates whether the widget is flipped vertically or not. More...
 
virtual void setColor (const ccColor3B &color)
 Sets color to widget. More...
 
virtual const ccColor3BgetColor ()
 Gets color of widget. More...
 
virtual void setOpacity (int opacity)
 Sets opacity to widget. More...
 
virtual int getOpacity ()
 Gets opacity of widget. More...
 
virtual bool isCascadeOpacityEnabled ()
virtual void setCascadeOpacityEnabled (bool cascadeOpacityEnabled)
virtual bool isCascadeColorEnabled ()
virtual void setCascadeColorEnabled (bool cascadeColorEnabled)
void setBlendFunc (ccBlendFunc blendFunc)
virtual void setActionManager (CCActionManager *actionManager)
virtual CCActionManagergetActionManager ()
CCActionrunAction (CCAction *action)
void stopAllActions (void)
void stopAction (CCAction *action)
void stopActionByTag (int tag)
CCActiongetActionByTag (int tag)
void didNotSelectSelf ()
 A call back function when widget lost of focus. More...
 
bool clippingParentAreaContainPoint (const CCPoint &pt)
virtual void checkChildInfo (int handleState, UIWidget *sender, const CCPoint &touchPoint)
const CCPointgetTouchStartPos ()
const CCPointgetTouchMovePos ()
const CCPointgetTouchEndPos ()
void setTag (int tag)
 Changes the tag that is used to identify the widget easily. More...
 
int getTag () const
 Returns a tag that is used to identify the widget easily. More...
 
void setName (const char *name)
 Changes the name that is used to identify the widget easily. More...
 
const char * getName () const
 Returns a name that is used to identify the widget easily. More...
 
WidgetType getWidgetType () const
 Returns a type that is widget's type. More...
 
virtual void setSize (const CCSize &size)
 Changes the size that is widget's size. More...
 
virtual void setSizePercent (const CCPoint &percent)
 Changes the percent that is widget's percent size. More...
 
void setSizeType (SizeType type)
 Changes the size type of widget. More...
 
SizeType getSizeType () const
 Gets the size type of widget. More...
 
const CCSizegetSize () const
 Returns size of widget. More...
 
const CCPointgetSizePercent () const
 Returns size percent of widget. More...
 
virtual bool hitTest (const CCPoint &pt)
 Checks a point if is in widget's space. More...
 
virtual bool onTouchBegan (const CCPoint &touchPoint)
 A call back function called when widget is selected, and on touch began. More...
 
virtual void onTouchMoved (const CCPoint &touchPoint)
 A call back function called when widget is selected, and on touch moved. More...
 
virtual void onTouchEnded (const CCPoint &touchPoint)
 A call back function called when widget is selected, and on touch ended. More...
 
virtual void onTouchCancelled (const CCPoint &touchPoint)
 A call back function called when widget is selected, and on touch canceled. More...
 
virtual void onTouchLongClicked (const CCPoint &touchPoint)
 A call back function called when widget is selected, and on touch long clicked. More...
 
void setLayoutParameter (LayoutParameter *parameter)
 Sets a LayoutParameter to widget. More...
 
LayoutParametergetLayoutParameter ()
 Gets LayoutParameter of widget. More...
 
virtual void ignoreContentAdaptWithSize (bool ignore)
 Ignore the widget size. More...
 
bool isIgnoreContentAdaptWithSize () const
 Gets the widget if is ignore it's size. More...
 
CCPoint getWorldPosition ()
 Gets world position of widget. More...
 
CCPoint convertToWorldSpace (const CCPoint &pt)
 Converts a Point to world space coordinates. More...
 
virtual CCNodegetVirtualRenderer ()
 Gets the Virtual Renderer of widget. More...
 
void setUpdateEnabled (bool enable)
 Schedules the "update" method. More...
 
bool isUpdateEnabled ()
 is the "update" method scheduled. More...
 
virtual const CCSizegetContentSize () const
 Gets the content size of widget. More...
 
virtual const char * getDescription () const
 Returns the "class name" of widget. More...
 
virtual void onEnter ()
virtual void onExit ()
void setTouchEnable (bool enabled, bool containChildren=false)
 These methods will be removed. More...
 
void disable (bool containChildren=false)
void active (bool containChildren=false)
bool isActive ()
void setBright (bool bright, bool containChild)
CCRect getRect ()
CCNodegetValidNode ()
void setWidgetZOrder (int z)
int getWidgetZOrder ()
float getRelativeLeftPos ()
float getRelativeBottomPos ()
float getRelativeRightPos ()
float getRelativeTopPos ()
CCNodegetContainerNode ()
void setWidgetParent (UIWidget *parent)
UIWidgetgetWidgetParent ()
void setWidgetTag (int tag)
int getWidgetTag ()
void addCCNode (CCNode *node)
void removeCCNode (bool cleanup)
void addPushDownEvent (CCObject *target, SEL_PushEvent selector)
void addMoveEvent (CCObject *target, SEL_MoveEvent selector)
void addReleaseEvent (CCObject *target, SEL_ReleaseEvent selector)
void addCancelEvent (CCObject *target, SEL_CancelEvent selector)
bool removeChild (UIWidget *child, bool cleanup)
void removeFromParentAndCleanup (bool cleanup)
void removeAllChildrenAndCleanUp (bool cleanup)
void setActionTag (int tag)
int getActionTag ()
- Public Member Functions inherited from CCObject
 CCObject (void)
virtual ~CCObject (void)
void release (void)
void retain (void)
CCObjectautorelease (void)
CCObjectcopy (void)
bool isSingleReference (void) const
unsigned int retainCount (void) const
virtual bool isEqual (const CCObject *pObject)
virtual void acceptVisitor (CCDataVisitor &visitor)
virtual void update (float dt)
- Public Member Functions inherited from CCCopying
virtual CCObjectcopyWithZone (CCZone *pZone)

Static Public Member Functions

static UIWidgetcreate ()
 Allocates and initializes a widget. More...
 

Protected Member Functions

virtual void onSizeChanged ()
virtual bool init ()
virtual void initRenderer ()
virtual void onPressStateChangedToNormal ()
virtual void onPressStateChangedToPressed ()
virtual void onPressStateChangedToDisabled ()
void pushDownEvent ()
void moveEvent ()
void releaseUpEvent ()
void cancelUpEvent ()
void longClickEvent ()
void updateAnchorPoint ()
virtual void releaseResoures ()
 Release texture resoures of widget. More...
 
void updateSizeAndPosition ()

Protected Attributes

bool m_bEnabled
 Highest control of widget. More...
 
bool m_bVisible
 is this widget visible More...
 
bool m_bBright
 is this widget bright More...
 
bool m_bTouchEnabled
 is this widget touch endabled More...
 
bool m_bTouchPassedEnabled
 is the touch event should be passed More...
 
bool m_bFocus
 is the widget on focus More...
 
int m_nWidgetZOrder
 z-order value that affects the draw order and touch order More...
 
CCPoint m_anchorPoint
 anchor point normalized More...
 
UIWidgetm_pWidgetParent
 parent of widget More...
 
BrightStyle m_eBrightStyle
 bright style More...
 
bool m_bUpdateEnabled
 is "update" method scheduled More...
 
CCNodem_pRenderer
 base renderer More...
 
CCPoint m_touchStartPos
 touch began point More...
 
CCPoint m_touchMovePos
 touch moved point More...
 
CCPoint m_touchEndPos
 touch ended point More...
 
CCObjectm_pTouchEventListener
SEL_TouchEvent m_pfnTouchEventSelector
int m_nWidgetTag
std::string m_strName
WidgetType m_WidgetType
int m_nActionTag
CCSize m_size
CCSize m_customSize
LayoutParameterm_pLayoutParameter
bool m_bIgnoreSize
CCArraym_children
bool m_bAffectByClipping
CCSchedulerm_pScheduler
SizeType m_eSizeType
CCPoint m_sizePercent
PositionType m_ePositionType
CCPoint m_positionPercent
bool m_bIsRunning
CCObjectm_pPushListener
SEL_PushEvent m_pfnPushSelector
CCObjectm_pMoveListener
SEL_MoveEvent m_pfnMoveSelector
CCObjectm_pReleaseListener
SEL_ReleaseEvent m_pfnReleaseSelector
CCObjectm_pCancelListener
SEL_ReleaseEvent m_pfnCancelSelector
- Protected Attributes inherited from CCObject
unsigned int m_uReference
unsigned int m_uAutoReleaseCount

Additional Inherited Members

- Public Attributes inherited from CCObject
unsigned int m_uID
int m_nLuaID

Constructor & Destructor Documentation

UIWidget ( void  )
virtual ~UIWidget ( )
virtual

Default destructor.

Member Function Documentation

void active ( bool  containChildren = false)
inline
void addCancelEvent ( CCObject target,
SEL_CancelEvent  selector 
)
inline
void addCCNode ( CCNode node)
inline
virtual bool addChild ( UIWidget child)
virtual

Adds a child to the container.

Parameters
childA child widget

Reimplemented in UIScrollView, UIPageView, UIDragPanel, and UIListView.

void addMoveEvent ( CCObject target,
SEL_MoveEvent  selector 
)
inline
void addPushDownEvent ( CCObject target,
SEL_PushEvent  selector 
)
inline
void addReleaseEvent ( CCObject target,
SEL_ReleaseEvent  selector 
)
inline
void addRenderer ( CCNode renderer,
int  zOrder 
)

Add a CCNode for rendering.

renderer is a CCNode, it's for drawing

Parameters
rendererA render node
zOrderZ order for drawing priority. Please refer to CCNode::setZOrder(int)
void addTouchEventListener ( CCObject target,
SEL_TouchEvent  selector 
)

Sets the touch event target/selector of the menu item.

void cancelUpEvent ( )
protected
virtual void checkChildInfo ( int  handleState,
UIWidget sender,
const CCPoint touchPoint 
)
virtual

Reimplemented in UIDragPanel, UIScrollView, UIListView, and UIPageView.

bool clippingParentAreaContainPoint ( const CCPoint pt)
CCPoint convertToWorldSpace ( const CCPoint pt)

Converts a Point to world space coordinates.

The result is in Points.

static UIWidget* create ( )
static

Allocates and initializes a widget.

void didNotSelectSelf ( )

A call back function when widget lost of focus.

void disable ( bool  containChildren = false)
inline
void disableUpdate ( )

Unschedules the "update" method.

CCAction* getActionByTag ( int  tag)
virtual CCActionManager*
getActionManager
( )
virtual
int getActionTag ( )
const CCPoint& getAnchorPoint ( )

Returns the anchor point in percent.

See Also
setAnchorPoint(const CCPoint&)
Returns
The anchor point of widget.
float getBottomInParent ( )

Gets the bottom boundary position of this widget.

Returns
The bottom boundary position of this widget.
UIWidget* getChildByName ( const char *  name)

Gets a child from the container with its name.

Parameters
nameAn key to find the child widget.
Returns
a UIWidget object whose name equals to the input parameter
UIWidget* getChildByTag ( int  tag)

Gets a child from the container with its tag.

Parameters
tagAn identifier to find the child widget.
Returns
a UIWidget object whose tag equals to the input parameter
virtual CCArray* getChildren ( )
virtual

Return an array of children.

Composing a "tree" structure is a very important feature of UIWidget

Returns
An array of children

Reimplemented in UIScrollView, and UIDragPanel.

virtual const ccColor3B& getColor ( )
virtual

Gets color of widget.

Returns
color
CCNode* getContainerNode ( )
inline
virtual const CCSize&
getContentSize
( ) const
virtual

Gets the content size of widget.

Content size is widget's texture size.

Reimplemented in UISlider, Layout, UITextField, UICheckBox, UIButton, UIImageView, UILabel, UILoadingBar, UILabelAtlas, and UILabelBMFont.

virtual const char* getDescription ( ) const
virtual
LayoutParameter* getLayoutParameter ( )

Gets LayoutParameter of widget.

See Also
LayoutParameter
float getLeftInParent ( )

Gets the left boundary position of this widget.

Returns
The left boundary position of this widget.
const char* getName ( ) const

Returns a name that is used to identify the widget easily.

You can set tags to widget then identify them easily.

Returns
A const char* that identifies the widget.
virtual int getOpacity ( )
virtual

Gets opacity of widget.

Returns
opacity
UIWidget* getParent ( )

Returns a pointer to the parent widget.

See Also
setParent(UIWidget*)
Returns
A pointer to the parnet widget
const CCPoint& getPosition ( )

Gets the position (x,y) of the widget in OpenGL coordinates.

See Also
setPosition(const CCPoint&)
Returns
The position (x,y) of the widget in OpenGL coordinates
const CCPoint& getPositionPercent ( )

Gets the percent (x,y) of the widget in OpenGL coordinates.

See Also
setPosition(const CCPoint&)
Returns
The percent (x,y) of the widget in OpenGL coordinates
PositionType getPositionType ( ) const

Gets the position type of the widget.

See Also
PositionType
Returns
type the position type of widget
CCRect getRect ( )
inline
float getRelativeBottomPos ( )
inline
float getRelativeLeftPos ( )
inline
float getRelativeRightPos ( )
inline
float getRelativeTopPos ( )
inline
CCNode* getRenderer ( )

Gets the renderer of widget.

renderer is a CCNode, it's for drawing

Returns
a CCNode object
float getRightInParent ( )

Gets the right boundary position of this widget.

Returns
The right boundary position of this widget.
float getRotation ( )

Returns the rotation of the widget in degrees.

See Also
setRotation(float)
Returns
The rotation of the widget in degrees.
float getRotationX ( )

Gets the X rotation (angle) of the widget in degrees which performs a horizontal rotation skew.

See Also
setRotationX(float)
Returns
The X rotation in degrees.
float getRotationY ( )

Gets the Y rotation (angle) of the widget in degrees which performs a vertical rotational skew.

See Also
setRotationY(float)
Returns
The Y rotation in degrees.
float getScale ( )

Gets the scale factor of the widget, when X and Y have the same scale factor.

Warning
Assert when m_fScaleX != m_fScaleY.
See Also
setScale(float)
Returns
The scale factor of the widget.
float getScaleX ( )

Returns the scale factor on X axis of this widget.

See Also
setScaleX(float)
Returns
The scale factor on X axis.
float getScaleY ( )

Returns the scale factor on Y axis of this widget.

See Also
setScaleY(float)
Returns
The scale factor on Y axis.
const CCSize& getSize ( ) const

Returns size of widget.

Returns
size
const CCPoint& getSizePercent ( ) const

Returns size percent of widget.

Returns
size percent
SizeType getSizeType ( ) const

Gets the size type of widget.

See Also
SizeType
Parameters
typethat is widget's size type
int getTag ( ) const

Returns a tag that is used to identify the widget easily.

You can set tags to widget then identify them easily.

Returns
A interger that identifies the widget.
float getTopInParent ( )

Gets the top boundary position of this widget.

Returns
The top boundary position of this widget.
const CCPoint& getTouchEndPos ( )
const CCPoint& getTouchMovePos ( )
const CCPoint& getTouchStartPos ( )
CCNode* getValidNode ( )
inline
virtual CCNode* getVirtualRenderer ( )
virtual

Gets the Virtual Renderer of widget.

For example, a button's Virtual Renderer is it's texture renderer.

Returns
CCNode pointer.

Reimplemented in UISlider, UITextField, UICheckBox, UIButton, UIImageView, UILabel, UILoadingBar, UILabelAtlas, and UILabelBMFont.

UIWidget* getWidgetParent ( )
inline
int getWidgetTag ( )
inline
WidgetType getWidgetType ( ) const

Returns a type that is widget's type.

See Also
WidgetType
Returns
A WidgetType
int getWidgetZOrder ( )
inline
CCPoint getWorldPosition ( )

Gets world position of widget.

Returns
world position of widget.
int getZOrder ( )

Gets the Z order of this widget.

See Also
setZOrder(int)
Returns
The Z order.
virtual bool hitTest ( const CCPoint pt)
virtual

Checks a point if is in widget's space.

Parameters
point
Returns
true if the point is in widget's space, flase otherwise.

Reimplemented in Layout.

virtual void
ignoreContentAdaptWithSize
( bool  ignore)
virtual

Ignore the widget size.

Parameters
ignore,truethat widget will ignore it's size, use texture size, false otherwise. Default value is true.

Reimplemented in UISlider, UIButton, UILoadingBar, and UIImageView.

virtual bool init ( )
protectedvirtual
virtual void initRenderer ( )
protectedvirtual
bool isActive ( )
inline
bool isBright ( ) const

Determines if the widget is bright.

Returns
true if the widget is bright, false if the widget is dark.
virtual bool isCascadeColorEnabled ( )
virtual
virtual bool
isCascadeOpacityEnabled
( )
virtual
bool isEnabled ( ) const

Determines if the widget is enabled.

Returns
true if the widget is enabled, false if the widget is disabled.
virtual bool isFlipX ( )
inlinevirtual

Returns the flag which indicates whether the widget is flipped horizontally or not.

It only flips the texture of the widget, and not the texture of the widget's children. Also, flipping the texture doesn't alter the anchorPoint. If you want to flip the anchorPoint too, and/or to flip the children too use: widget->setScaleX(sprite->getScaleX() * -1);

Returns
true if the widget is flipped horizaontally, false otherwise.

Reimplemented in UICheckBox, UIButton, UILabel, and UIImageView.

virtual bool isFlipY ( )
inlinevirtual

Return the flag which indicates whether the widget is flipped vertically or not.

It only flips the texture of the widget, and not the texture of the widget's children. Also, flipping the texture doesn't alter the anchorPoint. If you want to flip the anchorPoint too, and/or to flip the children too use: widget->setScaleY(widget->getScaleY() * -1);

Returns
true if the widget is flipped vertically, flase otherwise.

Reimplemented in UICheckBox, UIButton, UILabel, and UIImageView.

bool isFocused ( ) const

Determines if the widget is on focused.

Returns
true if the widget is on focused, false if the widget is not on focused.
bool isIgnoreContentAdaptWithSize ( ) const

Gets the widget if is ignore it's size.

Parameters
ignore,truethat widget will ignore it's size, use texture size, false otherwise. Default value is true.
bool isTouchEnabled ( ) const

Determines if the widget is touch enabled.

Returns
true if the widget is touch enabled, false if the widget is touch disabled.
bool isUpdateEnabled ( )

is the "update" method scheduled.

bool isVisible ( ) const

Determines if the widget is visible.

Returns
true if the widget is visible, false if the widget is hidden.
void longClickEvent ( )
protected
void moveEvent ( )
protected
virtual void onEnter ( )
virtual
virtual void onExit ( )
virtual
virtual void
onPressStateChangedToDisabled
( )
protectedvirtual

Reimplemented in UISlider, UIButton, UICheckBox, and UILabel.

virtual void
onPressStateChangedToNormal
( )
protectedvirtual

Reimplemented in UISlider, UIButton, UICheckBox, and UILabel.

virtual void
onPressStateChangedToPressed
( )
protectedvirtual

Reimplemented in UISlider, UIButton, UICheckBox, and UILabel.

virtual void onSizeChanged ( )
protectedvirtual
virtual bool onTouchBegan ( const CCPoint touchPoint)
virtual

A call back function called when widget is selected, and on touch began.

Parameters
touchpoint
Returns
true if the event should be pass to parent, flase otherwise.

Reimplemented in UIScrollView, UISlider, UIDragPanel, UIPageView, UITextField, UIImageView, and UIListView.

virtual void onTouchCancelled ( const CCPoint touchPoint)
virtual

A call back function called when widget is selected, and on touch canceled.

Parameters
touchpoint

Reimplemented in UIScrollView, UISlider, UIDragPanel, UIPageView, and UIListView.

virtual void onTouchEnded ( const CCPoint touchPoint)
virtual

A call back function called when widget is selected, and on touch ended.

Parameters
touchpoint

Reimplemented in UIScrollView, UISlider, UICheckBox, UIDragPanel, UIPageView, UIImageView, and UIListView.

virtual void onTouchLongClicked ( const CCPoint touchPoint)
virtual

A call back function called when widget is selected, and on touch long clicked.

Parameters
touchpoint

Reimplemented in UIScrollView, UIDragPanel, and UIListView.

virtual void onTouchMoved ( const CCPoint touchPoint)
virtual

A call back function called when widget is selected, and on touch moved.

Parameters
touchpoint

Reimplemented in UIScrollView, UISlider, UIDragPanel, UIPageView, and UIListView.

void pushDownEvent ( )
protected
virtual void releaseResoures ( )
protectedvirtual

Release texture resoures of widget.

Release renderer. If you override releaseResoures, you shall call its parent's one, e.g. UIWidget::releaseResoures().

Reimplemented in UIDragPanel, and UIScrollView.

void releaseUpEvent ( )
protected
virtual void removeAllChildren ( )
virtual

Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter.

Reimplemented in UIScrollView, UIDragPanel, UIPageView, and UIListView.

void removeAllChildrenAndCleanUp ( bool  cleanup)
inline
void removeCCNode ( bool  cleanup)
inline
virtual bool removeChild ( UIWidget child)
virtual

Removes a child from the container with a cleanup.

Parameters
childThe child widget which will be removed.
Returns
the result of removing, succeeded or failed.

Reimplemented in UIScrollView, UIDragPanel, UIPageView, and UIListView.

bool removeChild ( UIWidget child,
bool  cleanup 
)
inline
virtual void removeFromParent ( )
virtual

Removes this widget itself from its parent widget.

If the widget orphan, then it will destroy itself.

void removeFromParentAndCleanup ( bool  cleanup)
inline
void removeRenderer ( CCNode renderer,
bool  cleanup 
)

Remove a CCNode from widget.

renderer is a CCNode, it's for drawing

Parameters
rendererA render node which needs to be removed
cleanuptrue if all running actions and callbacks on the render node will be cleanup, false otherwise.
virtual void reorderChild ( UIWidget child)
virtual

Reorders a child according to a new z value.

Parameters
childAn already added child node. It MUST be already added.
zOrderZ order for drawing priority and touched priority. Please refer to setZOrder(int)
CCAction* runAction ( CCAction action)
virtual void setActionManager ( CCActionManager actionManager)
virtual
void setActionTag ( int  tag)
virtual void setAnchorPoint ( const CCPoint pt)
virtual

Sets the anchor point in percent.

anchorPoint is the point around which all transformations and positioning manipulations take place. It's like a pin in the widget where it is "attached" to its parent. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. But you can use values higher than (1,1) and lower than (0,0) too. The default anchorPoint is (0.5,0.5), so it starts in the center of the widget.

Parameters
anchorPointThe anchor point of widget.

Reimplemented in UITextField, UICheckBox, UIButton, UILabel, UIImageView, UILabelAtlas, and UILabelBMFont.

void setBlendFunc ( ccBlendFunc  blendFunc)
void setBright ( bool  bright)

Sets whether the widget is bright.

The default value is true, a widget is default to bright

Parameters
visibletrue if the widget is bright, false if the widget is dark.
void setBright ( bool  bright,
bool  containChild 
)
inline
void setBrightStyle ( BrightStyle  style)

To set the bright style of widget.

See Also
BrightStyle
Parameters
styleBRIGHT_NORMAL the widget is normal state, BRIGHT_HIGHLIGHT the widget is height light state.
virtual void setCascadeColorEnabled ( bool  cascadeColorEnabled)
virtual
virtual void
setCascadeOpacityEnabled
( bool  cascadeOpacityEnabled)
virtual
virtual void setColor ( const ccColor3B color)
virtual

Sets color to widget.

It default change the color of widget's children.

Parameters
color

Reimplemented in UIButton, UITextField, and Layout.

virtual void setEnabled ( bool  enabled)
virtual

Sets whether the widget is enabled.

Highest control of widget. The default value is true, a widget is default to enabled

Parameters
enabledtrue if the widget is enabled, widget may be touched and visible, false if the widget is disabled, widget cannot be touched and hidden.
virtual void setFlipX ( bool  flipX)
inlinevirtual

Sets whether the widget should be flipped horizontally or not.

Parameters
bFlipXtrue if the widget should be flipped horizaontally, false otherwise.

Reimplemented in UICheckBox, UIButton, UILabel, and UIImageView.

virtual void setFlipY ( bool  flipY)
inlinevirtual

Sets whether the widget should be flipped vertically or not.

Parameters
bFlipYtrue if the widget should be flipped vertically, flase otherwise.

Reimplemented in UICheckBox, UIButton, UILabel, and UIImageView.

void setFocused ( bool  fucosed)

Sets whether the widget is on focused.

The default value is false, a widget is default to not on focused

Parameters
fucosedtrue if the widget is on focused, false if the widget is not on focused.
void setLayoutParameter ( LayoutParameter parameter)

Sets a LayoutParameter to widget.

See Also
LayoutParameter
Parameters
LayoutParameterpointer
void setName ( const char *  name)

Changes the name that is used to identify the widget easily.

Parameters
Aconst char* that indentifies the widget.
virtual void setOpacity ( int  opacity)
virtual

Sets opacity to widget.

It default change the opacity of widget's children.

Parameters
color

Reimplemented in UITextField, and Layout.

void setParent ( UIWidget parent)

Sets the parent widget.

Parameters
parentA pointer to the parnet widget
void setPosition ( const CCPoint pos)

Changes the position (x,y) of the widget in OpenGL coordinates.

Usually we use ccp(x,y) to compose CCPoint object. The original point (0,0) is at the left-bottom corner of screen.

Parameters
positionThe position (x,y) of the widget in OpenGL coordinates
void setPositionPercent ( const CCPoint percent)

Changes the position (x,y) of the widget in OpenGL coordinates.

Usually we use ccp(x,y) to compose CCPoint object. The original point (0,0) is at the left-bottom corner of screen.

Parameters
percentThe percent (x,y) of the widget in OpenGL coordinates
void setPositionType ( PositionType  type)

Changes the position type of the widget.

See Also
PositionType
Parameters
typethe position type of widget
void setRotation ( float  rotation)

Sets the rotation (angle) of the widget in degrees.

0 is the default rotation angle. Positive values rotate widget clockwise, and negative values for anti-clockwise.

Parameters
fRotationThe roration of the widget in degrees.
void setRotationX ( float  rotationX)

Sets the X rotation (angle) of the widget in degrees which performs a horizontal rotational skew.

0 is the default rotation angle. Positive values rotate widget clockwise, and negative values for anti-clockwise.

Parameters
fRotationXThe X rotation in degrees which performs a horizontal rotational skew.
void setRotationY ( float  rotationY)

Sets the Y rotation (angle) of the widget in degrees which performs a vertical rotational skew.

0 is the default rotation angle. Positive values rotate widget clockwise, and negative values for anti-clockwise.

Parameters
fRotationYThe Y rotation in degrees.
virtual void setScale ( float  fScale)
virtual

Changes both X and Y scale factor of the widget.

1.0 is the default scale factor. It modifies the X and Y scale at the same time.

Parameters
scaleThe scale factor for both X and Y axis.
virtual void setScaleX ( float  fScaleX)
virtual

Changes the scale factor on X axis of this widget.

The deafult value is 1.0 if you haven't changed it before

Parameters
fScaleXThe scale factor on X axis.
virtual void setScaleY ( float  fScaleY)
virtual

Changes the scale factor on Y axis of this widget.

The Default value is 1.0 if you haven't changed it before.

Parameters
fScaleYThe scale factor on Y axis.
virtual void setSize ( const CCSize size)
virtual

Changes the size that is widget's size.

Parameters
sizethat is widget's size
virtual void setSizePercent ( const CCPoint percent)
virtual

Changes the percent that is widget's percent size.

Parameters
percentthat is widget's percent size
void setSizeType ( SizeType  type)

Changes the size type of widget.

See Also
SizeType
Parameters
typethat is widget's size type
void setTag ( int  tag)

Changes the tag that is used to identify the widget easily.

Parameters
Ainterger that indentifies the widget.
void setTouchEnable ( bool  enabled,
bool  containChildren = false 
)
inline

These methods will be removed.

virtual void setTouchEnabled ( bool  enabled)
virtual

Sets whether the widget is touch enabled.

The default value is false, a widget is default to touch disabled

Parameters
visibletrue if the widget is touch enabled, false if the widget is touch disabled.
void setUpdateEnabled ( bool  enable)

Schedules the "update" method.

void setVisible ( bool  visible)

Sets whether the widget is visible.

The default value is true, a widget is default to visible

Parameters
visibletrue if the widget is visible, false if the widget is hidden.
void setWidgetParent ( UIWidget parent)
inline
void setWidgetTag ( int  tag)
inline
void setWidgetZOrder ( int  z)
inline
void setZOrder ( int  z)

Sets the Z order which stands for the drawing order, and reorder this widget in its parent's children array.

The Z order of widget is relative to its "brothers": children of the same parent. It's nothing to do with OpenGL's z vertex. This one only affects the draw order of widgets in cocos2d. The larger number it is, the later this widget will be drawn in each message loop. Please refer to setVertexZ(float) for the difference.

Parameters
nZOrderZ order of this widget.
void stopAction ( CCAction action)
void stopActionByTag ( int  tag)
void stopAllActions ( void  )
void updateAnchorPoint ( )
protected
void updateSizeAndPosition ( )
protected

Member Data Documentation

CCPoint m_anchorPoint
protected

anchor point normalized

bool m_bAffectByClipping
protected
bool m_bBright
protected

is this widget bright

bool m_bEnabled
protected

Highest control of widget.

bool m_bFocus
protected

is the widget on focus

bool m_bIgnoreSize
protected
bool m_bIsRunning
protected
bool m_bTouchEnabled
protected

is this widget touch endabled

bool m_bTouchPassedEnabled
protected

is the touch event should be passed

bool m_bUpdateEnabled
protected

is "update" method scheduled

bool m_bVisible
protected

is this widget visible

CCArray* m_children
protected
CCSize m_customSize
protected
BrightStyle m_eBrightStyle
protected

bright style

PositionType m_ePositionType
protected
SizeType m_eSizeType
protected
int m_nActionTag
protected
int m_nWidgetTag
protected
int m_nWidgetZOrder
protected

z-order value that affects the draw order and touch order

CCObject* m_pCancelListener
protected
SEL_ReleaseEvent
m_pfnCancelSelector
protected
SEL_MoveEvent m_pfnMoveSelector
protected
SEL_PushEvent m_pfnPushSelector
protected
SEL_ReleaseEvent
m_pfnReleaseSelector
protected
SEL_TouchEvent
m_pfnTouchEventSelector
protected
LayoutParameter* m_pLayoutParameter
protected
CCObject* m_pMoveListener
protected
CCPoint m_positionPercent
protected
CCObject* m_pPushListener
protected
CCObject* m_pReleaseListener
protected
CCNode* m_pRenderer
protected

base renderer

CCScheduler* m_pScheduler
protected
CCObject* m_pTouchEventListener
protected
UIWidget* m_pWidgetParent
protected

parent of widget

CCSize m_size
protected
CCPoint m_sizePercent
protected
std::string m_strName
protected
CCPoint m_touchEndPos
protected

touch ended point

CCPoint m_touchMovePos
protected

touch moved point

CCPoint m_touchStartPos
protected

touch began point

WidgetType m_WidgetType
protected

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