CCObject* CGridViewBasicTest::gridviewDataSource(CCObject* pConvertView, unsigned int idx) { CGridViewCell* pCell = (CGridViewCell*) pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CGridViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(CCSizeMake(70, 70), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(CCPoint(480 / 5 / 2, 320 / 4 / 2)); pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } char buff[64]; sprintf(buff, "%u", idx); pButton->getLabel()->setString(buff); pButton->setUserTag(idx); return pCell; }
CCObject* CTableViewReloadTest::tableviewDataSource(CCObject* pConvertView, unsigned int idx) { CTableViewCell* pCell = (CTableViewCell*) pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CTableViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(CCSizeMake(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(CCPoint(150.0f / 2, 54.0f / 2)); pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } pButton->getLabel()->setString(m_vDatas[idx].c_str()); pButton->setUserTag(idx); return pCell; }
bool CTableViewReloadTest::init() { CTableViewTestSceneBase::init(); setTitle("CTableViewReloadTest"); setDescription("click button will pop a string into vector and reload\n table with auto relocate"); m_lDataQueue.push_back("B"); m_lDataQueue.push_back("C"); m_lDataQueue.push_back("D"); m_lDataQueue.push_back("E"); m_lDataQueue.push_back("F"); m_lDataQueue.push_back("G"); m_lDataQueue.push_back("H"); m_lDataQueue.push_back("I"); m_lDataQueue.push_back("J"); m_lDataQueue.push_back("K"); m_lDataQueue.push_back("L"); m_lDataQueue.push_back("M"); m_lDataQueue.push_back("N"); m_lDataQueue.push_back("O"); m_lDataQueue.push_back("P"); m_lDataQueue.push_back("Q"); m_lDataQueue.push_back("R"); m_lDataQueue.push_back("S"); m_lDataQueue.push_back("T"); m_lDataQueue.push_back("U"); m_lDataQueue.push_back("V"); m_lDataQueue.push_back("W"); m_lDataQueue.push_back("X"); m_lDataQueue.push_back("Y"); m_lDataQueue.push_back("Z"); m_vDatas.push_back("A"); pTable = CTableView::create( CCSize(150.0f, 54.0f * 5), CCSize(150.0f, 54.0f), m_vDatas.size(), this, ccw_datasource_adapter_selector(CTableViewReloadTest::tableviewDataSource)); pTable->setDirection(eScrollViewDirectionVertical); pTable->setAutoRelocate(true); pTable->setPosition(CCPoint(480, 320)); m_pWindow->addChild(pTable); pTable->reloadData(); CButton* pButton = CButton::createWith9Sprite(CCSizeMake(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setOnClickListener(this, ccw_click_selector(CTableViewReloadTest::onClick)); pButton->setPosition(CCPoint(200, 320)); pButton->getLabel()->setFontSize(25.0f); pButton->getLabel()->setString("reloadData"); m_pWindow->addChild(pButton); return true; }
Ref* CTableViewBasicTest::tableviewDataSource(Ref* pConvertView, unsigned int idx) { CTableViewCell* pCell = (CTableViewCell*)pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CTableViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(Size(70, 70), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(74.0f / 2, 70.0f / 2)); //pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } char buff[64]; sprintf(buff, "%u", idx); pButton->getLabel()->setString(buff); pButton->setUserTag(idx); return pCell; }
Ref* CTableViewBindingDataAndVertical::tableviewDataSource(Ref* pConvertView, unsigned int idx) { CTableViewCell* pCell = (CTableViewCell*)pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CTableViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setOnClickListener(this, ccw_click_selector(CTableViewBindingDataAndVertical::onClick)); pButton->setPosition(Vec2(150.0f / 2, 54.0f / 2)); //pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } pButton->getLabel()->setString(m_vDatas[idx].c_str()); pButton->setUserTag(idx); return pCell; }
CCObject* ViewScene::gridViewDataSource(CCObject* pContentView, unsigned int idx){ CGridViewCell* pCell = (CGridViewCell*) pContentView; CButton* pButton = NULL; CCheckBox* pCheckbox = NULL; Notes = SQLiteData::getNote(unit_id,zi_id); vector<string> oneNote = Notes.at(idx); //oneNote 中第一个元素为ID,第二个元素为笔画序列 if (!pCell) { pCell = new CGridViewCell(); pCell->autorelease(); pButton = CButton::create("strangedesign/Dlg_cancel_button.png","strangedesign/Dlg_cancel_button_down.png"); pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2)); pCheckbox = CCheckBox::create(); pCheckbox->setNormalImage("ckb_normal_01.png"); pCheckbox->setNormalPressImage("ckb_normal_02.png"); pCheckbox->setCheckedImage("ckb_selected_01.png"); pCheckbox->setCheckedPressImage("ckb_selected_02.png"); pCheckbox->setDisabledNormalImage("ckb_disable_01.png"); pCheckbox->setDisabledCheckedImage("ckb_disable_02.png"); pCheckbox->setPosition(CCPoint(360-pCheckbox->getContentSize().width, 350-pButton->getContentSize().height/2)); pCell->addChild(pCheckbox,10); //pCell->addChild(pButton,10); HcharacterDrawnode* handwritingHz = HcharacterDrawnode::create(); vector< vector<CCPoint> > strokesvec = DataTool::spliteString(oneNote.at(1)); for (unsigned int i = 0; i < strokesvec.size(); i++) { vector<CCPoint> oneStrokeVec = strokesvec[i]; Stroke stroke(oneStrokeVec); handwritingHz->addStroke(stroke); } handwritingHz->setContentSize(CCSize(320,320)); CCPoint position = ccp(360/2- handwritingHz->getContentSize().width/2, 350/2- handwritingHz->getContentSize().height/2); handwritingHz->setPosition(position); pCell->addChild(handwritingHz,1); }else { pButton = CButton::create("strangedesign/Dlg_cancel_button.png","strangedesign/Dlg_cancel_button_down.png"); pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2)); pCheckbox = CCheckBox::create(); pCheckbox->setNormalImage("ckb_normal_01.png"); pCheckbox->setNormalPressImage("ckb_normal_02.png"); pCheckbox->setCheckedImage("ckb_selected_01.png"); pCheckbox->setCheckedPressImage("ckb_selected_02.png"); pCheckbox->setDisabledNormalImage("ckb_disable_01.png"); pCheckbox->setDisabledCheckedImage("ckb_disable_02.png"); pCheckbox->setPosition(CCPoint(360-pCheckbox->getContentSize().width, 350-pButton->getContentSize().height/2)); pCell->addChild(pCheckbox,10); //pCell->addChild(pButton,10); HcharacterDrawnode* handwritingHz = HcharacterDrawnode::create(); vector<string> oneNote = Notes.at(idx); //oneNote 中第一个元素为ID,第二个元素为笔画序列 vector< vector<CCPoint> > strokesvec = DataTool::spliteString(oneNote.at(1)); for (unsigned int i = 0; i < strokesvec.size(); i++) { vector<CCPoint> oneStrokeVec = strokesvec[i]; Stroke stroke(oneStrokeVec); handwritingHz->addStroke(stroke); } handwritingHz->setContentSize(CCSize(320,320)); CCPoint position = ccp(360/2- handwritingHz->getContentSize().width/2, 350/2- handwritingHz->getContentSize().height/2); handwritingHz->setPosition(position); pCell->addChild(handwritingHz,1); } char buff[64]; sprintf(buff, "%u", idx); pButton->getLabel()->setString(buff); int userTag = DataTool::stringToInt(oneNote.at(0)); pButton->setUserTag(userTag); pCheckbox->setUserTag(userTag); pButton->setOnClickListener(this,ccw_click_selector(ViewScene::buttonClick)); pCheckbox->setOnClickListener(this,ccw_click_selector(ViewScene::checkBoxClick)); return pCell; }
CCObject* MainScene::gridviewDataSource(CCObject* pConvertView, unsigned int idx){ CGridViewCell* pCell = (CGridViewCell*) pConvertView; CButton* pButton = NULL; CCLog("idx %d",idx); if(!pCell) { pCell = new CGridViewCell(); pCell->autorelease(); pButton = CButton::create("strangedesign/main_clincher.png","strangedesign/main_clincher_down.png"); pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2)); pButton->getLabel()->setFontSize(40.0f); pButton->setTag(1); pCell->addChild(pButton,10); CCSprite* sprite = CCSprite::create("strangedesign/table4mul4.png"); sprite->setContentSize(CCSize(320,320)); sprite->setPosition(CCPoint(360/2,350/2)); pCell->addChild(sprite,1); CCLog("idx %d",idx); vector<vector<string> > groupCharacter = SQLiteData::getUnit(unit_ids.at(idx)); CCPoint positions[16] = {ccp(40,280),ccp(120,280),ccp(200,280),ccp(280,280), ccp(40,200),ccp(120,200),ccp(200,200),ccp(280,200), ccp(40,120),ccp(120,120),ccp(200,120),ccp(280,120), ccp(40,40),ccp(120,40),ccp(200,40),ccp(280,40) }; for (unsigned int i = 0; i < groupCharacter.size(); i++) { string hanzi = groupCharacter.at(i).at(0); CCLabelTTF* clabel = CCLabelTTF::create(hanzi.c_str(),"Arial",40); clabel->setPosition(positions[i]); clabel->setColor(ccc3(0,0,0)); sprite->addChild(clabel); } } else { pButton = CButton::create("strangedesign/main_clincher.png","strangedesign/main_clincher_down.png"); pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2)); pButton->getLabel()->setFontSize(40.0f); pButton->setTag(1); pCell->addChild(pButton,10); CCSprite* sprite = CCSprite::create("strangedesign/table4mul4.png"); sprite->setContentSize(CCSize(320,320)); sprite->setPosition(CCPoint(360/2,350/2)); pCell->addChild(sprite,1); CCLog("idx %d",idx); vector<vector<string> > groupCharacter = SQLiteData::getUnit(unit_ids.at(idx)); CCPoint positions[16] = {ccp(40,280),ccp(120,280),ccp(200,280),ccp(280,280), ccp(40,200),ccp(120,200),ccp(200,200),ccp(280,200), ccp(40,120),ccp(120,120),ccp(200,120),ccp(280,120), ccp(40,40),ccp(120,40),ccp(200,40),ccp(280,40) }; for (unsigned int i = 0; i < groupCharacter.size(); i++) { string hanzi = groupCharacter.at(i).at(0); CCLabelTTF* clabel = CCLabelTTF::create(hanzi.c_str(),"Arial",40); clabel->setPosition(positions[i]); clabel->setColor(ccc3(0,0,0)); sprite->addChild(clabel); } } char buff[64]; unsigned int labelidx = idx+1; sprintf(buff, "%u", labelidx); pButton->getLabel()->setString(buff); pButton->setUserTag(idx); pButton->setOnClickListener(this,ccw_click_selector(MainScene::buttonClick)); pButton->setOnLongClickListener(this,ccw_longclick_selector(MainScene::buttonLongClick)); return pCell; }