void PageView::addPage(Layout* page) { if (!page) { return; } if (page->getWidgetType() != WidgetTypeContainer) { return; } if (_pages.contains(page)) { return; } Size pSize = page->getSize(); Size pvSize = getSize(); if (!pSize.equals(pvSize)) { CCLOG("page size does not match pageview size, it will be force sized!"); page->setSize(pvSize); } page->setPosition(Point(getPositionXByIndex(_pages.size()), 0)); _pages.pushBack(page); addChild(page); updateBoundaryPages(); }
void UIPageView::addPage(Layout* page) { if (!page) { return; } if (page->getWidgetType() != WidgetTypeContainer) { return; } if (m_pages->containsObject(page)) { return; } CCSize pSize = page->getSize(); CCSize pvSize = getSize(); if (!pSize.equals(pvSize)) { CCLOG("page size does not match pageview size, it will be force sized!"); page->setSize(pvSize); } page->setPosition(ccp(getPositionXByIndex(m_pages->count()), 0)); m_pages->addObject(page); addChild(page); updateBoundaryPages(); }
void UIPageView::insertPage(Layout* page, int idx) { if (idx < 0) { return; } if (!page) { return; } if (page->getWidgetType() != WidgetTypeContainer) { return; } if (m_pages->containsObject(page)) { return; } int pageCount = m_pages->count(); if (idx >= pageCount) { addPage(page); } else { m_pages->insertObject(page, idx); page->setPosition(ccp(getPositionXByIndex(idx), 0)); addChild(page); CCSize pSize = page->getSize(); CCSize pvSize = getSize(); if (!pSize.equals(pvSize)) { CCLOG("page size does not match pageview size, it will be force sized!"); page->setSize(pvSize); } ccArray* arrayPages = m_pages->data; int length = arrayPages->num; for (int i=(idx+1); i<length; i++) { UIWidget* behindPage = dynamic_cast<UIWidget*>(arrayPages->arr[i]); CCPoint formerPos = behindPage->getPosition(); behindPage->setPosition(ccp(formerPos.x+getSize().width, 0)); } updateBoundaryPages(); } }
void PageView::insertPage(Layout* page, int idx) { if (idx < 0) { return; } if (!page) { return; } if (page->getWidgetType() != WidgetTypeContainer) { return; } if (_pages.contains(page)) { return; } ssize_t pageCount = _pages.size(); if (idx >= pageCount) { addPage(page); } else { _pages.insert(idx, page); page->setPosition(Point(getPositionXByIndex(idx), 0)); addChild(page); Size pSize = page->getSize(); Size pvSize = getSize(); if (!pSize.equals(pvSize)) { CCLOG("page size does not match pageview size, it will be force sized!"); page->setSize(pvSize); } ssize_t length = _pages.size(); for (ssize_t i=(idx+1); i<length; i++){ Widget* behindPage = _pages.at(i); Point formerPos = behindPage->getPosition(); behindPage->setPosition(Point(formerPos.x+getSize().width, 0)); } updateBoundaryPages(); } }