本文整理汇总了C++中CACollectionViewCell::setFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ CACollectionViewCell::setFrame方法的具体用法?C++ CACollectionViewCell::setFrame怎么用?C++ CACollectionViewCell::setFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CACollectionViewCell
的用法示例。
在下文中一共展示了CACollectionViewCell::setFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadCollectionCell
void CACollectionView::loadCollectionCell()
{
CCRect 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_pUsedCollectionCells.begin(); itr != m_pUsedCollectionCells.end(); itr++)
{
CC_CONTINUE_IF(itr->second != NULL);
CAIndexPath3E r = itr->first;
CCRect 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;
if (m_pSelectedCollectionCells.count(r))
{
cell->setControlStateSelected();
}
}
}
}
示例2: reloadData
void CACollectionView::reloadData()
{
CC_RETURN_IF(m_pCollectionViewDataSource == NULL);
this->reloadViewSizeData();
this->removeAllSubviews();
DRect winRect = this->getBounds();
winRect.origin = getContentOffset();
float width = winRect.size.width;
int y = 0;
if (m_nCollectionHeaderHeight > 0 && m_pCollectionHeaderView)
{
m_pCollectionHeaderView->setDisplayRange(true);
m_pCollectionHeaderView->setFrame(DRect(0, y, width, m_nCollectionHeaderHeight));
addSubview(m_pCollectionHeaderView);
y += m_nCollectionHeaderHeight;
}
;
int begin = (int)m_rSectionRects.size();
m_rSectionRects.resize(m_rSectionRects.size() + m_nSections);
for (int i = 0; i < m_nSections; i++)
{
unsigned int iSectionHeaderHeight = m_nSectionHeaderHeights.at(i);
DRect sectionHeaderRect = DRect(0, y, width, iSectionHeaderHeight);
if (iSectionHeaderHeight>0)
{
CAView* pSectionHeaderView = m_pCollectionViewDataSource->collectionViewSectionViewForHeaderInSection(this, sectionHeaderRect.size, i);
if (pSectionHeaderView != NULL)
{
pSectionHeaderView->setDisplayRange(true);
pSectionHeaderView->setFrame(sectionHeaderRect);
insertSubview(pSectionHeaderView, 1);
m_pSectionHeaderViews[i] = pSectionHeaderView;
y += iSectionHeaderHeight;
}
}
y += m_nVertInterval;
unsigned int rowCount = m_nRowsInSections.at(i);
for (int j = 0; j < rowCount; j++)
{
int iHeight = m_nRowHeightss.at(i).at(j);
unsigned int itemCount = m_pCollectionViewDataSource->numberOfItemsInRowsInSection(this, i, j);
unsigned int cellWidth = 0;
if (itemCount>0)
{
cellWidth = (width - m_nHoriInterval) / itemCount - m_nHoriInterval;
}
for (int k = 0; k < itemCount; k++)
{
CAIndexPath3E indexPath = CAIndexPath3E(i, j, k);
DRect cellRect = DRect(m_nHoriInterval + (cellWidth + m_nHoriInterval)*k, y, cellWidth, iHeight);
m_rUsedCollectionCellRects[indexPath] = cellRect;
std::pair<std::map<CAIndexPath3E, CACollectionViewCell*>::iterator, bool> itrResult =
m_mpUsedCollectionCells.insert(std::make_pair(indexPath, (CACollectionViewCell*)NULL));
CC_CONTINUE_IF(!winRect.intersectsRect(cellRect));
CACollectionViewCell* cell = m_pCollectionViewDataSource->collectionCellAtIndex(this, cellRect.size, i, j, k);
if (cell)
{
addSubview(cell);
cell->setFrame(cellRect);
cell->m_nSection = i;
cell->m_nRow = j;
cell->m_nItem = k;
itrResult.first->second = cell;
m_vpUsedCollectionCells.pushBack(cell);
if (m_pCollectionViewDataSource)
{
m_pCollectionViewDataSource->collectionViewWillDisplayCellAtIndex(this, cell, i, j, k);
}
}
}
y += (iHeight + m_nVertInterval);
}
unsigned int iSectionFooterHeight = m_nSectionFooterHeights.at(i);
DRect sectionFooterRect = DRect(0, y, width, iSectionFooterHeight);
if (iSectionFooterHeight > 0)
{
CAView* pSectionFooterView = m_pCollectionViewDataSource->collectionViewSectionViewForFooterInSection(this, sectionFooterRect.size, i);
if (pSectionFooterView != NULL)
{
pSectionFooterView->setDisplayRange(true);
pSectionFooterView->setFrame(sectionFooterRect);
insertSubview(pSectionFooterView, 1);
m_pSectionFooterViews[i] = pSectionFooterView;
y += iSectionFooterHeight;
}
}
//.........这里部分代码省略.........