CAView* SecondViewController::tableViewSectionViewForHeaderInSection(CATableView* table, const CCSize& viewSize, unsigned int section)
{
	CADipSize _viewSize = viewSize;
	char head[10] = "";
	CAView* view = CAView::createWithColor(ccc4(239,242,243,255));
	CAButton* headControl1 = CAButton::createWithCenter(CADipRect(60, _viewSize.height*0.5, 80, 80),
		CAButtonTypeRoundedRect);
	headControl1->setTag(100 + (int)section);
	if (sect[section] == CELL_COUNT)
	{
		headControl1->setBackGroundViewForState(CAControlStateNormal, CAImageView::createWithImage(CAImage::create("source_material/close1.png")));
	}
	else
	{
		headControl1->setBackGroundViewForState(CAControlStateNormal, CAImageView::createWithImage(CAImage::create("source_material/open1.png")));
	}
	headControl1->addTarget(this, CAControl_selector(SecondViewController::switchCellListInSection), CAControlEventTouchUpInSide);
	view->addSubview(headControl1);

	CALabel* header = CALabel::createWithCenter(CADipRect(_viewSize.width*0.5, _viewSize.height*0.5, 300, 50));
	sprintf(head, "Section-%d", section);
	header->setFontSize(_px(30));
	header->setText(head);
	header->setColor(CAColor_blueStyle);
	header->setTextAlignment(CATextAlignmentCenter);
	header->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
	view->addSubview(header);

	return view;
}
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));
    }
}
void CDNewsViewController::initNewsPageView()
{
    //初始化pageView
    CAView* tempview = CAView::create();
    
    p_PageView = CAPageView::createWithFrame(DRect(0,0,winSize.width,winSize.width/2), CAPageViewDirectionHorizontal);
    p_PageView->setPageViewDelegate(this);
    p_PageView->setTouchEnabled(true);
    CAVector<CAView* > viewList;
    CommonUrlImageView* temImage0 = CommonUrlImageView::createWithFrame(DRect(winSize.width/2,100,winSize.width,winSize.width/2));
    temImage0->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
    temImage0->setImage(CAImage::create("image/HelloWorld.png"));
    temImage0->setUrl(m_page[m_page.size()-1].m_pic);
    
    viewList.pushBack(temImage0);
    for (int i=0; i<m_page.size(); i++) {
        //初始化viewList
        CommonUrlImageView* temImage = CommonUrlImageView::createWithFrame(DRect(winSize.width/2,100,winSize.width,winSize.width/2));
        temImage->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
        temImage->setImage(CAImage::create("image/HelloWorld.png"));
        temImage->setUrl(m_page[i].m_pic);
        viewList.pushBack(temImage);
    }
    CommonUrlImageView* temImage1 = CommonUrlImageView::createWithFrame(DRect(winSize.width/2,100,winSize.width,winSize.width/2));
    temImage1->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
    temImage1->setImage(CAImage::create("image/HelloWorld.png"));
    temImage1->setUrl(m_page[0].m_pic);
    viewList.pushBack(temImage1);
    
    p_PageView->setViews(viewList);
    tempview->addSubview(p_PageView);
    p_PageView->setCurrPage(1, false);
    pageControl = CAPageControl::createWithCenter(DRect(winSize.width-80, winSize.width/2-25, 100, 50));
    pageControl->setNumberOfPages((int)m_page.size());
    pageControl->setPageIndicatorImage(CAImage::create("image/pagecontrol_selected.png"));
    pageControl->setCurrIndicatorImage(CAImage::create("image/pagecontrol_bg.png"));
    pageControl->setPageIndicatorTintColor(CAColor_gray);
    //pageControl->setCurrentPageIndicatorTintColor(CAColor_clear);
    pageControl->addTarget(this, CAControl_selector(CDNewsViewController::pageControlCallBack));
    tempview->addSubview(pageControl);
    
    CAView* bg = CAView::createWithColor(ccc4(0, 0, 0, 128));
    bg->setFrame(DRect(0,winSize.width/2-50,winSize.width,50));
    tempview->addSubview(bg);
    
    if (m_page.size()>0) {
        pageViewTitle = CALabel::createWithFrame(DRect(10, winSize.width/2-40, winSize.width-50, 50));
        pageViewTitle->setText(m_page[0].m_title);
		pageViewTitle->setColor(CAColor_white);
        pageViewTitle->setFontSize(_px(28));
        tempview->addSubview(pageViewTitle);
    }
    
    p_TableView->setTableHeaderView(tempview);
    p_TableView->setTableHeaderHeight(_px(winSize.width/2));
}
void ThirdViewController::viewDidLoad()
{
	CCRect rect = this->getView()->getBounds();

	CCRect tableRect = rect;

	m_pCollectionView = new CACollectionView();
	m_pCollectionView->initWithFrame(tableRect);
	m_pCollectionView->setCollectionViewDataSource(this);
	m_pCollectionView->setCollectionViewDelegate(this);
	this->getView()->addSubview(m_pCollectionView);
	m_pCollectionView->release();
	m_pCollectionView->setBackGroundColor(CAColor_gray);

    CAView* headView = CAView::createWithColor(CAColor_red);
    
    CCSize sz = CCSize(rect.size.width, 100);
	CALabel* pLabel = new CALabel();
	pLabel->initWithCenter(CCRectMake(sz.width / 2, sz.height / 2, sz.width, sz.height));
	pLabel->setTextAlignment(CATextAlignmentCenter);
	pLabel->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
	pLabel->setText("CollectionView");
	pLabel->setFontName("fonts/arial.ttf");
	pLabel->setFontSize(36);
	pLabel->setColor(CAColor_white);
	headView->addSubview(pLabel);
	pLabel->release();
    
	m_pCollectionView->setCollectionHeaderView(headView);
    m_pCollectionView->setCollectionHeaderHeight(100);
    
    
    CAView* footerView = CAView::createWithColor(CAColor_blue);
    
    CALabel* pLabel2 = new CALabel();
	pLabel2->initWithCenter(CCRectMake(sz.width / 2, sz.height / 2, sz.width, sz.height));
	pLabel2->setTextAlignment(CATextAlignmentCenter);
	pLabel2->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
	pLabel2->setText("Footer View");
	pLabel2->setFontName("fonts/arial.ttf");
	pLabel2->setFontSize(28);
	pLabel2->setColor(CAColor_gray);
	footerView->addSubview(pLabel2);
	pLabel2->release();
    
	m_pCollectionView->setCollectionFooterView(footerView);
    m_pCollectionView->setCollectionFooterHeight(100);

	m_pCollectionView->setAllowsSelection(true);

}
Exemple #5
0
void UtilManager::toast(string text, CAViewController* object) {

	CAApplication::getApplication()->getRootWindow()->removeSubviewByTag(TOAST_VIEW_TAG);

	CCSize winSize = CAApplication::getApplication()->getWinSize();
	//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
	CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, 180 * getScale(), 30 * getScale()));
	back->setTag(TOAST_VIEW_TAG);
	back->setColor(ccc4(31, 31, 31, 200));//40

	CALabel *title = CALabel::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),
		_dip(back->getBounds().size.height*0.5), 180 * getScale(), 30 * getScale()));
  //	title->setText(UTF8ToGBK::transferToGbk(text));
	title->setText(text);
	//title->setText("sssss");
//	title->setFontName(getChineseFont());
	title->setColor(CAColor_white);
	title->setTextAlignment(CATextAlignmentCenter);
	title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
	title->setFontSize(_px(15));
	back->addSubview(title);
	//CAApplication::getApplication()->getRootWindow()->getRootViewController()->getView()->addSubview(back);
	back->runAction(CCFadeOut::create(1));

	//CAApplication::getApplication()->getRootWindow()->addSubview(back);
	object->getView()->addSubview(back);
	//CCLog("%s", get_date_now().c_str());
	scheduleOnce(schedule_selector(UtilManager::removeToast), this, TOAST_TIME);
}
void DMCatalogController::viewDidLoad()
{
    if (m_mvData.empty())
    {
        HTTP_URL::S_HTTP_URL s_http_url = HTTP_URL::get_HTTP_URL(HTTP_URL::HttpUrlTypeRecommend);
        CommonHttpManager::getInstance()->send_post(s_http_url.url, s_http_url.key_value, this, CommonHttpJson_selector(DMCatalogController::onRequestFinished));
        
        {
            CCRect loadingRect = this->getView()->getBounds();
            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->setColor(CAColor_white);
            this->getView()->insertSubview(m_pLoading, CAWindowZoderTop);
            m_pLoading->setTargetOnCancel(this, callfunc_selector(DMCatalogController::initWithCollectionView));
        }
    }
    else
    {
        this->initWithCollectionView();
    }
}
void FSNewsAboutController::viewDidLoad()
{
    winSize = this->getView()->getBounds().size;
    
    if (p_TableView!=NULL)
    {
        this->getView()->removeSubview(p_TableView);
        p_TableView = NULL;
    }
    p_TableView= CATableView::createWithFrame(CADipRect(0, -150, winSize.width, winSize.height+150));
    p_TableView->setTableViewDataSource(this);
    p_TableView->setTableViewDelegate(this);
    p_TableView->setAllowsSelection(true);
    p_TableView->setAllowsMultipleSelection(false);
    p_TableView->setAlwaysTopSectionHeader(false);
    this->getView()->addSubview(p_TableView);
    p_TableView->setTableHeaderHeight(_px(602));
    CAView* view = CAView::createWithColor(CAColor_clear);
    view->setFrame(CADipRect(0,0,winSize.width,602));
    
    CAImageView* head_bg = CAImageView::createWithFrame(CADipRect(0,0,winSize.width,602));
    head_bg->setImage(CAImage::create("image/about_head_bg.png"));
    view->addSubview(head_bg);
    
//    CAImageView* head = CAImageView::createWithCenter(CADipRect(winSize.width/2,320,96,96));
//    head->setImage(CAImage::create("image/avatar_bg_70.png"));
//    view->addSubview(head);
    

    
    p_TableView->setTableHeaderView(view);
}
CAView* RootViewController::tableViewSectionViewForFooterInSection(CATableView* table, unsigned int section)
{
    CAView* view = CAView::createWithFrame(CCRect(0, 0, 0, 0), ccc4(200, 255, 200, 255));
    
    CCString* str = CCString::createWithFormat("Footer - %u", section);
    CCLabelTTF* ttf = CCLabelTTF::create(str->getCString(), "Arial", 20);
    ttf->setColor(ccc3(127, 127, 127));
    ttf->setFrame(CCRect(10, 10, 0, 0));
    view->addSubview(ttf);
    
    return view;
}
CAView* ThirdViewController::collectionViewSectionViewForHeaderInSection(CACollectionView *collectionView, const CCSize& viewSize, unsigned int section)
{
    CAView* view = CAView::createWithFrame(CCRect(0, 0, 0, 0), ccc4(224, 224, 224, 255));
    
    CCString* str = CCString::createWithFormat("Section Header - %u", section);
    CALabel* label = CALabel::createWithFrame(CCRect(20, 0, 200, viewSize.height));
    label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
    label->setFontSize(24);
    label->setText(str->getCString());
    label->setColor(ccc4(127, 127, 127, 255));
    view->addSubview(label);
    
	return view;
}
CAView* RecipeListViewController::tableViewSectionViewForHeaderInSection(CATableView* table, const DSize& viewSize, unsigned int section)
{
    std::string head = m_strSectionTitle;
    CAView* view = CAView::createWithColor(SectionTitleColor);
    
    DSize _size = viewSize;
    CALabel* header = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(0,0), DVerticalLayoutFill));
    header->setText(head);
    header->setFontSize(30);
    header->setColor(CAColor_white);
    header->setTextAlignment(CATextAlignmentCenter);
    header->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
    view->addSubview(header);
    
    return view;
}
CAView* MainViewController::tableViewSectionViewForHeaderInSection(CATableView* table, const DSize& viewSize, unsigned int section)
{
    CAView* view = NULL;
    if(m_filterMsg.empty())
    {
        // lable
        view = CAView::createWithFrame(DRect(0, 0, m_winSize.width, m_winSize.height));
        CALabel* label = CALabel::createWithCenter(DRect((m_winSize.width / 2), (120), (640 - 80), (240)));
        label->setText("My following sessions. (Avaliable on 2nd March)");
        label->setFontSize((30));
        label->setColor(ccc4(0, 0xa8, 0xfc, 0xff));
        label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
        label->setTextAlignment(CATextAlignmentCenter);
        view->addSubview(label);
    }
    return view;
}
Exemple #12
0
void CANavigationController::createWithContainer(CAViewController* viewController)
{
    CAView* container = new CAView();
    container->setFrame(this->getView()->getBounds());
    this->getView()->addSubview(container);
    m_pContainers.pushBack(container);
    container->release();
    
    CANavigationBar* navigationBar = CANavigationBar::create(DSize(this->getView()->getBounds().size.width, 0));
    if (viewController->getNavigationBarItem() == NULL && viewController->getTitle().compare("") != 0)
    {
        viewController->setNavigationBarItem(CANavigationBarItem::create(viewController->getTitle()));
    }
    if (m_pViewControllers.empty())
    {
        viewController->getNavigationBarItem()->setShowGoBackButton(false);
    }
    navigationBar->setItem(viewController->getNavigationBarItem());
    
    if (m_pNavigationBarBackgroundImage)
    {
        navigationBar->setBackgroundView(CAScale9ImageView::createWithImage(m_pNavigationBarBackgroundImage));
    }
    else
    {
        navigationBar->setBackgroundView(CAView::create());
    }
    navigationBar->getBackgroundView()->setColor(m_sNavigationBarBackgroundColor);
    navigationBar->setTitleColor(m_sNavigationBarTitleColor);
    navigationBar->setTitleColor(m_sNavigationBarTitleColor);
    container->insertSubview(navigationBar, 1);
    navigationBar->setDelegate(this);
    m_pNavigationBars.pushBack(navigationBar);
    
    CAView* secondContainer = new CAView();
    container->addSubview(secondContainer);
    secondContainer->release();
    m_pSecondContainers.pushBack(secondContainer);
    
    viewController->m_pNavigationController = this;
    m_pViewControllers.pushBack(viewController);
}
void CommonHttpManager::starActivityIndicatorView()
{
    if (m_pActivityIndicatorView == NULL)
    {
        CAWindow* window = CAApplication::getApplication()->getRootWindow();
        CCRect rect = window->getBounds();
        
        m_pActivityIndicatorView = CAActivityIndicatorView::createWithFrame(rect);
        CAImageView* indicator = CAImageView::createWithFrame(CADipRect(0, 0, 50, 50));
        indicator->setImage(CAImage::create(common_loadingIcon));
        m_pActivityIndicatorView->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(common_loadingBackground));
        bg->addSubview(bg2);
        m_pActivityIndicatorView->setActivityBackView(bg);
        m_pActivityIndicatorView->setLoadingMinTime(0.3f);
        window->insertSubview(m_pActivityIndicatorView, CAWindowZoderTop);
    }
    else
    {
        m_pActivityIndicatorView->startAnimating();
    }
}
Exemple #14
0
void CCTransitionCrossFade::onEnter()
{
    CCTransitionScene::onEnter();

    // create a transparent color layer
    // in which we are going to add our rendertextures
    ccColor4B  color = {0,0,0,0};
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    CAView* layer = CAView::createWithFrame(CCRect(0, 0, size.width, size.height));
    layer->setColor(ccc3(color.r, color.g, color.b));
    layer->setOpacity(color.a);

    // create the first render texture for inScene
    CCRenderTexture* inTexture = CCRenderTexture::create((int)size.width, (int)size.height);

    if (NULL == inTexture)
    {
        return;
    }

    inTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) );
    inTexture->setPosition( ccp(size.width/2, size.height/2) );
    inTexture->setAnchorPoint( ccp(0.5f,0.5f) );

    // render inScene to its texturebuffer
    inTexture->begin();
    m_pInScene->visit();
    inTexture->end();

    // create the second render texture for outScene
    CCRenderTexture* outTexture = CCRenderTexture::create((int)size.width, (int)size.height);
    outTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) );
    outTexture->setPosition( ccp(size.width/2, size.height/2) );
    outTexture->setAnchorPoint( ccp(0.5f,0.5f) );

    // render outScene to its texturebuffer
    outTexture->begin();
    m_pOutScene->visit();
    outTexture->end();

    // create blend functions

    ccBlendFunc blend1 = {GL_ONE, GL_ONE}; // inScene will lay on background and will not be used with alpha
    ccBlendFunc blend2 = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; // we are going to blend outScene via alpha 

    // set blendfunctions
    inTexture->getSprite()->setBlendFunc(blend1);
    outTexture->getSprite()->setBlendFunc(blend2);    

    // add render textures to the layer
    layer->addSubview(inTexture);
    layer->addSubview(outTexture);

    // initial opacity:
    inTexture->getSprite()->setOpacity(255);
    outTexture->getSprite()->setOpacity(255);

    // create the blend action
    CCAction* layerAction = CCSequence::create
    (
        CCFadeTo::create(m_fDuration, 0),
        CCCallFunc::create(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),
        CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
        NULL
    );


    // run the blend action
    outTexture->getSprite()->runAction( layerAction );

    // add the layer (which contains our two rendertextures) to the scene
    layer->setTag(kSceneFade);
    insertSubview(layer, 2);
}
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);
             }
             m_pageView->setViews(viewList);
             m_pageView->setCurrPage(0, false);
             this->getView()->addSubview(m_pageView);
             //headView->addSubview(m_pageView);
        }
    }
    
    // picture dots bg in page view
    m_pageControlBG = CAView::createWithColor(ccc4(0, 0, 0, 20));
    m_pageControlBG->setFrame(DRect(0, pageViewHeight + headerHeight - (50), m_winSize.width, (50)));
    m_pageControlBG->setTouchEnabled(false);
    this->getView()->addSubview(m_pageControlBG);
    //headView->addSubview(bg);
    
    // picture dots
    m_pageControl = CAPageControl::createWithCenter(DRect(m_winSize.width / 2, pageViewHeight + headerHeight - (25), (120), (50)));
    if (m_pageControl) {
        m_pageControl->setNumberOfPages((int)m_page.size());
        m_pageControl->setTag(200);
        m_pageControl->addTarget(this, CAControl_selector(MainViewController::buttonCallBack));
        this->getView()->addSubview(m_pageControl);
    }
    //headView->addSubview(m_pageControl);
     */
    
    int buttonHight = (150);//m_winSize.height * 0.15;//(116);
    // three center button
    for (int i = 0; i < 3; i++)
    {
        DRect r(i * (m_winSize.width / 3), headerHeight + pageViewHeight, m_winSize.width / 3, buttonHight);
        CAButton* btn = CAButton::createWithFrame(r, CAButtonTypeCustom);
        btn->setTag(300 + i);
        CAImageView* imageView = CAImageView::createWithCenter(DRect(m_winSize.width / 3 / 2, (60), (60), (60)));//createWithImage(CAImage::create(crossapp_format_string("main/short_%d.png", i)));
        imageView->setImage(CAImage::create(crossapp_format_string("main/short_%d.png", i)));
        imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
        //imageView->setFrame(DRect(m_winSize.width / 3 / 2, (30), (60), (60)));
        imageView->setTouchEnabled(false);
        btn->addSubview(imageView);
        CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 3 / 2, (140), m_winSize.width / 3, (60)));
        label->setTextAlignment(CATextAlignmentCenter);
        label->setColor(CAColor_gray);
        label->setFontSize((28));
        label->setText(unicode_to_utf8(mainShort[i]));
        label->setFontName(SAP_FONT_ARIAL);
        label->setTouchEnabled(false);
        btn->addSubview(label);
        btn->addTarget(this, CAControl_selector(MainViewController::buttonCallBack), CAControlEventTouchUpInSide);
        this->getView()->addSubview(btn);
        //headView->addSubview(btn);
    }
    
    /*
     if (m_page.size() > 0)
     {
     m_pageViewTitle = CALabel::createWithFrame(DRect(20, m_winSize.width / 2 - 40, m_winSize.width - 50, 50));
     m_pageViewTitle->setText(m_page[0].m_title);
     m_pageViewTitle->setColor(CAColor_white);
     m_pageViewTitle->setFontSize((28));
     m_pageViewTitle->setScrollEnabled(false);
     m_pageViewTitle->setTouchEnabled(false);
     this->getView()->addSubview(m_pageViewTitle);
     //headView->addSubview(m_pageViewTitle);
     }
     */
    
    // sub title bar left picture
    CAView *subViewleft = CAView::createWithCenter(DRect((100), headerHeight + pageViewHeight + buttonHight + (20), m_winSize.width / 4, (20)));
    //CAView *subViewleft = CAView::createWithFrame(DRect(0, 0, m_winSize.width, (20)));
    CAImageView* subbarView1 = CAImageView::createWithImage(CAImage::create("main/home_bar.png"));
    subbarView1->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
    subbarView1->setFrame(DRect(0, 0, m_winSize.width / 4, (20)));
    subbarView1->setTouchEnabled(false);
    subViewleft->addSubview(subbarView1);
    this->getView()->addSubview(subViewleft);

    // sub title
    CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 2, headerHeight + pageViewHeight + buttonHight + (30), m_winSize.width / 2, (45)));
    label->setTextAlignment(CATextAlignmentCenter);
    label->setColor(CAColor_gray);//ccc4(0x0f, 0xaa, 0xff, 0xff));//CAColor_gray);//CAColor_blue);
    label->setFontSize((27));
    label->setText("My Agenda");
    label->setFontName(SAP_FONT_ARIAL);//markerfelt.ttf");
    label->setTouchEnabled(false);
    this->getView()->addSubview(label);
    
    // sub title bar right picture
    CAView *subViewright = CAView::createWithCenter(DRect(m_winSize.width - (100), headerHeight + pageViewHeight +buttonHight + (20), m_winSize.width / 4, (20)));
    CAImageView* subbarView2 = CAImageView::createWithImage(CAImage::create("main/home_bar.png"));
    subbarView2->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
    subbarView2->setFrame(DRect(0, 0, m_winSize.width / 4, (20)));
    subbarView2->setTouchEnabled(false);
    subViewright->addSubview(subbarView2);
    this->getView()->addSubview(subViewright);

    //CAView* headView = CAView::createWithFrame(DRect(0, 0, m_winSize.width, m_winSize.width * 0.6 - (120)));
    //m_msgTableView->setTableHeaderView(headView);
    //m_msgTableView->setTableHeaderHeight(m_winSize.width / 2 + (130));
    
    int tableStartY = pageViewHeight + butViewHeight + headerHeight + buttitleHeight + (15);
    m_msgTableView = CATableView::createWithFrame(DRect(0, tableStartY, m_winSize.width, m_winSize.height - tableStartY));
    if (m_msgTableView) {
        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::CAPullToRefreshTypeFooter);
        if (refreshDiscount) {
            refreshDiscount->setLabelColor(CAColor_black);
            m_msgTableView->setFooterRefreshView(refreshDiscount);
        }
//        CAPullToRefreshView *refreshDiscount1 = CAPullToRefreshView::create(CAPullToRefreshView::CAPullToRefreshTypeHeader);
//        if (refreshDiscount1) {
//            refreshDiscount1->setLabelColor(CAColor_black);
//            m_msgTableView->setHeaderRefreshView(refreshDiscount1);
//        }
    }
    
    if (m_msg->empty())
    {
        requestSessionMsg();
        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(MainViewController::initMsgTableView));
    }
    else
    {
    //    this->initMsgTableView();
    }

}
void DMChartsController::viewDidLoad()
{

    CCRect rect = this->getView()->getBounds();
    rect.size.height = _px(96);

    CAView* navigaView = CAView::createWithFrame(rect, ccc4(87, 154, 244, 255));
    this->getView()->addSubview(navigaView);

    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);
    navigaView->addSubview(button);
    button->addTarget(this, CAControl_selector(DMChartsController::onReturn), CAControlEventTouchUpInSide);

    CASegmentedControl *segmentedControl = CASegmentedControl::createWithFrame(CCRect(0, 0, 10, 10), 3);

    segmentedControl->setTitleAtIndex("总", 0, CAControlStateAll);
    segmentedControl->setTitleAtIndex("月", 1, CAControlStateAll);
    segmentedControl->setTitleAtIndex("周", 2, CAControlStateAll);

    for (int i=0; i<3; i++)
    {
        segmentedControl->setTitleColorAtIndex(ccc4(87, 154, 244, 255), i, CAControlStateSelected);
        segmentedControl->setTitleColorAtIndex(CAColor_white, i, CAControlStateHighlighted);
        segmentedControl->setTitleColorAtIndex(CAColor_white, i, CAControlStateNormal);
    }



    segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal1), 0, CAControlStateNormal);
    segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal1), 0, CAControlStateHighlighted);
    segmentedControl->setBackgroundImageAtIndex(CAImage::create(segSelected1), 0, CAControlStateSelected);

    segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal3), 1, CAControlStateNormal);
    segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal3), 1, CAControlStateHighlighted);
    segmentedControl->setBackgroundImageAtIndex(CAImage::create(segSelected3), 1, CAControlStateSelected);

    segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal2), 2, CAControlStateNormal);
    segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal2), 2, CAControlStateHighlighted);
    segmentedControl->setBackgroundImageAtIndex(CAImage::create(segSelected2), 2, CAControlStateSelected);

    segmentedControl->addTarget(this, CAControl_selector(DMChartsController::onSegmented));
    segmentedControl->setSelectedAtIndex(0);

    float segmentwid = 300;
    CCRect segR = CCRect((this->getView()->getFrame().size.width-_px(segmentwid))/2, _px(15), _px(segmentwid), _px(62));
    segmentedControl->setFrame(segR);
    navigaView->addSubview(segmentedControl);

    this->searchTopItems();

    {
        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.3f);
        m_pLoading->setColor(CAColor_white);
        this->getView()->insertSubview(m_pLoading, CAWindowZoderTop);
        m_pLoading->setTargetOnCancel(this, callfunc_selector(DMChartsController::initWithTableView));
    }
}
Exemple #17
0
void CATabBar::showItems()
{
    do
    {
        CC_BREAK_IF(m_pViews.empty() == false);
        
        unsigned int count = MIN(m_nMaxShowCount, m_pItems.size());
        
        float width = m_obContentSize.width / count;
        float height = m_obContentSize.height;
        m_cItemSize = CCSize(width, height);
        
        for (unsigned int i=0; i<count; i++)
        {
            CAView* view = CAView::createWithFrame(CCRect(i * width, 0, width, height), ccc4(0, 0, 0, 0));
            this->insertSubview(view, 3);
            view->setDisplayRange(false);
            m_pViews.push_back(view);
            
            CAImageView* imageView = NULL;
            CCLabelTTF* title = NULL;
            
            if (m_pItems.at(i)->getImage())
            {
                imageView = CAImageView::createWithImage(m_pItems.at(i)->getImage());
                imageView->setTag(0xffff);
                view->addSubview(imageView);
            }
            
            
            if (m_pItems.at(i)->getTitle().compare("") != 0)
            {
                int fontSize = this->getContentSize().height / 5.0f;
                title = CCLabelTTF::create(m_pItems.at(i)->getTitle().c_str(), "Arial", fontSize);
                title->setTag(0xfffe);
                view->addSubview(title);
            }
            
            
            if (imageView && title == NULL)
            {
                CCSize imageViewSize = imageView->getBounds().size;
                float scaleX = width / imageViewSize.width * 2/3.0f;
                float scaleY = height / imageViewSize.height * 2/3.0f;
                float scale = MIN(scaleX, scaleY);
                scale = MIN(scale, 1.0f);
                imageViewSize = ccpMult(imageViewSize, scale);
                
                CCRect rect;
                rect.origin = view->getBounds().size/2;
                rect.size = imageViewSize;
                
                imageView->setCenter(rect);
    
            }
            else if (title && imageView == NULL)
            {
                int fontSize = this->getContentSize().height / 2.0f;
                title->setFontSize(fontSize);
                
                CCSize titleSize = title->getBounds().size;
                float titleScale = height / titleSize.height * 1/2.0f;
                titleSize = ccpMult(titleSize, titleScale);
                
                CCRect rect;
                rect.origin = view->getBounds().size/2;
                rect.size = titleSize;
                
                title->setCenter(rect);
            }
            else if (title && imageView)
            {

                CCSize imageViewSize = imageView->getBounds().size;
                float scaleX = width / imageViewSize.width * 1/2.0f;
                float scaleY = height / imageViewSize.height * 1/2.0f;
                float scale = MIN(scaleX, scaleY);
                scale = MIN(scale, 1.0f);
                imageViewSize = ccpMult(imageViewSize, scale);
 
                CCRect rect;
                rect.size = imageViewSize;
                rect.origin = view->getBounds().size;
                rect.origin.x *= 1/2.0f;
                rect.origin.y *= 7/20.0f;
                imageView->setCenter(rect);

                CCSize titleSize = title->getBounds().size;
                float titleScale = height / titleSize.height * 3/10;
                titleSize = ccpMult(titleSize, titleScale);
                
                CCRect rect2;
                rect2.size = titleSize;
                rect2.origin = view->getBounds().size;
                rect2.origin.x *= 1/2.0f;
                rect2.origin.y *= 15/20.0f;
                title->setCenter(rect2);
                
            }
        }
    }
    while (0);
}