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


C++ CAButton类代码示例

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


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

示例1: CAButton

CAButton* CAButton::createWithCenter(const CCRect& rect, const CAButtonType& buttonType)
{
    
    CAButton* btn = new CAButton(buttonType);
    
    if (btn && btn->initWithCenter(rect))
    {
        btn->autorelease();
        return btn;
    }
    
    CC_SAFE_DELETE(btn);
    return NULL;
}
开发者ID:ancon,项目名称:CrossApp,代码行数:14,代码来源:CAButton.cpp

示例2: CAButton

CAButton* CAButton::create(const CAButtonType& buttonType)
{
    
    CAButton* btn = new CAButton(buttonType);
    
    if (btn && btn->init())
    {
        btn->autorelease();
        return btn;
    }
    
    CC_SAFE_DELETE(btn);
    return NULL;
}
开发者ID:MingjunHu,项目名称:CrossApp,代码行数:14,代码来源:CAButton.cpp

示例3: _px

void CANavigationBar::showRightButton()
{
    std::vector<CAButton*>::iterator itr;
    for (itr = m_pRightButtons.begin(); itr != m_pRightButtons.end(); itr++)
    {
        (*itr)->removeFromSuperview();
    }
    m_pRightButtons.clear();
    
    const CAVector<CAObject*>& buttonItems = m_pItem->getRightButtonItems();
    
    CCRect rect;
    rect.size.width = this->getBounds().size.height * 0.9f;
    rect.size.height = this->getBounds().size.height * 0.8f;
    rect.origin.x = this->getBounds().size.width - 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)
        {
            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_pRightButtons.push_back(button);
    }
}
开发者ID:nightdomain,项目名称:CrossApp,代码行数:54,代码来源:CABar.cpp

示例4: 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

示例5: setTitleColorAtIndex

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

示例6: 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

示例7: setImageAtIndex

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

示例8: setBackgroundImageAtIndex

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

示例9: setBackgroundViewAtIndex

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

示例10: viewDidLoad

void NoticeDetailViewController::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((0), (0), m_winSize.width, (120)));
    this->getView()->addSubview(sView);
    
    CAButton* button = CAButton::createWithFrame(DRect((0), (20), (100), (100)), CAButtonTypeCustom);
    CAImageView* imageView = CAImageView::createWithImage(CAImage::create("common/nav_back.png"));
    imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
    imageView->setFrame(DRect((20), (20), (80), (80)));
    button->setBackgroundViewForState(CAControlStateAll, imageView);
    button->addTarget(this, CAControl_selector(NoticeDetailViewController::buttonCallBack), CAControlEventTouchUpInSide);
    button->setTag(20);
    sView->addSubview(button);
    
    CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 2, (70), m_winSize.width, (50)));
    label->setTextAlignment(CATextAlignmentCenter);
    label->setColor(CAColor_white);
    label->setTouchEnabled(false);
    label->setFontSize((40));
    label->setText("Notice");
    label->setFontName(SAP_FONT_ARIAL);
    sView->addSubview(label);
    
    label = CALabel::createWithFrame(DRect(0, (200), m_winSize.width, (60)));
    label->setTextAlignment(CATextAlignmentCenter);
    label->setColor(CAColor_gray);
    label->setTouchEnabled(false);
    label->setFontSize((40));
    label->setText(m_title);
    label->setFontName(SAP_FONT_ARIAL);
    this->getView()->addSubview(label);
    
    label = CALabel::createWithFrame(DRect(40, (300), m_winSize.width - 80, (800)));
    label->setTextAlignment(CATextAlignmentLeft);
    label->setColor(CAColor_gray);
    label->setTouchEnabled(false);
    label->setFontSize((30));
    label->setText(m_detail);
    label->setFontName(SAP_FONT_ARIAL);
    this->getView()->addSubview(label);
    
    CCLog("%f", CAApplication::getApplication()->getWinSize().width);
}
开发者ID:DreamCastleShanghai,项目名称:client_new,代码行数:47,代码来源:NoticeDetailViewController.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: 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

示例13: CCSize

void CASegmentedControl::layoutSubviews()
{
    const CCSize controlSize = this->getBounds().size;
    const int totalCount = this->getItemCount();
    const float elemWidth = controlSize.width / totalCount;
    m_itemSize = CCSize(elemWidth, controlSize.height);
    CCRect elemFrame = CCRect(0, 0, m_itemSize.width, m_itemSize.height);
    
    for (int i = 0; i < totalCount; ++i)
    {
        CAButton *btn = m_segments.at(i);
        if (btn)
        {
            btn->setFrame(elemFrame);
            btn->setControlState((m_selectedIndex == i) ? CAControlStateSelected : CAControlStateNormal);
        }
        elemFrame.origin.x += elemWidth;
    }
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:19,代码来源:CASegmentedControl.cpp

示例14: replaceItemAtIndex

void CATabBar::replaceItemAtIndex(size_t index, CATabBarItem* item)
{
    if (index < m_pItems.size())
    {
		m_pItems.replace(index, item);
        if (!m_pButtons.empty())
        {
            CAButton* btn = m_pButtons.at(index);
            btn->setTitleForState(CAControlStateAll, item->getTitle());
            btn->setImageForState(CAControlStateNormal, item->getImage());
            CAImage* selectedImage = item->getSelectedImage()
            ? item->getSelectedImage()
            : item->getImage();
            btn->setImageForState(CAControlStateHighlighted, selectedImage);
            btn->setImageForState(CAControlStateSelected, selectedImage);

            CABadgeView* badgeView = m_pBadgeViews.at(index);
            badgeView->setBadgeText(item->getBadgeValue());
        }
    }
}
开发者ID:nightdomain,项目名称:CrossApp,代码行数:21,代码来源:CABar.cpp

示例15: buttonCallback

void FourthViewController::buttonCallback(CrossApp::CAControl *btn, CrossApp::CCPoint point)
{
    point = btn->convertToWorldSpace(point);
    CAButton* button = (CAButton*)btn;
    
    if (button->getTag() == 1)
    {
        --action_index;
        action_index = MAX(action_index, 0);
    }
    else
    {
        ++action_index;
        action_index = MIN(action_index, 9);
    }
    
    defaultBtnL->setVisible(action_index > 0);
    defaultBtnR->setVisible(action_index < 9);
    
    if (action_index < 6)
    {
        char str[32];
        sprintf(str, "play animation %d", action_index+1);
        defaultLable->setText(str);
    }
    else if (action_index < 9)
    {
        char str[32];
        sprintf(str, "play animation %d", action_index+1 - 6);
        defaultLable->setText(str);
    }
    else
    {
        defaultLable->setText("play animation delay");
    }
    
    
    flag = true;
    this->refreshView(false);
}
开发者ID:MingjunHu,项目名称:CrossApp,代码行数:40,代码来源:FourthViewController.cpp


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