コード例 #1
0
ファイル: CAPageControl.cpp プロジェクト: ancon/CrossApp
void CAPageControl::onEnter()
{
    CAControl::onEnter();
    
    if (m_pIndicators.size() != m_numberOfPages) {
        m_pIndicators.clear();
        
        for (int i=0; i<m_numberOfPages; i++) {
            CAImageView* view;
            if (i == m_currentPage) {
                view = CAImageView::createWithImage(m_pSelectPageImage);
                view->setColor(m_currentPageIndicatorTintColor);
            } else {
                view = CAImageView::createWithImage(m_pPageImage);        
                view->setColor(m_pageIndicatorTintColor);
            }
            
            CCRect rect;
            float width = getFrame().size.width/m_numberOfPages;
            rect.origin.x = i * width + width/2;
            rect.origin.y = getFrame().size.height/2;
            view->setCenterOrigin(rect.origin);
            
            addSubview(view);
            
            m_pIndicators.pushBack(view);
        }
    }
}
コード例 #2
0
ファイル: CAStepper.cpp プロジェクト: 9miao/CrossApp
CAView* CAStepper::getTailorImageAtIndex(int i)
{
    CAImageView* imageView = NULL;
    
    CAScale9ImageView* clipNode = CAScale9ImageView::createWithFrame(m_pBackgroundImageView->getBounds());
    clipNode->setImage(m_pBackgroundImage[CAControlStateHighlighted]);
    
    DSize size = clipNode->getFrame().size;
    CARenderImage* render = CARenderImage::create(size.width, size.height);
    render->printscreenWithView(clipNode);
    
    DRect rect;
    if (m_pCAStepperOrientation==CAStepperOrientationHorizontal) {
        rect.origin = DPoint(i*m_pBackgroundImageView->getBounds().size.width/2,0);
        rect.size   = DSize(m_pBackgroundImageView->getBounds().size.width/2,m_pBackgroundImageView->getBounds().size.height);
    }else{
        rect.origin = DPoint(0,i*m_pBackgroundImageView->getBounds().size.height/2);
        rect.size   = DSize(m_pBackgroundImageView->getBounds().size.width,m_pBackgroundImageView->getBounds().size.height/2);
    }
    
    imageView = CAImageView::createWithImage(render->getImageView()->getImage());
    imageView->setFrame(rect);
    imageView->setImageRect(rect);
    return imageView;
}
コード例 #3
0
ファイル: MenuViewController.cpp プロジェクト: bazhi/CrossApp
CATableViewCell* MenuViewController::tableCellAtIndex(CATableView* table, const DSize& cellSize, unsigned int section, unsigned int row)
{
    DSize _size = cellSize;
    CATableViewCell* cell = table->dequeueReusableCellWithIdentifier("CrossApp");
    if (cell == NULL)
    {
        cell = CATableViewCell::create("CrossApp");
        cell->setBackgroundView(NULL);
        CALabel* test = CALabel::createWithCenter(DRect(_size.width/2+30,
                                                            _size.height/2,
                                                            _size.width,
                                                            _size.height));
        test->setTextAlignment(CATextAlignmentLeft);
        test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
        test->setFontSize(_px(32));
		test->setColor(CAColor_white);
        test->setTag(100);
        cell->addSubview(test);
        
        CAImageView* arrow = CAImageView::createWithCenter(DRect(_size.width-64,_size.height/2,64,64));
        arrow->setTag(101);
        cell->addSubview(arrow);
    }
	CALabel* test = (CALabel*)cell->getSubviewByTag(100);
	test->setText(unicode_to_utf8(menuList[row]));// menuList[row]);
    CAImageView* arrow = (CAImageView*)cell->getSubviewByTag(101);
    arrow->setImage(CAImage::create("source_material/cell_btn_right.png"));

    return cell;
}
コード例 #4
0
void FSBooklibraryCell::setNewsInfo(NewsInfo *newsinfo)
{
    
//    CCLOG("imageSrc = %s",newsinfo->getImageSrc());
    string strImage = "news/"+newsinfo->getImageSrc();
//    
//    
////    tabbar_function/bookRankingList_1.png
////    CAImage* image=CAImage::create(strImage);
//
//    CAImage* image=CAImage::create("tabbar_function/bookRankingList_1.png");
//    
//    itemText->setText(strImage);
    
    //itemText->setText("123123");
    
    //image->autorelease();
//    itemImage->setImage(image);
    
    CAImageView *itemImage = (CAImageView*)this->getSubviewByTag(99);
    CAImage* image=CAImage::create(strImage);
    itemImage->setImage(image);
    CALabel* itemText = (CALabel*)this->getSubviewByTag(99)->getSubviewByTag(100);
    itemText->setText(newsinfo->getNewsTitle());
    
    
}
コード例 #5
0
void CDNewsImageController::showAlert()
{
    p_alertView = CAView::createWithFrame(this->getView()->getBounds());
    this->getView()->addSubview(p_alertView);
    
    CAImageView* bg = CAImageView::createWithFrame(DRect(0,0,winSize.width,winSize.height));
    bg->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
    bg->setImage(CAImage::create("image/HelloWorld.png"));
    
    CAButton* btn5 = CAButton::create(CAButtonTypeSquareRect);
    btn5->setTag(100);
    btn5->setCenter(DRect(winSize.width/2, winSize.height/2, winSize.width, winSize.height));
    btn5->setTitleColorForState(CAControlStateNormal,CAColor_white);
    btn5->setBackgroundViewForState(CAControlStateNormal, bg);
    btn5->setBackgroundViewForState(CAControlStateHighlighted, bg);
    btn5->addTarget(this, CAControl_selector(CDNewsImageController::buttonCallBack), CAControlEventTouchUpInSide);
    p_alertView->addSubview(btn5);
    
    CALabel* test = CALabel::createWithCenter(DRect(winSize.width/2,
                                                        winSize.height-100,
                                                        winSize.width,
                                                        40));
	test->setColor(CAColor_gray);
    test->setTextAlignment(CATextAlignmentCenter);
    test->setVerticalTextAlignmet(CAVerticalTextAlignmentTop);
    test->setFontSize(24);
    test->setText("网络不给力,请点击屏幕重新加载~");
    p_alertView->addSubview(test);
    
}
コード例 #6
0
void FSBooklibraryCell::initWithSize(CADipSize& cellSize)
{
    CADipSize _size = cellSize;
    
    
    
//    itemImage = CAImageView::createWithFrame(CADipRect(0, 0, _size.width, _size.height));
//    itemImage->setTag(99);
//    this->addSubview(itemImage);
    
//    CADipSize itemSize = itemImage->getBounds().size;
//        CALabel*   itemText = CALabel::createWithCenter(CADipRect(_size.width*0.5, _size.height*0.5, 150, 40));
//    itemText->setTag(100);
//    itemText->setFontSize(_px(29));
//    itemText->setTextAlignment(CATextAlignmentCenter);
//    itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
//    itemImage->addSubview(itemText);
    
    
    CAImageView* itemImage = CAImageView::createWithFrame(CADipRect(0, 0, _size.width, _size.height*4/5));
    itemImage->setTag(99);
    this->addSubview(itemImage);
    
    CADipSize itemSize = itemImage->getBounds().size;
    CALabel* itemText = CALabel::createWithCenter(CADipRect(itemSize.width*0.5, itemSize.height+20, 150, 40));
    itemText->setTag(100);
    itemText->setFontSize(_px(29));
    itemText->setTextAlignment(CATextAlignmentCenter);
    itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
    itemImage->addSubview(itemText);
    
   // this->setControlCanSelected(false);
}
コード例 #7
0
/*
void MainViewController::initPageView()
{
}
*/
void MainViewController::showAlert()
{
    if (p_alertView) {
        this->getView()->removeSubview(p_alertView);
        p_alertView = NULL;
    }
    
    p_alertView = CAView::createWithFrame(DRect((0), (120), m_winSize.width, m_winSize.height - (220)));
    this->getView()->addSubview(p_alertView);
    
    CAImageView* bg = CAImageView::createWithFrame(DRect((0), (0), m_winSize.width, m_winSize.height - (220)));
    bg->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
    bg->setImage(CAImage::create("common/bg.png"));
    bg->setTouchEnabled(false);
    
    CAButton* btn5 = CAButton::create(CAButtonTypeSquareRect);
    btn5->setTag(100);
    btn5->setFrame(DRect((0), (0), m_winSize.width, m_winSize.height - (220)));
    btn5->setTitleColorForState(CAControlStateNormal, CAColor_white);
    btn5->setBackgroundViewForState(CAControlStateNormal, bg);
    btn5->setBackgroundViewForState(CAControlStateHighlighted, bg);
    btn5->addTarget(this, CAControl_selector(MainViewController::buttonCallBack), CAControlEventTouchUpInSide);
    p_alertView->addSubview(btn5);
    
    CALabel* test = CALabel::createWithFrame(DRect(0, m_winSize.height - (300), m_winSize.width, (40)));
    test->setColor(CAColor_gray);
    test->setTextAlignment(CATextAlignmentCenter);
    test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
    test->setFontSize((30));
    test->setText("Network cannot connect!");
    p_alertView->addSubview(test);
    
}
コード例 #8
0
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();
    }
}
コード例 #9
0
void SessionsViewController::showAlert()
{
    if (p_alertView) {
        this->getView()->removeSubview(p_alertView);
        p_alertView = NULL;
    }
    
    p_alertView = CAView::createWithFrame(this->getView()->getBounds());
    this->getView()->addSubview(p_alertView);
    
    CAImageView* bg = CAImageView::createWithFrame(DRect(_px(0), _px(120), m_winSize.width, m_winSize.height - _px(120)));
    bg->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
    bg->setImage(CAImage::create("common/bg.png"));
    
    CAButton* btn5 = CAButton::create(CAButtonTypeSquareRect);
    btn5->setTag(100);
    btn5->setFrame(DRect(_px(0), _px(120), m_winSize.width, m_winSize.height - _px(120)));
    btn5->setTitleColorForState(CAControlStateNormal, CAColor_white);
    btn5->setBackGroundViewForState(CAControlStateNormal, bg);
    btn5->setBackGroundViewForState(CAControlStateHighlighted, bg);
    btn5->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
    p_alertView->addSubview(btn5);
    
    CALabel* test = CALabel::createWithCenter(DRect(m_winSize.width / 2, (m_winSize.height - _px(120)) / 2, m_winSize.width, m_winSize.height - _px(120)));
    test->setColor(CAColor_gray);
    test->setTextAlignment(CATextAlignmentCenter);
    test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
    test->setFontSize(_px(24));
    test->setText("Network cannot connected !");
    p_alertView->addSubview(test);

}
コード例 #10
0
CATableViewCell* ExchangeViewController::tableCellAtIndex(CATableView* table, const CCSize& cellSize, unsigned int section, unsigned int row)
{
    
    CCLog("row = %d , section = %d", row, section);
    CADipSize _size = cellSize;
    CATableViewCell* p_Cell = p_TableView->dequeueReusableCellWithIdentifier("2155");
    if (p_Cell == NULL )
    {
        p_Cell = CATableViewCell::create("2155");
        p_Cell->setAllowsSelected(false);
        
        CAView* itemImage = CAView::createWithFrame(CADipRect(0, 0, _size.width, _size.height));
        itemImage->setColor(ccc4(244, 243, 243, 255));
        itemImage->setTag(99);
        p_Cell->addSubview(itemImage);
        
        CADipSize itemSize = itemImage->getBounds().size;
        CALabel* itemText = CALabel::createWithCenter(CADipRect(itemSize.width/2, itemSize.height/3, itemSize.width,40));
        itemText->setTag(100);
        itemText->setFontSize(_px(35));
        itemText->setTextAlignment(CATextAlignmentCenter);
        itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
        p_Cell->addSubview(itemText);
        
        CALabel* itemText2 = CALabel::createWithCenter(CADipRect(itemSize.width/2, itemSize.height/5*4, itemSize.width,40));
        itemText2->setTag(101);
        itemText2->setFontSize(_px(25));
        itemText2->setTextAlignment(CATextAlignmentCenter);
        itemText2->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
        p_Cell->addSubview(itemText2);
        
        CAScale9ImageView* iv = CAScale9ImageView::createWithCenter(CADipRect(itemSize.width-50,itemSize.height/2,50,50));
        iv->setImage(CAImage::create("source_material/cell_btn_right.png"));
        iv->setTag(101);
        p_Cell->addSubview(iv);
        
        CAImageView* icon = CAImageView::createWithCenter(CADipRect(50,itemSize.height/2,64,64));
        icon->setTag(101);
        icon->setScale(0.6f);
        icon->setImage(CAImage::create("source_material/btn_right_blue.png"));
        p_Cell->addSubview(icon);
    }
    
    CALabel * label = (CALabel*)p_Cell->getSubviewByTag(100);
    label->setText( unicode_to_utf8(exChangeMenuTag[row]) );
    label->setColor(CAColor_black);
    
    CALabel* label2 = (CALabel*)p_Cell->getSubviewByTag(101);
    label2->setText(unicode_to_utf8(exChangeMenuTag2[row]));
    label2->setColor(CAColor_gray);
    
    
   
    
    return p_Cell;

}
コード例 #11
0
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));
    }
}
コード例 #12
0
ファイル: CATextView.cpp プロジェクト: boaass/CrossApp
	JNIEXPORT void JNICALL Java_org_CrossApp_lib_CrossAppTextView_onByte(JNIEnv *env, jclass cls, jint key, jbyteArray buf, jint width, jint height)
    {
        unsigned char* data = (unsigned char*)malloc(sizeof(unsigned char) * width * height * 4);
        env->GetByteArrayRegion(buf, 0, width * height * 4, (jbyte *)data);
        CAImage* image = CAImage::createWithRawDataNoCache(data, CAImage::PixelFormat_RGBA8888, width, height);
        CAImageView* imageView = (CAImageView*)(s_map[(int)key]->getSubviewByTextTag("textView"));
        imageView->setImage(image);
        imageView->setVisible(true);
        free(data);
    }
コード例 #13
0
void CAActivityIndicatorView::setStyle(CAActivityIndicatorViewStyle style)
{
    m_style = style;
    
    if (m_style != CAActivityIndicatorViewStyleImage)
    {
        this->removeSubview(m_pImageView);
        CC_SAFE_RELEASE(m_pImageView);
        
        this->removeSubview(m_pBackView);
        CC_SAFE_RELEASE(m_pBackView);
        
        DRect center = getBounds();
        center.origin = center.size/2;
        CAImage* image = NULL;
        
        switch (m_style)
        {
            case CAActivityIndicatorViewStyleGray:
            {
                image = CAImage::create("source_material/loading_black.png");
                center.size = DSize(40, 40);
            }
                break;
            case CAActivityIndicatorViewStyleWhite:
            {
                image = CAImage::create("source_material/loading_write.png");
                center.size = DSize(40, 40);
            }                break;
            case CAActivityIndicatorViewStyleGrayLarge:
            {
                image = CAImage::create("source_material/loading_black.png");
                center.size = DSize(68, 68);
            }
                break;
            case CAActivityIndicatorViewStyleWhiteLarge:
            {
                image = CAImage::create("source_material/loading_write.png");
                center.size = DSize(68, 68);
            }
                break;
            
            default:
                break;
        }
        setTimesOneCycle(m_nTimesOneCycle);
        
        
        CAImageView* imageView = CAImageView::createWithCenter(center);
        imageView->retain();
        imageView->setImage(image);
        this->insertSubview(imageView, 1);
        m_pImageView = imageView;
    }
}
コード例 #14
0
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);
}
コード例 #15
0
ファイル: CAImageView.cpp プロジェクト: WoYang/CrossApp
CAImageView* CAImageView::createWithLayout(const CrossApp::DLayout &layout)
{
    CAImageView * pRet = new CAImageView();
    if (pRet && pRet->initWithLayout(layout))
    {
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
    return NULL;
}
コード例 #16
0
ファイル: CAImageView.cpp プロジェクト: WoYang/CrossApp
CAImageView* CAImageView::createWithCenter(const DRect& rect)
{
	CAImageView * pRet = new CAImageView();
    if (pRet && pRet->initWithCenter(rect))
    {
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
	return NULL;
}
コード例 #17
0
ファイル: CCSprite.cpp プロジェクト: anarki1234/9miao
CAImageView* CAImageView::createWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
{
    CAImageView *pobSprite = new CAImageView();
    if (pSpriteFrame && pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame))
    {
        pobSprite->autorelease();
        return pobSprite;
    }
    CC_SAFE_DELETE(pobSprite);
    return NULL;
}
コード例 #18
0
ファイル: CAImageView.cpp プロジェクト: domzhaosh/CrossApp
CAImageView* CAImageView::create()
{
    CAImageView *pSprite = new CAImageView();
    if (pSprite && pSprite->init())
    {
        pSprite->autorelease();
        return pSprite;
    }
    CC_SAFE_DELETE(pSprite);
    return NULL;
}
コード例 #19
0
ファイル: CCSprite.cpp プロジェクト: anarki1234/9miao
CAImageView* CAImageView::createWithImage(CAImage* Image, const CCRect& rect)
{
    CAImageView *pobSprite = new CAImageView();
    if (pobSprite && pobSprite->initWithImage(Image, rect))
    {
        pobSprite->autorelease();
        return pobSprite;
    }
    CC_SAFE_DELETE(pobSprite);
    return NULL;
}
コード例 #20
0
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);
    }
}
コード例 #21
0
ファイル: CAImageView.cpp プロジェクト: domzhaosh/CrossApp
CAImageView* CAImageView::createWithFrame(const CCRect& rect)
{
	CAImageView * pRet = new CAImageView();
    if (pRet && pRet->init())
    {
        pRet->setFrame(rect);
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
	return NULL;
}
コード例 #22
0
void FSBookReadTimesCell::initWithCell()
{
    
    CADipSize _size = this->getBounds().size;
//    CAView *view = CAView::createWithFrame(this->getBounds());
//    view->setTag(99);
//    this->addSubview(view);
    
    CAImageView* itemImage = CAImageView::createWithFrame(CADipRect(LEFTSPACE, TOPSPACE, (_size.height-TOPSPACE-BOTTOMSPACE)*3/4, _size.height-TOPSPACE-BOTTOMSPACE));
    itemImage->setTag(99);
    this->addSubview(itemImage);
    
//    CADipSize itemSize = itemImage->getBounds().size;
//    CALabel* itemText = CALabel::createWithCenter(CADipRect(itemSize.width*0.5, itemSize.height+20, 150, 40));
//    itemText->setTag(100);
//    itemText->setFontSize(_px(29));
//    itemText->setTextAlignment(CATextAlignmentCenter);
//    itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
//    itemImage->addSubview(itemText);
    
    
    CALabel *textTitle = CALabel::createWithFrame(CADipRect(itemImage->getFrame().size.width+LEFTSPACE*2, TOPSPACE, _size.width-itemImage->getFrame().size.width-LEFTSPACE*2, (_size.height-TOPSPACE-BOTTOMSPACE)/2));
    
    textTitle->setTag(100);
        textTitle->setFontSize(_px(29));
        textTitle->setTextAlignment(CATextAlignmentLeft);
        textTitle->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
//        textTitle->setColor(ccc4(100,100,100,1));
    this->addSubview(textTitle);
    
    
    CALabel *authorTitle = CALabel::createWithFrame(CADipRect(itemImage->getFrame().size.width+LEFTSPACE*2, TOPSPACE+(_size.height-TOPSPACE-BOTTOMSPACE)/2, _size.width-itemImage->getFrame().size.width-LEFTSPACE-LEFTSPACE, (_size.height-TOPSPACE-BOTTOMSPACE)/2));
    authorTitle->setTag(101);
    authorTitle->setFontSize(_px(29));
    authorTitle->setTextAlignment(CATextAlignmentLeft);
    authorTitle->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
    this->addSubview(authorTitle);
    
//    CADipSize m_size = this->getFrame().size;
//    CALabel* cellText = CALabel::createWithCenter(CADipRect(m_size.width*0.1, m_size.height*0.5, m_size.width*0.3, m_size.height*0.8));
//    cellText->setTag(100);
//    cellText->setFontSize(_px(30));
//    cellText->setTextAlignment(CATextAlignmentCenter);
//    cellText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
//    this->addSubview(cellText);
    
//    CAButton* btnOnCell = CAButton::createWithCenter(CADipRect(m_size.width*0.85, m_size.height*0.5, m_size.width*0.2, m_size.height*0.7), CAButtonTypeRoundedRect);
//    btnOnCell->setTag(102);
//    btnOnCell->setTitleForState(CAControlStateAll, "Touch");
//    btnOnCell->addTarget(this, CAControl_selector(FSBookReadTimesCell::cellBtnCallback), CAControlEventTouchUpInSide);
//    this->addSubview(btnOnCell);
}
コード例 #23
0
void FirstViewController::viewDidLoad()
{
    // Do any additional setup after loading the view from its nib.
    
    CAImageView* imageView = CAImageView::createWithImage(CAImage::create("9m.jpg"));
    imageView->setFrame(CCRect(200, 300, 330, 214));
    this->getView()->addSubview(imageView);
    
    CCLabelTTF* ttf = CCLabelTTF::create("Hello World!", "Arial", 50);
    ttf->setColor(ccBLACK);
    ttf->setFrame(CCRect(200, 450, 0, 0));
    this->getView()->addSubview(ttf);
}
コード例 #24
0
ファイル: CAImageView.cpp プロジェクト: domzhaosh/CrossApp
NS_CC_BEGIN

CAImageView* CAImageView::createWithImage(CAImage* image)
{
    CAImageView *pobSprite = new CAImageView();
    if (pobSprite && pobSprite->initWithImage(image))
    {
        pobSprite->autorelease();
        return pobSprite;
    }
    CC_SAFE_DELETE(pobSprite);
    return NULL;
}
コード例 #25
0
ファイル: CATextField.cpp プロジェクト: boaass/CrossApp
void CATextField::setMarginImageRight(const DSize& imgSize, const std::string& filePath)
{
	setMarginRight(imgSize.width);

	CAImageView* ima = (CAImageView*)this->getSubviewByTag(1011);
	if (!ima)
	{
		ima = CAImageView::create();
		ima->setTag(1011);
		this->addSubview(ima);
	}
	ima->setCenter(DRect(getBounds().size.width - imgSize.width / 2, getBounds().size.height / 2, imgSize.width, imgSize.height));
	ima->setImage(CAImage::create(filePath));
}
コード例 #26
0
void FSBookReadTimesCell::updateNewsInfoForCell(NewsInfo *newsinfo)
{
    
    //    CCLOG("imageSrc = %s",newsinfo->getImageSrc());
    string strImage = "news/"+newsinfo->getImageSrc();
    //
    CAImageView *itemImage = (CAImageView*)this->getSubviewByTag(99);
    CAImage* image=CAImage::create(strImage);
    itemImage->setImage(image);
    CALabel* itemText = (CALabel*)this->getSubviewByTag(100);
    itemText->setText(newsinfo->getNewsTitle());
    CALabel* authorTitle = (CALabel*)this->getSubviewByTag(101);
    authorTitle->setText(newsinfo->getAuthor());
    
}
コード例 #27
0
ファイル: CAPageControl.cpp プロジェクト: ancon/CrossApp
void CAPageControl::updateCurrentPageDisplay()
{
    for (int i=0; i<m_numberOfPages; i++) {
        CAImageView* view = m_pIndicators.at(i);
        if (i == m_currentPage) {
            view->setImage(m_pSelectPageImage);
            view->setColor(m_currentPageIndicatorTintColor);
        } else {
            view->setImage(m_pPageImage);
            view->setColor(m_pageIndicatorTintColor);
        }
    }
    
    updateDraw();
}
コード例 #28
0
void ViewController::viewDidLoad()
{

    CAScrollView* scroll = new CAScrollView();
    scroll->initWithFrame(this->getView()->getBounds());
    this->getView()->addSubview(scroll);
    scroll->setViewSize(scroll->getBounds().size * 2);
    scroll->setMaximumZoomScale(3.0f);
    scroll->setMinimumZoomScale(0.5f);
    scroll->setBouncesZoom(false);
    
    CAImageView* v = CAImageView::createWithImage(CAImage::create("1.jpg"));
    v->setFrame(CCRect(0, 0, scroll->getViewSize().width, scroll->getViewSize().height));
    scroll->addSubview(v);
    
    
    ccColor3B color = ccRED;
    if (this->getTitle().compare("view1") == 0)
    {
        color = ccBLACK;
    }
    else if (this->getTitle().compare("view2") == 0)
    {
        scroll->setMaximumZoomScale(1.0f);
        scroll->setMinimumZoomScale(1.0f);
        scroll->setBounces(false);
    }
    else if (this->getTitle().compare("view3") == 0)
    {
        color = ccYELLOW;
    }
    else if (this->getTitle().compare("view4") == 0)
    {
        color = ccGRAY;
        
        scroll->setBounceHorizontal(false);
        
        
    }
    else if (this->getTitle().compare("view5") == 0)
    {
        color = ccRED;
        
        scroll->setBounces(false);
    }

    this->getView()->setColor(color);
}
コード例 #29
0
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);
}
コード例 #30
0
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);
}