本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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());
}
}
}
示例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);
}