CCheckBox* TuiManager::createCheckBox(float tag,const char* normal1,const char* normal2,const char* select1, const char* select2,const char* disable1,const char* disable2,float x,float y,float rotation){ CCheckBox* pCheckBox = NULL; if(m_isUseSpriteFrame){ pCheckBox = CCheckBox::create(); pCheckBox->setNormalSpriteFrameName(normal1); pCheckBox->setNormalPressSpriteFrameName(normal2); pCheckBox->setCheckedSpriteFrameName(select1); pCheckBox->setCheckedPressSpriteFrameName(select2); pCheckBox->setDisabledNormalSpriteFrameName(disable1); pCheckBox->setDisabledCheckedSpriteFrameName(disable2); }else{ pCheckBox = CCheckBox::create(); pCheckBox->setNormalImage(normal1); pCheckBox->setNormalPressImage(normal2); pCheckBox->setCheckedImage(select1); pCheckBox->setCheckedPressImage(select2); pCheckBox->setDisabledNormalImage(disable1); pCheckBox->setDisabledCheckedImage(disable2); } pCheckBox->setRotation(rotation); pCheckBox->setPosition(Point(x,-y)); pCheckBox->setTag(tag); return pCheckBox; }
bool CCheckBoxBasicTest::init() { CCheckBoxTestSceneBase::init(); setTitle("CCheckBoxBasicTest"); setDescription("checkbox face, click it"); CCheckBox* 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->setOnClickListener(this, ccw_click_selector(CCheckBoxBasicTest::onClick)); pCheckBox->setPosition(CCPoint(480, 320)); m_pWindow->addChild(pCheckBox); CCheckBox* pCheckBox2 = CCheckBox::create(); pCheckBox2->setNormalImage("ckb_normal_01.png"); pCheckBox2->setCheckedImage("ckb_selected_01.png"); pCheckBox2->setOnClickListener(this, ccw_click_selector(CCheckBoxBasicTest::onClick)); pCheckBox2->setPosition(CCPoint(560, 320)); m_pWindow->addChild(pCheckBox2); m_pText = CLabel::create(); m_pText->setAnchorPoint(CCPoint(0, 0.5)); m_pText->setPosition(CCPoint(380, 400)); m_pText->setFontSize(35.0f); m_pText->setString("none"); m_pWindow->addChild(m_pText); return true; }
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; }