コード例 #1
0
bool CExpandableListViewBasicTest::init()
{
	CExpandableListViewTestSceneBase::init();
	setTitle("CExpandableListViewBasicTest");
	setDescription("click item to expand");
	
	pListView = CExpandableListView::create(CCSize(320, 390));
	pListView->setBackgroundImage("background2.png");
	pListView->setPosition(CCPoint(480, 320));
	m_pWindow->addChild(pListView);

	for( int i = 0; i < 10; i++ )
	{
		CExpandableNode* pExpandableNode = CExpandableNode::create();
		pExpandableNode->setContentSize(CCSize(320, 50));
		pListView->insertExpandableNodeAtLast(pExpandableNode);

		CImageViewScale9* pExpandableNodeBg = CImageViewScale9::create(CCSize(320, 45), "expandnodebg.png");
		pExpandableNodeBg->setPosition(CCPoint(320/2, 50/2));
		pExpandableNode->addChild(pExpandableNodeBg);

		CButton* pColBtn = CButton::createWith9Sprite(CCSize(35, 35), "sprite9_btn1.png", "sprite9_btn2.png");
		pColBtn->setPosition(ccp(320 - 30, 50 / 2));
		pColBtn->setText("-");
		pColBtn->setUserTag(i);
		pColBtn->setOnClickListener(this, ccw_click_selector(CExpandableListViewBasicTest::onClick));
		pExpandableNode->addChild(pColBtn);

		char buff[64] = {0};
		sprintf(buff, "ExpandableNode : %d", i);
		CLabel* pTitleLabel = CLabel::create(buff, "", 28);
		pTitleLabel->setPosition(CCPoint(10, 50/2));
		pTitleLabel->setAnchorPoint(CCPoint(0, 0.5));
		pExpandableNode->addChild(pTitleLabel);


		sprintf(buff, "Label %d - 1", i);
		pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
		sprintf(buff, "Label %d - 2", i);
		pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
		sprintf(buff, "Label %d - 3", i);
		pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
		
		CButton* pButton = CButton::createWith9Sprite(CCSize(150, 38), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setOnClickListener(this, ccw_click_selector(CExpandableListViewBasicTest::onClick));
		pButton->initText("collapse", "", 28);
		pButton->setUserTag(i);
		pButton->setPosition(CCPoint(100, 40/2));
		CLayout* pBtnLayout = CLayout::create(CCSize(320, 40));
		pBtnLayout->addChild(pButton);
		pExpandableNode->insertItemNodeAtLast(pBtnLayout);
	}

	pListView->reloadData();
	

	return true;
}
コード例 #2
0
ファイル: TableViewTest.cpp プロジェクト: Kudoo/Tui-x
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;
}
コード例 #3
0
ファイル: TableViewTest.cpp プロジェクト: Kudoo/Tui-x
Ref* CTableViewReloadTest::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->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;
}
コード例 #4
0
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;
}
コード例 #5
0
CCObject* CTableViewBindingDataAndVertical::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->setOnClickListener(this, ccw_click_selector(CTableViewBindingDataAndVertical::onClick));
		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;
}
コード例 #6
0
ファイル: ListViewTest.cpp プロジェクト: Kudoo/Tui-x
bool CListViewOperateTest::init()
{
	CListViewTestSceneBase::init();
	setTitle("CListViewOperateTest");
	setDescription("Add or Remove operate");

	m_pListView = CListView::create(Size(480, 320));
	m_pListView->setBackgroundImage("background.png");
	m_pListView->setPosition(Vec2(480, 320));
	m_pListView->setDirection(eScrollViewDirectionVertical);
	m_pWindow->addChild(m_pListView);

	CButton* pButton = CButton::createWith9Sprite(Size(150, 50),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton->setPosition(Vec2(150, 450));
	pButton->setUserTag(1);
	pButton->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick));
	pButton->initText("Add Last", "", 30);
	m_pWindow->addChild(pButton);

	CButton* pButton2 = CButton::createWith9Sprite(Size(150, 50),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton2->setPosition(Vec2(150, 380));
	pButton2->setUserTag(2);
	pButton2->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick));
	pButton2->initText("Add Front", "", 30);
	m_pWindow->addChild(pButton2);

	CButton* pButton3 = CButton::createWith9Sprite(Size(150, 50),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton3->setPosition(Vec2(150, 310));
	pButton3->setUserTag(3);
	pButton3->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick));
	pButton3->initText("Remove Last", "", 30);
	m_pWindow->addChild(pButton3);

	CButton* pButton4 = CButton::createWith9Sprite(Size(150, 50),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton4->setPosition(Vec2(150, 240));
	pButton4->setUserTag(4);
	pButton4->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick));
	pButton4->initText("Remove Front", "", 30);
	m_pWindow->addChild(pButton4);

	return true;
}
コード例 #7
0
bool CCheckBoxExclusionTest::init()
{
	CCheckBoxTestSceneBase::init();
	setTitle("CCheckBoxExclusionTest");
	setDescription("checkbox exclusion test");

	CREATE_CHECKBOX(pCheckBox1, CCPoint(480, 490));
	pCheckBox1->setTag(1);
	pCheckBox1->setExclusion(1);
	pCheckBox1->setChecked(true);
	pCheckBox1->setEnabled(false);
	m_pWindow->addChild(pCheckBox1);

	CREATE_CHECKBOX(pCheckBox2, CCPoint(480, 425));
	pCheckBox2->setExclusion(1);
	m_pWindow->addChild(pCheckBox2);
	
	CREATE_CHECKBOX(pCheckBox3, CCPoint(480, 360));
	pCheckBox3->setExclusion(1);
	m_pWindow->addChild(pCheckBox3);

	CREATE_CHECKBOX(pCheckBox4, CCPoint(480, 295));
	pCheckBox4->setExclusion(1);
	m_pWindow->addChild(pCheckBox4);

	CREATE_CHECKBOX(pCheckBox5, CCPoint(480, 230));
	pCheckBox5->setExclusion(1);
	m_pWindow->addChild(pCheckBox5);

	CREATE_CHECKBOX(pCheckBox6, CCPoint(480, 165));
	pCheckBox6->setExclusion(1);
	m_pWindow->addChild(pCheckBox6);

	CButton* pButton = CButton::createWith9Sprite(CCSize(280, 60),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton->setPosition(CCPoint(200, 450));
	pButton->setUserTag(1);
	pButton->setOnClickListener(this, ccw_click_selector(CCheckBoxExclusionTest::onClick));
	pButton->initText("set true for first", "", 30);
	m_pWindow->addChild(pButton);

	return true;
}
コード例 #8
0
ファイル: Bagui.cpp プロジェクト: 110440/Tui-x
Ref* Bagui::event_adapt_gvBag(Ref* pConvertCell, unsigned int uIdx)
{
	CGridViewCell* pCell = (CGridViewCell*)pConvertCell;
	CButton *btn = nullptr;
	if (!pCell)
	{
		pCell = new CGridViewCell();
		pCell->autorelease();

		TuiManager::getInstance()->parseCell(pCell, "cell_grid", PATH_BAG);

		btn = (CButton*)pCell->getChildByTag(BTN_GRID);
		btn->setOnClickListener(this, ccw_click_selector(Bagui::event_btn_gv));
	}else{
		btn = (CButton*)pCell->getChildByTag(BTN_GRID);
	}
	btn->setUserTag(uIdx);
	return pCell;
}
コード例 #9
0
ファイル: ProgressBarTest.cpp プロジェクト: 110440/Tui-x
bool CProgressBarBasicTest::init()
{
	CProgressBarTestSceneBase::init();
	setTitle("CProgressBarBasicTest");
	setDescription("click the button to changed progress");

	Sprite* m_pBg = Sprite::create("background.png");
	m_pBg->setScale(1.3f);
	m_pBg->setPosition(Vec2(480, 320));
	m_pWindow->addChild(m_pBg);

	m_pProgressBar = CProgressBar::create("progress.png");
	m_pProgressBar->setBackgroundImage("progress_bg.png");
	m_pProgressBar->setPosition(Vec2(480, 320));
	m_pProgressBar->setMaxValue(100);
	m_pProgressBar->setMinValue(0);
	m_pProgressBar->setDirection(eProgressBarDirectionLeftToRight);
	m_pProgressBar->setOnValueChangedListener(
		this, ccw_valuechanged_selector(CProgressBarBasicTest::onProgressing));
	m_pProgressBar->setContentSize(Size(960, 640));
	m_pWindow->addChild(m_pProgressBar);

	CButton* pButton = CButton::createWith9Sprite(Size(150, 60),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton->setPosition(Vec2(250, 450));
	pButton->setUserTag(1);
	pButton->setOnClickListener(this, ccw_click_selector(CProgressBarBasicTest::onClick));
	pButton->initText("Add", "", 30);
	m_pWindow->addChild(pButton);

	CButton* pButton2 = CButton::createWith9Sprite(Size(150, 60),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton2->setPosition(Vec2(450, 450));
	pButton2->setUserTag(2);
	pButton2->setOnClickListener(this, ccw_click_selector(CProgressBarBasicTest::onClick));
	pButton2->initText("Less", "", 30);
	m_pWindow->addChild(pButton2);

	CButton* pButton3 = CButton::createWith9Sprite(Size(200, 60),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton3->setPosition(Vec2(670, 450));
	pButton3->setUserTag(3);
	pButton3->setOnClickListener(this, ccw_click_selector(CProgressBarBasicTest::onClick));
	pButton3->initText("change direction", "", 30);
	m_pWindow->addChild(pButton3);

	CButton* pButton4 = CButton::createWith9Sprite(Size(150, 60),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton4->setPosition(Vec2(350, 200));
	pButton4->setUserTag(4);
	pButton4->setOnClickListener(this, ccw_click_selector(CProgressBarBasicTest::onClick));
	pButton4->initText("startProgress", "", 30);
	pButton4->setCascadeTextSizeEnabled(true, Size(50, 30));
	m_pWindow->addChild(pButton4);

	CButton* pButton5 = CButton::createWith9Sprite(Size(150, 60),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton5->setPosition(Vec2(650, 200));
	pButton5->setUserTag(5);
	pButton5->setOnClickListener(this, ccw_click_selector(CProgressBarBasicTest::onClick));
	pButton5->initText("stopProgress", "", 30);
	pButton5->setCascadeTextSizeEnabled(true, Size(50, 30));
	m_pWindow->addChild(pButton5);
	
	m_pText = CLabel::create();
	m_pText->setAnchorPoint(Vec2(0, 0.5));
	m_pText->setPosition(Vec2(200, 400));
	//m_pText->setFontSize(35.0f);
	m_pText->setString("none");
	m_pWindow->addChild(m_pText);

	return true;
}
コード例 #10
0
ファイル: ViewScene.cpp プロジェクト: echenonline/writing
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;
}
コード例 #11
0
ファイル: MainScene.cpp プロジェクト: echenonline/writing
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;
}