void CCTableViewCreator::endNode(CCNode* pNode) { CCTableView* pTableView = (CCTableView*)pNode; pTableView->initWithViewSize(ccXmlAttrParse::toSize(mAttrMap["view_size"].c_str()), NULL); pTableView->setDataSource(dynamic_cast<CCTableViewDataSource*>(mRootDelegate)); pTableView->setDelegate(dynamic_cast<CCTableViewDelegate*>(mRootDelegate)); CCNodeCreator::setAttribute(pNode); }
CCTableView* CCTableView::create(CCTableViewDataSource* dataSource, CCSize size, CCNode *container) { CCTableView *table = new CCTableView(); table->initWithViewSize(size, container); table->autorelease(); table->setDataSource(dataSource); table->_updateContentSize(); return table; }
KDbool TestList::init ( KDvoid ) { if ( !CCLayer::initWithVisibleViewport ( ) ) { return KD_FALSE; } const CCSize& tLyrSize = this->getContentSize ( ); CCLayerGradient* pBG = CCLayerGradient::create ( ccc4 ( 52, 84, 236, 200 ), ccc4 ( 149, 0, 202, 200 ) ); pBG->setContentSize ( tLyrSize ); this->addChild ( pBG, -10 ); CCSprite* pBottomLeft = CCSprite::create ( "ccb/jungle-left.png" ); this->addChild ( pBottomLeft, 10 ); pBottomLeft->setScale ( 1.5f ); pBottomLeft->setOpacity ( 210 ); pBottomLeft->setPositionWithParent ( kCCAlignmentBottomLeft ); CCSprite* pBottomRight = CCSprite::create ( "ccb/jungle-right.png" ); this->addChild ( pBottomRight, 10 ); pBottomRight->setScale ( 1.5f ); pBottomRight->setOpacity ( 210 ); pBottomRight->setPositionWithParent ( kCCAlignmentBottomRight ); CCMenuItemImage* pQuit = CCMenuItemImage::create ( "xm_supports/CloseNormal.png", "xm_supports/CloseSelected.png", this, menu_selector ( TestList::onQuit ) ); pQuit->setScale ( 1.2f ); pQuit->setPosition ( this, kCCAlignmentTopRight, ccp ( 10, 10 ) ); this->addChild ( CCMenu::createWithItem ( pQuit ), 10 ); CCTableView* pTableView = CCTableView::create ( this, ccs ( tLyrSize.cx, tLyrSize.cy - 20.f ) ); this->addChild ( pTableView ); pTableView->setDelegate ( this ); pTableView->setDataSource ( this ); pTableView->setPosition ( ccp ( 0, 10 ) ); if ( s_tPrevPosition.x != -1 ) { pTableView->setContentOffset ( s_tPrevPosition ); } CCMenuItemFont::setFontSize ( 30 ); CCMenuItemFont::setFontName ( "fonts/ThonburiBold.ttf" ); return KD_TRUE; }
static int tolua_Cocos2dx_CCTableView_setDataSource(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCTableView",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { CCTableView* self = (CCTableView*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDataSource'", NULL); #endif LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource(); if (NULL == dataSource) return 0; CCDictionary* userDict = static_cast<CCDictionary*>(self->getUserObject()); if (NULL == userDict) { userDict = new CCDictionary(); if (NULL == userDict) return 0; self->setUserObject(userDict); userDict->release(); } userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE); self->setDataSource(dataSource); dataSource->release(); return 0; } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setDataSource'.",&tolua_err); return 0; #endif }