当前位置: 首页>>代码示例>>C++>>正文


C++ CAButton::setTitleForState方法代码示例

本文整理汇总了C++中CAButton::setTitleForState方法的典型用法代码示例。如果您正苦于以下问题:C++ CAButton::setTitleForState方法的具体用法?C++ CAButton::setTitleForState怎么用?C++ CAButton::setTitleForState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CAButton的用法示例。


在下文中一共展示了CAButton::setTitleForState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: showLeftButton

void CANavigationBar::showLeftButton()
{
    std::vector<CAButton*>::iterator itr;
    for (itr = m_pLeftButtons.begin(); itr != m_pLeftButtons.end(); itr++)
    {
        (*itr)->removeFromSuperview();
    }
    m_pLeftButtons.clear();
    
    const CAVector<CAObject*>& buttonItems = m_pItem->getLeftButtonItems();

    CCRect rect;
    rect.size.width = _px(80);
    rect.size.height = this->getBounds().size.height * 0.8f;
    rect.origin.x = rect.size.width * 0.7f;
    rect.origin.y = this->getBounds().size.height * 0.5f;

    for (size_t i=0; i<buttonItems.size(); i++)
    {
        CABarButtonItem* item = dynamic_cast<CABarButtonItem*>(buttonItems.at(i));
        
        rect.size.width = item ? item->getItemWidth() : _px(80);
        rect.origin.x += i * rect.size.width;
        
        CAButton* button = CAButton::createWithCenter(rect, CAButtonTypeCustom);
        this->addSubview(button);
        
        if (item == NULL && m_pItem)
        {
            button->setImageForState(CAControlStateNormal, CAImage::create("source_material/btn_left_white.png"));
            button->setImageColorForState(CAControlStateHighlighted, ccc4(255, 255, 200, 255));
            button->addTarget(this, CAControl_selector(CANavigationBar::goBack), CAControlEventTouchUpInSide);
        }
        else if (item)
        {
            if (item->getImage())
            {
                button->setImageForState(CAControlStateNormal, item->getImage());
                if (item->getHighlightedImage())
                {
                    button->setImageForState(CAControlStateHighlighted, item->getHighlightedImage());
                }
                else
                {
                    button->setImageColorForState(CAControlStateHighlighted, ccc4(127, 127, 127, 255));
                }
            }
            else
            {
                button->setTitleForState(CAControlStateNormal, item->getTitle());
                button->setTitleColorForState(CAControlStateNormal, m_cButtonColor);
                button->setTitleForState(CAControlStateHighlighted, item->getTitle());
                button->setTitleColorForState(CAControlStateHighlighted, ccc4(m_cButtonColor.r/2, m_cButtonColor.g/2, m_cButtonColor.b/2, 255));
            }
            
            button->addTarget(item->getTarget(), item->getSel(), CAControlEventTouchUpInSide);
        }
        m_pLeftButtons.push_back(button);
    }
}
开发者ID:nightdomain,项目名称:CrossApp,代码行数:60,代码来源:CABar.cpp

示例2: initWithCenter

bool CASegmentedControl::initWithCenter(const CCRect& rect)
{
    if (!CAControl::init())
    {
        return false;
    }
    
    this->setCenter(rect);
    m_selectedIndex = 0;
    
    this->removeAllSegments();
    const float elemWidth = rect.size.width / m_nItemsCount;
    m_itemSize = CCSize(elemWidth, rect.size.height);
    CCRect elemFrame = CCRect(0, 0, m_itemSize.width, m_itemSize.height);
    for (int i = 0; i < m_nItemsCount; ++i)
    {
        CAButton *btn = this->createDefaultSegment();
        if (btn)
        {
            btn->setFrame(elemFrame);
            char tmp[8] = {0};
            snprintf(tmp, 8, "%d", i);
            btn->setTitleForState(CAControlStateNormal, tmp);
            btn->setTitleForState(CAControlStateSelected, tmp);
            btn->setTitleForState(CAControlStateHighlighted, tmp);
            m_segments.push_back(btn);
            this->addSubview(btn);
            btn->setControlState((m_selectedIndex == i) ? CAControlStateSelected : CAControlStateNormal);
        }
        elemFrame.origin.x += elemWidth;
    }
    return true;
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:33,代码来源:CASegmentedControl.cpp

示例3: buttonBackground

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);
}
开发者ID:AojiaoZero,项目名称:CrossApp,代码行数:52,代码来源:ButtonTest.cpp

示例4: showLeftButton

void CANavigationBar::showLeftButton()
{
    std::vector<CAButton*>::iterator itr;
    for (itr = m_pLeftButtons.begin(); itr != m_pLeftButtons.end(); itr++)
    {
        (*itr)->removeFromSuperview();
    }
    m_pLeftButtons.clear();
    
    CCArray* buttonItems = m_pItems.back()->getLeftButtonItems();

    CCRect rect = this->getBounds();
    rect.size.width = rect.size.height * 0.9f;
    rect.size.height *= 0.8f;
    rect.origin.x = rect.size.width * 0.7f;
    rect.origin.y = this->getBounds().size.height / 2;
    
    for (int i=0; i<buttonItems->count(); i++)
    {
        rect.origin.x += i * rect.size.width * 1.1f;
        CAButton* button = CAButton::createWithCenter(rect, CAButtonTypeCustom);
        this->addSubview(button);
        
        CABarButtonItem* item = dynamic_cast<CABarButtonItem*>(buttonItems->objectAtIndex(i));
        if (item == NULL && m_pItems.size() > 1)
        {
            button->setImageForState(CAControlStateNormal, CAImage::create("source_material/btn_left_white.png"));
            button->setImageColorForState(CAControlStateHighlighted, ccc4(255, 255, 200, 255));
            button->addTarget(this, CAControl_selector(CANavigationBar::goBack), CAControlEventTouchUpInSide);
        }
        else if (item)
        {
            button->setTitleForState(CAControlStateNormal, item->getTitle());
            button->setTitleColorForState(CAControlStateNormal, CAColor_white);
            button->setTitleForState(CAControlStateHighlighted, item->getTitle());
            button->setTitleColorForState(CAControlStateHighlighted, ccc4(255, 255, 200, 255));
            button->setImageForState(CAControlStateNormal, item->getImage());
            if (item->getHighlightedImage())
            {
                button->setImageForState(CAControlStateHighlighted, item->getHighlightedImage());
            }
            else
            {
                button->setImageColorForState(CAControlStateHighlighted, ccc4(255, 255, 200, 255));
            }
            button->addTarget(item->getTarget(), item->getSel(), CAControlEventTouchUpInSide);
        }
        m_pLeftButtons.push_back(button);
    }
}
开发者ID:JasonWorking,项目名称:CrossApp,代码行数:50,代码来源:CABar.cpp

示例5: onClickSelectAllButton

void RecipeListViewController::onClickSelectAllButton(CAControl* btn,DPoint point)
{
    CAButton *curBtn = (CAButton*)btn;
    if(isSelectedAll())
    {
        setAllCheckBoxState(false);
        curBtn->setTitleForState(CAControlState::CAControlStateAll, "全选");
    }
    else
    {
        setAllCheckBoxState(true);
        curBtn->setTitleForState(CAControlState::CAControlStateAll, "全不选");
    }
    p_TableView->reloadData();
}
开发者ID:fx0883,项目名称:AppCPlus,代码行数:15,代码来源:RecipeListViewController.cpp

示例6: buttonTouchEvent

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);
}
开发者ID:Brian1900,项目名称:CrossApp,代码行数:48,代码来源:ButtonTest.cpp

示例7: insertSegmentWithTitle

bool CASegmentedControl::insertSegmentWithTitle(const char* title, int index, const 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->setTitleForState(controlState, title);
    newBtn->setTitleFontName(m_sTitleFontName);
    m_segments.insert(m_segments.begin() + index, newBtn);
    this->addSubview(newBtn);
    this->layoutSubviews();
    return true;
}
开发者ID:dlpc,项目名称:CrossApp,代码行数:25,代码来源:CASegmentedControl.cpp

示例8: initView

void huaFeiViewController::initView(){
    if (m_View) {
        this->getView()->removeSubview(m_View);
        m_View = NULL;
    }
    
    winSize = this->getView()->getBounds().size;
    
    m_View = CAView::createWithFrame(CADipRect(0,0,winSize.width, winSize.height), ccc4(166, 166, 166, 80));
    
    CATextField* textField = CATextField::createWithCenter(CADipRect(winSize.width/2, 100, winSize.width-100, 80));
    textField->setFontSize(_px(40));
    textField->setTag(100);
    textField->setPlaceHolder("输入你的号码");
    textField->setKeyboardType(KEY_BOARD_TYPE_NUMBER);
    m_View->addSubview(textField);
    
//    CATextField* textField2 = CATextField::createWithCenter(CADipRect(winSize.width/2, 200, winSize.width-100, 80));
//    textField2->setFontSize(_px(40));
//    textField2->setTag(101);
//    textField2->setPlaceHolder("充值金额");
//    textField2->setKeyboardType(KEY_BOARD_TYPE_NUMBER);
//    m_View->addSubview(textField2);
    
    
    CAButton * but = CAButton::createWithCenter(CADipRect(winSize.width/2, 250, winSize.width -100, 80), CAButtonTypeSquareRect);
    but->setTitleForState(CAControlStateAll, "提交");
    but->addTarget(this, CAControl_selector(huaFeiViewController::buttonCallBack), CAControlEventTouchUpInSide);
    m_View->addSubview(but);
    
    this->getView()->addSubview(m_View);
}
开发者ID:ksca686812,项目名称:MyApp_2155,代码行数:32,代码来源:huaFeiViewController.cpp

示例9: initEditBottomView

void RecipeListViewController::initEditBottomView()
{
    m_EditBottomView = CAView::createWithLayout(m_bottomViewLayout[0]);
    this->getView()->addSubview(m_EditBottomView);
    
    CAView* horizontallineview = CAView::createWithLayout(DLayout(DHorizontalLayout_L_R(1, 1), DVerticalLayout_T_H(1, 1)), CAColor_gray);
    m_EditBottomView->addSubview(horizontallineview);
    
    selectAllButton = CAButton::createWithLayout(DLayout(DHorizontalLayout_L_W(0, AppWidth/2 - 2), DVerticalLayoutFill), CAButtonTypeCustom);
    selectAllButton->setTitleFontSize(FONT3);
    selectAllButton->setTitleForState(CAControlState::CAControlStateAll, "全选");
    selectAllButton->addTarget(this, CAControl_selector(RecipeListViewController::onClickSelectAllButton), CAControlEvents::CAControlEventTouchUpInSide);
    m_EditBottomView->addSubview(selectAllButton);
    
    
    
    CAView* verticalLineView = CAView::createWithLayout(DLayout(DHorizontalLayout_L_W(AppWidth/2, 1), DVerticalLayout_T_B(5, 5)), CAColor_gray);
    m_EditBottomView->addSubview(verticalLineView);
    
    CAButton *rightButton = CAButton::createWithLayout(DLayout(DHorizontalLayout_R_W(0, AppWidth/2 - 2), DVerticalLayoutFill), CAButtonTypeCustom);
    rightButton->setTitleFontSize(FONT3);
    rightButton->setTitleForState(CAControlState::CAControlStateAll, "删除");
        rightButton->addTarget(this, CAControl_selector(RecipeListViewController::onClickDeleteButton), CAControlEvents::CAControlEventTouchUpInSide);
    m_EditBottomView->addSubview(rightButton);
}
开发者ID:fx0883,项目名称:AppCPlus,代码行数:25,代码来源:RecipeListViewController.cpp

示例10: listViewCellAtIndex

CAListViewCell* ListViewTest::listViewCellAtIndex(CAListView *listView, const DSize& cellSize, unsigned int index)
{
    CAListViewCell* cell = (CAListViewCell*)listView->dequeueReusableCellWithIdentifier("ListViewCell");
    if (cell==NULL)
    {
        cell = CAListViewCell::create("ListViewCell");
        
        CALabel* test = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_W(0, 200), DVerticalLayoutFill));
        test->setColor(ccc4(51, 204, 255, 255));
        test->setTextAlignment(CATextAlignmentCenter);
        test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
        test->setFontSize(28);
        test->setTag(100);
        cell->addSubview(test);
        
        CAButton* btn = CAButton::createWithLayout(DLayout(DHorizontalLayout_W_C(100, 0.85), DVerticalLayout_H_C(50, 0.5)), CAButtonTypeSquareRect);
        btn->setTitleForState(CAControlStateNormal, "btn");
        btn->setTag(200);
        cell->addSubview(btn);
        btn->setTouchEventScrollHandOverToSuperview(false);
    }
    char temptext[10];
    sprintf(temptext, "cell-%d",index);
    CALabel* test = (CALabel*)cell->getSubviewByTag(100);
    test->setText(temptext);
    
    return cell;
}
开发者ID:WoYang,项目名称:CrossApp,代码行数:28,代码来源:ListViewTest.cpp

示例11: threeButtonType

void ButtonTest::threeButtonType(void)
{
	CADipSize size = typeView->getBounds().size;
	CALabel* buttonType = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.2, size.width*0.4, 50));
	buttonType->setText("DefaultType");
	buttonType->setFontSize(_px(30));
	buttonType->setTextAlignment(CATextAlignmentCenter);
	buttonType->setColor(ccc4(51, 204, 255, 255));
	typeView->addSubview(buttonType);

	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, "Noborder");
	defaultBtn->setTitleColorForState(CAControlStateNormal, CAColor_blueStyle);
	typeView->addSubview(defaultBtn);

	CALabel* custom = CALabel::createWithCenter(CADipRect(size.width*0.25 - 50, size.height*0.5 + 80, size.width*0.3, 50));
	custom->setText("(Custom)");
	custom->setFontSize(_px(20));
	custom->setTextAlignment(CATextAlignmentCenter);
	custom->setColor(ccc4(51, 204, 255, 255));
	typeView->addSubview(custom);

	CAButton* squareRectBtn = CAButton::create(CAButtonTypeSquareRect);
	squareRectBtn->setCenter(CADipRect(size.width*0.5, size.height*0.5, size.width*0.25, size.height*0.1));
	squareRectBtn->setTitleForState(CAControlStateAll,"SquareRect");
	typeView->addSubview(squareRectBtn);

	CALabel* square = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.5 + 80, size.width*0.3, 50));
	square->setText("(SquareRect)");
	square->setFontSize(_px(20));
	square->setTextAlignment(CATextAlignmentCenter);
	square->setColor(CAColor_blueStyle);
	typeView->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->setTitleForState(CAControlStateAll, "RoundedRect");
	typeView->addSubview(roundedRectBtn);

	CALabel* rounded = CALabel::createWithCenter(CADipRect(size.width*0.75 + 50, size.height*0.5 + 80, size.width*0.3, 50));
	rounded->setText("(RoundedRect)");
	rounded->setFontSize(_px(20));
	rounded->setTextAlignment(CATextAlignmentCenter);
	rounded->setColor(CAColor_blueStyle);
	typeView->addSubview(rounded);
}
开发者ID:Brian1900,项目名称:CrossApp,代码行数:47,代码来源:ButtonTest.cpp

示例12: initAllButton

void CAAlertView::initAllButton(std::vector<std::string>& vBtnText)
{
	std::vector<CAButton*> vbtns;
	for (int i = 0; i < vBtnText.size(); i++)
	{
		CAButton* btn = CAButton::create(CAButtonTypeSquareRect);
		CCAssert(btn, "");
		btn->setTitleForState(CAControlStateAll, vBtnText[i].c_str());
		vbtns.push_back(btn);
	}
	initAllButton(vbtns);
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:12,代码来源:CAAlertView.cpp

示例13: setTitleAtIndex

bool CASegmentedControl::setTitleAtIndex(const char* title, int index, CAControlState controlState)
{
    if (!this->indexIsValid(index))
    {
        return false;
    }
    
    CAButton *btn = m_segments.at(index);
    if (NULL == btn)
    {
        return false;
    }
    btn->setTitleForState(controlState, title);
    
    return true;
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:16,代码来源:CASegmentedControl.cpp

示例14: show

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;
}
开发者ID:garyyyy,项目名称:CrossApp,代码行数:47,代码来源:CATextEditHelper.cpp

示例15: initCell

void MyTableViewCell::initCell()
{
	CADipSize cellSize = this->getFrame().size;
	CALabel* cellText = CALabel::createWithCenter(CADipRect(cellSize.width*0.1, cellSize.height*0.5, cellSize.width*0.3, cellSize.height*0.8));
	cellText->setTag(100);
	cellText->setFontSize(30 * CROSSAPP_ADPTATION_RATIO);
	cellText->setColor(CAColor_blueStyle);
	cellText->setTextAlignment(CATextAlignmentCenter);
	cellText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
	this->addSubview(cellText);

	CAButton* cellBtn = CAButton::createWithCenter(CADipRect(cellSize.width*0.8, cellSize.height*0.5, cellSize.width*0.2, cellSize.height*0.5), CAButtonTypeRoundedRect);
	cellBtn->setTag(102);
	cellBtn->setTitleForState(CAControlStateAll, "Touch");
	cellBtn->addTarget(this, CAControl_selector(MyTableViewCell::cellBtnCallback), CAControlEventTouchUpInSide);
	this->addSubview(cellBtn);
}
开发者ID:Watchet,项目名称:CrossApp,代码行数:17,代码来源:MyTableViewCell.cpp


注:本文中的CAButton::setTitleForState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。