CGridView* CGridView::create(const Size& tViewSize) { CGridView * pRet = new CGridView(); if( pRet && pRet->initWithSize(tViewSize) ) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; }
CGridView* TuiManager::createGridView(float tag, const char* img, int column, int num, int cellWidth, int cellHeight, float x, float y, float w, float h, float rotation){ CGridView* pView = CGridView::create(Size(w, h)); m_isUseSpriteFrame ? pView->setBackgroundSpriteFrameName(img) : pView->setBackgroundImage(img); pView->setAutoRelocate(true); pView->setRotation(rotation); pView->setPosition(x, -y); pView->setColumns(column); pView->setCountOfCell(num); pView->setSizeOfCell(Size(cellWidth, cellHeight)); pView->setTag(tag); return pView; }
CGridView* CGridView::create(const Size& tViewSize, const Size& tCellSize, unsigned int uCellCount, Ref* pListener, SEL_DataSoucreAdapterHandler pHandler) { CGridView * pRet = new CGridView(); if( pRet && pRet->initWithParams(tViewSize, tCellSize, uCellCount, pListener, pHandler)) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; }
CGridView* TuiManager::createGridView(float tag, Color4B color, int column, int num, int cellWidth, int cellHeight, float x, float y, float w, float h, float rotation){ CGridView* pView = CGridView::create(Size(w, h)); if (color.a != 0) pView->setBackgroundColor(color); pView->setAutoRelocate(true); pView->setRotation(rotation); pView->setPosition(x, -y); pView->setColumns(column); pView->setCountOfCell(num); pView->setSizeOfCell(Size(cellWidth, cellHeight)); pView->setTag(tag); return pView; }
NS_BAG_BEGIN void Bagui::onLoadScene() { SpriteFrameCache::getInstance()->addSpriteFramesWithFile("bag/bagui.plist"); TuiManager::getInstance()->parseScene(this, "panel_bag", PATH_BAG); CGridView* pGridView = (CGridView*)this->getControl(PANEL_BAG, GV_BAG); pGridView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(Bagui::event_adapt_gvBag)); pGridView->reloadData(); CTableView* pTblView = (CTableView*)this->getControl(PANEL_BAG, TBL_BAG); pTblView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(Bagui::event_adapt_tblBag)); pTblView->reloadData(); CPageView* pPageView = (CPageView*)this->getControl(PANEL_BAG, PV_BAG); pPageView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(Bagui::event_adapt_pageBag)); pPageView->reloadData(); CButton* pBtnView = (CButton*)this->getControl(PANEL_BAG, BTN_BACK); pBtnView->setOnClickListener(this, ccw_click_selector(Bagui::event_btn_back)); }
bool CGridViewBasicTest::init() { CGridViewTestSceneBase::init(); setTitle("CGridViewBasicTest"); setDescription("GridView basic test (only work in vertical)"); Sprite* pBg = Sprite::create("background.png"); pBg->setPosition(Point(480, 320)); m_pWindow->addChild(pBg); CGridView* pGridView = CGridView::create( Size(480, 320), Size(480 / 5, 320 / 4), 96, this, ccw_datasource_adapter_selector(CGridViewBasicTest::gridviewDataSource)); pGridView->setColumns(5); pGridView->setPosition(Point(480, 320)); m_pWindow->addChild(pGridView); pGridView->setAutoRelocate(true); pGridView->reloadData(); return true; }