| 486 | } |
| 487 | |
| 488 | void CACollectionView::reloadData() |
| 489 | { |
| 490 | CC_RETURN_IF(m_pCollectionViewDataSource == NULL); |
| 491 | |
| 492 | this->reloadViewSizeData(); |
| 493 | |
| 494 | this->removeAllSubviews(); |
| 495 | |
| 496 | DRect winRect = this->getBounds(); |
| 497 | winRect.origin = getContentOffset(); |
| 498 | float width = winRect.size.width; |
| 499 | int y = 0; |
| 500 | |
| 501 | if (m_nCollectionHeaderHeight > 0 && m_pCollectionHeaderView) |
| 502 | { |
| 503 | m_pCollectionHeaderView->setDisplayRange(true); |
| 504 | m_pCollectionHeaderView->setFrame(DRect(0, y, width, m_nCollectionHeaderHeight)); |
| 505 | addSubview(m_pCollectionHeaderView); |
| 506 | y += m_nCollectionHeaderHeight; |
| 507 | } |
| 508 | |
| 509 | ; |
| 510 | int begin = (int)m_rSectionRects.size(); |
| 511 | m_rSectionRects.resize(m_rSectionRects.size() + m_nSections); |
| 512 | for (int i = 0; i < m_nSections; i++) |
| 513 | { |
| 514 | unsigned int iSectionHeaderHeight = m_nSectionHeaderHeights.at(i); |
| 515 | DRect sectionHeaderRect = DRect(0, y, width, iSectionHeaderHeight); |
| 516 | if (iSectionHeaderHeight>0) |
| 517 | { |
| 518 | CAView* pSectionHeaderView = m_pCollectionViewDataSource->collectionViewSectionViewForHeaderInSection(this, sectionHeaderRect.size, i); |
| 519 | if (pSectionHeaderView != NULL) |
| 520 | { |
| 521 | pSectionHeaderView->setDisplayRange(true); |
| 522 | pSectionHeaderView->setFrame(sectionHeaderRect); |
| 523 | insertSubview(pSectionHeaderView, 1); |
| 524 | m_pSectionHeaderViews[i] = pSectionHeaderView; |
| 525 | y += iSectionHeaderHeight; |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | y += m_nVertInterval; |
| 530 | unsigned int rowCount = m_nRowsInSections.at(i); |
| 531 | for (int j = 0; j < rowCount; j++) |
| 532 | { |
| 533 | int iHeight = m_nRowHeightss.at(i).at(j); |
| 534 | |
| 535 | unsigned int itemCount = m_pCollectionViewDataSource->numberOfItemsInRowsInSection(this, i, j); |
| 536 | |
| 537 | unsigned int cellWidth = 0; |
| 538 | if (itemCount>0) |
| 539 | { |
| 540 | cellWidth = (width - m_nHoriInterval) / itemCount - m_nHoriInterval; |
| 541 | } |
| 542 | for (int k = 0; k < itemCount; k++) |
| 543 | { |
| 544 | CAIndexPath3E indexPath = CAIndexPath3E(i, j, k); |
| 545 | DRect cellRect = DRect(m_nHoriInterval + (cellWidth + m_nHoriInterval)*k, y, cellWidth, iHeight); |
no test coverage detected