Merge pull request #3660 from nutty898/Merge_GUI_to_Develop

Merge gui to develop
This commit is contained in:
minggo 2013-09-17 06:25:09 -07:00
commit 5e858becf4
44 changed files with 833 additions and 1004 deletions

View File

@ -56,4 +56,9 @@ bool UIRootWidget::init()
return false; return false;
} }
const char* UIRootWidget::getDescription() const
{
return "RootWidget";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -46,6 +46,11 @@ public:
* Allocates and initializes a widget. * Allocates and initializes a widget.
*/ */
static UIRootWidget* create(); static UIRootWidget* create();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
//initializes state of widget. //initializes state of widget.
virtual bool init(); virtual bool init();

View File

@ -1158,6 +1158,11 @@ LayoutParameter* UIWidget::getLayoutParameter()
return _layoutParameter; return _layoutParameter;
} }
const char* UIWidget::getDescription() const
{
return "Widget";
}
/*temp action*/ /*temp action*/
void UIWidget::setActionTag(int tag) void UIWidget::setActionTag(int tag)
{ {

View File

@ -875,6 +875,11 @@ public:
virtual void onEnter(); virtual void onEnter();
virtual void onExit(); virtual void onExit();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
/*temp action*/ /*temp action*/
void setActionTag(int tag); void setActionTag(int tag);
int getActionTag(); int getActionTag();

View File

@ -425,6 +425,11 @@ const Size& Layout::getContentSize() const
return _renderer->getContentSize(); return _renderer->getContentSize();
} }
const char* Layout::getDescription() const
{
return "Layout";
}
RectClippingNode::RectClippingNode(): RectClippingNode::RectClippingNode():
m_pInnerStencil(NULL), m_pInnerStencil(NULL),
_enabled(true), _enabled(true),

View File

@ -179,6 +179,10 @@ public:
*/ */
virtual const Size& getContentSize() const; virtual const Size& getContentSize() const;
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
//override "init" method of widget. //override "init" method of widget.
virtual bool init(); virtual bool init();

View File

@ -45,7 +45,6 @@ _rootWidget(NULL)
UIInputManager::~UIInputManager() UIInputManager::~UIInputManager()
{ {
CCLOG("~UIInputManager");
_manageredWidget->removeAllObjects(); _manageredWidget->removeAllObjects();
CC_SAFE_RELEASE_NULL(_manageredWidget); CC_SAFE_RELEASE_NULL(_manageredWidget);
_checkedDoubleClickWidget->removeAllObjects(); _checkedDoubleClickWidget->removeAllObjects();
@ -177,9 +176,7 @@ void UIInputManager::onTouchEnd(Touch* touch)
{ {
UIWidget* hitWidget = (UIWidget*)(selectedWidgetArray->arr[i]); UIWidget* hitWidget = (UIWidget*)(selectedWidgetArray->arr[i]);
hitWidget->onTouchEnded(_touchEndedPoint); hitWidget->onTouchEnded(_touchEndedPoint);
CCLOG("widget touch end");
} }
CCLOG("_selectedWidgets remove widgets");
_selectedWidgets->removeAllObjects(); _selectedWidgets->removeAllObjects();
} }

View File

@ -72,47 +72,31 @@ enum DRAGPANEL_BOUNCE_DIR
DRAGPANEL_BOUNCE_DIR_BOTTOM, DRAGPANEL_BOUNCE_DIR_BOTTOM,
}; };
/** typedef enum
* dragpanel berth event {
*/ DRAGPANEL_EVENT_BERTH_LEFTBOTTOM,
typedef void (Object::*SEL_DragPanelBerthToLeftBottomEvent)(Object*); DRAGPANEL_EVENT_BERTH_LFETTOP,
#define coco_DragPane_BerthToLeftBottom_selector(_SELECTOR) (SEL_DragPanelBerthToLeftBottomEvent)(&_SELECTOR) DRAGPANEL_EVENT_BERTH_RIGHTBOTTOM,
typedef void (Object::*SEL_DragPanelBerthToLeftTopEvent)(Object*); DRAGPANEL_EVENT_BERTH_RIGHTTOP,
#define coco_DragPanel_BerthToLeftTop_selector(_SELECTOR) (SEL_DragPanelBerthToLeftTopEvent)(&_SELECTOR) DRAGPANEL_EVENT_BERTH_LEFT,
typedef void (Object::*SEL_DragPanelBerthToRightBottomEvent)(Object*); DRAGPANEL_EVENT_BERTH_TOP,
#define coco_DragPanel_BerthToRightBottom_selector(_SELECTOR) (SEL_DragPanelBerthToRightBottomEvent)(&_SELECTOR) DRAGPANEL_EVENT_BERTH_RIGHT,
typedef void (Object::*SEL_DragPanelBerthToRightTopEvent)(Object*); DRAGPANEL_EVENT_BERTH_BOTTOM,
#define coco_DragPanel_BerthToRightTop_selector(_SELECTOR) (SEL_DragPanelBerthToRightTopEvent)(&_SELECTOR) DRAGPANEL_EVENT_BOUNCE_LEFTBOTTOM,
typedef void (Object::*SEL_DragPanelBerthToLeftEvent)(Object*); DRAGPANEL_EVENT_BOUNCE_LEFTTOP,
#define coco_DragPanel_BerthToLeft_selector(_SELECTOR) (SEL_DragPanelBerthToLeftEvent)(&_SELECTOR) DRAGPANEL_EVENT_BOUNCE_RIGHTBOTTOM,
typedef void (Object::*SEL_DragPanelBerthToRightEvent)(Object*); DRAGPANEL_EVENT_BOUNCE_RIGHTTOP,
#define coco_DragPanel_BerthToRight_selector(_SELECTOR) (SEL_DragPanelBerthToRightEvent)(&_SELECTOR) DRAGPANEL_EVENT_BOUNCE_LEFT,
typedef void (Object::*SEL_DragPanelBerthToTopEvent)(Object*); DRAGPANEL_EVENT_BOUNCE_TOP,
#define coco_DragPanel_BerthToTop_selector(_SELECTOR) (SEL_DragPanelBerthToTopEvent)(&_SELECTOR) DRAGPANEL_EVENT_BOUNCE_RIGHT,
typedef void (Object::*SEL_DragPanelBerthToBottomEvent)(Object*); DRAGPANEL_EVENT_BOUNCE_BOTTOM,
#define coco_DragPanel_BerthToBottom_selector(_SELECTOR) (SEL_DragPanelBerthToBottomEvent)(&_SELECTOR) }DragPanelEventType;
/** /**
* dragpanel bounce event * dragpanel event
*/ */
typedef void (Object::*SEL_DragPanelBounceOverEvent)(Object*); typedef void (Object::*SEL_DragPanelEvent)(Object*, DragPanelEventType);
#define coco_DragPanel_BounceOver_selector(_SELECTOR) (SEL_DragPanelBounceOverEvent)(&_SELECTOR) #define dragpaneleventselector(_SELECTOR)(SEL_DragPanelEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToLeftBottomEvent)(Object*);
#define coco_DragPanel_BounceToLeftBottom_selector(_SELECTOR) (SEL_DragPanelBounceToLeftBottomEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToLeftTopEvent)(Object*);
#define coco_DragPanel_BounceToLeftTop_selector(_SELECTOR) (SEL_DragPanelBounceToLeftTopEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToRightBottomEvent)(Object*);
#define coco_DragPanel_BounceToRightBottom_selector(_SELECTOR) (SEL_DragPanelBounceToRightBottomEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToRightTopEvent)(Object*);
#define coco_DragPanel_BounceToRightTop_selector(_SELECTOR) (SEL_DragPanelBounceToRightTopEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToLeftEvent)(Object*);
#define coco_DragPanel_BounceToLeft_selector(_SELECTOR) (SEL_DragPanelBounceToLeftEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToTopEvent)(Object*);
#define coco_DragPanel_BounceToTop_selector(_SELECTOR) (SEL_DragPanelBounceToTopEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToRightEvent)(Object*);
#define coco_DragPanel_BounceToRight_selector(_SELECTOR) (SEL_DragPanelBounceToRightEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToBottomEvent)(Object*);
#define coco_DragPanel_BounceToBottom_selector(_SELECTOR) (SEL_DragPanelBounceToBottomEvent)(&_SELECTOR)
class UIDragPanel : public Layout, public UIScrollInterface class UIDragPanel : public Layout, public UIScrollInterface
{ {
@ -180,16 +164,9 @@ public:
bool isBerth(); bool isBerth();
/** /**
* berth event by direction * event
*/ */
void addBerthToLeftBottomEvent(Object* target, SEL_DragPanelBerthToLeftBottomEvent selector); void addEventListener(Object* target, SEL_DragPanelEvent selector);
void addBerthToLeftTopEvent(Object* target, SEL_DragPanelBerthToLeftTopEvent selector);
void addBerthToRightBottomEvent(Object* target, SEL_DragPanelBerthToRightBottomEvent selector);
void addBerthToRightTopEvent(Object* target, SEL_DragPanelBerthToRightTopEvent selector);
void addBerthToLeftEvent(Object* target, SEL_DragPanelBerthToLeftEvent selector);
void addBerthToTopEvent(Object* target, SEL_DragPanelBerthToTopEvent selector);
void addBerthToRightEvent(Object* target, SEL_DragPanelBerthToRightEvent selector);
void addBerthToBottomEvent(Object* target, SEL_DragPanelBerthToBottomEvent selector);
/** /**
* get and set bounce enable * get and set bounce enable
@ -204,18 +181,6 @@ public:
* set bounce ease rate * set bounce ease rate
*/ */
void setBounceEaseRate(float rate); void setBounceEaseRate(float rate);
/**
* bounce event by dircetion
*/
void addBounceOverEvent(Object* target, SEL_DragPanelBounceOverEvent selector);
void addBounceToLeftBottomEvent(Object* target, SEL_DragPanelBounceToLeftBottomEvent selector);
void addBounceToLeftTopEvent(Object* target, SEL_DragPanelBounceToLeftTopEvent selector);
void addBounceToRightBottomEvent(Object* target, SEL_DragPanelBounceToRightBottomEvent selector);
void addBounceToRightTopEvent(Object* target, SEL_DragPanelBounceToRightTopEvent selector);
void addBounceToLeftEvent(Object* target, SEL_DragPanelBounceToLeftEvent selector);
void addBounceToTopEvent(Object* target, SEL_DragPanelBounceToTopEvent selector);
void addBounceToRightEvent(Object* target, SEL_DragPanelBounceToRightEvent selector);
void addBounceToBottomEvent(Object* target, SEL_DragPanelBounceToBottomEvent selector);
/** /**
* Gets inner container of dragpanel. * Gets inner container of dragpanel.
@ -226,6 +191,11 @@ public:
*/ */
Layout* getInnerContainer(); Layout* getInnerContainer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
virtual bool init(); virtual bool init();
virtual void initRenderer(); virtual void initRenderer();
@ -286,7 +256,6 @@ protected:
void bounceToCorner(); void bounceToCorner();
void bounceOver(); void bounceOver();
// bounce event // bounce event
void bounceOverEvent();
void bounceToLeftBottomEvent(); void bounceToLeftBottomEvent();
void bounceToRightBottomEvent(); void bounceToRightBottomEvent();
void bounceToLeftTopEvent(); void bounceToLeftTopEvent();
@ -318,94 +287,59 @@ protected:
/************/ /************/
virtual void setClippingEnabled(bool able){Layout::setClippingEnabled(able);}; virtual void setClippingEnabled(bool able){Layout::setClippingEnabled(able);};
protected: protected:
Layout* m_pInnerContainer; Layout* _innerContainer;
/* /*
DRAGPANEL_DIR m_eDirection; DRAGPANEL_DIR m_eDirection;
DRAGPANEL_MOVE_DIR m_eMoveDirection; DRAGPANEL_MOVE_DIR m_eMoveDirection;
*/ */
bool m_bTouchPressed; bool _touchPressed;
bool m_bTouchMoved; bool _touchMoved;
bool m_bTouchReleased; bool _touchReleased;
bool m_bTouchCanceld; // check touch out of drag panel boundary bool _touchCanceld; // check touch out of drag panel boundary
Point m_touchStartNodeSpace; Point _touchStartNodeSpace;
Point m_touchStartWorldSpace; Point _touchStartWorldSpace;
Point m_touchEndWorldSpace; Point _touchEndWorldSpace;
float m_fSlidTime; float _slidTime;
// move type // move type
DRAGPANEL_MOVE_TYPE m_eMoveType; DRAGPANEL_MOVE_TYPE _moveType;
// auto move // auto move
float m_fAutoMoveDuration; float _autoMoveDuration;
float m_fAutoMoveEaseRate; float _autoMoveEaseRate;
// event
Object* _eventLister;
SEL_DragPanelEvent _eventSelector;
// berth // berth
DRAGPANEL_BERTH_DIR m_eBerthDirection; DRAGPANEL_BERTH_DIR _berthDirection;
// berth event
Object* m_pBerthToLeftListener;
SEL_DragPanelBerthToLeftEvent m_pfnBerthToLeftSelector;
Object* m_pBerthToRightListener;
SEL_DragPanelBerthToRightEvent m_pfnBerthToRightSelector;
Object* m_pBerthToTopListener;
SEL_DragPanelBerthToTopEvent m_pfnBerthToTopSelector;
Object* m_pBerthToBottomListener;
SEL_DragPanelBerthToBottomEvent m_pfnBerthToBottomSelector;
Object* m_pBerthToLeftBottomListener;
SEL_DragPanelBerthToLeftBottomEvent m_pfnBerthToLeftBottomSelector;
Object* m_pBerthToLeftTopListener;
SEL_DragPanelBerthToLeftTopEvent m_pfnBerthToLeftTopSelector;
Object* m_pBerthToRightBottomListener;
SEL_DragPanelBerthToRightBottomEvent m_pfnBerthToRightBottomSelector;
Object* m_pBerthToRightTopListener;
SEL_DragPanelBerthToRightTopEvent m_pfnBerthToRightTopSelector;
// bounce // bounce
bool m_bBounceEnable; bool _bounceEnable;
DRAGPANEL_BOUNCE_DIR m_eBounceDirection; DRAGPANEL_BOUNCE_DIR _bounceDirection;
float m_fBounceDuration; float _bounceDuration;
float m_fBounceEaseRate; float _bounceEaseRate;
// bounce event
Object* m_pBounceOverListener;
SEL_DragPanelBounceOverEvent m_pfnBounceOverSelector;
Object* m_pBounceToLeftBottomListener;
SEL_DragPanelBounceToLeftBottomEvent m_pfnBounceToLeftBottomSelector;
Object* m_pBounceToLeftTopListener;
SEL_DragPanelBounceToLeftTopEvent m_pfnBounceToLeftTopSelector;
Object* m_pBounceToRightBottomListener;
SEL_DragPanelBounceToRightBottomEvent m_pfnBounceToRightBottomSelector;
Object* m_pBounceToRightTopListener;
SEL_DragPanelBounceToRightTopEvent m_pfnBounceToRightTopSelector;
Object* m_pBounceToLeftListener;
SEL_DragPanelBounceToLeftEvent m_pfnBounceToLeftSelector;
Object* m_pBounceToTopListener;
SEL_DragPanelBounceToTopEvent m_pfnBounceToTopSelector;
Object* m_pBounceToRightListener;
SEL_DragPanelBounceToRightEvent m_pfnBounceToRightSelector;
Object* m_pBounceToBottomListener;
SEL_DragPanelBounceToBottomEvent m_pfnBounceToBottomSelector;
float _runningAction;
int _actionType;
float m_bRunningAction; UIWidget* _actionWidget;
int m_nActionType;
UIWidget* m_pActionWidget; float _duration;
float _elapsed;
bool _firstTick;
float m_fDuration; Point _positionDelta;
float m_elapsed; Point _startPosition;
bool m_bFirstTick; Point _previousPosition;
Point m_positionDelta; Point _endPosition;
Point m_startPosition;
Point m_previousPosition;
Point m_endPosition;
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -42,10 +42,8 @@ UIListView::UIListView()
, _bePressed(false) , _bePressed(false)
, _slidTime(0.0f) , _slidTime(0.0f)
, _childFocusCancelOffset(5.0f) , _childFocusCancelOffset(5.0f)
, _initChildListener(NULL) , _eventListener(NULL)
, _initChildSelector(NULL) , _eventSelector(NULL)
, _updateChildListener(NULL)
, _updateChildSelector(NULL)
, _childPool(NULL) , _childPool(NULL)
, _updatePool(NULL) , _updatePool(NULL)
, _dataLength(0) , _dataLength(0)
@ -1431,30 +1429,30 @@ void UIListView::updateChild()
void UIListView::initChildEvent() void UIListView::initChildEvent()
{ {
if (_initChildListener && _initChildSelector) if (_eventListener && _eventSelector)
{ {
(_initChildListener->*_initChildSelector)(this); (_eventListener->*_eventSelector)(this, LISTVIEW_EVENT_INIT_CHILD);
} }
} }
void UIListView::updateChildEvent() void UIListView::updateChildEvent()
{ {
if (_updateChildListener && _updateChildSelector) if (_eventListener && _eventSelector)
{ {
(_updateChildListener->*_updateChildSelector)(this); (_eventListener->*_eventSelector)(this, LISTVIEW_EVENT_UPDATE_CHILD);
} }
} }
void UIListView::addInitChildEvent(Object *target, SEL_ListViewInitChildEvent seletor) void UIListView::addEventListenter(Object *target, SEL_ListViewEvent selector)
{ {
_initChildListener = target; _eventListener = target;
_initChildSelector = seletor; _eventSelector = selector;
} }
void UIListView::addUpdateChildEvent(Object *target, SEL_ListViewUpdateChildEvent selector) const char* UIListView::getDescription() const
{ {
_updateChildListener = target; return "ListView";
_updateChildSelector = selector;
} }
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -53,13 +53,17 @@ typedef enum LISTVIEW_MOVE_DIR
LISTVIEW_MOVE_DIR_RIGHT, LISTVIEW_MOVE_DIR_RIGHT,
}ListViewMoveDirection; }ListViewMoveDirection;
typedef enum
{
LISTVIEW_EVENT_INIT_CHILD,
LISTVIEW_EVENT_UPDATE_CHILD,
}ListViewEventType;
/** /**
* list view event * list view event
*/ */
typedef void (cocos2d::Object::*SEL_ListViewInitChildEvent)(cocos2d::Object*); typedef void (Object::*SEL_ListViewEvent)(Object*, ListViewEventType);
typedef void (cocos2d::Object::*SEL_ListViewUpdateChildEvent)(cocos2d::Object*); #define listvieweventselector(_SELECTOR)(SEL_ListViewEvent)(&_SELECTOR)
#define coco_ListView_InitChild_selector(_SELECTOR) (SEL_ListViewInitChildEvent)(&_SELECTOR)
#define coco_ListView_UpdateChild_selector(_SELECTOR) (SEL_ListViewUpdateChildEvent)(&_SELECTOR)
class UIListView : public Layout class UIListView : public Layout
{ {
@ -124,13 +128,9 @@ public:
* add event call-back function * add event call-back function
*/ */
/** /**
* add init child event * add event
*/ */
void addInitChildEvent(cocos2d::Object* target, SEL_ListViewInitChildEvent seletor); void addEventListenter(cocos2d::Object* target, SEL_ListViewEvent selector);
/**
* add udpate child event
*/
void addUpdateChildEvent(cocos2d::Object* target, SEL_ListViewUpdateChildEvent selector);
/* gui mark */ /* gui mark */
/** /**
@ -139,6 +139,10 @@ public:
/**/ /**/
virtual void update(float dt); virtual void update(float dt);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
virtual bool init(); virtual bool init();
@ -209,10 +213,8 @@ protected:
Point _moveChildPoint; Point _moveChildPoint;
float _childFocusCancelOffset; float _childFocusCancelOffset;
cocos2d::Object* _initChildListener; Object* _eventListener;
SEL_ListViewInitChildEvent _initChildSelector; SEL_ListViewEvent _eventSelector;
cocos2d::Object* _updateChildListener;
SEL_ListViewUpdateChildEvent _updateChildSelector;
Array* _childPool; Array* _childPool;
Array* _updatePool; Array* _updatePool;

View File

@ -43,8 +43,8 @@ _autoScrollDistance(0.0f),
_autoScrollSpeed(0.0f), _autoScrollSpeed(0.0f),
_autoScrollDir(0), _autoScrollDir(0),
_childFocusCancelOffset(5.0f), _childFocusCancelOffset(5.0f),
_pageTurningListener(NULL), _eventListener(NULL),
_pageTurningSelector(NULL) _eventSelector(NULL)
{ {
} }
@ -548,16 +548,16 @@ void UIPageView::interceptTouchEvent(int handleState, UIWidget *sender, const Po
void UIPageView::pageTurningEvent() void UIPageView::pageTurningEvent()
{ {
if (_pageTurningListener && _pageTurningSelector) if (_eventListener && _eventSelector)
{ {
(_pageTurningListener->*_pageTurningSelector)(this); (_eventListener->*_eventSelector)(this, PAGEVIEW_EVENT_TURNING);
} }
} }
void UIPageView::addPageTurningEvent(Object *target, SEL_PageViewPageTurningEvent selector) void UIPageView::addEventListener(Object *target, SEL_PageViewEvent selector)
{ {
_pageTurningListener = target; _eventListener = target;
_pageTurningSelector = selector; _eventSelector = selector;
} }
int UIPageView::getCurPageIndex() const int UIPageView::getCurPageIndex() const
@ -565,4 +565,9 @@ int UIPageView::getCurPageIndex() const
return _curPageIdx; return _curPageIdx;
} }
const char* UIPageView::getDescription() const
{
return "PageView";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -30,8 +30,13 @@
NS_CC_EXT_BEGIN NS_CC_EXT_BEGIN
typedef void (Object::*SEL_PageViewPageTurningEvent)(Object*); typedef enum
#define coco_PageView_PageTurning_selector(_SELECTOR) (SEL_PageViewPageTurningEvent)(&_SELECTOR) {
PAGEVIEW_EVENT_TURNING,
}PageViewEventType;
typedef void (Object::*SEL_PageViewEvent)(Object*, PageViewEventType);
#define pagevieweventselector(_SELECTOR)(SEL_PageViewEvent)(&_SELECTOR)
typedef enum { typedef enum {
PAGEVIEW_TOUCHLEFT, PAGEVIEW_TOUCHLEFT,
@ -110,8 +115,8 @@ public:
*/ */
int getCurPageIndex() const; int getCurPageIndex() const;
//Add call back function called when page turning. // event
void addPageTurningEvent(Object *target, SEL_PageViewPageTurningEvent selector); void addEventListener(Object *target, SEL_PageViewEvent selector);
//override "removeChild" method of widget. //override "removeChild" method of widget.
virtual bool removeChild(UIWidget* widget); virtual bool removeChild(UIWidget* widget);
@ -134,6 +139,10 @@ public:
//override "update" method of widget. //override "update" method of widget.
virtual void update(float dt); virtual void update(float dt);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
virtual bool addChild(UIWidget* widget); virtual bool addChild(UIWidget* widget);
virtual bool init(); virtual bool init();
@ -170,8 +179,8 @@ protected:
float _autoScrollSpeed; float _autoScrollSpeed;
int _autoScrollDir; int _autoScrollDir;
float _childFocusCancelOffset; float _childFocusCancelOffset;
Object* _pageTurningListener; Object* _eventListener;
SEL_PageViewPageTurningEvent _pageTurningSelector; SEL_PageViewEvent _eventSelector;
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -28,6 +28,7 @@
NS_CC_EXT_BEGIN NS_CC_EXT_BEGIN
UIScrollView::UIScrollView(): UIScrollView::UIScrollView():
_innerContainer(NULL),
_direction(SCROLLVIEW_DIR_VERTICAL), _direction(SCROLLVIEW_DIR_VERTICAL),
_moveDirection(SCROLLVIEW_MOVE_DIR_NONE), _moveDirection(SCROLLVIEW_MOVE_DIR_NONE),
_touchStartLocation(0.0f), _touchStartLocation(0.0f),
@ -48,15 +49,8 @@ _bePressed(false),
_slidTime(0.0f), _slidTime(0.0f),
_moveChildPoint(Point::ZERO), _moveChildPoint(Point::ZERO),
_childFocusCancelOffset(5.0f), _childFocusCancelOffset(5.0f),
_scrollToTopListener(NULL), _eventListener(NULL),
_scrollToTopSelector(NULL), _eventSelector(NULL)
_scrollToBottomListener(NULL),
_scrollToBottomSelector(NULL),
_scrollToLeftListener(NULL),
_scrollToLeftSelector(NULL),
_scrollToRightListener(NULL),
_scrollToRightSelector(NULL),
_innerContainer(NULL)
{ {
} }
@ -609,58 +603,40 @@ void UIScrollView::checkChildInfo(int handleState,UIWidget* sender,const Point &
void UIScrollView::scrollToTopEvent() void UIScrollView::scrollToTopEvent()
{ {
if (_scrollToTopListener && _scrollToTopSelector) if (_eventListener && _eventSelector)
{ {
(_scrollToTopListener->*_scrollToTopSelector)(this); (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_TOP);
} }
} }
void UIScrollView::scrollToBottomEvent() void UIScrollView::scrollToBottomEvent()
{ {
if (_scrollToBottomListener && _scrollToBottomSelector) if (_eventListener && _eventSelector)
{ {
(_scrollToBottomListener->*_scrollToBottomSelector)(this); (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM);
} }
} }
void UIScrollView::scrollToLeftEvent() void UIScrollView::scrollToLeftEvent()
{ {
if (_scrollToLeftListener && _scrollToLeftSelector) if (_eventListener && _eventSelector)
{ {
(_scrollToLeftListener->*_scrollToLeftSelector)(this); (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_LEFT);
} }
} }
void UIScrollView::scrollToRightEvent() void UIScrollView::scrollToRightEvent()
{ {
if (_scrollToRightListener && _scrollToRightSelector) if (_eventListener && _eventSelector)
{ {
(_scrollToRightListener->*_scrollToRightSelector)(this); (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT);
} }
} }
void UIScrollView::addScrollToTopEvent(Object *target, SEL_ScrollToTopEvent selector) void UIScrollView::addEventListener(Object *target, SEL_ScrollViewEvent selector)
{ {
_scrollToTopListener = target; _eventListener = target;
_scrollToTopSelector = selector; _eventSelector = selector;
}
void UIScrollView::addScrollToBottomEvent(Object *target, SEL_ScrollToBottomEvent selector)
{
_scrollToBottomListener = target;
_scrollToBottomSelector = selector;
}
void UIScrollView::addScrollToLeftEvent(Object *target, SEL_ScrollToLeftEvent selector)
{
_scrollToLeftListener = target;
_scrollToLeftSelector = selector;
}
void UIScrollView::addScrollToRightEvent(Object *target, SEL_ScrollToRightEvent selector)
{
_scrollToRightListener = target;
_scrollToRightSelector = selector;
} }
void UIScrollView::setDirection(SCROLLVIEW_DIR dir) void UIScrollView::setDirection(SCROLLVIEW_DIR dir)
@ -698,4 +674,9 @@ LayoutExecutant* UIScrollView::getLayoutExecutant() const
return _innerContainer->getLayoutExecutant(); return _innerContainer->getLayoutExecutant();
} }
const char* UIScrollView::getDescription() const
{
return "ScrollView";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -46,14 +46,16 @@ enum SCROLLVIEW_MOVE_DIR
SCROLLVIEW_MOVE_DIR_RIGHT, SCROLLVIEW_MOVE_DIR_RIGHT,
}; };
typedef void (Object::*SEL_ScrollToTopEvent)(Object*); typedef enum
typedef void (Object::*SEL_ScrollToBottomEvent)(Object*); {
typedef void (Object::*SEL_ScrollToLeftEvent)(Object*); SCROLLVIEW_EVENT_SCROLL_TO_TOP,
typedef void (Object::*SEL_ScrollToRightEvent)(Object*); SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM,
#define coco_ScrollToTopSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToTopEvent)(&_SELECTOR) SCROLLVIEW_EVENT_SCROLL_TO_LEFT,
#define coco_ScrollToBottomSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToBottomEvent)(&_SELECTOR) SCROLLVIEW_EVENT_SCROLL_TO_RIGHT,
#define coco_ScrollToLeftSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToLeftEvent)(&_SELECTOR) }ScrollviewEventType;
#define coco_ScrollToRightSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToRightEvent)(&_SELECTOR)
typedef void (Object::*SEL_ScrollViewEvent)(Object*, ScrollviewEventType);
#define scrollvieweventselector(_SELECTOR) (SEL_ScrollViewEvent)(&_SELECTOR)
class UIScrollView : public Layout , public UIScrollInterface class UIScrollView : public Layout , public UIScrollInterface
@ -130,24 +132,9 @@ public:
const Size& getInnerContainerSize() const; const Size& getInnerContainerSize() const;
/** /**
* Add call back function called when scrollview scrolled to top. * Add call back function called scrollview event triggered
*/ */
void addScrollToTopEvent(Object* target, SEL_ScrollToTopEvent selector); void addEventListener(Object* target, SEL_ScrollViewEvent selector);
/**
* Add call back function called when scrollview scrolled to bottom.
*/
void addScrollToBottomEvent(Object* target, SEL_ScrollToBottomEvent selector);
/**
* Add call back function called when scrollview scrolled to left.
*/
void addScrollToLeftEvent(Object* target, SEL_ScrollToLeftEvent selector);
/**
* Add call back function called when scrollview scrolled to right.
*/
void addScrollToRightEvent(Object* target, SEL_ScrollToRightEvent selector);
//override "setLayoutExecutant" method of widget. //override "setLayoutExecutant" method of widget.
virtual void setLayoutExecutant(LayoutExecutant* exe); virtual void setLayoutExecutant(LayoutExecutant* exe);
@ -183,6 +170,11 @@ public:
virtual void onTouchLongClicked(const Point &touchPoint); virtual void onTouchLongClicked(const Point &touchPoint);
virtual void update(float dt); virtual void update(float dt);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
virtual bool init(); virtual bool init();
virtual void initRenderer(); virtual void initRenderer();
@ -212,6 +204,8 @@ protected:
virtual void onSizeChanged(); virtual void onSizeChanged();
virtual void setClippingEnabled(bool able){Layout::setClippingEnabled(able);}; virtual void setClippingEnabled(bool able){Layout::setClippingEnabled(able);};
protected: protected:
Layout* _innerContainer;
SCROLLVIEW_DIR _direction; SCROLLVIEW_DIR _direction;
SCROLLVIEW_MOVE_DIR _moveDirection; SCROLLVIEW_MOVE_DIR _moveDirection;
float _touchStartLocation; float _touchStartLocation;
@ -237,16 +231,9 @@ protected:
Point _moveChildPoint; Point _moveChildPoint;
float _childFocusCancelOffset; float _childFocusCancelOffset;
Object* _scrollToTopListener; Object* _eventListener;
SEL_ScrollToTopEvent _scrollToTopSelector; SEL_ScrollViewEvent _eventSelector;
Object* _scrollToBottomListener;
SEL_ScrollToBottomEvent _scrollToBottomSelector;
Object* _scrollToLeftListener;
SEL_ScrollToLeftEvent _scrollToLeftSelector;
Object* _scrollToRightListener;
SEL_ScrollToRightEvent _scrollToRightSelector;
Layout* _innerContainer;
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -431,54 +431,6 @@ void UIButton::setAnchorPoint(const Point &pt)
_titleRenderer->setPosition(Point(_size.width*(0.5f-_anchorPoint.x), _size.height*(0.5f-_anchorPoint.y))); _titleRenderer->setPosition(Point(_size.width*(0.5f-_anchorPoint.x), _size.height*(0.5f-_anchorPoint.y)));
} }
void UIButton::setNormalSpriteFrame(SpriteFrame *frame)
{
if (!frame)
{
return;
}
if (_scale9Enabled)
{
dynamic_cast<Scale9Sprite*>(_buttonNormalRenderer)->setSpriteFrame(frame);
}
else
{
dynamic_cast<Sprite*>(_buttonNormalRenderer)->setDisplayFrame(frame);
}
}
void UIButton::setPressedSpriteFrame(SpriteFrame *frame)
{
if (!frame)
{
return;
}
if (_scale9Enabled)
{
dynamic_cast<Scale9Sprite*>(_buttonClickedRenderer)->setSpriteFrame(frame);
}
else
{
dynamic_cast<Sprite*>(_buttonClickedRenderer)->setDisplayFrame(frame);
}
}
void UIButton::setDisabledSpriteFrame(SpriteFrame *frame)
{
if (!frame)
{
return;
}
if (_scale9Enabled)
{
dynamic_cast<Scale9Sprite*>(_buttonDisableRenderer)->setSpriteFrame(frame);
}
else
{
dynamic_cast<Sprite*>(_buttonDisableRenderer)->setDisplayFrame(frame);
}
}
void UIButton::onSizeChanged() void UIButton::onSizeChanged()
{ {
normalTextureScaleChangedWithSize(); normalTextureScaleChangedWithSize();
@ -657,4 +609,9 @@ void UIButton::setColor(const Color3B &color)
setTitleColor(_titleColor); setTitleColor(_titleColor);
} }
const char* UIButton::getDescription() const
{
return "Button";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -171,9 +171,10 @@ public:
void setTitleFontName(const char* fontName); void setTitleFontName(const char* fontName);
const char* getTitleFontName() const; const char* getTitleFontName() const;
virtual void setNormalSpriteFrame(SpriteFrame* frame); /**
virtual void setPressedSpriteFrame(SpriteFrame* frame); * Returns the "class name" of widget.
virtual void setDisabledSpriteFrame(SpriteFrame* frame); */
virtual const char* getDescription() const;
protected: protected:
virtual bool init(); virtual bool init();
virtual void initRenderer(); virtual void initRenderer();

View File

@ -287,7 +287,7 @@ void UICheckBox::unSelectedEvent()
} }
} }
void UICheckBox::addSelectedStateEvent(Object *target, SEL_SelectedStateEvent selector) void UICheckBox::addEventListener(Object *target, SEL_SelectedStateEvent selector)
{ {
_selectedStateEventListener = target; _selectedStateEventListener = target;
_selectedStateEventSelector = selector; _selectedStateEventSelector = selector;
@ -456,4 +456,9 @@ void UICheckBox::frontCrossDisabledTextureScaleChangedWithSize()
} }
} }
const char* UICheckBox::getDescription() const
{
return "CheckBox";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -134,7 +134,7 @@ public:
virtual void setAnchorPoint(const Point &pt); virtual void setAnchorPoint(const Point &pt);
//add a call back function would called when checkbox is selected or unselected. //add a call back function would called when checkbox is selected or unselected.
void addSelectedStateEvent(Object* target,SEL_SelectedStateEvent selector); void addEventListener(Object* target,SEL_SelectedStateEvent selector);
//override "setFlipX" method of widget. //override "setFlipX" method of widget.
virtual void setFlipX(bool flipX); virtual void setFlipX(bool flipX);
@ -157,6 +157,10 @@ public:
//override "getVirtualRenderer" method of widget. //override "getVirtualRenderer" method of widget.
virtual Node* getVirtualRenderer(); virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
virtual bool init(); virtual bool init();
virtual void initRenderer(); virtual void initRenderer();

View File

@ -368,4 +368,9 @@ void UIImageView::imageTextureScaleChangedWithSize()
} }
} }
const char* UIImageView::getDescription() const
{
return "ImageView";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -107,6 +107,11 @@ public:
void checkDoubleClick(float dt); void checkDoubleClick(float dt);
virtual const Size& getContentSize() const; virtual const Size& getContentSize() const;
virtual Node* getVirtualRenderer(); virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
virtual void initRenderer(); virtual void initRenderer();
virtual void onSizeChanged(); virtual void onSizeChanged();

View File

@ -221,7 +221,11 @@ void UILabel::labelScaleChangedWithSize()
_labelRenderer->setScaleX(scaleX); _labelRenderer->setScaleX(scaleX);
_labelRenderer->setScaleY(scaleY); _labelRenderer->setScaleY(scaleY);
} }
}
const char* UILabel::getDescription() const
{
return "Label";
} }
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -117,6 +117,11 @@ public:
//override "getVirtualRenderer" method of widget. //override "getVirtualRenderer" method of widget.
virtual Node* getVirtualRenderer(); virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
void setTextAreaSize(const Size &size); void setTextAreaSize(const Size &size);
void setTextHorizontalAlignment(TextHAlignment alignment); void setTextHorizontalAlignment(TextHAlignment alignment);
void setTextVerticalAlignment(TextVAlignment alignment); void setTextVerticalAlignment(TextVAlignment alignment);

View File

@ -167,4 +167,9 @@ void UILabelAtlas::labelAtlasScaleChangedWithSize()
} }
} }
const char* UILabelAtlas::getDescription() const
{
return "LabelAtlase";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -87,6 +87,11 @@ public:
//override "getVirtualRenderer" method of widget. //override "getVirtualRenderer" method of widget.
virtual Node* getVirtualRenderer(); virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
virtual void initRenderer(); virtual void initRenderer();
virtual void onSizeChanged(); virtual void onSizeChanged();

View File

@ -126,4 +126,10 @@ void UILabelBMFont::labelBMFontScaleChangedWithSize()
} }
} }
const char* UILabelBMFont::getDescription() const
{
return "LabelBMFont";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -58,6 +58,11 @@ public:
virtual void setAnchorPoint(const Point &pt); virtual void setAnchorPoint(const Point &pt);
virtual const Size& getContentSize() const; virtual const Size& getContentSize() const;
virtual Node* getVirtualRenderer(); virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
virtual void initRenderer(); virtual void initRenderer();
virtual void onSizeChanged(); virtual void onSizeChanged();

View File

@ -331,4 +331,9 @@ void UILoadingBar::setScale9Scale()
dynamic_cast<Scale9Sprite*>(_barRenderer)->setPreferredSize(Size(width, _barRendererTextureSize.height)); dynamic_cast<Scale9Sprite*>(_barRenderer)->setPreferredSize(Size(width, _barRendererTextureSize.height));
} }
const char* UILoadingBar::getDescription() const
{
return "LoadingBar";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -117,6 +117,10 @@ public:
//override "getVirtualRenderer" method of widget. //override "getVirtualRenderer" method of widget.
virtual Node* getVirtualRenderer(); virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
virtual void initRenderer(); virtual void initRenderer();
virtual void onSizeChanged(); virtual void onSizeChanged();

View File

@ -410,7 +410,7 @@ float UISlider::getPercentWithBallPos(float px)
return (((px-(-_barLength/2.0f))/_barLength)*100.0f); return (((px-(-_barLength/2.0f))/_barLength)*100.0f);
} }
void UISlider::addPercentEvent(Object *target, SEL_SlidPercentChangedEvent selector) void UISlider::addEventListener(Object *target, SEL_SlidPercentChangedEvent selector)
{ {
_slidPercentListener = target; _slidPercentListener = target;
_slidPercentSelector = selector; _slidPercentSelector = selector;
@ -535,4 +535,10 @@ void UISlider::onPressStateChangedToDisabled()
_slidBallPressedRenderer->setVisible(false); _slidBallPressedRenderer->setVisible(false);
_slidBallDisabledRenderer->setVisible(true); _slidBallDisabledRenderer->setVisible(true);
} }
const char* UISlider::getDescription() const
{
return "Slider";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -158,7 +158,7 @@ public:
/** /**
* Add call back function called when slider's percent has changed to slider. * Add call back function called when slider's percent has changed to slider.
*/ */
void addPercentEvent(Object* target,SEL_SlidPercentChangedEvent selector); void addEventListener(Object* target,SEL_SlidPercentChangedEvent selector);
//override "onTouchBegan" method of widget. //override "onTouchBegan" method of widget.
virtual bool onTouchBegan(const Point &touchPoint); virtual bool onTouchBegan(const Point &touchPoint);
@ -180,6 +180,11 @@ public:
//override "ignoreContentAdaptWithSize" method of widget. //override "ignoreContentAdaptWithSize" method of widget.
virtual void ignoreContentAdaptWithSize(bool ignore); virtual void ignoreContentAdaptWithSize(bool ignore);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected: protected:
virtual void initRenderer(); virtual void initRenderer();
float getPercentWithBallPos(float location); float getPercentWithBallPos(float location);

View File

@ -271,18 +271,12 @@ bool UICCTextField::getDeleteBackward()
UITextField::UITextField(): UITextField::UITextField():
_textFieldRenderer(NULL),
_touchWidth(0.0f), _touchWidth(0.0f),
_touchHeight(0.0f), _touchHeight(0.0f),
_useTouchArea(false), _useTouchArea(false),
_attachWithIMEListener(NULL), _eventListener(NULL),
_detachWithIMEListener(NULL), _eventSelector(NULL)
_insertTextListener(NULL),
_deleteBackwardListener(NULL),
_attachWithIMESelector(NULL),
_detachWithIMESelector(NULL),
_insertTextSelector(NULL),
_deleteBackwardSelector(NULL),
_textFieldRenderer(NULL)
{ {
} }
@ -475,58 +469,40 @@ void UITextField::setDeleteBackward(bool deleteBackward)
void UITextField::attachWithIMEEvent() void UITextField::attachWithIMEEvent()
{ {
if (_attachWithIMEListener && _attachWithIMESelector) if (_eventListener && _eventSelector)
{ {
(_attachWithIMEListener->*_attachWithIMESelector)(this); (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_ATTACH_WITH_IME);
} }
} }
void UITextField::detachWithIMEEvent() void UITextField::detachWithIMEEvent()
{ {
if (_detachWithIMEListener && _detachWithIMESelector) if (_eventListener && _eventSelector)
{ {
(_detachWithIMEListener->*_detachWithIMESelector)(this); (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DETACH_WITH_IME);
} }
} }
void UITextField::insertTextEvent() void UITextField::insertTextEvent()
{ {
if (_insertTextListener && _insertTextSelector) if (_eventListener && _eventSelector)
{ {
(_insertTextListener->*_insertTextSelector)(this); (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_INDERT_TEXT);
} }
} }
void UITextField::deleteBackwardEvent() void UITextField::deleteBackwardEvent()
{ {
if (_deleteBackwardListener && _deleteBackwardSelector) if (_eventListener && _eventSelector)
{ {
(_deleteBackwardListener->*_deleteBackwardSelector)(this); (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DELETE_BACKWARD);
} }
} }
void UITextField::addAttachWithIMEEvent(Object *target, SEL_TextFieldAttachWithIMEEvent selecor) void UITextField::addEventListener(Object *target, SEL_TextFieldEvent selecor)
{ {
_attachWithIMEListener = target; _eventListener = target;
_attachWithIMESelector = selecor; _eventSelector = selecor;
}
void UITextField::addDetachWithIMEEvent(Object *target, SEL_TextFieldDetachWithIMEEvent selecor)
{
_detachWithIMEListener = target;
_detachWithIMESelector = selecor;
}
void UITextField::addInsertTextEvent(Object *target, SEL_TextFieldInsertTextEvent selecor)
{
_insertTextListener = target;
_insertTextSelector = selecor;
}
void UITextField::addDeleteBackwardEvent(Object *target, SEL_TextFieldDeleteBackwardEvent selecor)
{
_deleteBackwardListener = target;
_deleteBackwardSelector = selecor;
} }
void UITextField::setAnchorPoint(const Point &pt) void UITextField::setAnchorPoint(const Point &pt)
@ -584,4 +560,9 @@ Node* UITextField::getVirtualRenderer()
return _textFieldRenderer; return _textFieldRenderer;
} }
const char* UITextField::getDescription() const
{
return "TextField";
}
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -70,6 +70,8 @@ public:
bool getInsertText(); bool getInsertText();
void setDeleteBackward(bool deleteBackward); void setDeleteBackward(bool deleteBackward);
bool getDeleteBackward(); bool getDeleteBackward();
protected: protected:
bool m_bMaxLengthEnabled; bool m_bMaxLengthEnabled;
int m_nMaxLength; int m_nMaxLength;
@ -82,14 +84,16 @@ protected:
}; };
typedef void (Object::*SEL_TextFieldAttachWithIMEEvent)(Object*); typedef enum
#define coco_TextField_AttachWithIME_selector(_SELECTOR) (SEL_TextFieldAttachWithIMEEvent)(&_SELECTOR) {
typedef void (Object::*SEL_TextFieldDetachWithIMEEvent)(Object*); TEXTFIELD_EVENT_ATTACH_WITH_IME,
#define coco_TextField_DetachWithIME_selector(_SELECTOR) (SEL_TextFieldDetachWithIMEEvent)(&_SELECTOR) TEXTFIELD_EVENT_DETACH_WITH_IME,
typedef void (Object::*SEL_TextFieldInsertTextEvent)(Object*); TEXTFIELD_EVENT_INDERT_TEXT,
#define coco_TextField_InsertText_selector(_SELECTOR) (SEL_TextFieldInsertTextEvent)(&_SELECTOR) TEXTFIELD_EVENT_DELETE_BACKWARD,
typedef void (Object::*SEL_TextFieldDeleteBackwardEvent)(Object*); }TextFiledEventType;
#define coco_TextField_DeleteBackward_selector(_SELECTOR) (SEL_TextFieldDeleteBackwardEvent)(&_SELECTOR)
typedef void (Object::*SEL_TextFieldEvent)(Object*, TextFiledEventType);
#define textfieldeventselector(_SELECTOR) (SEL_TextFieldEvent)(&_SELECTOR)
//class UITextField : public UIWidget //class UITextField : public UIWidget
class UITextField : public UIWidget class UITextField : public UIWidget
@ -124,14 +128,14 @@ public:
void setInsertText(bool insertText); void setInsertText(bool insertText);
bool getDeleteBackward(); bool getDeleteBackward();
void setDeleteBackward(bool deleteBackward); void setDeleteBackward(bool deleteBackward);
void addAttachWithIMEEvent(Object* target, SEL_TextFieldAttachWithIMEEvent selecor); void addEventListener(Object* target, SEL_TextFieldEvent selecor);
void addDetachWithIMEEvent(Object* target, SEL_TextFieldDetachWithIMEEvent selecor);
void addInsertTextEvent(Object* target, SEL_TextFieldInsertTextEvent selecor);
void addDeleteBackwardEvent(Object* target, SEL_TextFieldDeleteBackwardEvent selecor);
virtual void setAnchorPoint(const Point &pt); virtual void setAnchorPoint(const Point &pt);
virtual void setColor(const Color3B &color); virtual void setColor(const Color3B &color);
virtual void setOpacity(int opacity); virtual void setOpacity(int opacity);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
/*compatibel*/ /*compatibel*/
/** /**
* These methods will be removed * These methods will be removed
@ -150,21 +154,15 @@ protected:
virtual void onSizeChanged(); virtual void onSizeChanged();
void textfieldRendererScaleChangedWithSize(); void textfieldRendererScaleChangedWithSize();
protected: protected:
UICCTextField* _textFieldRenderer;
float _touchWidth; float _touchWidth;
float _touchHeight; float _touchHeight;
bool _useTouchArea; bool _useTouchArea;
Object* _attachWithIMEListener; Object* _eventListener;
Object* _detachWithIMEListener; SEL_TextFieldEvent _eventSelector;
Object* _insertTextListener;
Object* _deleteBackwardListener;
SEL_TextFieldAttachWithIMEEvent _attachWithIMESelector;
SEL_TextFieldDetachWithIMEEvent _detachWithIMESelector;
SEL_TextFieldInsertTextEvent _insertTextSelector;
SEL_TextFieldDeleteBackwardEvent _deleteBackwardSelector;
UICCTextField* _textFieldRenderer;
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -54,7 +54,7 @@ bool UICheckBoxTest::init()
"cocosgui/check_box_active_disable.png"); "cocosgui/check_box_active_disable.png");
checkBox->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); checkBox->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
checkBox->addSelectedStateEvent(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent)); checkBox->addEventListener(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent));
// checkBox->addSelectEvent(this, coco_selectselector(UICheckBoxTest::selectedEvent)); // checkBox->addSelectEvent(this, coco_selectselector(UICheckBoxTest::selectedEvent));
m_pUiLayer->addWidget(checkBox); m_pUiLayer->addWidget(checkBox);

View File

@ -57,14 +57,7 @@ bool UIDragPanelTest::init()
(backgroundSize.width - dragPanel->getSize().width) / 2, (backgroundSize.width - dragPanel->getSize().width) / 2,
(widgetSize.height - backgroundSize.height) / 2 + (widgetSize.height - backgroundSize.height) / 2 +
(backgroundSize.height - dragPanel->getSize().height) / 2)); (backgroundSize.height - dragPanel->getSize().height) / 2));
dragPanel->addBerthToLeftBottomEvent(this, coco_DragPane_BerthToLeftBottom_selector(UIDragPanelTest::berthToLeftBottomEvent)); dragPanel->addEventListener(this, dragpaneleventselector(UIDragPanelTest::dragPanelEvent));
dragPanel->addBerthToLeftTopEvent(this, coco_DragPanel_BerthToLeftTop_selector(UIDragPanelTest::berthToLeftTopEvent));
dragPanel->addBerthToRightBottomEvent(this, coco_DragPanel_BerthToRightBottom_selector(UIDragPanelTest::berthToRightBottomEvent));
dragPanel->addBerthToRightTopEvent(this, coco_DragPanel_BerthToRightTop_selector(UIDragPanelTest::berthToRightTopEvent));
dragPanel->addBerthToLeftEvent(this, coco_DragPanel_BerthToLeft_selector(UIDragPanelTest::berthToLeftEvent));
dragPanel->addBerthToTopEvent(this, coco_DragPanel_BerthToTop_selector(UIDragPanelTest::berthToTopEvent));
dragPanel->addBerthToRightEvent(this, coco_DragPanel_BerthToRight_selector(UIDragPanelTest::berthToRightEvent));
dragPanel->addBerthToBottomEvent(this, coco_DragPanel_BerthToBottom_selector(UIDragPanelTest::berthToBottomEvent));
UIImageView* imageView = UIImageView::create(); UIImageView* imageView = UIImageView::create();
imageView->setTouchEnabled(true); imageView->setTouchEnabled(true);
@ -82,44 +75,45 @@ bool UIDragPanelTest::init()
return false; return false;
} }
void UIDragPanelTest::berthToLeftBottomEvent(Object *pSender) void UIDragPanelTest::dragPanelEvent(Object *pSender, DragPanelEventType type)
{ {
switch (type)
{
case DRAGPANEL_EVENT_BERTH_LEFTBOTTOM:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left Bottom")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left Bottom")->getCString());
} break;
void UIDragPanelTest::berthToLeftTopEvent(Object *pSender) case DRAGPANEL_EVENT_BERTH_LFETTOP:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left Top")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left Top")->getCString());
} break;
void UIDragPanelTest::berthToRightBottomEvent(Object *pSender) case DRAGPANEL_EVENT_BERTH_RIGHTBOTTOM:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right Bottom")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right Bottom")->getCString());
} break;
void UIDragPanelTest::berthToRightTopEvent(Object *pSender) case DRAGPANEL_EVENT_BERTH_RIGHTTOP:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right Top")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right Top")->getCString());
} break;
void UIDragPanelTest::berthToLeftEvent(Object* pSender) case DRAGPANEL_EVENT_BERTH_LEFT:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left")->getCString());
} break;
void UIDragPanelTest::berthToTopEvent(Object *pSender) case DRAGPANEL_EVENT_BERTH_TOP:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Top")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Top")->getCString());
} break;
void UIDragPanelTest::berthToRightEvent(Object *pSender) case DRAGPANEL_EVENT_BERTH_RIGHT:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right")->getCString());
} break;
void UIDragPanelTest::berthToBottomEvent(Object *pSender) case DRAGPANEL_EVENT_BERTH_BOTTOM:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Bottom")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Bottom")->getCString());
break;
default:
break;
}
} }
// UIDragPanelTest_Bounce // UIDragPanelTest_Bounce
@ -171,14 +165,7 @@ bool UIDragPanelTest_Bounce::init()
(backgroundSize.width - dragPanel->getSize().width) / 2, (backgroundSize.width - dragPanel->getSize().width) / 2,
(widgetSize.height - backgroundSize.height) / 2 + (widgetSize.height - backgroundSize.height) / 2 +
(backgroundSize.height - dragPanel->getSize().height) / 2)); (backgroundSize.height - dragPanel->getSize().height) / 2));
dragPanel->addBounceToLeftBottomEvent(this, coco_DragPanel_BounceToLeftBottom_selector(UIDragPanelTest_Bounce::bounceToLeftBottomEvent)); dragPanel->addEventListener(this, dragpaneleventselector(UIDragPanelTest_Bounce::dragPanelEvent));
dragPanel->addBounceToLeftTopEvent(this, coco_DragPanel_BounceToLeftTop_selector(UIDragPanelTest_Bounce::bounceToLeftTopEvent));
dragPanel->addBounceToRightBottomEvent(this, coco_DragPanel_BounceToRightBottom_selector(UIDragPanelTest_Bounce::bounceToRightBottomEvent));
dragPanel->addBounceToRightTopEvent(this, coco_DragPanel_BounceToRightTop_selector(UIDragPanelTest_Bounce::bounceToRightTopEvent));
dragPanel->addBounceToLeftEvent(this, coco_DragPanel_BounceToLeft_selector(UIDragPanelTest_Bounce::bounceToLeftEvent));
dragPanel->addBounceToTopEvent(this, coco_DragPanel_BounceToTop_selector(UIDragPanelTest_Bounce::bounceToTopEvent));
dragPanel->addBounceToRightEvent(this, coco_DragPanel_BounceToRight_selector(UIDragPanelTest_Bounce::bounceToRightEvent));
dragPanel->addBounceToBottomEvent(this, coco_DragPanel_BounceToBottom_selector(UIDragPanelTest_Bounce::bounceToBottomEvent));
UIImageView* imageView = UIImageView::create(); UIImageView* imageView = UIImageView::create();
imageView->setTouchEnabled(true); imageView->setTouchEnabled(true);
@ -197,42 +184,43 @@ bool UIDragPanelTest_Bounce::init()
return false; return false;
} }
void UIDragPanelTest_Bounce::bounceToLeftBottomEvent(Object *pSender) void UIDragPanelTest_Bounce::dragPanelEvent(Object *pSender, DragPanelEventType type)
{ {
switch (type)
{
case DRAGPANEL_EVENT_BOUNCE_LEFTBOTTOM:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left Bottom")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left Bottom")->getCString());
} break;
void UIDragPanelTest_Bounce::bounceToLeftTopEvent(Object *pSender) case DRAGPANEL_EVENT_BOUNCE_LEFTTOP:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left Top")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left Top")->getCString());
} break;
void UIDragPanelTest_Bounce::bounceToRightBottomEvent(Object *pSender) case DRAGPANEL_EVENT_BOUNCE_RIGHTBOTTOM:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right Bottom")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right Bottom")->getCString());
} break;
void UIDragPanelTest_Bounce::bounceToRightTopEvent(Object *pSender) case DRAGPANEL_EVENT_BOUNCE_RIGHTTOP:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right Top")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right Top")->getCString());
} break;
void UIDragPanelTest_Bounce::bounceToLeftEvent(Object *pSender) case DRAGPANEL_EVENT_BOUNCE_LEFT:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left")->getCString());
} break;
void UIDragPanelTest_Bounce::bounceToTopEvent(Object *pSender) case DRAGPANEL_EVENT_BOUNCE_TOP:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Top")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Top")->getCString());
} break;
void UIDragPanelTest_Bounce::bounceToRightEvent(Object *pSender) case DRAGPANEL_EVENT_BOUNCE_RIGHT:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right")->getCString());
} break;
void UIDragPanelTest_Bounce::bounceToBottomEvent(Object *pSender) case DRAGPANEL_EVENT_BOUNCE_BOTTOM:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Bottom")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Bottom")->getCString());
break;
default:
break;
}
} }

View File

@ -33,14 +33,7 @@ public:
UIDragPanelTest(); UIDragPanelTest();
~UIDragPanelTest(); ~UIDragPanelTest();
bool init(); bool init();
void berthToLeftBottomEvent(Object* pSender); void dragPanelEvent(Object* pSender, DragPanelEventType type);
void berthToLeftTopEvent(Object* pSender);
void berthToRightBottomEvent(Object* pSender);
void berthToRightTopEvent(Object* pSender);
void berthToLeftEvent(Object* pSender);
void berthToTopEvent(Object* pSender);
void berthToRightEvent(Object* pSender);
void berthToBottomEvent(Object* pSender);
protected: protected:
UI_SCENE_CREATE_FUNC(UIDragPanelTest) UI_SCENE_CREATE_FUNC(UIDragPanelTest)
@ -53,14 +46,7 @@ public:
UIDragPanelTest_Bounce(); UIDragPanelTest_Bounce();
~UIDragPanelTest_Bounce(); ~UIDragPanelTest_Bounce();
bool init(); bool init();
void bounceToLeftBottomEvent(Object* pSender); void dragPanelEvent(Object* pSender, DragPanelEventType type);
void bounceToRightBottomEvent(Object* pSender);
void bounceToLeftTopEvent(Object* pSender);
void bounceToRightTopEvent(Object* pSender);
void bounceToLeftEvent(Object* pSender);
void bounceToTopEvent(Object* pSender);
void bounceToRightEvent(Object* pSender);
void bounceToBottomEvent(Object* pSender);
protected: protected:
UI_SCENE_CREATE_FUNC(UIDragPanelTest_Bounce) UI_SCENE_CREATE_FUNC(UIDragPanelTest_Bounce)

View File

@ -90,8 +90,7 @@ bool UIListViewTest_Vertical::init()
listView->addChild(layout); listView->addChild(layout);
} }
listView->addInitChildEvent(this, coco_ListView_InitChild_selector(UIListViewTest_Vertical::initChildEvent)); listView->addEventListenter(this, listvieweventselector(UIListViewTest_Vertical::listViewEvent));
listView->addUpdateChildEvent(this, coco_ListView_UpdateChild_selector(UIListViewTest_Vertical::updateChildEvent));
listView->initChildWithDataLength(m_array->count()); listView->initChildWithDataLength(m_array->count());
m_pUiLayer->addWidget(listView); m_pUiLayer->addWidget(listView);
@ -101,8 +100,12 @@ bool UIListViewTest_Vertical::init()
return false; return false;
} }
void UIListViewTest_Vertical::initChildEvent(Object *pSender) void UIListViewTest_Vertical::listViewEvent(Object *pSender, ListViewEventType type)
{ {
switch (type)
{
case LISTVIEW_EVENT_INIT_CHILD:
{
String* ccstr = static_cast<String*>(m_array->getObjectAtIndex(m_nCount)); String* ccstr = static_cast<String*>(m_array->getObjectAtIndex(m_nCount));
UIListView* list = dynamic_cast<UIListView*>(pSender); UIListView* list = dynamic_cast<UIListView*>(pSender);
@ -111,10 +114,11 @@ void UIListViewTest_Vertical::initChildEvent(Object *pSender)
textButton->setTitleText(ccstr->getCString()); textButton->setTitleText(ccstr->getCString());
m_nCount++; m_nCount++;
} }
break;
void UIListViewTest_Vertical::updateChildEvent(Object *pSender) case LISTVIEW_EVENT_UPDATE_CHILD:
{ {
UIListView* list = dynamic_cast<UIListView*>(pSender); UIListView* list = dynamic_cast<UIListView*>(pSender);
int index = list->getUpdateDataIndex(); int index = list->getUpdateDataIndex();
@ -128,6 +132,12 @@ void UIListViewTest_Vertical::updateChildEvent(Object *pSender)
UIButton* textButton = dynamic_cast<UIButton*>(layout->getChildByName("TextButton")); UIButton* textButton = dynamic_cast<UIButton*>(layout->getChildByName("TextButton"));
textButton->setTitleText(ccstr->getCString()); textButton->setTitleText(ccstr->getCString());
list->setUpdateSuccess(true); list->setUpdateSuccess(true);
}
break;
default:
break;
}
} }
// UIListViewTest_Horizontal // UIListViewTest_Horizontal
@ -211,8 +221,7 @@ bool UIListViewTest_Horizontal::init()
listView->addChild(layout); listView->addChild(layout);
} }
listView->addInitChildEvent(this, coco_ListView_InitChild_selector(UIListViewTest_Horizontal::initChildEvent)); listView->addEventListenter(this, listvieweventselector(UIListViewTest_Horizontal::listViewEvent));
listView->addUpdateChildEvent(this, coco_ListView_UpdateChild_selector(UIListViewTest_Horizontal::updateChildEvent));
listView->initChildWithDataLength(m_array->count()); listView->initChildWithDataLength(m_array->count());
m_pUiLayer->addWidget(listView); m_pUiLayer->addWidget(listView);
@ -222,8 +231,12 @@ bool UIListViewTest_Horizontal::init()
return false; return false;
} }
void UIListViewTest_Horizontal::initChildEvent(Object *pSender) void UIListViewTest_Horizontal::listViewEvent(Object *pSender, ListViewEventType type)
{ {
switch (type)
{
case LISTVIEW_EVENT_INIT_CHILD:
{
String* ccstr = static_cast<String*>(m_array->getObjectAtIndex(m_nCount)); String* ccstr = static_cast<String*>(m_array->getObjectAtIndex(m_nCount));
UIListView* list = dynamic_cast<UIListView*>(pSender); UIListView* list = dynamic_cast<UIListView*>(pSender);
@ -232,10 +245,11 @@ void UIListViewTest_Horizontal::initChildEvent(Object *pSender)
textButton->setTitleText(ccstr->getCString()); textButton->setTitleText(ccstr->getCString());
m_nCount++; m_nCount++;
} }
break;
void UIListViewTest_Horizontal::updateChildEvent(Object *pSender) case LISTVIEW_EVENT_UPDATE_CHILD:
{ {
UIListView* list = dynamic_cast<UIListView*>(pSender); UIListView* list = dynamic_cast<UIListView*>(pSender);
int index = list->getUpdateDataIndex(); int index = list->getUpdateDataIndex();
@ -249,4 +263,10 @@ void UIListViewTest_Horizontal::updateChildEvent(Object *pSender)
UIButton* textButton = dynamic_cast<UIButton*>(layout->getChildByName("TextButton")); UIButton* textButton = dynamic_cast<UIButton*>(layout->getChildByName("TextButton"));
textButton->setTitleText(ccstr->getCString()); textButton->setTitleText(ccstr->getCString());
list->setUpdateSuccess(true); list->setUpdateSuccess(true);
}
break;
default:
break;
}
} }

View File

@ -33,8 +33,7 @@ public:
UIListViewTest_Vertical(); UIListViewTest_Vertical();
~UIListViewTest_Vertical(); ~UIListViewTest_Vertical();
bool init(); bool init();
void initChildEvent(Object* pSender); void listViewEvent(Object* pSender, ListViewEventType type);
void updateChildEvent(Object* pSender);
protected: protected:
UI_SCENE_CREATE_FUNC(UIListViewTest_Vertical) UI_SCENE_CREATE_FUNC(UIListViewTest_Vertical)
@ -50,8 +49,7 @@ public:
UIListViewTest_Horizontal(); UIListViewTest_Horizontal();
~UIListViewTest_Horizontal(); ~UIListViewTest_Horizontal();
bool init(); bool init();
void initChildEvent(Object* pSender); void listViewEvent(Object* pSender, ListViewEventType type);
void updateChildEvent(Object* pSender);
protected: protected:
UI_SCENE_CREATE_FUNC(UIListViewTest_Horizontal) UI_SCENE_CREATE_FUNC(UIListViewTest_Horizontal)

View File

@ -79,8 +79,7 @@ bool UIPageViewTest::init()
pageView->addPage(layout); pageView->addPage(layout);
} }
pageView->addEventListener(this, pagevieweventselector(UIPageViewTest::pageViewEvent));
pageView->addPageTurningEvent(this, coco_PageView_PageTurning_selector(UIPageViewTest::pageTurningEvent));
m_pUiLayer->addWidget(pageView); m_pUiLayer->addWidget(pageView);
@ -89,10 +88,19 @@ bool UIPageViewTest::init()
return false; return false;
} }
void UIPageViewTest::pageTurningEvent(Object *pSender) void UIPageViewTest::pageViewEvent(Object *pSender, PageViewEventType type)
{ {
switch (type)
{
case PAGEVIEW_EVENT_TURNING:
{
UIPageView* pageView = dynamic_cast<UIPageView*>(pSender); UIPageView* pageView = dynamic_cast<UIPageView*>(pSender);
CCLOG("page = %d", pageView->getCurPageIndex());
m_pDisplayValueLabel->setText(CCString::createWithFormat("page = %d", pageView->getCurPageIndex() + 1)->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("page = %d", pageView->getCurPageIndex() + 1)->getCString());
}
break;
default:
break;
}
} }

View File

@ -34,7 +34,7 @@ public:
~UIPageViewTest(); ~UIPageViewTest();
bool init(); bool init();
void pageTurningEvent(Object* pSender); void pageViewEvent(Object* pSender, PageViewEventType type);
protected: protected:
UI_SCENE_CREATE_FUNC(UIPageViewTest) UI_SCENE_CREATE_FUNC(UIPageViewTest)

View File

@ -2,6 +2,7 @@
#include "cocos-ext.h" #include "cocos-ext.h"
#include "UIScene.h" #include "UIScene.h"
#include "UISceneManager.h" #include "UISceneManager.h"
#include "../ExtensionsTest.h"
UIScene::UIScene() UIScene::UIScene()
: m_pSceneTitle(NULL) : m_pSceneTitle(NULL)
@ -40,13 +41,16 @@ bool UIScene::init()
UIButton *right_button = dynamic_cast<UIButton*>(m_pUiLayer->getWidgetByName("right_Button")); UIButton *right_button = dynamic_cast<UIButton*>(m_pUiLayer->getWidgetByName("right_Button"));
right_button->addTouchEventListener(this, toucheventselector(UIScene::nextCallback)); right_button->addTouchEventListener(this, toucheventselector(UIScene::nextCallback));
// exit button
UIButton* exit_button = UIButton::create(); UILabel* mainMenuLabel = UILabel::create();
exit_button->setTouchEnabled(true); mainMenuLabel->setText("MainMenu");
exit_button->loadTextures("CloseNormal.png", "CloseSelected.png", ""); mainMenuLabel->setFontSize(20);
exit_button->setPosition(Point(m_pUiLayer->getContentSize().width - exit_button->getContentSize().width, exit_button->getContentSize().height)); mainMenuLabel->setTouchScaleChangeEnabled(true);
exit_button->addTouchEventListener(this, toucheventselector(UIScene::menuCloseCallback)); mainMenuLabel->setPosition(Point(430,30));
m_pUiLayer->addWidget(exit_button); mainMenuLabel->setTouchEnabled(true);
mainMenuLabel->addTouchEventListener(this, toucheventselector(UIScene::menuCloseCallback));
m_pUiLayer->addWidget(mainMenuLabel);
return true; return true;
} }
@ -57,12 +61,10 @@ void UIScene::menuCloseCallback(Object* pSender, TouchEventType type)
{ {
if (type == TOUCH_EVENT_ENDED) if (type == TOUCH_EVENT_ENDED)
{ {
CCDirector::getInstance()->end(); auto scene = new ExtensionsTestScene();
scene->runThisTest();
scene->release();
} }
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
} }
void UIScene::previousCallback(Object* sender, TouchEventType type) void UIScene::previousCallback(Object* sender, TouchEventType type)

View File

@ -52,7 +52,7 @@ bool UISliderTest::init()
slider->loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", ""); slider->loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", "");
slider->loadProgressBarTexture("cocosgui/sliderProgress.png"); slider->loadProgressBarTexture("cocosgui/sliderProgress.png");
slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
slider->addPercentEvent(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent)); slider->addEventListener(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent));
m_pUiLayer->addWidget(slider); m_pUiLayer->addWidget(slider);
return true; return true;
@ -116,7 +116,7 @@ bool UISliderTest_Scale9::init()
slider->setCapInsets(Rect(0, 0, 0, 0)); slider->setCapInsets(Rect(0, 0, 0, 0));
slider->setSize(Size(250, 10)); slider->setSize(Size(250, 10));
slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
slider->addPercentEvent(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent)); slider->addEventListener(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent));
m_pUiLayer->addWidget(slider); m_pUiLayer->addWidget(slider);
return true; return true;

View File

@ -51,10 +51,7 @@ bool UITextFieldTest::init()
textField->setFontSize(30); textField->setFontSize(30);
textField->setPlaceHolder("input words here"); textField->setPlaceHolder("input words here");
textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
textField->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(UITextFieldTest::attachWithIMEEvent)); textField->addEventListener(this, textfieldeventselector(UITextFieldTest::textFieldEvent));
textField->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(UITextFieldTest::detachWithIMEEvent));
textField->addInsertTextEvent(this, coco_TextField_InsertText_selector(UITextFieldTest::insertTextEvent));
textField->addDeleteBackwardEvent(this, coco_TextField_DeleteBackward_selector(UITextFieldTest::deleteBackwardEvent));
m_pUiLayer->addWidget(textField); m_pUiLayer->addWidget(textField);
return true; return true;
@ -62,31 +59,40 @@ bool UITextFieldTest::init()
return false; return false;
} }
void UITextFieldTest::attachWithIMEEvent(Object *pSender) void UITextFieldTest::textFieldEvent(Object *pSender, TextFiledEventType type)
{ {
switch (type)
{
case TEXTFIELD_EVENT_ATTACH_WITH_IME:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender); UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize(); Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.225, textField->runAction(CCMoveTo::create(0.225,
Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME")->getCString());
} }
break;
void UITextFieldTest::detachWithIMEEvent(Object* pSender) case TEXTFIELD_EVENT_DETACH_WITH_IME:
{ {
UITextField* textField = dynamic_cast<UITextField*>(pSender); UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize(); Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME")->getCString());
} }
break;
void UITextFieldTest::insertTextEvent(Object *pSender) case TEXTFIELD_EVENT_INDERT_TEXT:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words")->getCString());
} break;
void UITextFieldTest::deleteBackwardEvent(Object *pSender) case TEXTFIELD_EVENT_DELETE_BACKWARD:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word")->getCString());
break;
default:
break;
}
} }
// UITextFieldTest_MaxLength // UITextFieldTest_MaxLength
@ -133,10 +139,7 @@ bool UITextFieldTest_MaxLength::init()
textField->setFontSize(30); textField->setFontSize(30);
textField->setPlaceHolder("input words here"); textField->setPlaceHolder("input words here");
textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
textField->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(UITextFieldTest_MaxLength::attachWithIMEEvent)); textField->addEventListener(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent));
textField->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(UITextFieldTest_MaxLength::detachWithIMEEvent));
textField->addInsertTextEvent(this, coco_TextField_InsertText_selector(UITextFieldTest_MaxLength::insertTextEvent));
textField->addDeleteBackwardEvent(this, coco_TextField_DeleteBackward_selector(UITextFieldTest_MaxLength::deleteBackwardEvent));
m_pUiLayer->addWidget(textField); m_pUiLayer->addWidget(textField);
return true; return true;
@ -144,33 +147,46 @@ bool UITextFieldTest_MaxLength::init()
return false; return false;
} }
void UITextFieldTest_MaxLength::attachWithIMEEvent(Object *pSender) void UITextFieldTest_MaxLength::textFieldEvent(Object *pSender, TextFiledEventType type)
{ {
switch (type)
{
case TEXTFIELD_EVENT_ATTACH_WITH_IME:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender); UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize(); Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.225, textField->runAction(CCMoveTo::create(0.225,
Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME max length %d", textField->getMaxLength())->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME max length %d", textField->getMaxLength())->getCString());
} }
break;
void UITextFieldTest_MaxLength::detachWithIMEEvent(Object* pSender) case TEXTFIELD_EVENT_DETACH_WITH_IME:
{ {
UITextField* textField = dynamic_cast<UITextField*>(pSender); UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize(); Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME max length %d", textField->getMaxLength())->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME max length %d", textField->getMaxLength())->getCString());
} }
break;
void UITextFieldTest_MaxLength::insertTextEvent(Object *pSender) case TEXTFIELD_EVENT_INDERT_TEXT:
{ {
UITextField* textField = dynamic_cast<UITextField*>(pSender); UITextField* textField = dynamic_cast<UITextField*>(pSender);
m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words max length %d", textField->getMaxLength())->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words max length %d", textField->getMaxLength())->getCString());
} }
break;
void UITextFieldTest_MaxLength::deleteBackwardEvent(Object *pSender) case TEXTFIELD_EVENT_DELETE_BACKWARD:
{ {
UITextField* textField = dynamic_cast<UITextField*>(pSender); UITextField* textField = dynamic_cast<UITextField*>(pSender);
m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word max length %d", textField->getMaxLength())->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word max length %d", textField->getMaxLength())->getCString());
}
break;
default:
break;
}
} }
// UITextFieldTest_Password // UITextFieldTest_Password
@ -217,10 +233,7 @@ bool UITextFieldTest_Password::init()
textField->setFontSize(30); textField->setFontSize(30);
textField->setPlaceHolder("input password here"); textField->setPlaceHolder("input password here");
textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
textField->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(UITextFieldTest_Password::attachWithIMEEvent)); textField->addEventListener(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent));
textField->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(UITextFieldTest_Password::detachWithIMEEvent));
textField->addInsertTextEvent(this, coco_TextField_InsertText_selector(UITextFieldTest_Password::insertTextEvent));
textField->addDeleteBackwardEvent(this, coco_TextField_DeleteBackward_selector(UITextFieldTest_Password::deleteBackwardEvent));
m_pUiLayer->addWidget(textField); m_pUiLayer->addWidget(textField);
return true; return true;
@ -228,29 +241,38 @@ bool UITextFieldTest_Password::init()
return false; return false;
} }
void UITextFieldTest_Password::attachWithIMEEvent(Object *pSender) void UITextFieldTest_Password::textFieldEvent(Object *pSender, TextFiledEventType type)
{ {
switch (type)
{
case TEXTFIELD_EVENT_ATTACH_WITH_IME:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender); UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize(); Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.225, textField->runAction(CCMoveTo::create(0.225,
Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2))); Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME password")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME password")->getCString());
} }
break;
void UITextFieldTest_Password::detachWithIMEEvent(Object* pSender) case TEXTFIELD_EVENT_DETACH_WITH_IME:
{ {
UITextField* textField = dynamic_cast<UITextField*>(pSender); UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize(); Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f))); textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME password")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME password")->getCString());
} }
break;
void UITextFieldTest_Password::insertTextEvent(Object *pSender) case TEXTFIELD_EVENT_INDERT_TEXT:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words password")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words password")->getCString());
} break;
void UITextFieldTest_Password::deleteBackwardEvent(Object *pSender) case TEXTFIELD_EVENT_DELETE_BACKWARD:
{
m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word password")->getCString()); m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word password")->getCString());
break;
default:
break;
}
} }

View File

@ -33,10 +33,7 @@ public:
UITextFieldTest(); UITextFieldTest();
~UITextFieldTest(); ~UITextFieldTest();
bool init(); bool init();
void attachWithIMEEvent(Object* pSender); void textFieldEvent(Object* pSender, TextFiledEventType type);
void detachWithIMEEvent(Object* pSender);
void insertTextEvent(Object* pSender);
void deleteBackwardEvent(Object* pSender);
protected: protected:
UI_SCENE_CREATE_FUNC(UITextFieldTest) UI_SCENE_CREATE_FUNC(UITextFieldTest)
@ -49,10 +46,7 @@ public:
UITextFieldTest_MaxLength(); UITextFieldTest_MaxLength();
~UITextFieldTest_MaxLength(); ~UITextFieldTest_MaxLength();
bool init(); bool init();
void attachWithIMEEvent(Object* pSender); void textFieldEvent(Object* pSender, TextFiledEventType type);
void detachWithIMEEvent(Object* pSender);
void insertTextEvent(Object* pSender);
void deleteBackwardEvent(Object* pSender);
protected: protected:
UI_SCENE_CREATE_FUNC(UITextFieldTest_MaxLength) UI_SCENE_CREATE_FUNC(UITextFieldTest_MaxLength)
@ -65,10 +59,7 @@ public:
UITextFieldTest_Password(); UITextFieldTest_Password();
~UITextFieldTest_Password(); ~UITextFieldTest_Password();
bool init(); bool init();
void attachWithIMEEvent(Object* pSender); void textFieldEvent(Object* pSender, TextFiledEventType type);
void detachWithIMEEvent(Object* pSender);
void insertTextEvent(Object* pSender);
void deleteBackwardEvent(Object* pSender);
protected: protected:
UI_SCENE_CREATE_FUNC(UITextFieldTest_Password) UI_SCENE_CREATE_FUNC(UITextFieldTest_Password)