本文整理汇总了C++中CAButton::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CAButton::setTag方法的具体用法?C++ CAButton::setTag怎么用?C++ CAButton::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAButton
的用法示例。
在下文中一共展示了CAButton::setTag方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: viewDidLoad
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((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_search.png"));
imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
button->setBackgroundViewForState(CAControlStateAll, imageView);
button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
button->setTag(20);
this->getView()->addSubview(button);
FSegmentView* seg = FSegmentView::createWithFrame(DRect(m_winSize.width - 240, 45, 200, 50), 2);
seg->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
imageView = CAImageView::createWithImage(CAImage::create("common/nav_time.png"));
seg->setItemBackgroundImage(imageView, 0);
imageView = CAImageView::createWithImage(CAImage::create("common/nav_type.png"));
seg->setItemBackgroundImage(imageView, 1);
seg->setTag(200, 0);
seg->setTag(201, 1);
this->getView()->addSubview(seg);
m_navType = 0;
m_navTimeType = 0;
m_navFormatType = 0;
CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 2, (75), m_winSize.width, (50)));
label->setTextAlignment(CATextAlignmentCenter);
label->setColor(CAColor_white);
label->setFontSize(SAP_TITLE_FONT_SIZE);
label->setText("Agenda");
label->setFontName(SAP_FONT_ARIAL);
sView->addSubview(label);
if (m_msg->empty())
{
requestMsg();
{
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(SessionsViewController::initMsgTableView));
}
}
else
{
initMsgTableView();
}
CCLog("%f", CAApplication::getApplication()->getWinSize().width);
}
示例2: buttonTouchEvent
void ButtonTest::buttonTouchEvent()
{
CALabel* buttonTouch = CALabel::createWithCenter(CCRect(size.width*0.5, size.height*0.55, size.width*0.4, 50));
buttonTouch->setText("TouchEvent");
buttonTouch->setFontSize(35 * CROSSAPP_ADPTATION_RATIO);
buttonTouch->setTextAlignment(CATextAlignmentCenter);
buttonTouch->setColor(ccc4(51, 204, 255, 255));
this->getView()->addSubview(buttonTouch);
CAButton* btnOne = CAButton::create(CAButtonTypeCustom);
btnOne->setCenter(CCRect(size.width*0.25 - 50, size.height*0.65, size.width*0.2, size.height*0.05));
btnOne->setTag(BUTTONONE);
btnOne->setTitleForState(CAControlStateNormal, "Normal");
btnOne->setTitleColorForState(CAControlStateNormal, ccc4(51,204,255,255));
btnOne->addTarget(this,CAControl_selector(ButtonTest::buttonCallback),CAControlEventTouchUpInSide);
this->getView()->addSubview(btnOne);
CAButton* btnTwo = CAButton::create(CAButtonTypeSquareRect);
btnTwo->setCenter(CCRect(size.width*0.5, size.height*0.65, size.width*0.2, size.height*0.05));
btnTwo->setTag(BUTTONTWO);
btnTwo->addTarget(this, CAControl_selector(ButtonTest::buttonCallback), CAControlEventTouchUpInSide);
this->getView()->addSubview(btnTwo);
CAButton* btnThree = CAButton::create(CAButtonTypeRoundedRect);
btnThree->setCenter(CCRect(size.width*0.75 + 50, size.height*0.65, size.width*0.2, size.height*0.05));
btnThree->setTag(BUTTONTHREE);
btnThree->addTarget(this, CAControl_selector(ButtonTest::buttonCallback), CAControlEventTouchUpInSide);
this->getView()->addSubview(btnThree);
descTest = CALabel::createWithCenter(CCRect(size.width*0.5, size.height*0.8, size.width*0.9, 50));
descTest->setText("Display coordinates");
descTest->setFontSize(30*CROSSAPP_ADPTATION_RATIO);
descTest->setColor(ccc4(51, 204, 255, 255));
descTest->setTextAlignment(CATextAlignmentCenter);
this->getView()->addSubview(descTest);
}
示例3: 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;
}
示例4: 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);
}
示例5: 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);
}
示例6: addButton
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;
}
示例7: viewDidLoad
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);
}
//.........这里部分代码省略.........
示例8: init
bool CATabBar::init(const CAVector<CATabBarItem*>& items, const CCSize& size)
{
if (!CAView::init())
{
return false;
}
this->setColor(CAColor_clear);
this->setItems(items);
CCSize winSize = CAApplication::getApplication()->getWinSize();
CCSize contentSize = size.equals(CCSizeZero) ? CCSize(winSize.width, _px(98)) : size;
this->setContentSize(contentSize);
CADipRect rect = this->getBounds();
rect.origin = rect.size / 2;
rect.size.width = MIN(rect.size.width, 1024);
m_pContentView = new CAView();
m_pContentView->setCenter(rect);
this->addSubview(m_pContentView);
m_pContentView->release();
unsigned int count = (unsigned int)m_pItems.size();
m_cItemSize = m_pContentView->getBounds().size;
m_cItemSize.width = rect.size.width/count;
if (m_pButtons.empty())
{
for (unsigned int i=0; i<count; i++)
{
CADipRect rect = CADipRectZero;
rect.size = m_cItemSize;
rect.origin.x = m_cItemSize.width * i;
CAButton* btn = CAButton::createWithFrame(rect, CAButtonTypeCustom);
m_pContentView->addSubview(btn);
btn->setTag(i);
btn->addTarget(this, CAControl_selector(CATabBar::setTouchSelected), CAControlEventTouchUpInSide);
m_pButtons.pushBack(btn);
CABadgeView* badgeView = new CABadgeView();
badgeView->init();
badgeView->setCenter(CADipRect(rect.size.width, 25, 0, 0));
btn->insertSubview(badgeView, 10);
m_pBadgeViews.pushBack(badgeView);
}
}
if (m_pBackGroundImage == NULL)
{
this->setBackGroundImage(CAImage::create("source_material/tabBar_bg.png"));
}
if (m_pSelectedBackGroundImage == NULL)
{
this->setSelectedBackGroundImage(CAImage::create("source_material/tabBar_selected_bg.png"));
}
if (m_pSelectedIndicatorImage == NULL)
{
this->setSelectedIndicatorImage(CAImage::create("source_material/tabBar_selected_indicator.png"));
}
return true;
}
示例9: initMsgTableView
void SessionsViewController::initMsgTableView()
{
if (m_msg->empty())
{
showAlert();
return;
}
if (m_msgTableView == NULL)
{
m_listView = CAListView::createWithFrame(DRect(0,(120),m_winSize.width,(60)));
m_listView->setListViewDelegate(this);
m_listView->setListViewDataSource(this);
m_listView->setAllowsSelection(true);
m_listView->setAllowsMultipleSelection(false);
m_listView->setListViewOrientation(CAListViewOrientationHorizontal);
m_listView->setShowsScrollIndicators(false);
m_listView->setSeparatorColor(ccc4(0xf6, 0xf6, 0xf6, 0xff));
m_listView->setBackgroundImage(CAImage::create("common/gray_bg.png"));
m_listView->setTag(1);
//m_listView->setc
this->getView()->addSubview(m_listView);
m_msgTableView = CATableView::createWithFrame(DRect(0, (180), m_winSize.width, m_winSize.height - (180)));
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::CAPullToRefreshTypeHeader);
refreshDiscount->setLabelColor(CAColor_black);
m_msgTableView->setHeaderRefreshView(refreshDiscount);
m_filterView = CAView::createWithFrame(DRect(0, (120), m_winSize.width, (60)));
CAScale9ImageView* imageView = CAScale9ImageView::createWithImage(CAImage::create("common/gray_bg.png"));
imageView->setFrame(DRect(0, 0, m_winSize.width, (60)));
m_filterView->addSubview(imageView);
this->getView()->addSubview(m_filterView);
m_filterViewVec.push_back(m_filterView);
for (int i = 0; i < 2; i++)
{
int cnt = 0;
if (i == 0) {
cnt = TrackNum;
} else if (i == 1) {
cnt = FormatNum;
}
m_filterBtn[i] = CAButton::createWithFrame(DRect(i * m_winSize.width / 2, 0, m_winSize.width / 2, (60)), CAButtonTypeCustom);
m_filterBtn[i]->setTitleForState(CAControlStateAll, filterItem[i]);
m_filterBtn[i]->setTitleFontName(SAP_FONT_ARIAL);
m_filterBtn[i]->setTitleFontSize((30));
m_filterBtn[i]->setTitleColorForState(CAControlStateAll, CAColor_gray);
m_filterBtn[i]->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
m_filterBtn[i]->setTag(300 + i);
m_filterBtn[i]->setAllowsSelected(true);
m_filterView->addSubview(m_filterBtn[i]);
m_downView[i] = CAView::createWithFrame(DRect(i * m_winSize.width / 2, (180), m_winSize.width / 2, (50) * cnt + (20)));
CAScale9ImageView* imageView = CAScale9ImageView::createWithImage(CAImage::create("common/gray_bg.png"));
imageView->setFrame(DRect(0, 0, m_winSize.width / 2, (50) * cnt + (20)));
m_downView[i]->addSubview(imageView);
this->getView()->addSubview(m_downView[i]);
m_filterViewVec.push_back(m_downView[i]);
}
for (int i = 0; i < m_filterViewVec.size(); i++)
{
m_filterViewVec[i]->setVisible(false);
}
for (int i = 0; i < TrackNum; i++)
{
CAButton* button = CAButton::createWithFrame(DRect((20), (50) * i, m_winSize.width / 2 - (40), (50)), CAButtonTypeCustom);
button->setTitleForState(CAControlStateAll, trackFilterItem[i]);
button->setTitleFontName(SAP_FONT_ARIAL);
button->setTitleColorForState(CAControlStateAll, CAColor_gray);
button->setTitleColorForState(CAControlStateSelected, CAColor_white);
button->setTitleFontSize((27));
button->setAllowsSelected(true);
//CAImageView* imageView = CAImageView::createWithImage(CAImage::create("common/white_bg.png"));
//button->setBackgroundViewForState(CAControlStateAll, imageView);
CAImageView* imageView = CAImageView::createWithImage(CAImage::create("common/sky_bg.png"));
button->setBackgroundViewForState(CAControlStateSelected, imageView);
button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
button->setTag(400 + i);
m_downView[0]->addSubview(button);
m_trackButtonVec.push_back(button);
}
for (int i = 0; i < FormatNum; i++)
{
CAButton* button = CAButton::createWithFrame(DRect((20), (50) * i, m_winSize.width / 2 - (40), (50)), CAButtonTypeCustom);
button->setTitleForState(CAControlStateAll, formatFilterItem[i]);
button->setTitleFontName(SAP_FONT_ARIAL);
button->setTitleColorForState(CAControlStateAll, CAColor_gray);
button->setTitleColorForState(CAControlStateSelected, CAColor_white);
//.........这里部分代码省略.........