本文整理汇总了C++中CACollectionViewCell::setControlState方法的典型用法代码示例。如果您正苦于以下问题:C++ CACollectionViewCell::setControlState方法的具体用法?C++ CACollectionViewCell::setControlState怎么用?C++ CACollectionViewCell::setControlState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CACollectionViewCell
的用法示例。
在下文中一共展示了CACollectionViewCell::setControlState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadCollectionCell
void CACollectionView::loadCollectionCell()
{
DRect rect = this->getBounds();
rect.origin = getContentOffset();
rect.origin.y -= rect.size.height * 0.1f;
rect.size.height *= 1.2f;
std::map<CAIndexPath3E, CACollectionViewCell*>::iterator itr;
for (itr = m_mpUsedCollectionCells.begin(); itr != m_mpUsedCollectionCells.end(); itr++)
{
CC_CONTINUE_IF(itr->second != NULL);
CAIndexPath3E r = itr->first;
DRect cellRect = m_rUsedCollectionCellRects[r];
CC_CONTINUE_IF(!rect.intersectsRect(cellRect));
CACollectionViewCell* cell = m_pCollectionViewDataSource->collectionCellAtIndex(this, cellRect.size, r.section, r.row, r.item);
if (cell)
{
cell->m_nSection = r.section;
cell->m_nRow = r.row;
cell->m_nItem = r.item;
cell->updateDisplayedAlpha(this->getAlpha());
this->addSubview(cell);
cell->setFrame(cellRect);
itr->second = cell;
m_vpUsedCollectionCells.pushBack(cell);
if (m_pSelectedCollectionCells.count(r))
{
cell->setControlState(CAControlStateSelected);
}
if (m_pCollectionViewDataSource)
{
m_pCollectionViewDataSource->collectionViewWillDisplayCellAtIndex(this, cell, r.section, r.row, r.item);
}
}
}
}
示例2: mouseMoved
void CACollectionView::mouseMoved(CATouch* pTouch, CAEvent* pEvent)
{
if (m_bAllowsSelection)
{
DPoint point = m_pContainer->convertTouchToNodeSpace(pTouch);
std::map<CAIndexPath3E, CACollectionViewCell*>::iterator itr;
for (itr = m_mpUsedCollectionCells.begin(); itr != m_mpUsedCollectionCells.end(); ++itr)
{
CACollectionViewCell* cell = itr->second;
CC_CONTINUE_IF(cell == NULL);
if (cell->getFrame().containsPoint(point) && cell->isVisible())
{
CC_BREAK_IF(cell->getControlState() == CAControlStateDisabled);
if (m_pHighlightedCollectionCells)
{
CAIndexPath3E index = CAIndexPath3E(m_pHighlightedCollectionCells->getSection(),
m_pHighlightedCollectionCells->getRow(),
m_pHighlightedCollectionCells->getItem());
if (m_pSelectedCollectionCells.count(index))
{
m_pHighlightedCollectionCells->setControlState(CAControlStateHighlighted);
}
else
{
m_pHighlightedCollectionCells->setControlState(CAControlStateNormal);
}
}
m_pHighlightedCollectionCells = cell;
cell->setControlState(CAControlStateHighlighted);
break;
}
}
}
}