Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
CAListViewCell* CDListViewTest::listViewCellAtIndex(CAListView *listView, const DSize& cellSize, unsigned int index)
{
    CAListViewCell* cell = (CAListViewCell*)listView->dequeueReusableCellWithIdentifier("ListViewCell");
    if (!cell)
    {
        cell = CAListViewCell::create("ListViewCell");
        CALabel* test = CALabel::createWithLayout(DLayoutFill);
        test->setColor(ccc4(51, 204, 255, 255));
        test->setTextAlignment(CATextAlignmentCenter);
        test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
        test->setFontSize(28);
        test->setTag(100);
        cell->addSubview(test);
    }
    char temptext[10];
    sprintf(temptext, "cell-%d",index);
    CALabel* test = (CALabel*)cell->getSubviewByTag(100);
    test->setText(temptext);
    
    return cell;
}
CAListViewCell* SessionsViewController::listViewCellAtIndex(CAListView *listView, const DSize& cellSize, unsigned int index)
{
    CAListViewCell* cell = NULL;
    if (listView->getTag() == 1)
    {
        DSize _size = cellSize;
        cell = (CAListViewCell*)listView->dequeueReusableCellWithIdentifier("ListViewCell");
        if (!cell)
        {
            cell = CAListViewCell::create("ListViewCell");
            cell->setColor(ccc4(0xEB, 0xEB, 0xEB, 0xff));
            CALabel* test = CALabel::createWithCenter(DRect(_size.width/2,
                                                            _size.height/2,
                                                            _size.width,
                                                            _size.height));
            test->setTextAlignment(CATextAlignmentCenter);
            test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
            test->setFontSize((28));
            test->setTag(100);
            CAScale9ImageView* sView = CAScale9ImageView::createWithImage(CAImage::create("common/gray_bg.png"));
            sView->setFrame(DRect((0), (0), _size.width, _size.height));
            cell->setBackgroundView(sView);
            cell->addSubview(test);
        }
        CALabel* test = (CALabel*)cell->getSubviewByTag(100);
        if (m_timeTblId == index)
            test->setColor(CAColor_white); // ccc4(0x96, 0x96, 0x96, 255)
        else
            test->setColor(SAP_GRAY);
        if (index == 0)
        {
            test->setText("All");
        }
        else
        {
            test->setText(crossapp_format_string("%2d:00", index + 8));
        }
    }
    /*
    else if(listView->getTag() == 2)
    {
        DSize _size = cellSize;
        cell = (CAListViewCell*)listView->dequeueReusableCellWithIdentifier("ListViewCell");
        if (!cell)
        {
            cell = CAListViewCell::create("ListViewCell");
            CAButton* button = CAButton::createWithFrame(DRect((20), (20), (120), (40)), CAButtonTypeCustom);

            CAScale9ImageView* sView = CAScale9ImageView::createWithFrame(DRect((0), (0), (120), (40)));
            sView->setImage(CAImage::create("common/seggreen_bg.png"));
            sView->setTouchEnabled(false);
            button->addSubview(sView);
            //button->setBackgroundViewForState(CAControlStateAll, sView);
            sView = CAScale9ImageView::createWithFrame(DRect((0), (0), (120), (40)));
            sView->setImage(CAImage::create("common/seggreen_bg.png"));
            sView->setColor(ccc4(0x86, 0xBD, 0x45, 0xff));
            button->setBackgroundViewForState(CAControlStateSelected, sView);
            button->setTitleForState(CAControlStateAll, filterItem[index * 2]);
            button->setTitleColorForState(CAControlStateAll, ccc4(0xA0, 0xA0, 0xA0, 0xA0));
            button->setTitleFontSize((20));
            button->setAllowsSelected(true);
            button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
            button->setTag(310 + index * 2);
            //m_listButton[index * 2] = button;
            cell->addSubview(button);
            
            button = CAButton::createWithFrame(DRect((20), (70), (120), (40)), CAButtonTypeCustom);
            sView = CAScale9ImageView::createWithFrame(DRect((0), (0), (120), (40)));
            sView->setImage(CAImage::create("common/seggreen_bg.png"));
            sView->setTouchEnabled(false);
            button->addSubview(sView);
            //button->setBackgroundViewForState(CAControlStateAll, sView);
            //button->addSubview(sView);
            //button->setBackgroundViewForState(CAControlStateAll, sView);
            sView = CAScale9ImageView::createWithFrame(DRect((0), (0), (120), (40)));
            sView->setImage(CAImage::create("common/btn_round.png"));
            sView->setColor(ccc4(0x86, 0xBD, 0x45, 0xff));
            button->setBackgroundViewForState(CAControlStateSelected, sView);
            button->setTitleForState(CAControlStateAll, filterItem[index * 2 + 1]);
            button->setTitleColorForState(CAControlStateAll, CAColor_gray);
            button->setTitleFontSize((20));
            button->setAllowsSelected(true);
            button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
            button->setTag(310 + index * 2 + 1);
            //m_listButton[index * 2 + 1] = button;
            cell->addSubview(button);
            
            //sView = CAScale9ImageView::createWithImage(CAImage::create("common/gray_bg.png"));
            //sView->setFrame(DRect((0), (0), _size.width, _size.height));
            //sView->setColor(CAColor_clear);
            //cell->setAlpha(0);
            //cell->setBackgroundView(sView);
                            
        }
        
    }*/
    return cell;
}