Exemple #1
0
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);
    }
}
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;
}
Exemple #3
0
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);
}
Exemple #4
0
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);
    }
}
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();
}
Exemple #6
0
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);
}
Exemple #7
0
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;
}
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);
}
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);
}
Exemple #10
0
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;
}
Exemple #11
0
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);
}
Exemple #12
0
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);
}
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;
}
Exemple #14
0
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;
}
Exemple #15
0
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);
}
Exemple #16
0
void ButtonTest::threeButtonType()
{
	CALabel* buttonType = CALabel::createWithCenter(CCRect(size.width*0.5, size.height*0.05, size.width*0.4, 50));
	buttonType->setText("ButtonType");
	buttonType->setFontSize(30*CROSSAPP_ADPTATION_RATIO);
	buttonType->setTextAlignment(CATextAlignmentCenter);
	buttonType->setColor(ccc4(51, 204, 255, 255));
	this->getView()->addSubview(buttonType);

	CAButton* defaultBtn = CAButton::create(CAButtonTypeCustom);
	defaultBtn->setCenter(CCRect(size.width*0.25-50, size.height*0.15, size.width*0.2, size.height*0.05));
	defaultBtn->setTitleForState(CAControlStateNormal, "Noborder");
	defaultBtn->setTitleColorForState(CAControlStateNormal, ccc4(51, 204, 255, 255));
	this->getView()->addSubview(defaultBtn);

	CALabel* custom = CALabel::createWithCenter(CCRect(size.width*0.25-50, size.height*0.15+80, size.width*0.2, 50));
	custom->setText("(CAButtonTypeCustom)");
	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.15, size.width*0.2, size.height*0.05));
	this->getView()->addSubview(squareRectBtn);

	CALabel* square = CALabel::createWithCenter(CCRect(size.width*0.5, size.height*0.15 + 80, size.width*0.2, 50));
	square->setText("(CAButtonTypeSquareRect)");
	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.15, size.width*0.2, size.height*0.05));
	this->getView()->addSubview(roundedRectBtn);

	CALabel* rounded = CALabel::createWithCenter(CCRect(size.width*0.75+50, size.height*0.15 + 80, size.width*0.2, 50));
	rounded->setText("(CAButtonTypeRoundedRect)");
	rounded->setFontSize(20 * CROSSAPP_ADPTATION_RATIO);
	rounded->setTextAlignment(CATextAlignmentCenter);
	rounded->setColor(ccc4(51, 204, 255, 255));
	this->getView()->addSubview(rounded);
}
Exemple #17
0
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());
        }
    }
}
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);
    
    
}
Exemple #19
0
void CATabBar::showSelectedBackGround()
{
    for (size_t i=0; i<m_pButtons.size(); i++)
    {
        CAButton* btn = m_pButtons.at(i);
        btn->setTitleForState(CAControlStateAll, m_pItems.at(i)->getTitle());
        btn->setTitleColorForState(CAControlStateAll, m_sTitleColor);
        btn->setTitleColorForState(CAControlStateHighlighted, m_sSelectedTitleColor);
        btn->setTitleColorForState(CAControlStateSelected, m_sSelectedTitleColor);
        btn->setImageForState(CAControlStateNormal, m_pItems.at(i)->getImage());
        CAImage* selectedImage = m_pItems.at(i)->getSelectedImage()
        ? m_pItems.at(i)->getSelectedImage()
        : m_pItems.at(i)->getImage();
        btn->setImageForState(CAControlStateHighlighted, selectedImage);
        btn->setImageForState(CAControlStateSelected, selectedImage);
        btn->setBackGroundViewForState(CAControlStateNormal, CAView::createWithColor(CAColor_clear));
        if (m_pSelectedBackGroundImage)
        {
            btn->setBackGroundViewForState(CAControlStateHighlighted,
                                           CAScale9ImageView::createWithImage(m_pSelectedBackGroundImage));
            btn->setBackGroundViewForState(CAControlStateSelected,
                                           CAScale9ImageView::createWithImage(m_pSelectedBackGroundImage));
        }
        else
        {
            btn->setBackGroundViewForState(CAControlStateHighlighted,
                                           CAView::createWithColor(m_sSelectedBackGroundColor));
            btn->setBackGroundViewForState(CAControlStateSelected,
                                           CAView::createWithColor(m_sSelectedBackGroundColor));
        }
        btn->setAllowsSelected(true);
        
        CABadgeView* badgeView = m_pBadgeViews.at(i);
        badgeView->setBadgeText(m_pItems.at(i)->getBadgeValue());
    }
}
Exemple #20
0
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);
}
Exemple #21
0
void ButtonTest::buttonBackground(void)
{
	CADipSize size = bkgView->getBounds().size;

	CALabel* buttonImage = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.2, size.width*0.4, 50));
	buttonImage->setText("ButtonImage");
	buttonImage->setFontSize(_px(30));
	buttonImage->setTextAlignment(CATextAlignmentCenter);
	buttonImage->setColor(ccc4(51, 204, 255, 255));
	bkgView->addSubview(buttonImage);

	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, "Normal");
	defaultBtn->setTitleColorForState(CAControlStateNormal, CAColor_white);
	defaultBtn->setTitleForState(CAControlStateSelected,"Selected");
	defaultBtn->setTitleForState(CAControlStateHighlighted, "Highlighted");
	defaultBtn->setBackGroundViewForState(CAControlStateNormal,CAView::createWithColor(CAColor_green));
	defaultBtn->setBackGroundViewForState(CAControlStateHighlighted, CAView::createWithColor(CAColor_yellow));
	bkgView->addSubview(defaultBtn);

	CALabel* custom = CALabel::createWithCenter(CADipRect(size.width*0.25 - 50, size.height*0.5 + 80, size.width*0.3, 50));
	custom->setText("(BackgroundView)");
	custom->setFontSize(_px(20));
	custom->setTextAlignment(CATextAlignmentCenter);
	custom->setColor(CAColor_blueStyle);
	bkgView->addSubview(custom);


	CAButton* squareRectBtn = CAButton::create(CAButtonTypeSquareRect);
	squareRectBtn->setAllowsSelected(true);
	squareRectBtn->setCenter(CADipRect(size.width*0.5, size.height*0.5, size.width*0.25, size.height*0.1));
	squareRectBtn->setTitleForState(CAControlStateNormal, "Normal");
	squareRectBtn->setTitleColorForState(CAControlStateNormal, CAColor_white);
	squareRectBtn->setTitleForState(CAControlStateSelected, "Selected");
	squareRectBtn->setTitleForState(CAControlStateHighlighted, "Highlighted");
	squareRectBtn->setBackGroundViewForState(CAControlStateNormal, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_normal.png")));
	squareRectBtn->setBackGroundViewForState(CAControlStateHighlighted, CAScale9ImageView::createWithImage(CAImage::create("source_material/ex4.png")));
	squareRectBtn->setBackGroundViewForState(CAControlStateSelected, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_selected.png")));
	bkgView->addSubview(squareRectBtn);

	CALabel* square = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.5 + 80, size.width*0.3, 50));
	square->setText("(StateImage)");
	square->setFontSize(_px(20));
	square->setTextAlignment(CATextAlignmentCenter);
	square->setColor(CAColor_blueStyle);
	bkgView->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->setBackGroundViewForState(CAControlStateDisabled, CAScale9ImageView::createWithImage(CAImage::create("source_material/ex5.png")));
	roundedRectBtn->setControlState(CAControlStateDisabled);
	bkgView->addSubview(roundedRectBtn);

	CALabel* rounded = CALabel::createWithCenter(CADipRect(size.width*0.75 + 50, size.height*0.5 + 80, size.width*0.3, 50));
	rounded->setText("(Disabled)");
	rounded->setFontSize(_px(20));
	rounded->setTextAlignment(CATextAlignmentCenter);
	rounded->setColor(CAColor_blueStyle);
	bkgView->addSubview(rounded);
}
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);
			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(500 + i);
			m_downView[1]->addSubview(button);
			m_formatButtonVec.push_back(button);
		}
    }
}