本文整理汇总了C++中CAListViewCell类的典型用法代码示例。如果您正苦于以下问题:C++ CAListViewCell类的具体用法?C++ CAListViewCell怎么用?C++ CAListViewCell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAListViewCell类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getContentOffset
void CAListView::recoveryCollectionCell()
{
CCRect rect = this->getBounds();
rect.origin = getContentOffset();
rect.origin.y -= rect.size.height * 0.1f;
rect.size.height *= 1.2f;
std::map<unsigned int, CAListViewCell*>::iterator itr;
for (itr = m_pUsedListCells.begin(); itr != m_pUsedListCells.end(); itr++)
{
CAListViewCell* cell = itr->second;
CC_CONTINUE_IF(cell == NULL);
CCRect cellRect = cell->getFrame();
CC_CONTINUE_IF(rect.intersectsRect(cellRect));
m_pFreedListCells[cell->getReuseIdentifier()].pushBack(cell);
cell->removeFromSuperview();
cell->resetListViewCell();
itr->second = NULL;
CAView* line = m_pUsedLines[itr->first];
CC_CONTINUE_IF(line == NULL);
m_pFreedLines.pushBack(line);
line->removeFromSuperview();
m_pUsedLines[itr->first] = NULL;
}
}
示例2: CC_CONTINUE_IF
void CAListView::clearData()
{
std::map<unsigned int, CAView*>::iterator it = m_pUsedLines.begin();
for (; it != m_pUsedLines.end(); ++it)
{
CAView* view = it->second;
CC_CONTINUE_IF(view == NULL);
m_pFreedLines.pushBack(view);
view->removeFromSuperview();
}
m_pUsedLines.clear();
m_mpUsedListCells.clear();
for (int i = 0; i < m_vpUsedListCells.size(); i++)
{
CAListViewCell* cell = m_vpUsedListCells.at(i);
CC_CONTINUE_IF(cell == NULL);
m_mpFreedListCells[cell->getReuseIdentifier()].pushBack(cell);
cell->removeFromSuperview();
cell->resetListViewCell();
}
m_vpUsedListCells.clear();
m_pSelectedListCells.clear();
m_nIndexs = 0;
m_rIndexRects.clear();
m_rLineRects.clear();
m_rHeaderRect = m_rFooterRect = DRectZero;
m_pHighlightedListCells = NULL;
}
示例3: listViewCellAtIndex
CAListViewCell* ListViewTest::listViewCellAtIndex(CAListView *listView, const DSize& cellSize, unsigned int index)
{
CAListViewCell* cell = (CAListViewCell*)listView->dequeueReusableCellWithIdentifier("ListViewCell");
if (cell==NULL)
{
cell = CAListViewCell::create("ListViewCell");
CALabel* test = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_W(0, 200), DVerticalLayoutFill));
test->setColor(ccc4(51, 204, 255, 255));
test->setTextAlignment(CATextAlignmentCenter);
test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
test->setFontSize(28);
test->setTag(100);
cell->addSubview(test);
CAButton* btn = CAButton::createWithLayout(DLayout(DHorizontalLayout_W_C(100, 0.85), DVerticalLayout_H_C(50, 0.5)), CAButtonTypeSquareRect);
btn->setTitleForState(CAControlStateNormal, "btn");
btn->setTag(200);
cell->addSubview(btn);
btn->setTouchEventScrollHandOverToSuperview(false);
}
char temptext[10];
sprintf(temptext, "cell-%d",index);
CALabel* test = (CALabel*)cell->getSubviewByTag(100);
test->setText(temptext);
return cell;
}
示例4: listViewDidDeselectCellAtIndex
void SessionsViewController::listViewDidDeselectCellAtIndex(CAListView *listView, unsigned int index)
{
CAListViewCell* cell = listView->cellForRowAtIndex(index);
if (cell) {
CALabel* text = (CALabel*)cell->getSubviewByTag(100);
if (text) {
text->setColor(SAP_GRAY);
}
}
}
示例5: CAListViewCell
CAListViewCell* CAListViewCell::create(const std::string& reuseIdentifier)
{
CAListViewCell* cell = new CAListViewCell();
if (cell && cell->initWithReuseIdentifier(reuseIdentifier))
{
cell->autorelease();
return cell;
}
CC_SAFE_DELETE(cell);
return NULL;
}
示例6: dequeueReusableCellWithIdentifier
CAListViewCell* CAListView::dequeueReusableCellWithIdentifier(const char* reuseIdentifier)
{
CAListViewCell* cell = NULL;
if (reuseIdentifier && !m_pFreedListCells[reuseIdentifier].empty())
{
cell = m_pFreedListCells[reuseIdentifier].back();
cell->retain()->autorelease();
m_pFreedListCells[reuseIdentifier].popBack();
}
return cell;
}
示例7: getContentOffset
void CAListView::loadCell()
{
DRect rect = this->getBounds();
rect.origin = getContentOffset();
rect.origin.y -= rect.size.height * 0.1f;
rect.origin.x -= rect.size.width * 0.1f;
rect.size.width *= 1.2f;
rect.size.height *= 1.2f;
std::map<unsigned int, CAListViewCell*>::iterator itr;
for (itr = m_mpUsedListCells.begin(); itr != m_mpUsedListCells.end(); itr++)
{
CC_CONTINUE_IF(itr->second != NULL);
unsigned int index = itr->first;
DRect cellRect = m_rIndexRects[index];
CC_CONTINUE_IF(!rect.intersectsRect(cellRect));
CAListViewCell* cell = m_pListViewDataSource->listViewCellAtIndex(this, cellRect.size, index);
if (cell)
{
cell->m_nIndex = index;
cell->updateDisplayedAlpha(this->getAlpha());
addSubview(cell);
cell->setFrame(cellRect);
m_mpUsedListCells[index] = cell;
m_vpUsedListCells.pushBack(cell);
}
if (m_pSelectedListCells.count(index))
{
cell->setControlState(CAControlStateSelected);
}
if (m_pListViewDataSource)
{
m_pListViewDataSource->listViewWillDisplayCellAtIndex(this, cell, index);
}
CAView* view = this->dequeueReusableLine();
DRect lineRect = m_rLineRects[index];
if (view == NULL)
{
view = CAView::createWithFrame(lineRect, m_obSeparatorColor);
}
m_pUsedLines[index] = view;
this->insertSubview(view, 1);
view->setFrame(lineRect);
}
}
示例8: refreshTableByTime
void SessionsViewController::listViewDidSelectCellAtIndex(CAListView *listView, unsigned int index)
{
m_navTimeType = index;
m_timeTblId = index;
refreshTableByTime(m_navTimeType);
CAListViewCell* cell = listView->cellForRowAtIndex(index);
if (cell) {
CALabel* text = (CALabel*)cell->getSubviewByTag(100);
if (text) {
text->setColor(CAColor_white);
}
}
/*
if (listView->getTag() == 100) {
CAView * lable = listView->getSubviewByTag(100);
//->setColor(ccc4(0x96, 0x96, 0x96, 255));
}*/
}
示例9: CC_CONTINUE_IF
bool CAListView::ccTouchBegan(CATouch *pTouch, CAEvent *pEvent)
{
if (m_pTouches->count() > 0)
{
m_pTouches->replaceObjectAtIndex(0, pTouch);
return true;
}
bool isInertia = m_tInertia.getLength() < 1.0f;
if (!CAScrollView::ccTouchBegan(pTouch, pEvent))
return false;
if (m_bAllowsSelection && this->isScrollWindowNotOutSide() == false && isInertia)
{
CCPoint point = m_pContainer->convertTouchToNodeSpace(pTouch);
std::map<unsigned int, CAListViewCell*>::iterator itr;
for (itr = m_pUsedListCells.begin(); itr != m_pUsedListCells.end(); ++itr)
{
CAListViewCell* pCell = itr->second;
CC_CONTINUE_IF(pCell == NULL);
if (pCell->getFrame().containsPoint(point) && pCell->isVisible())
{
CC_BREAK_IF(pCell->getControlState() == CAControlStateDisabled);
if (m_pHighlightedListCells)
{
m_pHighlightedListCells->setControlStateNormal();
}
m_pHighlightedListCells = pCell;
CC_BREAK_IF(pCell->getControlState() == CAControlStateSelected);
CCDelayTime* delayTime = CCDelayTime::create(0.05f);
CCCallFunc* func = CCCallFunc::create(pCell, callfunc_selector(CAListViewCell::setControlStateHighlighted));
CCSequence* actions = CCSequence::create(delayTime, func, NULL);
m_pContainer->runAction(actions);
break;
}
}
}
return true;
}
示例10: mouseMoved
void CAListView::mouseMoved(CATouch* pTouch, CAEvent* pEvent)
{
if (m_bAllowsSelection)
{
DPoint point = m_pContainer->convertTouchToNodeSpace(pTouch);
std::map<unsigned int, CAListViewCell*>::iterator itr;
for (itr = m_mpUsedListCells.begin(); itr != m_mpUsedListCells.end(); ++itr)
{
CAListViewCell* pCell = itr->second;
CC_CONTINUE_IF(pCell == NULL);
if (pCell->getFrame().containsPoint(point) && pCell->isVisible())
{
CC_BREAK_IF(pCell->getControlState() == CAControlStateDisabled);
if (m_pHighlightedListCells)
{
unsigned int index = m_pHighlightedListCells->getIndex();
if (m_pSelectedListCells.count(index))
{
m_pHighlightedListCells->setControlStateHighlighted();
}
else
{
m_pHighlightedListCells->setControlStateNormal();
}
}
m_pHighlightedListCells = pCell;
pCell->setControlStateHighlighted();
break;
}
}
}
}
示例11: addSubview
void CAListView::reloadData()
{
if (m_pListViewDataSource == NULL)
return;
this->reloadViewSizeData();
this->removeAllSubviews();
m_pUsedLines.clear();
m_pUsedListCells.clear();
m_pFreedListCells.clear();
m_pSelectedListCells.clear();
CCRect winRect = this->getBounds();
winRect.origin = this->getContentOffset();
if (m_nListHeaderHeight > 0)
{
if (m_pListHeaderView)
{
m_pListHeaderView->setFrame(m_rHeaderRect);
addSubview(m_pListHeaderView);
}
}
unsigned int cellCount = m_pListViewDataSource->numberOfIndex(this);
for (unsigned i = 0; i < cellCount; i++)
{
if (m_nIndexs > 0)
{
std::pair<std::map<unsigned int, CAListViewCell*>::iterator, bool> itrResult =
m_pUsedListCells.insert(std::make_pair(i, (CAListViewCell*)NULL));
CC_CONTINUE_IF(!winRect.intersectsRect(m_rIndexRects[i]));
CAListViewCell* pCellView = m_pListViewDataSource->listViewCellAtIndex(this, m_rIndexRects[i].size, i);
if (pCellView)
{
pCellView->m_nIndex = i;
pCellView->setFrame(m_rIndexRects[i]);
addSubview(pCellView);
itrResult.first->second = pCellView;
}
}
if (m_nSeparatorViewHeight > 0)
{
CAView* view = CAView::createWithFrame(m_rLineRects[i], m_obSeparatorColor);
addSubview(view);
m_pUsedLines[i] = view;
}
}
if (m_nListFooterHeight > 0)
{
if (m_pListFooterView)
{
m_pListFooterView->setFrame(m_rFooterRect);
addSubview(m_pListFooterView);
}
}
this->layoutPullToRefreshView();
this->startDeaccelerateScroll();
}
示例12: ccc4
CAListViewCell* SessionsViewController::listViewCellAtIndex(CAListView *listView, const DSize& cellSize, unsigned int index)
{
CAListViewCell* cell = NULL;
if (listView->getTag() == 1)
{
DSize _size = cellSize;
cell = (CAListViewCell*)listView->dequeueReusableCellWithIdentifier("ListViewCell");
if (!cell)
{
cell = CAListViewCell::create("ListViewCell");
cell->setColor(ccc4(0xEB, 0xEB, 0xEB, 0xff));
CALabel* test = CALabel::createWithCenter(DRect(_size.width/2,
_size.height/2,
_size.width,
_size.height));
test->setTextAlignment(CATextAlignmentCenter);
test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
test->setFontSize((28));
test->setTag(100);
CAScale9ImageView* sView = CAScale9ImageView::createWithImage(CAImage::create("common/gray_bg.png"));
sView->setFrame(DRect((0), (0), _size.width, _size.height));
cell->setBackgroundView(sView);
cell->addSubview(test);
}
CALabel* test = (CALabel*)cell->getSubviewByTag(100);
if (m_timeTblId == index)
test->setColor(CAColor_white); // ccc4(0x96, 0x96, 0x96, 255)
else
test->setColor(SAP_GRAY);
if (index == 0)
{
test->setText("All");
}
else
{
test->setText(crossapp_format_string("%2d:00", index + 8));
}
}
/*
else if(listView->getTag() == 2)
{
DSize _size = cellSize;
cell = (CAListViewCell*)listView->dequeueReusableCellWithIdentifier("ListViewCell");
if (!cell)
{
cell = CAListViewCell::create("ListViewCell");
CAButton* button = CAButton::createWithFrame(DRect((20), (20), (120), (40)), CAButtonTypeCustom);
CAScale9ImageView* sView = CAScale9ImageView::createWithFrame(DRect((0), (0), (120), (40)));
sView->setImage(CAImage::create("common/seggreen_bg.png"));
sView->setTouchEnabled(false);
button->addSubview(sView);
//button->setBackgroundViewForState(CAControlStateAll, sView);
sView = CAScale9ImageView::createWithFrame(DRect((0), (0), (120), (40)));
sView->setImage(CAImage::create("common/seggreen_bg.png"));
sView->setColor(ccc4(0x86, 0xBD, 0x45, 0xff));
button->setBackgroundViewForState(CAControlStateSelected, sView);
button->setTitleForState(CAControlStateAll, filterItem[index * 2]);
button->setTitleColorForState(CAControlStateAll, ccc4(0xA0, 0xA0, 0xA0, 0xA0));
button->setTitleFontSize((20));
button->setAllowsSelected(true);
button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
button->setTag(310 + index * 2);
//m_listButton[index * 2] = button;
cell->addSubview(button);
button = CAButton::createWithFrame(DRect((20), (70), (120), (40)), CAButtonTypeCustom);
sView = CAScale9ImageView::createWithFrame(DRect((0), (0), (120), (40)));
sView->setImage(CAImage::create("common/seggreen_bg.png"));
sView->setTouchEnabled(false);
button->addSubview(sView);
//button->setBackgroundViewForState(CAControlStateAll, sView);
//button->addSubview(sView);
//button->setBackgroundViewForState(CAControlStateAll, sView);
sView = CAScale9ImageView::createWithFrame(DRect((0), (0), (120), (40)));
sView->setImage(CAImage::create("common/btn_round.png"));
sView->setColor(ccc4(0x86, 0xBD, 0x45, 0xff));
button->setBackgroundViewForState(CAControlStateSelected, sView);
button->setTitleForState(CAControlStateAll, filterItem[index * 2 + 1]);
button->setTitleColorForState(CAControlStateAll, CAColor_gray);
button->setTitleFontSize((20));
button->setAllowsSelected(true);
button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
button->setTag(310 + index * 2 + 1);
//m_listButton[index * 2 + 1] = button;
cell->addSubview(button);
//sView = CAScale9ImageView::createWithImage(CAImage::create("common/gray_bg.png"));
//sView->setFrame(DRect((0), (0), _size.width, _size.height));
//sView->setColor(CAColor_clear);
//cell->setAlpha(0);
//cell->setBackgroundView(sView);
}
}*/
return cell;
}