CCTableGridCell* CCTableGridBackPackTest::tableviewDataSource(CCTableGrid* pTable, CCTableGridCell* pCell, unsigned int idx) { CCButton* pIconButton = NULL; if(!pCell) { pCell = new CCTableGridCell(); pCell->autorelease(); CC9Sprite* pBg = CC9Sprite::create("sprite9_btn1.png"); pBg->setContentSize(CCSize(70, 70)); pBg->setPosition(ccp(320 / 4 / 2, 390 / 5 / 2)); pCell->addChild(pBg); pIconButton = CCButton::create("icon.png"); pIconButton->setLongClickSelector(this, longclick_selector(CCTableGridBackPackTest::onItemLongClick)); pIconButton->getTextTTF()->setFontSize(25); pIconButton->setPosition(ccp(320 / 4 / 2, 390 / 5 / 2)); pIconButton->setTextOffset(ccp(-15, -15)); pIconButton->setTag(1); pCell->addChild(pIconButton); } else { pIconButton = (CCButton*) pCell->getChildByTag(1); } if( idx != CC_INVALID_INDEX ) { pIconButton->setVisible(true); pIconButton->getTextTTF()->setString(m_vData[idx].c_str()); pIconButton->setUserTag(idx); } else { pIconButton->setVisible(false); } return pCell; }
CCTableGridCell* CCTableGridBasicTest::tableviewDataSource(CCTableGrid* pTable, CCTableGridCell* pCell, unsigned int idx) { CCButton* pButton = NULL; if(!pCell) { pCell = new CCTableGridCell(); pCell->autorelease(); pButton = CCButton::createWith9Sprite(CCSizeMake(70, 70), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(ccp(320 / 4 / 2, 390 / 5 / 2)); pButton->getTextTTF()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CCButton*) pCell->getChildByTag(1); } if( idx != CC_INVALID_INDEX ) { pButton->setVisible(true); char buff[64]; sprintf(buff, "%u", idx); pButton->getTextTTF()->setString(buff); pButton->setUserTag(idx); } else { pButton->setVisible(false); } return pCell; }