void ButtonTest::buttonBackground() { CALabel* buttonImage = CALabel::createWithCenter(CCRect(size.width*0.5, size.height*0.3, size.width*0.4, 50)); buttonImage->setText("ButtonImage"); buttonImage->setFontSize(30 * CROSSAPP_ADPTATION_RATIO); buttonImage->setTextAlignment(CATextAlignmentCenter); buttonImage->setColor(ccc4(51, 204, 255, 255)); this->getView()->addSubview(buttonImage); CAButton* defaultBtn = CAButton::create(CAButtonTypeCustom); defaultBtn->setCenter(CCRect(size.width*0.25 - 50, size.height*0.4, size.width*0.2, size.height*0.05)); defaultBtn->setTitleForState(CAControlStateNormal, "Normal"); defaultBtn->setTitleForState(CAControlStateSelected,"Selected"); defaultBtn->setTitleForState(CAControlStateHighlighted, "Highlighted"); defaultBtn->setBackGroundViewForState(CAControlStateNormal,CAView::createWithColor(CAColor_green)); defaultBtn->setBackGroundViewForState(CAControlStateHighlighted, CAView::createWithColor(CAColor_yellow)); defaultBtn->setTitleColorForState(CAControlStateAll, ccc4(51, 204, 255, 255)); this->getView()->addSubview(defaultBtn); CALabel* custom = CALabel::createWithCenter(CCRect(size.width*0.25 - 50, size.height*0.4 + 80, size.width*0.2, 50)); custom->setText("(BackgroundView)"); custom->setFontSize(20 * CROSSAPP_ADPTATION_RATIO); custom->setTextAlignment(CATextAlignmentCenter); custom->setColor(ccc4(51, 204, 255, 255)); this->getView()->addSubview(custom); CAButton* squareRectBtn = CAButton::create(CAButtonTypeSquareRect); squareRectBtn->setCenter(CCRect(size.width*0.5, size.height*0.4, size.width*0.2, size.height*0.05)); squareRectBtn->setImageForState(CAControlStateNormal,CAImage::create("square_nor.png")); squareRectBtn->setImageForState(CAControlStateHighlighted, CAImage::create("square_sel.png")); this->getView()->addSubview(squareRectBtn); CALabel* square = CALabel::createWithCenter(CCRect(size.width*0.5, size.height*0.4 + 80, size.width*0.2, 50)); square->setText("(StateImage)"); square->setFontSize(20 * CROSSAPP_ADPTATION_RATIO); square->setTextAlignment(CATextAlignmentCenter); square->setColor(ccc4(51, 204, 255, 255)); this->getView()->addSubview(square); CAButton* roundedRectBtn = CAButton::create(CAButtonTypeRoundedRect); roundedRectBtn->setCenter(CCRect(size.width*0.75 + 50, size.height*0.4, size.width*0.2, size.height*0.05)); roundedRectBtn->setControlState(CAControlStateDisabled); this->getView()->addSubview(roundedRectBtn); CALabel* rounded = CALabel::createWithCenter(CCRect(size.width*0.75 + 50, size.height*0.4 + 80, size.width*0.2, 50)); rounded->setText("(Disabled)"); rounded->setFontSize(20 * CROSSAPP_ADPTATION_RATIO); rounded->setTextAlignment(CATextAlignmentCenter); rounded->setColor(ccc4(51, 204, 255, 255)); this->getView()->addSubview(rounded); }
void SessionsViewController::viewDidLoad() { // Do any additional setup after loading the view from its nib. m_winSize = this->getView()->getBounds().size; CAScale9ImageView* sView = CAScale9ImageView::createWithImage(CAImage::create("common/sky_bg.png")); sView->setFrame(DRect(_px(0), _px(0), m_winSize.width, _px(120))); this->getView()->addSubview(sView); CAButton* button = CAButton::createWithFrame(DRect(_px(20), _px(20), _px(100), _px(100)), CAButtonTypeCustom); CAImageView* imageView = CAImageView::createWithImage(CAImage::create("main/nav_notification.png")); imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY); button->setBackGroundViewForState(CAControlStateAll, imageView); button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide); button->setTag(20); this->getView()->addSubview(button); m_timeNoticeImageView = CAImageView::createWithFrame(DRect(_px(60), _px(30), _px(10), _px(10))); m_timeNoticeImageView->setImage(CAImage::create("common/reddot.png")); button->addSubview(m_timeNoticeImageView); button = CAButton::createWithFrame(DRect(m_winSize.width - _px(120), _px(20), _px(100), _px(100)), CAButtonTypeCustom); imageView = CAImageView::createWithImage(CAImage::create("main/nav_prize.png")); imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY); button->setBackGroundViewForState(CAControlStateAll, imageView); button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide); button->setTag(30); this->getView()->addSubview(button); CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 2, _px(70), m_winSize.width, _px(40))); label->setTextAlignment(CATextAlignmentCenter); label->setColor(CAColor_white); label->setFontSize(_px(40)); label->setText("Agenda"); label->setFontName("fonts/arial.ttf"); sView->addSubview(label); if (m_msg.empty()) { requestMsg(); } else { this->initMsgTableView(); } CCLog("%f", CAApplication::getApplication()->getWinSize().width); }
void CATextToolBarView::show(CAView* pView) { CCSize winSize = CAApplication::getApplication()->getWinSize(); float alertViewButtonHeight = 88; float alertViewWidth = winSize.width * 2 / 3; CCRect rect = CCRect(winSize.width / 2, winSize.height / 2 - alertViewButtonHeight, alertViewWidth, alertViewButtonHeight); m_pBackView = CAClippingView::create(); m_pBackView->setCenter(rect); this->addSubview(m_pBackView); this->setTextTag("CATextToolBarView"); m_pBackView->setAlphaThreshold(0.5f); CAScale9ImageView *backgroundImageView = CAScale9ImageView::createWithFrame(m_pBackView->getBounds()); backgroundImageView->setImage(CAImage::create("source_material/alert_back.png")); m_pBackView->addSubview(backgroundImageView); m_pBackView->setStencil(backgroundImageView->copy()); size_t btnCount = m_CallbackTargets.size(); for (int i = 0; i < btnCount; i++) { CAButton* btn = CAButton::create(CAButtonTypeSquareRect); btn->setTitleForState(CAControlStateAll, m_CallbackTargets[i].cszButtonText.c_str()); btn->setTitleColorForState(CAControlStateAll, ccc4(3, 100, 255, 255)); btn->setBackGroundViewForState(CAControlStateNormal, CAView::createWithColor(CAColor_clear)); btn->setBackGroundViewForState(CAControlStateHighlighted, CAView::createWithColor(ccc4(226, 226, 226, 225))); btn->setTag(i); btn->addTarget(this, CAControl_selector(CATextToolBarView::alertViewCallback), CAControlEventTouchUpInSide); btn->setFrame(CCRect(i*alertViewWidth / btnCount, 0, alertViewWidth / btnCount, alertViewButtonHeight)); m_pBackView->addSubview(btn); if (i>0) { addGrayLine(alertViewWidth/btnCount * i); } } if (CAWindow *rootWindow = CAApplication::getApplication()->getRootWindow()) { rootWindow->insertSubview(this, CAWindowZOderTop); } becomeFirstResponder(); m_pControlView = pView; }
CAButton* CASegmentedControl::createDefaultSegment() { CCRect elemFrame = CCRectMake(0, 0, m_itemSize.width, m_itemSize.height); CAButton *newBtn = CAButton::createWithFrame(elemFrame, CAButtonTypeCustom); if (newBtn) { CAView* normalBG = this->getDefaultNormalBackgroundView(); CAView* selectedBG = this->getDefaultSelectedBackgroundView(); CAView* highlightedBG = this->getDefaultHighlightedBackgroundView(); newBtn->setBackGroundViewForState(CAControlStateNormal, normalBG); newBtn->setBackGroundViewForState(CAControlStateSelected, selectedBG); newBtn->setBackGroundViewForState(CAControlStateHighlighted, highlightedBG); newBtn->setAllowsSelected(true); newBtn->setTouchEnabled(false); } return newBtn; }
void registerViewController::changeButtonView(CAControl*control, CCPoint){ CAView* _view2 = CAScale9ImageView::createWithImage(CAImage::create("image/bg1.png")); CAView* _view3 = CAScale9ImageView::createWithImage(CAImage::create("image/bg1R.png")); CAButton* btn = dynamic_cast<CAButton*>(control); if (btn->getTag() ==99) { btn->setBackGroundViewForState(CAControlStateAll, _view2); // authCodeButton->setBackGroundViewForState(CAControlStateDisabled, CAView::createWithColor(CAColor_gray)); btn->setTag(100); } else if (btn->getTag() == 100) { btn->setBackGroundViewForState(CAControlStateAll, _view3); // authCodeButton->setBackGroundViewForState(CAControlStateNormal, CAView::createWithColor(CAColor_blue)); btn->setTag(99); } }
void DMCatalogController::initWithCollectionView() { CADipRect rect = this->getView()->getBounds(); m_uiItems = (unsigned int)(rect.size.width / 300); m_uiItems = MIN(m_uiItems, 5); m_uiItems = MAX(m_uiItems, 3); m_pCollectionView = CACollectionView::createWithFrame(rect); m_pCollectionView->setCollectionViewDataSource(this); m_pCollectionView->setCollectionViewDelegate(this); m_pCollectionView->setScrollViewDelegate(this); CAPullToRefreshView* view = CAPullToRefreshView::create(CAPullToRefreshView::CAPullToRefreshTypeHeader); m_pCollectionView->setHeaderRefreshView(view); m_pCollectionView->setBackGroundColor(CAColor_clear); this->getView()->addSubview(m_pCollectionView); m_pCollectionView->setAllowsSelection(true); m_pCollectionView->setHoriInterval(_px(30)); m_pCollectionView->setVertInterval(_px(10)); float width = this->getView()->getBounds().size.width; m_pCollectionView->setCollectionHeaderHeight(width * 15/32.0f); CAButton* bg = CAButton::createWithFrame(CADipRect(0, 0, rect.size.width, _dip(m_pCollectionView->getCollectionHeaderHeight())), CAButtonTypeCustom); m_pHeaderImageView = CommonUrlImageView::createWithImage(NULL); bg->setBackGroundViewForState(CAControlStateNormal, m_pHeaderImageView); bg->addTarget(this, CAControl_selector(DMCatalogController::onButton), CAControlEventTouchUpInSide); m_pCollectionView->setCollectionHeaderView(bg); CADipRect headerRect = CADipRectZero; headerRect.size = rect.size; headerRect.size.height = 76; headerRect.origin.y = _dip(m_pCollectionView->getCollectionHeaderHeight()) - 76; CAImageView* imageView = CAImageView::createWithFrame(headerRect); imageView->setImage(CAImage::create(title_bg_first)); bg->insertSubview(imageView,1); headerRect.origin.x = 25; headerRect.size.height -= 20; headerRect.size.width -= headerRect.origin.x; headerRect.origin.y = _dip(m_pCollectionView->getCollectionHeaderHeight()) - headerRect.size.height; m_pHeaderLabel = CALabel::createWithFrame(headerRect); m_pHeaderLabel->setFontSize(_px(28)); m_pHeaderLabel->setColor(CAColor_white); m_pHeaderLabel->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); bg->insertSubview(m_pHeaderLabel,1); if (!m_mvData[m_sTitle].empty()) { const DMBriefInfo& info = m_mvData[m_sTitle].front(); m_pHeaderLabel->setText("《" + info.title + "》" + info.subtitle); m_pHeaderImageView->setUrl(info.cover); } }
void CATabBar::showSelectedBackGround() { for (size_t i=0; i<m_pButtons.size(); i++) { CAButton* btn = m_pButtons.at(i); btn->setTitleForState(CAControlStateAll, m_pItems.at(i)->getTitle()); btn->setTitleColorForState(CAControlStateAll, m_sTitleColor); btn->setTitleColorForState(CAControlStateHighlighted, m_sSelectedTitleColor); btn->setTitleColorForState(CAControlStateSelected, m_sSelectedTitleColor); btn->setImageForState(CAControlStateNormal, m_pItems.at(i)->getImage()); CAImage* selectedImage = m_pItems.at(i)->getSelectedImage() ? m_pItems.at(i)->getSelectedImage() : m_pItems.at(i)->getImage(); btn->setImageForState(CAControlStateHighlighted, selectedImage); btn->setImageForState(CAControlStateSelected, selectedImage); btn->setBackGroundViewForState(CAControlStateNormal, CAView::createWithColor(CAColor_clear)); if (m_pSelectedBackGroundImage) { btn->setBackGroundViewForState(CAControlStateHighlighted, CAScale9ImageView::createWithImage(m_pSelectedBackGroundImage)); btn->setBackGroundViewForState(CAControlStateSelected, CAScale9ImageView::createWithImage(m_pSelectedBackGroundImage)); } else { btn->setBackGroundViewForState(CAControlStateHighlighted, CAView::createWithColor(m_sSelectedBackGroundColor)); btn->setBackGroundViewForState(CAControlStateSelected, CAView::createWithColor(m_sSelectedBackGroundColor)); } btn->setAllowsSelected(true); CABadgeView* badgeView = m_pBadgeViews.at(i); badgeView->setBadgeText(m_pItems.at(i)->getBadgeValue()); } }
bool CASegmentedControl::setBackgroundImageAtIndex(CAImage *image, int index, CAControlState controlState) { if (!this->indexIsValid(index)) { return false; } CAButton *btn = m_segments.at(index); if (NULL == btn) { return false; } btn->setBackGroundViewForState(controlState, CAScale9ImageView::createWithImage(image)); return true; }
bool CASegmentedControl::setBackgroundViewAtIndex(CAView *view, int index, const CAControlState& controlState) { if (!this->indexIsValid(index)) { return false; } CAButton *btn = m_segments.at(index); if (NULL == btn) { return false; } btn->setBackGroundViewForState(controlState, view); return true; }
void ButtonTest::buttonTouchEvent(void) { CADipSize size = eventView->getBounds().size; CALabel* buttonTouch = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.2, size.width*0.4, 50)); buttonTouch->setText("TouchEvent"); buttonTouch->setFontSize(_px(35)); buttonTouch->setTextAlignment(CATextAlignmentCenter); buttonTouch->setColor(CAColor_blueStyle); eventView->addSubview(buttonTouch); CAButton* btnOne = CAButton::create(CAButtonTypeCustom); btnOne->setCenter(CADipRect(size.width*0.25 - 50, size.height*0.5, size.width*0.25, size.height*0.1)); btnOne->setTag(BUTTONONE); btnOne->setTitleForState(CAControlStateAll, "TouchDown"); btnOne->setTitleColorForState(CAControlStateNormal, CAColor_blueStyle); btnOne->setBackGroundViewForState(CAControlStateNormal, CAScale9ImageView::createWithImage(CAImage::create("source_material/round1.png"))); btnOne->setBackGroundViewForState(CAControlStateHighlighted, CAScale9ImageView::createWithImage(CAImage::create("source_material/round2.png"))); btnOne->addTarget(this, CAControl_selector(ButtonTest::buttonCallback), CAControlEventTouchDown); eventView->addSubview(btnOne); CAButton* btnTwo = CAButton::create(CAButtonTypeSquareRect); btnTwo->setCenter(CADipRect(size.width*0.5, size.height*0.5, size.width*0.25, size.height*0.1)); btnTwo->setTag(BUTTONTWO); btnTwo->setTitleForState(CAControlStateAll, "TouchMoved"); btnTwo->setTitleColorForState(CAControlStateNormal,CAColor_white); btnTwo->setBackGroundViewForState(CAControlStateNormal, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_square_highlighted.png"))); btnTwo->setBackGroundViewForState(CAControlStateHighlighted, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_square_selected.png"))); btnTwo->addTarget(this, CAControl_selector(ButtonTest::buttonCallback), CAControlEventTouchMoved); eventView->addSubview(btnTwo); CAButton* btnThree = CAButton::create(CAButtonTypeRoundedRect); btnThree->setCenter(CADipRect(size.width*0.75 + 50, size.height*0.5, size.width*0.25, size.height*0.1)); btnThree->setTag(BUTTONTHREE); btnThree->setTitleForState(CAControlStateAll, "TouchUpInSide"); btnThree->setTitleColorForState(CAControlStateNormal, CAColor_white); btnThree->setBackGroundViewForState(CAControlStateNormal, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_highlighted.png"))); btnThree->setBackGroundViewForState(CAControlStateHighlighted, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_selected.png"))); btnThree->addTarget(this, CAControl_selector(ButtonTest::buttonCallback), CAControlEventTouchUpInSide); eventView->addSubview(btnThree); descTest = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.8, size.width, 50)); descTest->setText("Display coordinates"); descTest->setFontSize(_px(30)); descTest->setColor(CAColor_blueStyle); descTest->setTextAlignment(CATextAlignmentCenter); eventView->addSubview(descTest); }
CCObject* CAUIHelper::addButton(CSJson::Value jsonValue, cocos2d::CCRect &uiRect) { CAButton *btn = CAButton::createWithFrame(uiRect, CAButtonTypeRoundedRect); int tag = jsonValue["tag"].asInt(); // bool isEffect = jsonValue["isEffect"].asBool(); // bool isClick = jsonValue["isClick"].asBool(); // bool isTouchSuspend = jsonValue["isTouchSuspend"].asBool(); CAControlState btnState = (CAControlState)jsonValue["btnState"].asInt(); int alpha = jsonValue["alpha"].asInt(); std::string imageRes = jsonValue["backgroundImage"].asString(); mCAButtonType btntype = (mCAButtonType)jsonValue["btnType"].asInt(); btn->setTag(tag); btn->setOpacity(alpha); btn->setControlState(btnState); if (btntype == ButtonColor) { } else if (btntype == ButtonGrid9) { CAScale9ImageView *image = CAScale9ImageView::createWithImage(CAImage::create(imageRes.c_str())); btn->setBackGroundViewForState(CAControlStateNormal, image); } else if (btntype == ButtonImage) { } else if (btntype == ButtonNone) { } return btn; }
bool CASegmentedControl::insertSegmentWithBackgroundImage(CAImage *image, int index, CAControlState controlState) { const int curItemCount = m_segments.size(); if (index < 0) { index = 0; } else if (index >= curItemCount) { index = curItemCount; } CAButton *newBtn = this->createDefaultSegment(); if (NULL == newBtn) { return false; } newBtn->setBackGroundViewForState(controlState, CAScale9ImageView::createWithImage(image)); m_segments.insert(m_segments.begin() + index, newBtn); this->addSubview(newBtn); this->layoutSubviews(); return true; }
void MainViewController::viewDidLoad() { // Do any additional setup after loading the view from its nib. m_winSize = this->getView()->getBounds().size; // header CAScale9ImageView* header = CAScale9ImageView::createWithImage(CAImage::create("common/sky_bg.png")); if (header) { header->setFrame(DRect((0), (0), m_winSize.width, (120))); header->setTouchEnabled(false); this->getView()->addSubview(header); // title lable CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 2, (80), m_winSize.width, (50))); if (label) { label->setTextAlignment(CATextAlignmentCenter); label->setColor(CAColor_white); label->setFontSize(SAP_TITLE_FONT_SIZE); label->setText("SAP d-kom"); label->setFontName(SAP_FONT_ARIAL); label->setTouchEnabled(false); header->addSubview(label); } } // left notification button CAButton* button = CAButton::createWithFrame(DRect((0), (20), (100), (100)), CAButtonTypeCustom); if (button) { button->addTarget(this, CAControl_selector(MainViewController::buttonCallBack), CAControlEventTouchUpInSide); button->setTag(20); this->getView()->addSubview(button); CAImageView* imageView = CAImageView::createWithImage(CAImage::create("main/nav_notification.png")); if (imageView) { imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY); button->setBackGroundViewForState(CAControlStateAll, imageView); } m_timeNoticeImageView = CAImageView::createWithFrame(DRect((60), (30), (20), (20))); if (m_timeNoticeImageView) { m_timeNoticeImageView->setImage(CAImage::create("common/reddot.png")); button->addSubview(m_timeNoticeImageView); } //refreshNoticeRedPoint(); } // notification alert point /* // right survey button button = CAButton::createWithFrame(DRect(m_winSize.width - (100), (20), (100), (100)), CAButtonTypeCustom); if (button) { button->addTarget(this, CAControl_selector(MainViewController::buttonCallBack), CAControlEventTouchUpInSide); button->setTag(30); this->getView()->addSubview(button); CAImageView* imageView = CAImageView::createWithImage(CAImage::create("main/nav_survey.png")); if (imageView) { imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY); button->setBackgroundViewForState(CAControlStateAll, imageView); } } // survey lable CALabel * surveylable = CALabel::createWithFrame(DRect(m_winSize.width - (75), (100), (100), (25))); if (surveylable) { surveylable->setTextAlignment(CATextAlignmentLeft); surveylable->setColor(CAColor_white); surveylable->setFontSize(15); surveylable->setText("Survey"); surveylable->setFontName(SAP_FONT_ARIAL); surveylable->setTouchEnabled(false); this->getView()->addSubview(surveylable); } */ int pageViewHeight = m_winSize.height * 0.3; int butViewHeight = m_winSize.height * 0.15; int headerHeight = (120); int buttitleHeight = (40); /* // Page view if (!m_pageView) { m_pageView = CAPageView::createWithFrame(DRect(0, headerHeight, m_winSize.width, pageViewHeight), CAPageViewDirectionHorizontal); if (m_pageView) { m_pageView->setPageViewDelegate(this); m_pageView->setTouchEnabled(true); CAVector<CAView* > viewList; for (int i = 0; i<m_page.size(); i++) { CommonUrlImageView* temImage = CommonUrlImageView::createWithFrame(DRect(0, (0), m_winSize.width, pageViewHeight - headerHeight)); temImage->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop); temImage->setImage(CAImage::create("common/bg.png")); temImage->setUrl(m_page[i].m_imageUrl); temImage->setTouchEnabled(false); viewList.pushBack(temImage); } m_pageView->setViews(viewList); m_pageView->setCurrPage(0, false); this->getView()->addSubview(m_pageView); //headView->addSubview(m_pageView); } } // picture dots bg in page view m_pageControlBG = CAView::createWithColor(ccc4(0, 0, 0, 20)); m_pageControlBG->setFrame(DRect(0, pageViewHeight + headerHeight - (50), m_winSize.width, (50))); m_pageControlBG->setTouchEnabled(false); this->getView()->addSubview(m_pageControlBG); //headView->addSubview(bg); // picture dots m_pageControl = CAPageControl::createWithCenter(DRect(m_winSize.width / 2, pageViewHeight + headerHeight - (25), (120), (50))); if (m_pageControl) { m_pageControl->setNumberOfPages((int)m_page.size()); m_pageControl->setTag(200); m_pageControl->addTarget(this, CAControl_selector(MainViewController::buttonCallBack)); this->getView()->addSubview(m_pageControl); } //headView->addSubview(m_pageControl); */ int buttonHight = (150);//m_winSize.height * 0.15;//(116); // three center button for (int i = 0; i < 3; i++) { DRect r(i * (m_winSize.width / 3), headerHeight + pageViewHeight, m_winSize.width / 3, buttonHight); CAButton* btn = CAButton::createWithFrame(r, CAButtonTypeCustom); btn->setTag(300 + i); CAImageView* imageView = CAImageView::createWithCenter(DRect(m_winSize.width / 3 / 2, (60), (60), (60)));//createWithImage(CAImage::create(crossapp_format_string("main/short_%d.png", i))); imageView->setImage(CAImage::create(crossapp_format_string("main/short_%d.png", i))); imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY); //imageView->setFrame(DRect(m_winSize.width / 3 / 2, (30), (60), (60))); imageView->setTouchEnabled(false); btn->addSubview(imageView); CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 3 / 2, (140), m_winSize.width / 3, (60))); label->setTextAlignment(CATextAlignmentCenter); label->setColor(CAColor_gray); label->setFontSize((28)); label->setText(unicode_to_utf8(mainShort[i])); label->setFontName(SAP_FONT_ARIAL); label->setTouchEnabled(false); btn->addSubview(label); btn->addTarget(this, CAControl_selector(MainViewController::buttonCallBack), CAControlEventTouchUpInSide); this->getView()->addSubview(btn); //headView->addSubview(btn); } /* if (m_page.size() > 0) { m_pageViewTitle = CALabel::createWithFrame(DRect(20, m_winSize.width / 2 - 40, m_winSize.width - 50, 50)); m_pageViewTitle->setText(m_page[0].m_title); m_pageViewTitle->setColor(CAColor_white); m_pageViewTitle->setFontSize((28)); m_pageViewTitle->setScrollEnabled(false); m_pageViewTitle->setTouchEnabled(false); this->getView()->addSubview(m_pageViewTitle); //headView->addSubview(m_pageViewTitle); } */ // sub title bar left picture CAView *subViewleft = CAView::createWithCenter(DRect((100), headerHeight + pageViewHeight + buttonHight + (20), m_winSize.width / 4, (20))); //CAView *subViewleft = CAView::createWithFrame(DRect(0, 0, m_winSize.width, (20))); CAImageView* subbarView1 = CAImageView::createWithImage(CAImage::create("main/home_bar.png")); subbarView1->setImageViewScaleType(CAImageViewScaleTypeFitImageXY); subbarView1->setFrame(DRect(0, 0, m_winSize.width / 4, (20))); subbarView1->setTouchEnabled(false); subViewleft->addSubview(subbarView1); this->getView()->addSubview(subViewleft); // sub title CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 2, headerHeight + pageViewHeight + buttonHight + (30), m_winSize.width / 2, (45))); label->setTextAlignment(CATextAlignmentCenter); label->setColor(CAColor_gray);//ccc4(0x0f, 0xaa, 0xff, 0xff));//CAColor_gray);//CAColor_blue); label->setFontSize((27)); label->setText("My Agenda"); label->setFontName(SAP_FONT_ARIAL);//markerfelt.ttf"); label->setTouchEnabled(false); this->getView()->addSubview(label); // sub title bar right picture CAView *subViewright = CAView::createWithCenter(DRect(m_winSize.width - (100), headerHeight + pageViewHeight +buttonHight + (20), m_winSize.width / 4, (20))); CAImageView* subbarView2 = CAImageView::createWithImage(CAImage::create("main/home_bar.png")); subbarView2->setImageViewScaleType(CAImageViewScaleTypeFitImageXY); subbarView2->setFrame(DRect(0, 0, m_winSize.width / 4, (20))); subbarView2->setTouchEnabled(false); subViewright->addSubview(subbarView2); this->getView()->addSubview(subViewright); //CAView* headView = CAView::createWithFrame(DRect(0, 0, m_winSize.width, m_winSize.width * 0.6 - (120))); //m_msgTableView->setTableHeaderView(headView); //m_msgTableView->setTableHeaderHeight(m_winSize.width / 2 + (130)); int tableStartY = pageViewHeight + butViewHeight + headerHeight + buttitleHeight + (15); m_msgTableView = CATableView::createWithFrame(DRect(0, tableStartY, m_winSize.width, m_winSize.height - tableStartY)); if (m_msgTableView) { m_msgTableView->setTableViewDataSource(this); m_msgTableView->setTableViewDelegate(this); m_msgTableView->setScrollViewDelegate(this); m_msgTableView->setAllowsSelection(true); m_msgTableView->setSeparatorColor(ccc4(200, 200, 200, 80)); //m_msgTableView->setSeparatorViewHeight((2)); this->getView()->addSubview(m_msgTableView); CAPullToRefreshView *refreshDiscount = CAPullToRefreshView::create(CAPullToRefreshView::CAPullToRefreshTypeFooter); if (refreshDiscount) { refreshDiscount->setLabelColor(CAColor_black); m_msgTableView->setFooterRefreshView(refreshDiscount); } // CAPullToRefreshView *refreshDiscount1 = CAPullToRefreshView::create(CAPullToRefreshView::CAPullToRefreshTypeHeader); // if (refreshDiscount1) { // refreshDiscount1->setLabelColor(CAColor_black); // m_msgTableView->setHeaderRefreshView(refreshDiscount1); // } } if (m_msg->empty()) { requestSessionMsg(); p_pLoading = CAActivityIndicatorView::createWithCenter(DRect(m_winSize.width / 2, m_winSize.height / 2, 50, 50)); this->getView()->insertSubview(p_pLoading, CAWindowZOderTop); p_pLoading->setLoadingMinTime(0.5f); // p_pLoading->setTargetOnCancel(this, callfunc_selector(MainViewController::initMsgTableView)); } else { // this->initMsgTableView(); } }
void PageMenu::viewDidLoad() { g_pCurrentPageMenu = this; PageBase::viewDidLoad(); CAImageView *pBk = CAImageView::createWithImage(CAImage::create("Bk.png")); pBk->setFrame( getView()->getFrame() ); getView()->addSubview( pBk ); m_pMenuList = new CATableView(); m_pMenuList->initWithFrame( CCRect( 0 , 0 , getView()->getFrame().size.width , getView()->getFrame().size.height - 120 ) ); m_pMenuList->setTableViewDataSource(this); m_pMenuList->setTableViewDelegate(this); m_pMenuList->setTablePullViewHeight( 96 ); //m_pMenuList->setTablePullDownView( CAView::createWithColor( ccc4( 34 , 168 , 109 , 255 ) ) ); m_pMenuList->setTablePullUpView( CAImageView::createWithImage(CAImage::create("MenuDropList.png") ) ); m_pMenuList->setTablePullDownView( CAView::createWithColor( ccc4( 34 , 168 , 109 , 255 ) ) ); getView()->addSubview( m_pMenuList ); m_pMenuList->release(); m_pMenuList->setAllowsSelection( true ); CAImageView *pBk2 = CAImageView::createWithImage(CAImage::create("Bk2.png")); pBk2->setFrame( CCRect( 0 , getView()->getFrame().size.height - 120 , getView()->getFrame().size.width , 120 ) ); getView()->addSubview( pBk2 ); m_pProgress = CAProgress::create(); m_pProgress->setFrame( CCRect( 0 , -40 , 720 , 44 ) ); //m_pProgress->setProgressTintColor( ccc4( 34 , 168 , 109 , 255 ) ); m_pProgress->setProgressTintColor( ccc4( 255 , 255 , 255 , 255 ) ); m_pProgress->setProgressTintImage( CAImage::create( "DownloadProgress.png" ) ); m_pProgress->setProgresstrackColor( ccc4( 74 , 103 , 92 , 255 ) ); m_pProgress->setVisible( false ); pBk2->addSubview( m_pProgress ); m_pProgressLabel = CALabel::createWithFrame( m_pProgress->getFrame() ); m_pProgressLabel->setColor( ccc4( 255 , 255 , 255 , 255 ) ); m_pProgressLabel->setFontSize( 28 ); m_pProgressLabel->setTextAlignment( CATextAlignmentCenter ); m_pProgressLabel->setVerticalTextAlignmet( CAVerticalTextAlignmentCenter ); pBk2->addSubview( m_pProgressLabel ); // 下载全书 { CAButton *pButton = CAButton::createWithFrame( CCRect( 64 , 22 , 260 , 88 ) , CAButtonTypeCustom ); pButton->setBackGroundViewForState( CAControlStateNormal , CAScale9ImageView::createWithImage( CAImage::create( "ButtonNormal.png" ) ) ); pButton->setBackGroundViewForState( CAControlStateHighlighted , CAScale9ImageView::createWithImage( CAImage::create( "ButtonLight.png" ) ) ); pButton->setBackGroundViewForState( CAControlStateDisabled , CAScale9ImageView::createWithImage( CAImage::create( "ButtonDisable.png" ) ) ); CALabel *pLabel = CALabel::createWithFrame( CCRect( 0 , 0 , pButton->getFrame().size.width , pButton->getFrame().size.height ) ); pLabel->setText( ("下载全书") ); pLabel->setColor( ccc4( 255 , 255 , 255 , 255 ) ); pLabel->setFontSize( 28 ); pLabel->setTextAlignment( CATextAlignmentCenter ); pLabel->setVerticalTextAlignmet( CAVerticalTextAlignmentCenter ); pButton->addSubview( pLabel ); pBk2->addSubview( pButton ); pButton->addTarget( this , CAControl_selector(PageMenu::OnDownloadAllButtonDown) , CAControlTouchUpInSide ); } // 章节下载 { CAButton *pButton = CAButton::createWithFrame( CCRect( 400 , 22 , 260 , 88 ) , CAButtonTypeCustom ); pButton->setBackGroundViewForState( CAControlStateNormal , CAScale9ImageView::createWithImage( CAImage::create( "ButtonNormal.png" ) ) ); pButton->setBackGroundViewForState( CAControlStateHighlighted , CAScale9ImageView::createWithImage( CAImage::create( "ButtonLight.png" ) ) ); pButton->setBackGroundViewForState( CAControlStateDisabled , CAScale9ImageView::createWithImage( CAImage::create( "ButtonDisable.png" ) ) ); CALabel *pLabel = CALabel::createWithFrame( CCRect( 0 , 0 , pButton->getFrame().size.width , pButton->getFrame().size.height ) ); pLabel->setText( ("下载后续章节") ); pLabel->setColor( ccc4( 255 , 255 , 255 , 255 ) ); pLabel->setFontSize( 28 ); pLabel->setTextAlignment( CATextAlignmentCenter ); pLabel->setVerticalTextAlignmet( CAVerticalTextAlignmentCenter ); pButton->addSubview( pLabel ); pBk2->addSubview( pButton ); pButton->addTarget( this , CAControl_selector(PageMenu::OnDownloadButtonDown) , CAControlTouchUpInSide ); } ShowWait( true ); BookDB::Instance()->GetBookMenu( &m_bookData , this , BookDB_selector(PageMenu::OnComplete) ); }
bool HeroInfoControllerCell::initWithReuseIdentifier(const std::string& reuseIdentifier, const CCSize& cellSize, const HeroInfo* info){ if (!CATableViewCell::initWithReuseIdentifier(reuseIdentifier)) { return false; } if (reuseIdentifier == "fristSection"){ CCRect fristRect; fristRect.size.width = (cellSize.width - _px(50) )/ 4; fristRect.size.height = cellSize.height - _px(20); fristRect.origin.x = _px(10) + fristRect.size.width / 2; fristRect.origin.y = cellSize.height / 2; CAView* _view1 = CAView::createWithCenter(fristRect); this->addSubview(_view1); char overly[10]; sprintf(overly, "%d", info->useTime); CALabel* m_pLabel1 = CALabel::createWithFrame(CCRect(_px(0), _px(0), fristRect.size.width, fristRect.size.height / 2)); m_pLabel1->setColor(CAColor_black); m_pLabel1->setFontSize(_px(20)); m_pLabel1->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel1->setTextAlignment(CATextAlignmentCenter); m_pLabel1->setText((overly + UTF8ToGBK::transferToGbk("万"))); _view1->addSubview(m_pLabel1); CALabel* m_pLabel1_v = CALabel::createWithFrame(CCRect(0, fristRect.origin.y / 2, fristRect.size.width, fristRect.size.height / 2)); m_pLabel1_v->setColor(CAColor_gray); m_pLabel1_v->setFontSize(_px(15)); m_pLabel1_v->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel1_v->setTextAlignment(CATextAlignmentCenter); m_pLabel1_v->setText(UTF8("本月场次")); _view1->addSubview(m_pLabel1_v); fristRect.origin.x += fristRect.size.width + _px(10); CAView* _view2 = CAView::createWithCenter(fristRect); this->addSubview(_view2); CALabel* m_pLabel2 = CALabel::createWithFrame(CCRect(0, 0, fristRect.size.width, fristRect.size.height / 2)); m_pLabel2->setColor(CAColor_black); m_pLabel2->setFontSize(_px(20)); m_pLabel2->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel2->setTextAlignment(CATextAlignmentCenter); m_pLabel2->setText(UTF8ToGBK::transferToGbk("60")); _view2->addSubview(m_pLabel2); CALabel* m_pLabel2_v = CALabel::createWithFrame(CCRect(0, fristRect.origin.y / 2, fristRect.size.width, fristRect.size.height / 2)); m_pLabel2_v->setColor(CAColor_gray); m_pLabel2_v->setFontSize(_px(15)); m_pLabel2_v->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel2_v->setTextAlignment(CATextAlignmentCenter); m_pLabel2_v->setText(UTF8("场次排名")); _view2->addSubview(m_pLabel2_v); fristRect.origin.x += fristRect.size.width + _px(10); CAView* _view3 = CAView::createWithCenter(fristRect); this->addSubview(_view3); char overly1[10]; sprintf(overly1, "%0.1f", info->winProb); CALabel* m_pLabel3 = CALabel::createWithFrame(CCRect(0, 0, fristRect.size.width, fristRect.size.height / 2)); m_pLabel3->setColor(CAColor_black); m_pLabel3->setFontSize(_px(20)); m_pLabel3->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel3->setTextAlignment(CATextAlignmentCenter); m_pLabel3->setText(UTF8ToGBK::transferToGbk(overly1)); _view3->addSubview(m_pLabel3); CALabel* m_pLabel3_v = CALabel::createWithFrame(CCRect(0, fristRect.origin.y / 2, fristRect.size.width, fristRect.size.height / 2)); m_pLabel3_v->setColor(CAColor_gray); m_pLabel3_v->setFontSize(_px(15)); m_pLabel3_v->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel3_v->setTextAlignment(CATextAlignmentCenter); m_pLabel3_v->setText(UTF8("本月胜率")); _view3->addSubview(m_pLabel3_v); fristRect.origin.x += fristRect.size.width + _px(10); CAView* _view4 = CAView::createWithCenter(fristRect); this->addSubview(_view4); CALabel* m_pLabel4 = CALabel::createWithFrame(CCRect(0, 0, fristRect.size.width, fristRect.size.height / 2)); m_pLabel4->setColor(CAColor_black); m_pLabel4->setFontSize(_px(20)); m_pLabel4->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel4->setTextAlignment(CATextAlignmentCenter); m_pLabel4->setText("3"); _view4->addSubview(m_pLabel4); CALabel* m_pLabel4_v = CALabel::createWithFrame(CCRect(0, fristRect.origin.y / 2, fristRect.size.width, fristRect.size.height / 2)); m_pLabel4_v->setColor(CAColor_gray); m_pLabel4_v->setFontSize(_px(15)); m_pLabel4_v->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel4_v->setTextAlignment(CATextAlignmentCenter); m_pLabel4_v->setText(UTF8("胜率排名")); _view4->addSubview(m_pLabel4_v); } else if (reuseIdentifier == "slider"){ CAButton* leftButton = CAButton::createWithCenter(CCRect(_px(30), cellSize.height/2, _px(30), _px(30)), CAButtonTypeCustom); leftButton->setBackGroundViewForState(CAControlStateAll, CAImageView::createWithImage(CAImage::create("image/sub.png"))); leftButton->setImageColorForState(CAControlStateHighlighted, CAColor_gray); //leftButton->addTarget(this, CAControl_selector(HeroInfoController::setButton), CAControlEventTouchUpInSide); this->addSubview(leftButton); CAButton* rightButton = CAButton::createWithCenter(CCRect(_px(cellSize.width - _px(40)), cellSize.height / 2, _px(30), _px(30)), CAButtonTypeCustom); rightButton->setBackGroundViewForState(CAControlStateAll, CAImageView::createWithImage(CAImage::create("image/_plus.png"))); rightButton->setImageColorForState(CAControlStateHighlighted, CAColor_gray); //leftButton->addTarget(this, CAControl_selector(HeroInfoController::setButton), CAControlEventTouchUpInSide); this->addSubview(rightButton); CALabel* level = CALabel::createWithFrame(CCRect(_px(cellSize.width - _px(90)), 10, _px(20), _px(20))); level->setColor(CAColor_black); level->setFontSize(_px(20)); level->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); level->setTextAlignment(CATextAlignmentCenter); level->setText("3"); this->addSubview(level); CASlider* slider = CASlider::createWithCenter(CCRect(cellSize.width / 2, cellSize.height / 2, cellSize.width-200, _px(10))); slider->setMaxTrackTintImage(CAImage::create("image/bcolor.png")); slider->setMinTrackTintImage(CAImage::create("image/fcolor.png")); slider->setMaxValue(25); slider->setMinValue(0); //slider->setThumbTintImage(CAImage::create("image/slideBlock.png")); // slider->addTarget(this, CAControl_selector(SliderTest::sliderValueChange)); this->addSubview(slider); } else if (reuseIdentifier == "secondSection"){ CCRect fristRect; fristRect.size.width = (cellSize.width - _px(50)) / 4; fristRect.size.height = cellSize.height - _px(20); fristRect.origin.x = _px(10) + fristRect.size.width / 2; fristRect.origin.y = cellSize.height / 2; CAView* _view1 = CAView::createWithCenter(fristRect); this->addSubview(_view1); /*char overly[10]; sprintf(overly, "%d", info->useTime); CALabel* m_pLabel1 = CALabel::createWithFrame(CCRect(_px(0), _px(0), fristRect.size.width, fristRect.size.height / 2)); m_pLabel1->setColor(CAColor_black); m_pLabel1->setFontSize(_px(20)); m_pLabel1->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel1->setTextAlignment(CATextAlignmentCenter); m_pLabel1->setText((overly + UTF8ToGBK::transferToGbk("万"))); _view1->addSubview(m_pLabel1);*/ CALabel* m_pLabel1_v = CALabel::createWithFrame(CCRect(0, fristRect.origin.y / 2, fristRect.size.width, fristRect.size.height / 2)); m_pLabel1_v->setColor(CAColor_gray); m_pLabel1_v->setFontSize(_px(15)); m_pLabel1_v->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel1_v->setTextAlignment(CATextAlignmentCenter); m_pLabel1_v->setText(UTF8("攻击力")); _view1->addSubview(m_pLabel1_v); fristRect.origin.x += fristRect.size.width + _px(10); CAView* _view2 = CAView::createWithCenter(fristRect); this->addSubview(_view2); /*CALabel* m_pLabel2 = CALabel::createWithFrame(CCRect(0, 0, fristRect.size.width, fristRect.size.height / 2)); m_pLabel2->setColor(CAColor_black); m_pLabel2->setFontSize(_px(20)); m_pLabel2->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel2->setTextAlignment(CATextAlignmentCenter); m_pLabel2->setText(UTF8ToGBK::transferToGbk("60")); _view2->addSubview(m_pLabel2);*/ CALabel* m_pLabel2_v = CALabel::createWithFrame(CCRect(0, fristRect.origin.y / 2, fristRect.size.width, fristRect.size.height / 2)); m_pLabel2_v->setColor(CAColor_gray); m_pLabel2_v->setFontSize(_px(15)); m_pLabel2_v->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel2_v->setTextAlignment(CATextAlignmentCenter); m_pLabel2_v->setText(UTF8("护甲")); _view2->addSubview(m_pLabel2_v); fristRect.origin.x += fristRect.size.width + _px(10); CAView* _view3 = CAView::createWithCenter(fristRect); this->addSubview(_view3); /*char overly1[10]; sprintf(overly1, "%0.1f", info->winProb); CALabel* m_pLabel3 = CALabel::createWithFrame(CCRect(0, 0, fristRect.size.width, fristRect.size.height / 2)); m_pLabel3->setColor(CAColor_black); m_pLabel3->setFontSize(_px(20)); m_pLabel3->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel3->setTextAlignment(CATextAlignmentCenter); m_pLabel3->setText(UTF8ToGBK::transferToGbk(overly1)); _view3->addSubview(m_pLabel3);*/ CALabel* m_pLabel3_v = CALabel::createWithFrame(CCRect(0, fristRect.origin.y / 2, fristRect.size.width, fristRect.size.height / 2)); m_pLabel3_v->setColor(CAColor_gray); m_pLabel3_v->setFontSize(_px(15)); m_pLabel3_v->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel3_v->setTextAlignment(CATextAlignmentCenter); m_pLabel3_v->setText(UTF8("移动速度")); _view3->addSubview(m_pLabel3_v); fristRect.origin.x += fristRect.size.width + _px(10); CAView* _view4 = CAView::createWithCenter(fristRect); this->addSubview(_view4); /*CALabel* m_pLabel4 = CALabel::createWithFrame(CCRect(0, 0, fristRect.size.width, fristRect.size.height / 2)); m_pLabel4->setColor(CAColor_black); m_pLabel4->setFontSize(_px(20)); m_pLabel4->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel4->setTextAlignment(CATextAlignmentCenter); m_pLabel4->setText("3"); _view4->addSubview(m_pLabel4);*/ CALabel* m_pLabel4_v = CALabel::createWithFrame(CCRect(0, fristRect.origin.y / 2, fristRect.size.width, fristRect.size.height / 2)); m_pLabel4_v->setColor(CAColor_gray); m_pLabel4_v->setFontSize(_px(15)); m_pLabel4_v->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_pLabel4_v->setTextAlignment(CATextAlignmentCenter); m_pLabel4_v->setText(UTF8("DPS(攻速)")); _view4->addSubview(m_pLabel4_v); _view1->setColor(COLOR_GRAY); _view2->setColor(COLOR_GRAY); _view3->setColor(COLOR_GRAY); _view4->setColor(COLOR_GRAY); } return true; }
void ButtonTest::buttonBackground(void) { CADipSize size = bkgView->getBounds().size; CALabel* buttonImage = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.2, size.width*0.4, 50)); buttonImage->setText("ButtonImage"); buttonImage->setFontSize(_px(30)); buttonImage->setTextAlignment(CATextAlignmentCenter); buttonImage->setColor(ccc4(51, 204, 255, 255)); bkgView->addSubview(buttonImage); CAButton* defaultBtn = CAButton::create(CAButtonTypeCustom); defaultBtn->setCenter(CADipRect(size.width*0.25 - 50, size.height*0.5, size.width*0.25, size.height*0.1)); defaultBtn->setTitleForState(CAControlStateNormal, "Normal"); defaultBtn->setTitleColorForState(CAControlStateNormal, CAColor_white); defaultBtn->setTitleForState(CAControlStateSelected,"Selected"); defaultBtn->setTitleForState(CAControlStateHighlighted, "Highlighted"); defaultBtn->setBackGroundViewForState(CAControlStateNormal,CAView::createWithColor(CAColor_green)); defaultBtn->setBackGroundViewForState(CAControlStateHighlighted, CAView::createWithColor(CAColor_yellow)); bkgView->addSubview(defaultBtn); CALabel* custom = CALabel::createWithCenter(CADipRect(size.width*0.25 - 50, size.height*0.5 + 80, size.width*0.3, 50)); custom->setText("(BackgroundView)"); custom->setFontSize(_px(20)); custom->setTextAlignment(CATextAlignmentCenter); custom->setColor(CAColor_blueStyle); bkgView->addSubview(custom); CAButton* squareRectBtn = CAButton::create(CAButtonTypeSquareRect); squareRectBtn->setAllowsSelected(true); squareRectBtn->setCenter(CADipRect(size.width*0.5, size.height*0.5, size.width*0.25, size.height*0.1)); squareRectBtn->setTitleForState(CAControlStateNormal, "Normal"); squareRectBtn->setTitleColorForState(CAControlStateNormal, CAColor_white); squareRectBtn->setTitleForState(CAControlStateSelected, "Selected"); squareRectBtn->setTitleForState(CAControlStateHighlighted, "Highlighted"); squareRectBtn->setBackGroundViewForState(CAControlStateNormal, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_normal.png"))); squareRectBtn->setBackGroundViewForState(CAControlStateHighlighted, CAScale9ImageView::createWithImage(CAImage::create("source_material/ex4.png"))); squareRectBtn->setBackGroundViewForState(CAControlStateSelected, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_selected.png"))); bkgView->addSubview(squareRectBtn); CALabel* square = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.5 + 80, size.width*0.3, 50)); square->setText("(StateImage)"); square->setFontSize(_px(20)); square->setTextAlignment(CATextAlignmentCenter); square->setColor(CAColor_blueStyle); bkgView->addSubview(square); CAButton* roundedRectBtn = CAButton::create(CAButtonTypeRoundedRect); roundedRectBtn->setCenter(CADipRect(size.width*0.75 + 50, size.height*0.5, size.width*0.25, size.height*0.1)); roundedRectBtn->setBackGroundViewForState(CAControlStateDisabled, CAScale9ImageView::createWithImage(CAImage::create("source_material/ex5.png"))); roundedRectBtn->setControlState(CAControlStateDisabled); bkgView->addSubview(roundedRectBtn); CALabel* rounded = CALabel::createWithCenter(CADipRect(size.width*0.75 + 50, size.height*0.5 + 80, size.width*0.3, 50)); rounded->setText("(Disabled)"); rounded->setFontSize(_px(20)); rounded->setTextAlignment(CATextAlignmentCenter); rounded->setColor(CAColor_blueStyle); bkgView->addSubview(rounded); }