예제 #1
0
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;
}
예제 #2
0
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;
}