bool CButtonChangeSizeTest::init() { CButtonTestSceneBase::init(); setTitle("CButtonChangeSizeTest"); setDescription("click the button for change anothor one"); m_lData.push_back("a"); m_lData.push_back("ab"); m_lData.push_back("abc"); m_lData.push_back("abcd"); m_lData.push_back("abcde"); m_lData.push_back("abcdef"); m_lData.push_back("abcdefg"); m_lData.push_back("abcdefgi"); m_lData.push_back("abcdefgj"); m_lData.push_back("hahahahaha\nhehehehehe"); m_lData.push_back("hahahahaha\nhehehehehe\nkukukukukukukuku"); m_pButton = CButton::create(); m_pButton->setScale9Enabled(true); m_pButton->setNormalImage("sprite9_btn1.png"); m_pButton->setSelectedImage("sprite9_btn2.png"); m_pButton->initText("none", "", 30.0f); m_pButton->setCascadeTextSizeEnabled(true, CCSize(50, 30)); m_pButton->setPosition(CCPoint(480, 320)); m_pWindow->addChild(m_pButton); CButton* pBtn = CButton::createWith9Sprite(CCSizeMake(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pBtn->setPosition(CCPoint(250, 320)); pBtn->initText("click me", "", 27.0f); pBtn->setOnClickListener(this, ccw_click_selector(CButtonChangeSizeTest::onClick)); m_pWindow->addChild(pBtn); return true; }
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; }
CButton* TuiManager::createBtn(float tag, Color3B color, int fontSize, const char* font, const char* lab, const char* normal, const char* select, const char* disable, float x, float y, float w, float h, float rotation, int isUseFrame){ CButton * pBtn = NULL; if(isUseFrame){ pBtn = CButton::createWith9SpriteFrameName(Size(w, h), normal, select, disable); }else{ pBtn = CButton::createWith9Sprite(Size(w,h),normal,select,disable); } if (lab) pBtn->initText(lab, font, fontSize, Size::ZERO, color); pBtn->setRotation(rotation); pBtn->setPosition(Vec2(x,-y)); pBtn->setTag(tag); return pBtn; }
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; }
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; }
bool CListViewBasicTest::init() { CListViewTestSceneBase::init(); setTitle("CListViewBasicTest"); setDescription("ListView Test"); //test data tagItem tag1 = { Size(480, 10), Color3B::WHITE }; tagItem tag2 = { Size(480, 20), Color3B::RED }; tagItem tag3 = { Size(480, 30), Color3B::GREEN }; tagItem tag4 = { Size(100, 40), Color3B::ORANGE }; tagItem tag5 = { Size(480, 50), Color3B::MAGENTA }; tagItem tag6 = { Size(400, 60), Color3B::BLUE }; tagItem tag7 = { Size(300, 80), Color3B::RED }; tagItem tag8 = { Size(480, 30), Color3B::GRAY }; tagItem tag9 = { Size(480, 40), Color3B::YELLOW }; m_lDatas.push_back(tag1); m_lDatas.push_back(tag2); m_lDatas.push_back(tag3); m_lDatas.push_back(tag4); m_lDatas.push_back(tag5); m_lDatas.push_back(tag6); m_lDatas.push_back(tag7); m_lDatas.push_back(tag8); m_lDatas.push_back(tag9); //<< 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, 320)); pButton->setOnClickListener(this, ccw_click_selector(CListViewBasicTest::onClick)); pButton->initText("Add", "", 30); m_pWindow->addChild(pButton); return true; }
bool CButton9SpriteTest::init() { CButtonTestSceneBase::init(); setTitle("CButton9SpriteTest"); setDescription("9PatchSprite by create"); CButton* pButton = CButton::createWith9Sprite(CCSize(196, 68),"sprite9_btn1.png", "sprite9_btn2.png"); pButton->initText("one", "", 30.0f); pButton->setPosition(CCPoint(480, 370)); m_pWindow->addChild(pButton); CButton* pButton2 = CButton::create(); pButton2->setContentSize(CCSize(196, 68)); pButton2->setScale9Enabled(true); pButton2->setNormalImage("sprite9_btn1.png"); pButton2->setSelectedImage("sprite9_btn2.png"); pButton2->initText("two", "", 30.0f); pButton2->setPosition(CCPoint(480, 270)); m_pWindow->addChild(pButton2); return true; }
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; }
void CListViewOperateTest::onClick(Ref* pSender) { CButton* pButton = (CButton*) pSender; switch(pButton->getUserTag()) { case 1: { CLayout* pLayout = CLayout::create(); pLayout->setContentSize(Size(480, 30)); /* CColorView* pColor = CColorView::create(Color4B(128, 0, 0, 255)); pColor->setContentSize(Size(478, 28)); pColor->setPosition(Point(480/2, 30/2)); pLayout->addChild(pColor); */ CButton* pButton = CButton::createWith9Sprite(Size(150, 25), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(480 /2, 30 /2)); char str[64] = {0}; sprintf(str, "%d", last_add_idx); pButton->initText(str, "", 20); pLayout->addChild(pButton); last_add_idx++; m_pListView->insertNodeAtLast(pLayout); m_pListView->reloadData(); } break; case 2: { CLayout* pLayout = CLayout::create(); pLayout->setContentSize(Size(480, 30)); /* CColorView* pColor = CColorView::create(Color4B(0, 128, 0, 255)); pColor->setContentSize(Size(478, 28)); pColor->setPosition(Point(480/2, 30/2)); pLayout->addChild(pColor); */ CButton* pButton = CButton::createWith9Sprite(Size(150, 25), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(480 /2, 30 /2)); char str[64] = {0}; sprintf(str, "%d", last_add_idx); pButton->initText(str, "", 20); pLayout->addChild(pButton); last_add_idx++; m_pListView->insertNodeAtFront(pLayout); m_pListView->reloadData(); } break; case 3: { m_pListView->removeLastNode(); m_pListView->reloadData(); } break; case 4: { m_pListView->removeFrontNode(); m_pListView->reloadData(); } break; default: break; } }