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


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

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


在下文中一共展示了CAButton::addTarget方法的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: 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

示例3: 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(_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);
}
开发者ID:DreamCastleShanghai,项目名称:client_new,代码行数:48,代码来源:VoteViewController.cpp

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

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

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

示例7: viewDidLoad

void SiteViewController::viewDidLoad()
{
    // Do any additional setup after loading the view from its nib.
    m_winSize = this->getView()->getBounds().size;

	CAScale9ImageView* tabBg = CAScale9ImageView::createWithImage(CAImage::create("common/yellow_bg.png"));
	tabBg->setCapInsets(DRect(1, 1, 1, 1));
	tabBg->setFrame(DRect((0), (0), m_winSize.width, (150)));
	this->getView()->addSubview(tabBg);

    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(SiteViewController::buttonCallBack), CAControlEventTouchUpInSide);
    button->setTag(20);
    this->getView()->addSubview(button);

	CALabel* mc = CALabel::createWithFrame(DRect((120), (62), (200), (50)));
	mc->setFontSize((40));
	mc->setText("Site");
	mc->setColor(CAColor_white);
	mc->setFontName(SAP_FONT_ARIAL);
	this->getView()->addSubview(mc);

    imageView = CAImageView::createWithFrame(DRect(0, (150), m_winSize.width, m_winSize.height - (150)));
    imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
    imageView->setImage(CAImage::create("common/site_map.png"));
    this->getView()->addSubview(imageView);
    
	button = CAButton::createWithFrame(DRect(m_winSize.width - 100, (50), (50), (50)), CAButtonTypeRoundedRect);
	imageView = CAImageView::createWithImage(CAImage::create("common/share_btn.png"));
	imageView->setImageViewScaleType(CAImageViewScaleTypeFitViewByHorizontal);
	button->setTag(200);
	button->setBackgroundViewForState(CAControlStateAll, imageView);
	button->addTarget(this, CAControl_selector(SiteViewController::buttonCallBack), CAControlEventTouchUpInSide);
	this->getView()->addSubview(button);

	requestMsg();
	m_pLoading = CAActivityIndicatorView::createWithCenter(DRect(m_winSize.width / 2, m_winSize.height / 2, 50, 50));
	m_pLoading->setLoadingMinTime(0.5f);
	this->getView()->addSubview(m_pLoading);

    CCLog("%f", CAApplication::getApplication()->getWinSize().width);
}
开发者ID:DreamCastleShanghai,项目名称:client_new,代码行数:46,代码来源:SiteViewController.cpp

示例8: viewDidLoad

void DMClassifCatalogViewController::viewDidLoad()
{
    CADipRect rect = this->getView()->getBounds();
    rect.size.height = 96;
    m_uiItems = (unsigned int)(rect.size.width / 300);
    m_uiItems = MIN(m_uiItems, 5);
    m_uiItems = MAX(m_uiItems, 3);
    
    CAView* bar = CAView::createWithFrame(rect, ccc4(87, 154, 244, 255));
    this->getView()->insertSubview(bar, 1);
    
    CADipRect titleRect;
    titleRect.origin = rect.size/2;
    titleRect.size.width = rect.size.width * 0.5f;
    titleRect.size.height = rect.size.height;
    CALabel* label = CALabel::createWithCenter(titleRect);
    label->setNumberOfLine(1);
    label->setFontSize(_px(32));
    label->setColor(CAColor_white);
    label->setTextAlignment(CATextAlignmentCenter);
    label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
    label->setText(m_sTitle);
    bar->addSubview(label);
    
    CCRect btnRect;
    btnRect.size.width = rect.size.height * 0.9f;
    btnRect.size.height = rect.size.height * 0.8f;
    btnRect.origin.x = btnRect.size.width * 0.7f;
    btnRect.origin.y = rect.size.height * 0.5f;
    CAButton* button = CAButton::createWithCenter(btnRect, CAButtonTypeCustom);
    button->setImageForState(CAControlStateNormal, CAImage::create("source_material/btn_left_white.png"));
    button->setImageColorForState(CAControlStateHighlighted, CAColor_gray);
    bar->addSubview(button);
    button->addTarget(this, CAControl_selector(DMIntroductionController::onReturn), CAControlEventTouchUpInSide);
    
    std::map<string, string> key_value;
    CommonHttpManager::getInstance()->send_get(get_url(HttpUrlTypeClassifCatalog, "update", m_sID, "", m_vDatas.size()), key_value, this, CommonHttpJson_selector(DMClassifCatalogViewController::onRequestFinished));
    
    {
        CCRect loadingRect = this->getView()->getBounds();
        loadingRect.origin.y = _px(96);
        loadingRect.size.height -= loadingRect.origin.y;
        m_pLoading = CAActivityIndicatorView::createWithFrame(loadingRect);
        CAImageView* indicator = CAImageView::createWithFrame(CADipRect(0, 0, 50, 50));
        indicator->setImage(CAImage::create(loadingIcon));
        m_pLoading->setActivityIndicatorView(indicator);
        CAView* bg = CAView::createWithFrame(CADipRect(0, 0, 275, 300), CAColor_clear);
        CAImageView* bg2 = CAImageView::createWithFrame(CADipRect(0, 0, 275, 100));
        bg2->setImage(CAImage::create(loadingBackground));
        bg->addSubview(bg2);
        m_pLoading->setActivityBackView(bg);
        m_pLoading->setLoadingMinTime(0.4f);
        m_pLoading->setColor(CAColor_white);
        this->getView()->insertSubview(m_pLoading, CAWindowZoderTop);
        m_pLoading->setTargetOnCancel(this, callfunc_selector(DMClassifCatalogViewController::initWithCollectionView));
    }
}
开发者ID:foio,项目名称:CrossApp,代码行数:57,代码来源:DMClassifCatalogViewController.cpp

示例9: 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);
}
开发者ID:DreamCastleShanghai,项目名称:client_new,代码行数:55,代码来源:SessionsViewController.cpp

示例10: initWithCollectionView

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);
    }
}
开发者ID:9miao,项目名称:CartoonHouse,代码行数:53,代码来源:DMCatalogController.cpp

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

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

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

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

示例15: viewDidLoad

void FirstViewController::viewDidLoad()
{
    // Do any additional setup after loading the view from its nib.
    CCSize size = this->getView()->getBounds().size;

    label = CALabel::createWithCenter(CCRect(size.width/2, 60, 200, 50));
    label->setTextAlignment(CATextAlignmentCenter);
    label->setFontSize(size.width/20);
    label->setText("0.000000");
    this->getView()->addSubview(label);
    
    float height = size.width * 0.8f * 0.15f;
    float off_Y = size.width * 0.8f * 0.15f + 10;
    
    CCRect progress_rect = CCRect(size.width / 2, off_Y + 60, size.width * 0.8f, 10);
	progress = CAProgress::create();
	progress->setCenter(progress_rect);
	this->getView()->addSubview(progress);
    
    CCRect slider_rect = CCRect(size.width/2, off_Y * 2 + 60, size.width * 0.8f, height);
    CASlider* slider = CASlider::createWithCenter(slider_rect);
    this->getView()->addSubview(slider);
    slider->addTarget(this, CAControl_selector(FirstViewController::updateSlider));
    
    CCRect segmentedControl_rect = CCRect(size.width/2, off_Y * 3 + 60, size.width * 0.8f, height);
    CASegmentedControl* segmentedControl = CASegmentedControl::createWithCenter(segmentedControl_rect, 2);
    segmentedControl->insertSegmentWithTitle("2", 2, CAControlStateAll);
    segmentedControl->insertSegmentWithTitle("3", 3, CAControlStateAll);
    this->getView()->addSubview(segmentedControl);
    
    CAButton* btn = CAButton::createWithCenter(CCRect(size.width/2, size.height - off_Y, 150, 60), CAButtonTypeRoundedRect);
    btn->setTitleForState(CAControlStateAll, "OK");
    this->getView()->addSubview(btn);
    btn->addTarget(this, CAControl_selector(FirstViewController::diss), CAControlEventTouchUpInSide);
    
    
}
开发者ID:JasonWorking,项目名称:CrossApp,代码行数:37,代码来源:FirstViewController.cpp


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