void CListViewBasicTest::onClick(Ref* pSender) { if( !m_lDatas.empty() ) { tagItem& tItem = m_lDatas.front(); CLayout* pLayout = CLayout::create(); pLayout->setContentSize(tItem.tSize); /* pLayout->setBackgroundColor(Color4B(tItem.tColor.r, tItem.tColor.g, tItem.tColor.b, 255)); */ pLayout->setBackgroundImage("icon.png"); pLayout->ignoreAnchorPointForPosition(false); pLayout->setAnchorPoint(Vec2(0.5f, 0.5f)); pLayout->setContentSize(Size(tItem.tSize.width - 4, tItem.tSize.height - 2)); pLayout->setPosition(Vec2(tItem.tSize.width/2, tItem.tSize.height/2)); m_pListView->insertNodeAtLast(pLayout); m_pListView->reloadData(); m_lDatas.pop_front(); } }
CLayout* CLayout::create(const Size& tContentSize) { CLayout* pRet = new CLayout(); if( pRet && pRet->init() ) { pRet->setContentSize(tContentSize); pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; }
void CVipCard::onEnter() { BaseLayer::onEnter(); //确定 CButton* pConfirm = (CButton*)m_ui->findWidgetById("confirm"); pConfirm->setOnClickListener(this, ccw_click_selector(CVipCard::onConfirm)); CButton* cancel = (CButton*)m_ui->findWidgetById("cancel"); cancel->setOnClickListener(this, ccw_click_selector(CVipCard::onCancel)); CButton* pClose = CButton::create("common/back.png", "common/back.png"); pClose->getSelectedImage()->setScale(1.1f); pClose->setPosition(VLEFT+50, VTOP-50); pClose->setOnClickListener(this,ccw_click_selector(CVipCard::onClose)); this->addChild(pClose, 999); CImageViewScale9* pRect1 = (CImageViewScale9*)m_ui->findWidgetById("rect1"); m_cardText = CursorTextField::textFieldWithPlaceHolder("", FONT_NAME, 29, CCSize(690, 110), ccBLACK); m_cardText->setPriority(this->getTouchPriority()); m_cardText->setLimitNum(17); m_cardText->setAnchorPoint(ccp(0, 0.5f)); m_cardText->setPosition( ccp(pRect1->getPositionX()-440, pRect1->getPositionY())); m_ui->addChild(m_cardText, 999); //展示区图片 CLayout *pShowInfo = CLayout::create(); CScrollView *pScroll = (CScrollView*)m_ui->findWidgetById("scroll_info"); pScroll->setDirection(eScrollViewDirectionVertical); pScroll->setBounceable(false); pScroll->getContainer()->addChild(pShowInfo); CCSize size = CCSize(957, 471); pShowInfo->setContentSize(size); pScroll->setContainerSize(size); pShowInfo->setPosition(ccp(pScroll->getContainerSize().width*0.5f, pScroll->getContainerSize().height*0.5f)); pScroll->setContentOffsetToTop(); //嫁接内容 CLayout* pLayout = (CLayout*)findWidgetById("layer_info"); pLayout->retain(); pLayout->removeFromParent(); pShowInfo->addChild(pLayout); pLayout->release(); pLayout->setPosition(ccp(size.width/2, size.height/2+10)); }
void TuiManager::parseControl(Node* container,xml_node<char> *item) { int tag = atof(item->first_attribute("tag")->value()); int x = atof(item->first_attribute("x")->value()); int y = atof(item->first_attribute("y")->value()); int w = atoi(item->first_attribute("width")->value()); int h = atoi(item->first_attribute("height")->value()); int rotation = atof(item->first_attribute("rotation")->value()); if (strcmp(item->first_attribute("type")->value(), kTuiContainerPanel) == 0){//panel CWidgetWindow* pPanel = createPanel(tag, x, y, w, h, rotation); container->addChild(pPanel); //recursive for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){ parseControl(pPanel, iitem); } }else if (strcmp(item->first_attribute("type")->value(),kTuiControlCell) == 0){//cell //recursive for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){ parseControl(container, iitem); } }else if(strcmp(item->first_attribute("type")->value(),kTuiControlImage) == 0){//image const char* file = item->first_attribute("image")->value(); float scaleX = atof(item->first_attribute("scaleX")->value()); float scaleY = atof(item->first_attribute("scaleY")->value()); int flipX = atoi(item->first_attribute("flipX")->value()); int flipY = atoi(item->first_attribute("flipY")->value()); int isUseFrame = atoi(item->first_attribute("spriteFrame")->value()); CImageView *pImg = createImage(tag, file, scaleX, scaleY, flipX, flipY, x, y, rotation, isUseFrame); container->addChild(pImg); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlImage9) == 0){//image9 const char* file = item->first_attribute("image")->value(); float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); float up = atof(item->first_attribute("up")->value()); float down = atof(item->first_attribute("down")->value()); float left = atof(item->first_attribute("left")->value()); float right = atof(item->first_attribute("right")->value()); int isUseFrame = atoi(item->first_attribute("spriteFrame")->value()); CImageViewScale9 *pImg = createImage9(tag,file,x,y,w,h,up,down,left,right,rotation,isUseFrame); container->addChild(pImg); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlButton) == 0){//button const char* normal = item->first_attribute("normal")->value(); const char* select = item->first_attribute("select")->value(); const char* disable = item->first_attribute("disable")->value(); float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); int isUseFrame = atoi(item->first_attribute("spriteFrame")->value()); CButton *pBtn = NULL; if (item->first_attribute("text")){ const char* lab = item->first_attribute("text")->value(); int r = atoi(item->first_attribute("red")->value()); int g = atoi(item->first_attribute("green")->value()); int b = atoi(item->first_attribute("blue")->value()); int fontSize = atoi(item->first_attribute("textSize")->value()); const char* font = item->first_attribute("textFont")->value(); pBtn = createBtn(tag, Color3B(r, g, b), fontSize, font, lab, normal, select, disable, x, y, w, h, rotation,isUseFrame); }else{ pBtn = createBtn(tag, Color3B(), 0, nullptr, nullptr, normal, select, disable, x, y, w, h, rotation,isUseFrame); } container->addChild(pBtn); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlToggleView) == 0){//toggleView const char* normal = item->first_attribute("normal")->value(); const char* select = item->first_attribute("select")->value(); const char* disable = item->first_attribute("disable")->value(); float exclusion = atof(item->first_attribute("exclusion")->value()); int isUseFrame = atoi(item->first_attribute("spriteFrame")->value()); CToggleView* toggle = createToggleView(tag, exclusion, normal, select, disable, x, y, rotation, isUseFrame); container->addChild(toggle); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlSlider) == 0){//slider const char* bg = item->first_attribute("bg")->value(); const char* progress = item->first_attribute("progress")->value(); const char* thumb = item->first_attribute("thumb")->value(); int max = atoi(item->first_attribute("max")->value()); int min = atoi(item->first_attribute("min")->value()); int cur = atoi(item->first_attribute("cur")->value()); int isUseFrame = atoi(item->first_attribute("spriteFrame")->value()); CSlider *pSlider = createSlider(tag,max,min,cur,bg,progress,thumb,x,y,rotation,isUseFrame); container->addChild(pSlider); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlProgress) == 0){//progress const char* bg = item->first_attribute("bg")->value(); const char* progress = item->first_attribute("progress")->value(); int isShowLabel = atoi(item->first_attribute("showLabel")->value()); int max = atoi(item->first_attribute("max")->value()); int min = atoi(item->first_attribute("min")->value()); int cur = atoi(item->first_attribute("cur")->value()); int isUseFrame = atoi(item->first_attribute("spriteFrame")->value()); CProgressBar *pProgress = createProgress(tag, max, min, cur, bg, progress, isShowLabel, x, y, rotation, isUseFrame); container->addChild(pProgress); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlLabel) == 0){//label float size = atof(item->first_attribute("textSize")->value()); int alignment = atoi(item->first_attribute("alignment")->value()); const char* text = item->first_attribute("text")->value(); const char* font = item->first_attribute("textFont")->value(); float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); int r = atoi(item->first_attribute("red")->value()); int g = atoi(item->first_attribute("green")->value()); int b = atoi(item->first_attribute("blue")->value()); int r2 = atoi(item->first_attribute("strokeRed")->value()); int g2 = atoi(item->first_attribute("strokeGreen")->value()); int b2 = atoi(item->first_attribute("strokeBlue")->value()); int strokeSize = atoi(item->first_attribute("strokeSize")->value()); int shadowDistance = atoi(item->first_attribute("shadowDistance")->value()); int shadowBlur = atoi(item->first_attribute("shadowBlur")->value()); CLabel *pLabel = createLabel(tag, text, font, alignment, size, r, g, b, x, y, w, h, r2,g2,b2,strokeSize,shadowDistance,shadowBlur,rotation); container->addChild(pLabel); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlLabelAtlas) == 0){//labelAtlas const char* imgPath = item->first_attribute("image")->value(); const char* num = item->first_attribute("num")->value(); float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); CLabelAtlas *pLabAtlas = createLabelAtlas(tag, num, imgPath, x, y, w, h, rotation); container->addChild(pLabAtlas); }else if (strcmp(item->first_attribute("type")->value(),kTuiControlLabelBMFont) == 0){//labelBmfont const char* file = item->first_attribute("fnt")->value(); const char* text = item->first_attribute("text")->value(); float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); CLabelBMFont *pLabBMFont = createLabelBMFont(tag, text, file, x, y, w, h, rotation); container->addChild(pLabBMFont); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlArmature) == 0){//armature const char* xml = item->first_attribute("xml")->value(); const char* png = item->first_attribute("png")->value(); const char* plist = item->first_attribute("plist")->value(); const char* name = item->first_attribute("name")->value(); const char* actionName = NULL; if (item->first_attribute("play")) actionName = item->first_attribute("play")->value(); Armature *pArmature = createArmature(tag, name,actionName,png, plist, xml, x, y, rotation); container->addChild(pArmature); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlAnim) == 0){//animation const char* plist = item->first_attribute("plist")->value(); const char* name = item->first_attribute("name")->value(); Sprite *pSprite = createAnim(tag,name,plist,x,y,rotation); container->addChild(pSprite); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlControl) == 0){//controlView const char* baseboard = item->first_attribute("baseboard")->value(); const char* joystick = item->first_attribute("joystick")->value(); int isUseFrame = atoi(item->first_attribute("spriteFrame")->value()); CControlView *pControl = createControl(tag, baseboard, joystick, x, y, rotation, isUseFrame); container->addChild(pControl); }else if (strcmp(item->first_attribute("type")->value(), kTuiContainerScroll) == 0){//scrollView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); int innerWidth = atoi(item->first_attribute("innerWidth")->value()); int innerHeight = atoi(item->first_attribute("innerHeight")->value()); int direction = atof(item->first_attribute("direction")->value()); int r = atoi(item->first_attribute("red")->value()); int g = atoi(item->first_attribute("green")->value()); int b = atoi(item->first_attribute("blue")->value()); int a = atoi(item->first_attribute("alpha")->value()); CScrollView *pView = createScrollView(tag,Color4B(r,g,b,a), direction, innerWidth, innerHeight, x, y, w, h, rotation); container->addChild(pView); //recursive for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){ parseControl(pView->getContainer(), iitem); } }else if (strcmp(item->first_attribute("type")->value(), kTuiContainerLayout) == 0){//layout float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); CLayout *pLayout = createLayout(tag, x, y, w, h, rotation); container->addChild(pLayout); //recursive for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){ parseControl(pLayout, iitem); } Vector<Node*> vet = pLayout->getChildren(); for (Node *pChild : vet){//Offset coordinates Because CLayout zero point in the lower left corner pChild->setPosition(pChild->getPosition() + Vec2(w / 2, h / 2)); } }else if (strcmp(item->first_attribute("type")->value(), kTuiControlListView) == 0){//listView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); float num = atof(item->first_attribute("num")->value()); int r = atoi(item->first_attribute("red")->value()); int g = atoi(item->first_attribute("green")->value()); int b = atoi(item->first_attribute("blue")->value()); int a = atoi(item->first_attribute("alpha")->value()); CListView* pList = createListView(tag, Color4B(r, g, b, a), x, y, w, h, rotation); container->addChild(pList); for (int i = 0; i < num; i++){//add item xml_node<char> *iitem = item->first_node(kTuiNodeControl); w = atof(iitem->first_attribute("width")->value()); h = atof(iitem->first_attribute("height")->value()); CLayout *pLayout = createLayout(i, 0, 0, w, h, rotation); for (xml_node<char> *iiitem = iitem->first_node(kTuiNodeControl); iiitem != NULL; iiitem = iiitem->next_sibling()){ parseControl(pLayout, iiitem); } Vector<Node*> vet = pLayout->getChildren(); for (Node *pChild : vet){//Offset coordinates Because CLayout zero point in the lower left corner if (pChild->getTag() > 0) pChild->setPosition(pChild->getPosition() + Vec2(w / 2, h / 2)); } pList->insertNodeAtLast(pLayout); } pList->reloadData(); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlExpList) == 0){//explist float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); float num = atof(item->first_attribute("num")->value()); int r = atoi(item->first_attribute("red")->value()); int g = atoi(item->first_attribute("green")->value()); int b = atoi(item->first_attribute("blue")->value()); int a = atoi(item->first_attribute("alpha")->value()); CExpandableListView* pList = createExpandableListView(tag, Color4B(r, g, b, a), x, y, w, h, rotation); container->addChild(pList); for (int i = 0; i < num; i++){//add item xml_node<char> *iitem = item->first_node(kTuiNodeControl); w = atof(iitem->first_attribute("width")->value()); h = atof(iitem->first_attribute("height")->value()); int iw, ih = 0; CExpandableNode *pExpNode = createExpandNode(i, 0, 0, w, h, rotation); CLayout *pExpNodeItem = nullptr; for (xml_node<char> *iiitem = iitem->first_node(kTuiNodeControl); iiitem != NULL; iiitem = iiitem->next_sibling()){ if (strcmp(iiitem->first_attribute("type")->value(), kTuiContainerLayout) != 0){ parseControl(pExpNode, iiitem); }else{ pExpNodeItem = createLayout(0, 0, 0, w, h, rotation); iw = atof(iiitem->first_attribute("width")->value()); ih = atof(iiitem->first_attribute("height")->value()); pExpNodeItem->setContentSize(Size(iw, ih)); for (xml_node<char> *iiiitem = iiitem->first_node(kTuiNodeControl); iiiitem != NULL; iiiitem = iiiitem->next_sibling()){ parseControl(pExpNodeItem, iiiitem); } } } for (Node *c : pExpNode->getChildren()) { if (c->getTag() > 0) c->setPosition(c->getPosition() + Vec2(w / 2, h / 2)); } for (Node *c : pExpNodeItem->getChildren()) { c->setPosition(c->getPosition() + Vec2(iw/2, ih / 2)); } pExpNode->insertItemNodeAtLast(pExpNodeItem); pList->insertExpandableNodeAtLast(pExpNode); } pList->reloadData(); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlCheckBox) == 0){//checkBox const char* normal1 = item->first_attribute("normal1")->value(); const char* normal2 = item->first_attribute("normal2")->value(); const char* select1 = item->first_attribute("select1")->value(); const char* select2 = item->first_attribute("select2")->value(); const char* disable1 = item->first_attribute("disable1")->value(); const char* disable2 = item->first_attribute("disable2")->value(); int isUseFrame = atoi(item->first_attribute("spriteFrame")->value()); CCheckBox *pCheckBox = createCheckBox(tag,normal1,normal2,select1,select2,disable1,disable2,x,y,rotation,isUseFrame); container->addChild(pCheckBox); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlArmatureBtn) == 0){//ArmatureBtn const char* png = item->first_attribute("png")->value(); const char* plist = item->first_attribute("plist")->value(); const char* name = item->first_attribute("name")->value(); const char* xml = item->first_attribute("xml")->value(); const char* normal = item->first_attribute("normal")->value(); const char* select = item->first_attribute("select")->value(); ArmatureBtn *pArmBtn = createArmatureBtn(tag, name, normal, select, png, plist, xml, x, y, rotation); container->addChild(pArmBtn); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlNumbericStepper) == 0){//NumbericStepper const char* lnormal = item->first_attribute("lnormal")->value(); const char* rnormal = item->first_attribute("rnormal")->value(); const char* lselect = item->first_attribute("lselect")->value(); const char* rselect = item->first_attribute("rselect")->value(); const char* ldisable = item->first_attribute("ldisable")->value(); const char* rdisable = item->first_attribute("rdisable")->value(); const char* stepBg = item->first_attribute("stepBg")->value(); int isLongClickRun = atoi(item->first_attribute("longClickRun")->value()); int max = atoi(item->first_attribute("max")->value()); int min = atoi(item->first_attribute("min")->value()); int cur = atoi(item->first_attribute("cur")->value()); int step = atoi(item->first_attribute("step")->value()); int isUseFrame = atoi(item->first_attribute("spriteFrame")->value()); NumericStepper *pNumStep = createNumStep(tag, isLongClickRun,max,min,cur,step,lnormal, lselect, ldisable, rnormal, rselect, rdisable, stepBg, x, y, rotation, isUseFrame); container->addChild(pNumStep); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlPaticle) == 0){//Particle const char* plist = item->first_attribute("plist")->value(); ParticleSystem *pPartical = createParticle(tag,plist,x,y); container->addChild(pPartical); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlPageView) == 0){//pageView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); float num = atoi(item->first_attribute("num")->value()); int dir = atoi(item->first_attribute("direction")->value()); int r = atoi(item->first_attribute("red")->value()); int g = atoi(item->first_attribute("green")->value()); int b = atoi(item->first_attribute("blue")->value()); int a = atoi(item->first_attribute("alpha")->value()); CPageView *pPageView = createPageView(tag, Color4B(r,g,b,a), dir, num, x, y, w, h, rotation); container->addChild(pPageView); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlTable) == 0){//TableView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); float num = atoi(item->first_attribute("num")->value()); int dir = atoi(item->first_attribute("direction")->value()); int cellWidth = atoi(item->first_attribute("cellWidth")->value()); int cellHeight = atoi(item->first_attribute("cellHeight")->value()); int r = atoi(item->first_attribute("red")->value()); int g = atoi(item->first_attribute("green")->value()); int b = atoi(item->first_attribute("blue")->value()); int a = atoi(item->first_attribute("alpha")->value()); CTableView *pView = createTableView(tag, Color4B(r, g, b, a), dir, num, cellWidth, cellHeight, x, y, w, h, rotation); container->addChild(pView); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlGridView) == 0){//GridView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); int cellWidth = atoi(item->first_attribute("cellWidth")->value()); int cellHeight = atoi(item->first_attribute("cellHeight")->value()); int column = atoi(item->first_attribute("column")->value()); int num = atoi(item->first_attribute("num")->value()); int r = atoi(item->first_attribute("red")->value()); int g = atoi(item->first_attribute("green")->value()); int b = atoi(item->first_attribute("blue")->value()); int a = atoi(item->first_attribute("alpha")->value()); CGridView *pView = createGridView(tag, Color4B(r, g, b, a), column, num, cellWidth, cellHeight, x, y, w, h, rotation); container->addChild(pView); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlGridPageView) == 0){//GridPageView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); int cellWidth = atoi(item->first_attribute("cellWidth")->value()); int cellHeight = atoi(item->first_attribute("cellHeight")->value()); int column = atoi(item->first_attribute("column")->value()); int row = atoi(item->first_attribute("row")->value()); int num = atoi(item->first_attribute("num")->value()); int dir = atoi(item->first_attribute("direction")->value()); int r = atoi(item->first_attribute("red")->value()); int g = atoi(item->first_attribute("green")->value()); int b = atoi(item->first_attribute("blue")->value()); int a = atoi(item->first_attribute("alpha")->value()); CGridPageView *pView = createGridPageView(tag, Color4B(r, g, b, a), dir, column, row, num, cellWidth, cellHeight, x, y, w, h, rotation); container->addChild(pView); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlEditBox) == 0){//EditBox float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); const char* img = item->first_attribute("image")->value(); int inputMode = atoi(item->first_attribute("inputMode")->value()); int inputFlag = atoi(item->first_attribute("inputFlag")->value()); const char* placeHolder = item->first_attribute("placeHolder")->value(); int isUseFrame = atoi(item->first_attribute("spriteFrame")->value()); extension::EditBox *pEdit = createEditBox(tag, placeHolder, img, inputMode, inputFlag, x, y, w, h, rotation,isUseFrame); container->addChild(pEdit); }else if (strcmp(item->first_attribute("type")->value(), kTuiContainerCircleMenu) == 0){//CircleMenu float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); CircleMenu *pMenu = createCircleMenu(tag, x, y, w, h, rotation); container->addChild(pMenu); //recursive for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){ parseControl(pMenu, iitem); } pMenu->reloadData(); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlRichText) == 0){ const char* text = item->first_attribute("text")->value(); int maxLen = atoi(item->first_attribute("max")->value()); int isSpriteFrame = atoi(item->first_attribute("spriteFrame")->value()); CTextRich *pTextRich = createTextRich(tag, text, maxLen, x, y, w, h, rotation, isSpriteFrame); container->addChild(pTextRich); } }
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; } }