本文整理汇总了C++中TableViewCell类的典型用法代码示例。如果您正苦于以下问题:C++ TableViewCell类的具体用法?C++ TableViewCell怎么用?C++ TableViewCell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TableViewCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
TableViewCell* TableViewTest::tableCellAtIndex(TableView *table, ssize_t idx)
{
auto string = String::createWithFormat("%ld", idx);
TableViewCell *cell = table->dequeueCell();
if (!cell) {
cell = new (std::nothrow) CustomTableViewCell();
cell->autorelease();
auto sprite = Sprite::create("Images/Icon.png");
sprite->setAnchorPoint(Vec2::ZERO);
sprite->setPosition(Vec2(0, 0));
cell->addChild(sprite);
auto label = Label::createWithSystemFont(string->getCString(), "Helvetica", 20.0);
label->setPosition(Vec2::ZERO);
label->setAnchorPoint(Vec2::ZERO);
label->setTag(123);
cell->addChild(label);
}
else
{
auto label = (Label*)cell->getChildByTag(123);
label->setString(string->getCString());
}
return cell;
}
示例2: removeCellAtIndex
void TableView::removeCellAtIndex(ssize_t idx)
{
if (idx == CC_INVALID_INDEX)
{
return;
}
long uCountOfItems = _dataSource->numberOfCellsInTableView(this);
if (0 == uCountOfItems || idx > uCountOfItems-1)
{
return;
}
ssize_t newIdx = 0;
TableViewCell* cell = this->cellAtIndex(idx);
if (!cell)
{
return;
}
newIdx = _cellsUsed.getIndex(cell);
//remove first
this->_moveCellOutOfSight(cell);
_indices->erase(idx);
this->_updateCellPositions();
for (ssize_t i = _cellsUsed.size()-1; i > newIdx; i--)
{
cell = _cellsUsed.at(i);
this->_setIndexForCell(cell->getIdx()-1, cell);
}
}
示例3: CustomTableViewCell
TableViewCell* TableViewTestLayer::tableCellAtIndex(TableView *table, unsigned int idx)
{
String *string = String::createWithFormat("%d", idx);
TableViewCell *cell = table->dequeueCell();
if (!cell) {
cell = new CustomTableViewCell();
cell->autorelease();
Sprite *sprite = Sprite::create("Images/Icon.png");
sprite->setAnchorPoint(Point::ZERO);
sprite->setPosition(Point(0, 0));
cell->addChild(sprite);
LabelTTF *label = LabelTTF::create(string->getCString(), "Helvetica", 20.0);
label->setPosition(Point::ZERO);
label->setAnchorPoint(Point::ZERO);
label->setTag(123);
cell->addChild(label);
}
else
{
LabelTTF *label = (LabelTTF*)cell->getChildByTag(123);
label->setString(string->getCString());
}
return cell;
}
示例4: MAX
void TableView::scrollViewDidScroll(ScrollView* view)
{
long countOfItems = _dataSource->numberOfCellsInTableView(this);
if (0 == countOfItems)
{
return;
}
if (_isUsedCellsDirty)
{
_isUsedCellsDirty = false;
std::sort(_cellsUsed.begin(), _cellsUsed.end(), [](TableViewCell *a, TableViewCell *b) -> bool{
return a->getIdx() < b->getIdx();
});
}
if(_tableViewDelegate != nullptr) {
_tableViewDelegate->scrollViewDidScroll(this);
}
ssize_t startIdx = 0, endIdx = 0, idx = 0, maxIdx = 0;
Vec2 offset = this->getContentOffset() * -1;
maxIdx = MAX(countOfItems-1, 0);
if (_vordering == VerticalFillOrder::TOP_DOWN)
{
offset.y = offset.y + _viewSize.height/this->getContainer()->getScaleY();
}
startIdx = this->_indexFromOffset(offset);
if (startIdx == CC_INVALID_INDEX)
{
startIdx = countOfItems - 1;
}
if (_vordering == VerticalFillOrder::TOP_DOWN)
{
offset.y -= _viewSize.height/this->getContainer()->getScaleY();
}
else
{
offset.y += _viewSize.height/this->getContainer()->getScaleY();
}
offset.x += _viewSize.width/this->getContainer()->getScaleX();
endIdx = this->_indexFromOffset(offset);
if (endIdx == CC_INVALID_INDEX)
{
endIdx = countOfItems - 1;
}
#if 0 // For Testing.
Ref* pObj;
int i = 0;
CCARRAY_FOREACH(_cellsUsed, pObj)
{
TableViewCell* pCell = static_cast<TableViewCell*>(pObj);
log("cells Used index %d, value = %d", i, pCell->getIdx());
i++;
}
示例5: GetHeight
unsigned int TableView::GetHeight() const noexcept {
unsigned int nCells = m_pTableViewDataSource->NumCells(this);
if (nCells == 0) {
return 0;
}
TableViewCell* pTableViewCell = m_pTableViewDataSource->CellAtIndex(0, this);
return pTableViewCell->GetHeight() *
((nCells - 1) / m_pTableViewDataSource->ColsPerPage(this) + 1);
}
示例6: log
TableViewCell* SelectMissionScene::tableCellAtIndex(TableView *table, ssize_t idx)
{
log("%d:geted!", idx);
GameManager *manager = GameManager::getInstance();
MissionInfoItem *info = MissionInfoItem::create(manager->getMissionStatus()[idx]);
TableViewCell *cell = table->dequeueCell();
if(!cell)
{
cell = TableViewCell::create(); //or cell = new TTableViewCell(); cell->autorelease()
}
else
{
MissionInfoItem *tmp = static_cast<MissionInfoItem *>(cell->getChildByTag(100));
tmp->removeFromParent();
}
info->setAnchorPoint(Vec2::ZERO);
info->setPosition(Vec2::ZERO);
info->setTag(100);
cell->addChild(info);
#ifdef TEST
/************ Test TableView ******************/
auto index_text = __String::createWithFormat("%ld",idx + 1);
if(!cell)
{
Label *label = Label::create(index_text->getCString(), "Marker Felt.ttf", 18);
label->setPosition( 80, 50 );
label->setTag(150);
cell = TableViewCell::create();
Sprite *sprite = Sprite::create("lock.png");
sprite->setPosition(270, 50);
sprite->setTag(100);
cell->addChild(label );
cell->addChild(sprite);
}
else
{
Label *label = static_cast<Label *>(cell->getChildByTag(150));
label->setString(index_text->getCString());
}
#endif // TEST
return cell;
}
示例7: TableViewCell
//生成列表每一项的内容
TableViewCell* RankScene::tableCellAtIndex(TableView *table, ssize_t idx)
{
Size mysize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
//读取数据
string str = opt + "_" + Global::shareGlobal()->iToS(idx + 1, 0);
TableViewCell* cell = table->cellAtIndex(idx);
if (!cell)
{
cell = new TableViewCell();
cell->autorelease();
Sprite *item = Sprite::create("tb.png");
item->setPosition(Vec2(origin.x + 180, 15));
cell->addChild(item);
string data = CCUserDefault::sharedUserDefault()->getStringForKey(str.c_str(), "");
//cocos2d::CCMessageBox(t.c_str(),num.c_str());
//return cell;
if (data != "")
{
string t = "";
string num = "";
string score = "";
int i = 0;
while (data[i] != ' ') t += data[i++]; i++; //时间
while (data[i] != ' ') num += data[i++]; i++; //步数
while (i < (int)data.length()) score += data[i++]; //分数
Label *item1 = Label::createWithTTF(Global::shareGlobal()->iToS(idx + 1, 0).c_str(), "fonts/arial.ttf", 18);
Label *item2 = Label::createWithTTF(t.c_str(), "fonts/arial.ttf", 18);
Label *item3 = Label::createWithTTF(num.c_str(), "fonts/arial.ttf", 18);
Label *item4 = Label::createWithTTF(score.c_str(), "fonts/arial.ttf", 18);
item1->setPosition(Vec2(origin.x + 30, 15));
item2->setPosition(Vec2(origin.x + 120, 15));
item3->setPosition(Vec2(origin.x + 210, 15));
item4->setPosition(Vec2(origin.x + 300, 15));
cell->addChild(item1);
cell->addChild(item2);
cell->addChild(item3);
cell->addChild(item4);
}
}
return cell;
}
示例8: TableViewCell
TableViewCell* GameChallengeMap::tableCellAtIndex(TableView* table,ssize_t idx)
{
std::string id = StringUtils::format("%d", idx+1);
TableViewCell *cell = table->dequeueCell();
if (1) {
cell = new TableViewCell();
cell->autorelease();
Sprite* bg = Sprite::create(RESOURCE("map_002.png"));
if (idx%2) {
bg->setTexture(RESOURCE("map_001.png"));
}
bg->setFlippedX(fileMap);
bg->setAnchorPoint(Point(0, 0));
bg->setTextureRect(Rect(0,0,window_size.width,window_size.height));
cell->addChild(bg);
// ID部分
auto *label = Label::createWithSystemFont(id.c_str(), "Arial", 20);
label->setAnchorPoint(Point(0, 0));
label->setPosition(Point(50, 0));
label->setColor(Color3B(0,0,0));
cell->addChild(label);
if (idx>=(12-ci_NormalMissionNum/10)) //如果130关,就是13,但必须是10的整数倍
{
int missionId=120-idx*10; //本单元最大关卡ID
for (int i=0;i<10;++i)
{
GameChallengeMission* mission = GameChallengeMission::create();
mission->setTag(missionId);
mission->setAnchorPoint(Vec2::ZERO);
//取得关卡ID对应的坐标
Vec2 temp=GameUIData::getInstance()->getNormalMissionPos(missionId);
mission->setPosition(temp);
cell->addChild(mission);
mission->setMissionPorperty(missionId);
mission->missionShow(missionId);
--missionId;
}
}
}
return cell;
}
示例9:
TableViewCell *TableView::dequeueCell()
{
TableViewCell *cell;
if (_cellsFreed.empty()) {
cell = nullptr;
} else {
cell = _cellsFreed.at(0);
cell->retain();
_cellsFreed.erase(0);
cell->autorelease();
}
return cell;
}
示例10: tableCellAtIndex
/*
TableViewCell* cell = table->dequeueCell();
if(NULL == cell){
cell = TableViewCell::create();
for(int i=0; i<3; i++){
Label* lbl = Label::create();
lbl->setTextColor(Color4B::WHITE);
lbl->setSystemFontSize(40.00);
lbl->setAnchorPoint(Point(0, 0));
lbl->setHorizontalAlignment(TextHAlignment::CENTER);
lbl->setTag(100+i);
float x = lbl->getPositionX();
lbl->setPositionX(x+i*m_width/3);
cell->addChild(lbl);
}
}
((Label*)cell->getChildByTag(100))->setString(StringUtils::format("Label %ld-1", idx));
((Label*)cell->getChildByTag(101))->setString(StringUtils::format("Label %ld-2", idx));
((Label*)cell->getChildByTag(102))->setString(StringUtils::format("Label %ld-3", idx));
return cell;
*/
TableViewCell* AlbumLayer::tableCellAtIndex(TableView *table, ssize_t idx){
TableViewCell* cell = table->dequeueCell();
Sprite* s = NULL;
if(NULL == cell){
cell = TableViewCell::create();
cell->removeAllChildren();
for(int i=0; i<3; i++){
}
}else{
}
return cell;
}
示例11: TableViewCell
TableViewCell* GCScoreTable::tableCellAtIndex(cocos2d::extension::TableView *table, ssize_t idx)
{
TableViewCell* cell = table->dequeueCell();
if(!cell)
{
cell = new TableViewCell();
cell->autorelease();
}
cell->removeAllChildrenWithCleanup(true);
log("idx = %zd",idx);
Ref* data = _result->getData().at(idx);
Layer* item = this->createCell(data, idx);
cell->addChild(item);
return cell;
}
示例12: CCARRAY_FOREACH
void TableView::reloadData()
{
_oldDirection = Direction::NONE;
Object* pObj = NULL;
CCARRAY_FOREACH(_cellsUsed, pObj)
{
TableViewCell* cell = static_cast<TableViewCell*>(pObj);
if(_tableViewDelegate != NULL) {
_tableViewDelegate->tableCellWillRecycle(this, cell);
}
_cellsFreed->addObject(cell);
cell->reset();
if (cell->getParent() == this->getContainer())
{
this->getContainer()->removeChild(cell, true);
}
}
示例13: TableViewCell
TableViewCell* SceneRule::tableCellAtIndex(TableView *table, ssize_t idx)
{
TableViewCell *cell = table->dequeueCell();
if (cell) {
cell->removeAllChildrenWithCleanup(true);
}
cell = new TableViewCell();
cell->autorelease();
QAKind *gk = listQAKind.at(idx);
std::string title = gk->getTitle();
Vector<MenuItem *> itemArray;
auto item = GameTool::addBtn2(&itemArray, title, 30, Point(cellWidth/2, cellHeight/2), ANCHOR_CENTER_CENTER, CC_CALLBACK_1(SceneRule::callbackBtn, this));
item->setTag((int)idx);
KUtil::addMenu(cell, &itemArray, 30);
return cell;
}
示例14: TableViewCell
// セルの内容を設定
TableViewCell* Overview::tableCellAtIndex(TableView *table, ssize_t idx){
std::string id = StringUtils::format("%zd", idx);
std::string text = StringUtils::format("Line %zd", idx);
TableViewCell *cell = table->dequeueCell();
cell = new TableViewCell();
cell->autorelease();
// セルの背景
auto background_color = Color3B(255,255,255);
if (idx%2) {
background_color = Color3B(200,200,200);
}
Sprite* bg = Sprite::create();
bg->setAnchorPoint(Point(0, 0));
bg->setTextureRect(Rect(0, 0, window_size.width, 24));
bg->setColor(background_color);
bg->setTag(100);
cell->addChild(bg, 0);
// ボーダーライン
Sprite* line = Sprite::create();
line->setAnchorPoint(Point(0, 0));
line->setTextureRect(Rect(0, 0, window_size.width, 1));
line->setColor(Color3B(0,0,0));
cell->addChild(line, 1);
//Story取得
auto story = story_list.begin() + idx;
// ID部分
auto *label_1 = LabelTTF::create(story.operator*()->getTitle().c_str(), "Arial", 16);
label_1->setAnchorPoint(Point(0, 0));
label_1->setPosition(Point(10, 0));
label_1->setColor(Color3B(0,0,0));
cell->addChild(label_1, 1);
return cell;
}
示例15: tableCellAtIndex
TableViewCell* HelloWorld::tableCellAtIndex(cocos2d::extension::TableView *table, ssize_t idx){
TableViewCell *cell = table->dequeueCell();
LabelTTF *label;
if(cell == NULL){
cell = TableViewCell::create();
label = LabelTTF::create();
label->setTag(2);
cell->addChild(label);
label->setFontSize(30);
label->setAnchorPoint(Point(0,0));
}
else {
label = (LabelTTF*)cell->getChildByTag(2);
}
label->setString(StringUtils::format("Label %ld",idx));
return cell;
};