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); }
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; }
void SwitchTest::viewDidLoad() { this->getView()->setColor(CAColor_gray); CASwitch* customSwitch1 = CASwitch::createWithLayout(DLayout(DHorizontalLayout_L_W(150, 100), DVerticalLayout_T_H(350, 20))); customSwitch1->setTag(100); customSwitch1->setIsOn(true, false); customSwitch1->addTarget(this, CAControl_selector(SwitchTest::switchStateChange)); this->getView()->addSubview(customSwitch1); CASwitch* customSwitch2 = CASwitch::createWithLayout(DLayout(DHorizontalLayout_R_W(150, 100), DVerticalLayout_T_H(350, 20))); customSwitch2->setTag(101); customSwitch2->setIsOn(true, false); customSwitch2->setOnImage(CAImage::create("image/Switch_on.png")); customSwitch2->setOffImage(CAImage::create("image/Switch_off.png")); customSwitch2->addTarget(this, CAControl_selector(SwitchTest::switchStateChange)); this->getView()->addSubview(customSwitch2); }
void CommonHttpManager::starActivityIndicatorView() { if (m_pActivityIndicatorView == NULL) { CAWindow* window = CAApplication::getApplication()->getRootWindow(); DRect rect = window->getBounds(); m_pActivityIndicatorView = CAActivityIndicatorView::createWithFrame(rect); CAImageView* indicator = CAImageView::createWithLayout(DLayout(DHorizontalLayout_L_W(0, 50), DVerticalLayout_T_H(0, 50))); indicator->setImage(CAImage::create(common_loadingIcon)); m_pActivityIndicatorView->setActivityIndicatorView(indicator); CAView* bg = CAView::createWithFrame(DRect(0, 0, 275, 300), CAColor_clear); CAImageView* bg2 = CAImageView::createWithFrame(DRect(0, 0, 275, 100)); bg2->setImage(CAImage::create(common_loadingBackground)); bg->addSubview(bg2); m_pActivityIndicatorView->setActivityBackView(bg); m_pActivityIndicatorView->setLoadingMinTime(0.3f); window->insertSubview(m_pActivityIndicatorView, CAWindowZOderTop); } else { m_pActivityIndicatorView->startAnimating(); } }
void CAVideoPlayerControlView::buildCtrlViews() { m_glView = CAVideoPlayerView::createWithLayout(DLayoutFill); this->addSubview(m_glView); // Bottom Panel Back CAImageView* bottomPanel = CAImageView::createWithLayout(DLayout(DHorizontalLayoutFill, DVerticalLayout_B_H(0, 188))); bottomPanel->setImage(CAImage::create("source_material/vdo_panel_bottom_bg.png")); m_glView->addSubview(bottomPanel); // Slider CAImage* barImage = CAImage::create("source_material/vdo_progress_bar.png"); m_playSlider = CASlider::createWithLayout(DLayout(DHorizontalLayout_L_R(32, 32), DVerticalLayout_T_H(25, 56))); m_playSlider->setThumbTintImage(barImage); m_playSlider->addTargetForTouchUpSide(this, CAControl_selector(CAVideoPlayerControlView::onSlideChanged)); bottomPanel->addSubview(m_playSlider); // Play Pause Button CAImage* backImage = CAImage::create("source_material/vdo_pause.png"); CAImage* backImage_h = CAImage::create("source_material/vdo_pause_down.png"); m_playButton = CAButton::createWithLayout(DLayout(DHorizontalLayout_L_W(32, 56), DVerticalLayout_T_H(96, 56)), CAButtonTypeCustom); m_playButton->setImageForState(CAControlStateAll, backImage); m_playButton->setImageForState(CAControlStateHighlighted, backImage_h); m_playButton->addTarget(this, CAControl_selector(CAVideoPlayerControlView::onButtonPause), CAControlEventTouchUpInSide); bottomPanel->addSubview(m_playButton); // play time m_playTimeLabel = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_W(120, 200), DVerticalLayout_T_H(96, 56))); m_playTimeLabel->setFontSize(32); m_playTimeLabel->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_playTimeLabel->setColor(ccc4(255, 255, 255, 255)); m_playTimeLabel->setText("00:00 / 00:00"); bottomPanel->addSubview(m_playTimeLabel); /* // Top Panel Back CAImageView* topPanel = NULL; do { CAImage* image = CAImage::create("source_material/vdo_panel_top_bg.png"); topPanel = CAImageView::createWithFrame(DRect(0, 0, m_glView->getFrame().size.width, image->getContentSize().height)); topPanel->setImage(image); m_glView->addSubview(topPanel); } while (0); // Back Button CAButton* buttonBack = NULL; do { DRect frame = topPanel->getFrame(); // CAImage* backImage = CAImage::create("source_material/vdo_btn_back.png"); // CAImage* backImage_h = CAImage::create("source_material/vdo_btn_back_h.png"); CAImage* backImage = CAImage::create("source_material/btn_left_blue.png"); CAImage* backImage_h = CAImage::create("source_material/btn_left_white.png"); frame.origin.y = frame.size.height / 3; frame.origin.x = frame.origin.y; frame.size.height = backImage->getContentSize().height; frame.size.width = backImage->getContentSize().width; buttonBack = CAButton::createWithCenter(frame, CAButtonTypeCustom); buttonBack->setImageForState(CAControlStateAll, backImage); buttonBack->setImageForState(CAControlStateHighlighted, backImage_h); buttonBack->addTarget(this, CAControl_selector(CAVideoPlayerControlView::onButtonBack), CAControlEventTouchUpInSide); topPanel->addSubview(buttonBack); } while (0); // Title do { DRect r = DRectZero; r.origin.x = buttonBack->getFrame().origin.x * 2 + buttonBack->getFrame().size.width; r.origin.y = buttonBack->getFrame().origin.y; r.size.width = m_glView->getFrame().size.width - r.origin.x; r.size.height = buttonBack->getFrame().size.height; CALabel* title = CALabel::createWithFrame(r); title->setText(m_szTitle); title->setFontSize(42); title->setColor(ccc4(255, 255, 255, 255)); title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); topPanel->addSubview(title); } while (0); */ updatePlayButton(); }