CAView* HeroInfoController::loadTabBarView(){ CAVector<CATabBarItem*> items; if (m_pTabBar == NULL){ CATabBarItem* tabBarItem1 = CATabBarItem::create(UTF8("英雄综合"), NULL, NULL); CATabBarItem* tabBarItem2 = CATabBarItem::create(UTF8("技能加点"), NULL, NULL); CATabBarItem* tabBarItem3 = CATabBarItem::create(UTF8("物品出装"), NULL, NULL); CATabBarItem* tabBarItem4 = CATabBarItem::create(UTF8("克制关系"), NULL, NULL); items.pushBack(tabBarItem1); items.pushBack(tabBarItem2); items.pushBack(tabBarItem3); items.pushBack(tabBarItem4); } m_pTabBar = CATabBar::create(items, CCSize(640, 30)); m_pTabBar->setTitleColorForNormal(CAColor_gray); m_pTabBar->setTitleColorForSelected(CAColor_white); m_pTabBar->setSelectedAtIndex(0); m_pTabBar->setBackGroundColor(CAColor_black); m_pTabBar->setSelectedBackGroundColor(CAColor_black); m_pTabBar->setSelectedIndicatorImage(CAImage::create("image/Indicator.png")); m_pTabBar->showSelectedIndicator(); m_pTabBar->setDelegate(this); m_pTabBar->setCenterOrigin(CCPoint(320, _size.height / 4 - _px(15))); this->getView()->insertSubview(m_pTabBar, 2); return m_pTabBar; }
void HeroInfoController::loadTableView(){ CCRect tableViewRect = this->getView()->getBounds(); tableViewRect.origin.y = tableViewRect.size.height / 4; tableViewRect.size.height = tableViewRect.size.height / 4 * 3; m_pPageView = CAPageView::createWithFrame(tableViewRect, CAPageViewDirection::CAPageViewDirectionHorizontal); m_pPageView->setPageViewDelegate(this); //m_pPageView->setZoomScale(0.2); this->getView()->addSubview(m_pPageView); m_pTableView1 = CATableView::createWithFrame(tableViewRect); m_pTableView1->setTableViewDelegate(this); m_pTableView1->setTableViewDataSource(this); m_pTableView1->setTableHeaderView(CAView::createWithColor(CAColor_red)); m_pTableView1->setTableHeaderHeight(_px(20)); m_pTableView1->setZoomScale(1); m_pTableView1->setBackGroundColor(COLOR_GRAY); m_pTableView1->setSeparatorColor(COLOR_GRAY1); m_pTableView1->setAlwaysTopSectionHeader(false); tableViewRect.origin.x += tableViewRect.size.width; m_pTableView2 = CATableView::createWithFrame(tableViewRect); m_pTableView2->setTableViewDelegate(this); m_pTableView2->setTableViewDataSource(this); m_pTableView2->setBackGroundColor(COLOR_GRAY); m_pTableView2->setSeparatorColor(COLOR_GRAY1); m_pTableView2->setAlwaysTopSectionHeader(false); tableViewRect.origin.x += tableViewRect.size.width; m_pTableView3 = CATableView::createWithFrame(tableViewRect); m_pTableView3->setTableViewDelegate(this); m_pTableView3->setTableViewDataSource(this); m_pTableView3->setBackGroundColor(COLOR_GRAY); m_pTableView3->setSeparatorColor(COLOR_GRAY1); m_pTableView3->setAlwaysTopSectionHeader(false); tableViewRect.origin.x += tableViewRect.size.width; m_pTableView4 = CATableView::createWithFrame(tableViewRect); m_pTableView4->setTableViewDelegate(this); m_pTableView4->setTableViewDataSource(this); m_pTableView4->setBackGroundColor(COLOR_GRAY); m_pTableView4->setSeparatorColor(COLOR_GRAY1); m_pTableView4->setAlwaysTopSectionHeader(false); //把CAView中的tableView设置到view中 CAVector<CAView*> views; views.pushBack(m_pTableView1); views.pushBack(m_pTableView2); views.pushBack(m_pTableView3); views.pushBack(m_pTableView4); m_pPageView->setViews(views); }
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 MainViewController::initPageView() { int pageViewHeight = m_winSize.height * 0.3; int headerHeight = (120); // Page view if (m_pageView == NULL) { m_pageView = CAPageView::createWithFrame(DRect(0, headerHeight, m_winSize.width, pageViewHeight), CAPageViewDirectionHorizontal); m_pageView->setPageViewDelegate(this); m_pageView->setTouchEnabled(true); m_pageView->setSpacing(0); this->getView()->addSubview(m_pageView); } if (m_pageView) { 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(true); temImage->setTag(500 + i); viewList.pushBack(temImage); } m_pageView->setViews(viewList); m_pageView->setCurrPage(0, false); } // picture dots bg in page view if (m_pageControlBG == NULL) { 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); } // picture dots if (m_pageControl != NULL) { this->getView()->removeSubview(m_pageControl); m_pageControl = NULL; } m_pageControl = CAPageControl::createWithCenter(DRect(m_winSize.width / 2, pageViewHeight + headerHeight - (25), (200), (50))); m_pageControl->setTag(200); m_pageControl->setTouchEnabled(false); m_pageControl->addTarget(this, CAControl_selector(MainViewController::buttonCallBack)); m_pageControl->setNumberOfPages((int)m_page.size()); this->getView()->addSubview(m_pageControl); // to : animate the page view CAScheduler::schedule(schedule_selector(MainViewController::updatePageView), this, 5);//, true, 3000); }
CAVector CToolCervicales::SegmentationGlob(CDib * m_Dib, CRxDoc * i_Document, CList<CPoint, CPoint&>& i_List) { CList<CPoint, CPoint&> Result; Result.AddTail(i_List.GetHead()); Segmentation(m_Dib, i_Document, i_List.GetHeadPosition(), i_List.GetTailPosition(), i_List, 0, Result); Result.AddTail(i_List.GetTail()); CAVector Vector; CPoint l_Point; POSITION c_Pos = Result.GetHeadPosition(); while (c_Pos != NULL) { l_Point = Result.GetNext(c_Pos); Vector.Add(CPoint(l_Point.x, m_Dib->GetHeight()-l_Point.y)); } /* replace very close points by an intermediate value */ for (int i=2;i<(int)((double)(m_Dib->GetWidth() + m_Dib->GetHeight())/2 * 0.03);i++) RemoveClosePoints(Vector, i); /* remove pattern points */ RemovePatternPoints(Vector); //i_Document->Add(Vector); return Vector; }
void CDNewsImageController::scrollViewStopMoved(CrossApp::CAScrollView *view) { CAVector<CATableViewCell*> temVec = p_TableView->displayingTableCell(); for(int i=0;i<temVec.size();i++) { CDNewsImageTableCell* cell = (CDNewsImageTableCell*)temVec.at(i); CCLog("cell-index===%d",cell->getRow()); int row = cell->getRow(); int img_num = m_ImageNum[row]; for (int i=0; i<img_num; i++) { CommonUrlImageView* temImage = dynamic_cast<CommonUrlImageView*>(cell->getSubviewByTag(200 + i)); if (temImage) { temImage->setUrl(m_ImageMsg[row].m_imageUrl[1 + i]); } } } }
void CToolCervicales::RemovePatternPoints(CAVector& Vector){ BOOL Removed; for (int k=Vector.GetSize()-1;k>=0;k--) { // for each existing point do Removed = FALSE; if (Vector.GetSize() <= 4) break; for (int m=0;m<Vector.GetSize();m++) { for (int l=k+1;l<Vector.GetSize();l++){ if (Vector.GetSize() <= 4) break; if ((k!=m)&&(k!=l)) { if ((Vector[k].x >= Vector[m].x)&&(Vector[k].y >= Vector[m].y)&& (Vector[k].x <= Vector[l].x)&&(Vector[k].y <= Vector[l].y)) { Vector.Remove(k); Removed = TRUE; break; } if ((Vector[k].x <= Vector[m].x)&&(Vector[k].y <= Vector[m].y)&& (Vector[k].x >= Vector[l].x)&&(Vector[k].y >= Vector[l].y)) { Vector.Remove(k); Removed = TRUE; break; } if ((Vector[k].x >= Vector[m].x)&&(Vector[k].y <= Vector[m].y)&& (Vector[k].x <= Vector[l].x)&&(Vector[k].y >= Vector[l].y)) { Vector.Remove(k); Removed = TRUE; break; } if ((Vector[k].x <= Vector[m].x)&&(Vector[k].y >= Vector[m].y)&& (Vector[k].x >= Vector[l].x)&&(Vector[k].y <= Vector[l].y)) { Vector.Remove(k); Removed = TRUE; break; } } } if (Removed) break; } } }
void CToolCervicales::RemoveClosePoints(CAVector& Vector, int Tol) { CAVector Hector; for (int j=0;j<Vector.GetSize();j++) { if (Vector.GetSize() <= 4) return; BOOL m_Add = TRUE; for (int k=0;k<Hector.GetSize();k++) { if (CAVector::Distance(Vector[j], Hector[k]) < Tol) { Hector.Add(CPoint((Vector[j].x + Hector[k].x) / 2, (Vector[j].y + Hector[k].y) / 2)); Hector.Remove(k); m_Add = FALSE; break; } } if (m_Add) Hector.Add(Vector[j]); if (Vector.GetSize() <= 4) break; } Vector = Hector; }
bool CATabBarController::initWithViewControllers(const CAVector<CAViewController*>& viewControllers, CABarVerticalAlignment var) { CAViewController::init(); do { CC_BREAK_IF(viewControllers.size() == 0); m_pViewControllers = viewControllers; std::vector<CATabBarItem*> items; for (unsigned int i=0; i<m_pViewControllers.size(); i++) { CAViewController* view = m_pViewControllers.at(i); if (view->getTabBarItem() == NULL) { char title[8]; sprintf(title, "item%d", i); CATabBarItem* item = CATabBarItem::create(title, NULL); item->setTag(i); view->setTabBarItem(item); } items.push_back(view->getTabBarItem()); view->m_pTabBarController = this; } m_pTabBar = CATabBar::create(items); m_pTabBar->retain(); m_pTabBar->setDelegate(this); } while (0); m_eTabBarVerticalAlignment = var; return true; }
void CATabBarController::viewDidLoad() { std::vector<CATabBarItem*> items; for (unsigned int i=0; i<m_pViewControllers.size(); i++) { CAViewController* view = m_pViewControllers.at(i); if (view->getTabBarItem() == NULL) { char title[8]; sprintf(title, "item%d", i); CATabBarItem* item = CATabBarItem::create(title, NULL); item->setTag(i); view->setTabBarItem(item); } items.push_back(view->getTabBarItem()); view->m_pTabBarController = this; } m_pTabBar = CATabBar::create(items, DSize(this->getView()->getBounds().size.width, 0), m_eTabBarVerticalAlignment); this->getView()->addSubview(m_pTabBar); m_pTabBar->setDelegate(this); DRect container_rect = this->getView()->getBounds(); DPoint tab_bar_rectOrgin = DPointZero; if (m_bTabBarHidden) { tab_bar_rectOrgin = this->getTabBarTakeBackPoint(); } else { tab_bar_rectOrgin = this->getTabBarOpenPoint(); container_rect.size.height -= m_pTabBar->getFrame().size.height; if (m_eTabBarVerticalAlignment == CABarVerticalAlignmentTop) { container_rect.origin.y = m_pTabBar->getFrame().size.height; } } DSize container_view_size = container_rect.size; container_view_size.width *= m_pViewControllers.size(); m_pContainer = CAPageView::createWithFrame(container_rect, CAPageViewDirectionHorizontal); m_pContainer->setBackgroundColor(CAColor_clear); m_pContainer->setPageViewDelegate(this); m_pContainer->setScrollViewDelegate(this); m_pContainer->setScrollEnabled(m_bScrollEnabled); m_pContainer->setDisplayRange(true); this->getView()->addSubview(m_pContainer); CAVector<CAView*> views; for (int i=0; i<m_pViewControllers.size(); i++) { CAView* view = new CAView(); views.pushBack(view); view->release(); } m_pContainer->setViews(views); if (m_pTabBarBackgroundImage) { m_pTabBar->setBackgroundImage(m_pTabBarBackgroundImage); } else { m_pTabBar->setBackgroundColor(m_sTabBarBackgroundColor); } if (m_pTabBarSelectedBackgroundImage) { m_pTabBar->setSelectedBackgroundImage(m_pTabBarSelectedBackgroundImage); } else { m_pTabBar->setSelectedBackgroundColor(m_sTabBarSelectedBackgroundColor); } if (m_pTabBarSelectedIndicatorImage) { m_pTabBar->setSelectedIndicatorImage(m_pTabBarSelectedIndicatorImage); } else { m_pTabBar->setSelectedIndicatorColor(m_sTabBarSelectedIndicatorColor); } m_pTabBar->setTitleColorForNormal(m_sTabBarTitleColor); m_pTabBar->setTitleColorForSelected(m_sTabBarSelectedTitleColor); if (m_bShowTabBarSelectedIndicator) { m_pTabBar->showSelectedIndicator(); } m_pTabBar->setFrameOrigin(tab_bar_rectOrgin); m_pTabBar->setSelectedAtIndex(m_nSelectedIndex); this->renderingSelectedViewController(); }
bool RootWindow::init() { if (!CAWindow::init()) { return false; } CAApplication::getApplication()->setNotificationView(CAView::createWithFrame(this->getBounds(), CAColor_green)); CAVector<CAViewController*> controllerVec; m_home = new MainViewController(); if (m_home) { m_home->setTabBarItem(CATabBarItem::create(unicode_to_utf8(mainBar[0]), CAImage::create("main/bar_0.png"),CAImage::create("main/bar_pre_0.png"))); m_home->init(); m_home->autorelease(); controllerVec.pushBack(m_home); } m_session = new SessionsViewController(); if (m_session) { m_session->init(); m_session->autorelease(); m_session->setTabBarItem(CATabBarItem::create(unicode_to_utf8(mainBar[1]), CAImage::create("main/bar_1.png"),CAImage::create("main/bar_pre_1.png"))); controllerVec.pushBack(m_session); } m_my = new MyStatusViewController(); if (m_my) { m_my->setTabBarItem(CATabBarItem::create(unicode_to_utf8(mainBar[2]), CAImage::create("main/bar_2.png"),CAImage::create("main/bar_pre_2.png"))); m_my->init(); m_my->autorelease(); controllerVec.pushBack(m_my); } CATabBarController* tabBarController = new CATabBarController(); tabBarController->initWithViewControllers(controllerVec); tabBarController->setTabBarSelectedBackgroundColor(CAColor_clear); tabBarController->setTabBarTitleColorForSelected(CAColor_white); tabBarController->setTabBarBackgroundImage(CAImage::create("common/sky_bg.png")); /* CANavigationBarItem* temp_nav = CANavigationBarItem::create(""); temp_nav->setNagigationBarHidden(true); tabBarController->setScrollEnabled(false); tabBarController->setNavigationBarItem(temp_nav); tabBarController->setTabBarTitleColorForSelected(CAColor_white); tabBarController->autorelease(); */ m_pRootNavigationController = new CANavigationController(); m_pRootNavigationController->initWithRootViewController(tabBarController); m_pRootNavigationController->setNavigationBarBackgroundImage(CAImage::create("common/sky_bg.png")); m_pRootNavigationController->setNavigationBarHidden(true, false); m_pRootNavigationController->setScrollEnabled(false); FUser user = FUserManager::sharedFUserManager()->onLineUser(); if (user.loginname.length() == 0) { LoginViewController* _viewController = new LoginViewController(); _viewController->init(); this->setRootViewController(_viewController); _viewController->release(); } else { FDataManager::getInstance()->setUserId(user.uid); this->setRootViewController(m_pRootNavigationController); } CAApplication::getApplication()->setNotificationView(NULL); return true; }
void CABatchView::updateAtlasIndex(CAView* view, int* curIndex) { const CAVector<CAView*> pVector = view->getSubviews(); unsigned int count = (unsigned int)pVector.size(); int oldIndex = 0; if( count == 0 ) { oldIndex = view->getAtlasIndex(); view->setAtlasIndex(*curIndex); view->setOrderOfArrival(0); if (oldIndex != *curIndex) { swap(oldIndex, *curIndex); } (*curIndex)++; } else { bool needNewIndex = true; if (pVector.front()->getZOrder() >= 0) { oldIndex = view->getAtlasIndex(); view->setAtlasIndex(*curIndex); view->setOrderOfArrival(0); if (oldIndex != *curIndex) { swap(oldIndex, *curIndex); } (*curIndex)++; needNewIndex = false; } CAVector<CAView*>::const_iterator itr; for (itr=pVector.begin(); itr!=pVector.end(); itr++) { CAView* subview = *itr; if (needNewIndex && subview->getZOrder() >= 0) { oldIndex = view->getAtlasIndex(); view->setAtlasIndex(*curIndex); view->setOrderOfArrival(0); if (oldIndex != *curIndex) { this->swap(oldIndex, *curIndex); } (*curIndex)++; needNewIndex = false; } updateAtlasIndex(subview, curIndex); } if (needNewIndex) { oldIndex = view->getAtlasIndex(); view->setAtlasIndex(*curIndex); view->setOrderOfArrival(0); if (oldIndex!=*curIndex) { swap(oldIndex, *curIndex); } (*curIndex)++; } } }
void CDShowNewsImage::initNewsImageView(newsImage _image) { m_image = _image; CAVector<CAView* > viewList; for (int i=0; i<m_image.m_imageUrl.size(); i++) { //初始化viewList CommonUrlImageView* temImage = CommonUrlImageView::createWithFrame(DRect(0,0,winSize.width,winSize.height)); temImage->setImageViewScaleType(CAImageViewScaleTypeFitImageInside); temImage->setImage(CAImage::create("HelloWorld.png")); temImage->setUrl(m_image.m_imageUrl[i]); CAScrollView* p_ScrollView = CAScrollView::createWithFrame(DRect(0,0,winSize.width,winSize.height)); p_ScrollView->setMinimumZoomScale(1.0f); p_ScrollView->setMaximumZoomScale(2.5f); p_ScrollView->setMultitouchGesture(CAScrollView::MultitouchGesture::Zoom); p_ScrollView->setBackgroundColor(CAColor_clear); p_ScrollView->setShowsScrollIndicators(false); p_ScrollView->setBounceVertical(false); p_ScrollView->setScrollViewDelegate(this); p_ScrollView->addSubview(temImage); viewList.pushBack(p_ScrollView); } p_PageView = CAPageView::createWithFrame(DRect(0, 30, winSize.width, winSize.height), CAPageViewDirectionHorizontal); p_PageView->setViews(viewList); p_PageView->setPageViewDelegate(this); p_PageView->setBackgroundColor(CAColor_black); p_PageView->setPageViewDelegate(this); this->getView()->addSubview(p_PageView); p_bg = CAView::createWithColor(ccc4(0,0,0,200)); p_bg->setFrame(DRect(0,winSize.height/3*2,winSize.width,winSize.height/2)); this->getView()->addSubview(p_bg); p_title = CALabel::createWithFrame(DRect(10,10,winSize.width-80,40)); p_title->setText(m_image.m_title); p_title->setColor(CAColor_white); p_title->setFontSize(34); p_title->setBold(true); p_bg->addSubview(p_title); char temp[10]; sprintf(temp, "1/%lu",m_image.m_imageUrl.size()); p_index = CALabel::createWithFrame(DRect(winSize.width-60,10,80,30)); p_index->setText(temp); p_index->setColor(CAColor_white); p_index->setFontSize(30); p_index->setBold(true); p_bg->addSubview(p_index); p_des = CALabel::createWithFrame(DRect(10,0,winSize.width-20,200)); p_des->setText(m_image.m_imageDesc[4]); p_des->setColor(ccc4(200, 200, 200, 255)); p_des->setFontSize(26); CAScrollView* ps = CAScrollView::createWithFrame(DRect(0,70,winSize.width,200)); ps->setBackgroundColor(CAColor_clear); ps->setShowsVerticalScrollIndicator(false); ps->setShowsHorizontalScrollIndicator(false); ps->setBounceHorizontal(false); ps->addSubview(p_des); p_bg->addSubview(ps); }
void CATabBar::setItems(const CAVector<CATabBarItem*>& items) { CC_RETURN_IF(items.empty()); m_pItems = items; }
void CATabBarController::viewDidLoad() { CCPoint tab_bar_rectOrgin = CCPointZero; CCRect container_rect = this->getView()->getBounds(); CCSize container_view_size = container_rect.size; container_view_size.width *= m_pViewControllers.size(); if (m_bTabBarHidden) { tab_bar_rectOrgin = this->getTabBarTakeBackPoint(); } else { tab_bar_rectOrgin = this->getTabBarOpenPoint(); container_rect.size.height -= m_pTabBar->getFrame().size.height; if (m_eTabBarVerticalAlignment == CABarVerticalAlignmentTop) { container_rect.origin.y = m_pTabBar->getFrame().size.height; } } m_pContainer = CAPageView::createWithFrame(container_rect, CAPageView::CAPageViewDirectionHorizontal); m_pContainer->setBackGroundColor(CAColor_clear); m_pContainer->setPageViewDelegate(this); m_pContainer->setScrollViewDelegate(this); m_pContainer->setScrollEnabled(m_bscrollEnabled); m_pContainer->setDisplayRange(true); this->getView()->addSubview(m_pContainer); CAVector<CAView*> views; for (int i=0; i<m_pViewControllers.size(); i++) { CAView* view = new CAView(); views.pushBack(view); view->release(); } m_pContainer->setViews(views); if (m_pTabBarBackGroundImage) { m_pTabBar->setBackGroundImage(m_pTabBarBackGroundImage); } else { m_pTabBar->setBackGroundColor(m_sTabBarBackGroundColor); } if (m_pTabBarSelectedBackGroundImage) { m_pTabBar->setSelectedBackGroundImage(m_pTabBarSelectedBackGroundImage); } else { m_pTabBar->setSelectedBackGroundColor(m_sTabBarSelectedBackGroundColor); } if (m_pTabBarSelectedIndicatorImage) { m_pTabBar->setSelectedIndicatorImage(m_pTabBarSelectedIndicatorImage); } else { m_pTabBar->setSelectedIndicatorColor(m_sTabBarSelectedBackGroundColor); } m_pTabBar->setTitleColorForNormal(m_sTabBarTitleColor); m_pTabBar->setTitleColorForSelected(m_sTabBarSelectedTitleColor); if (m_bShowTabBarSelectedIndicator) { m_pTabBar->showSelectedIndicator(); } m_pTabBar->setFrameOrigin(tab_bar_rectOrgin); this->getView()->addSubview(m_pTabBar); m_pTabBar->setSelectedAtIndex(m_nSelectedIndex); this->renderingSelectedViewController(); }
void CToolCervicales::TraceContour(CDib * m_Dib, CRxDoc * i_Document) { theApp.ShowProgress("Tracing contour, please be patient."); CList<CPoint, CPoint&> c_List; CList<CPoint, CPoint&> total_List; CList<CPoint, CPoint&> full_List[VERTEBRE_COUNT]; int full_ListCount = 0; /* locate any first black pixel */ CSize m_DibSize = m_Dib->GetDimensions(); CPoint l_Point; POSITION c_Pos; int x, y; for (x=0;x<m_DibSize.cx;x++) { theApp.SetProgress(x * 100 / m_DibSize.cx); for (y=0;y<m_DibSize.cy;y++) { if (m_Dib->GetPixel(x, y) == 0) { l_Point = CPoint(x,y); if (FindInList(total_List, l_Point) == -1) { c_List.RemoveAll(); AddNeighbors(m_Dib, c_List, l_Point, 6); // copy to full list c_Pos = c_List.GetHeadPosition(); while (c_Pos != NULL) total_List.AddTail(c_List.GetNext(c_Pos)); // find the smallest list int f_Min = full_ListCount; if (full_ListCount == VERTEBRE_COUNT) { f_Min = 0; //double f_Distance=0; for (int l=0;l<full_List[f_Min].GetCount()-1;l++) f_Distance+=CAVector::Distance(full_List[f_Min].GetAt(full_List[f_Min].FindIndex(l)), full_List[f_Min].GetAt(full_List[f_Min].FindIndex(l+1))); for (int i=1;i<VERTEBRE_COUNT;i++) { //double i_Distance=0; //for (int l=0;l<full_List[i].GetCount()-1;l++) i_Distance+=CAVector::Distance(full_List[i].GetAt(full_List[i].FindIndex(l)), full_List[i].GetAt(full_List[i].FindIndex(l+1))); if (full_List[i].GetCount() < full_List[f_Min].GetCount()) //if (i_Distance < f_Distance) f_Min = i; } } else full_ListCount++; // copy to array of lists full_List[f_Min].RemoveAll(); c_Pos = c_List.GetHeadPosition(); while (c_Pos != NULL) full_List[f_Min].AddTail(c_List.GetNext(c_Pos)); //TraceContourTRACER(m_Dib, l_Point, c_List); } } } } /* Segmentation */ if (full_ListCount >= REAL_VERTEBRE_COUNT) { m_Dib->Cnv24Bit(); m_Dib->Invert(); CAVector AVectors[VERTEBRE_COUNT]; CAVector RealVectors[REAL_VERTEBRE_COUNT]; int l, k; for (l=0; l<full_ListCount;l++) { AVectors[l] = SegmentationGlob(m_Dib, i_Document, full_List[l]); AVectors[l].RecalcDistance(); //break; CString Msg; Msg.Format("Segmentation for object %d done.", l); theApp.SetProgress(Msg); } /* remove vectors of minimal length */ for (l=0;l<REAL_VERTEBRE_COUNT;l++) { int MaxIndex = 0; for (k=1;k<full_ListCount;k++) { if (AVectors[k].GetSize() && (AVectors[k].GetDistance() > AVectors[MaxIndex].GetDistance())) MaxIndex = k; } if (AVectors[MaxIndex].GetSize()){ //i_Document->Add(AVectors[MaxIndex]); RealVectors[l] = AVectors[MaxIndex]; AVectors[MaxIndex].RemoveAll(); AVectors[MaxIndex].RecalcDistance(); } } /* create a vector of leftmost points only */ CAVector FrontVector; int l_Pos, s_Pos; for (l=0;l<REAL_VERTEBRE_COUNT;l++) { // find the leftmost point l_Pos = 0; for (k=1;k<RealVectors[l].GetSize();k++) if (RealVectors[l].GetAt(k).x < RealVectors[l].GetAt(l_Pos).x) l_Pos = k; FrontVector.Add(RealVectors[l].GetAt(l_Pos)); // find the second leftmost point s_Pos = 0; for (k=1;k<RealVectors[l].GetSize();k++) if ((RealVectors[l].GetAt(k).x < RealVectors[l].GetAt(s_Pos).x)&&(k!=l_Pos)) s_Pos = k; if (s_Pos != l_Pos) FrontVector.Add(RealVectors[l].GetAt(s_Pos)); } FrontVector.SortY(); while (FrontVector.GetSize() < 14) FrontVector.Add(CPoint(FrontVector[FrontVector.GetSize()-1].x + 5, FrontVector[FrontVector.GetSize()-1].y + 5)); i_Document->Add(FrontVector); } else MessageBox(::GetFocus(), "Insufficient trace zones detected!", "Cervicales Tracer Error", MB_OK | MB_ICONERROR); theApp.HideProgress(); }
void CATouchController::touchMoved() { CC_RETURN_IF(ccpDistance(m_tFirstPoint, m_pTouch->getLocation()) < _px(32)); m_tFirstPoint = CCPointZero; if (!m_vTouchMovedsViewCache.empty()) { bool isScheduledPassing = CAScheduler::isScheduled(schedule_selector(CATouchController::passingTouchesViews), this); CAScheduler::unschedule(schedule_selector(CATouchController::passingTouchesViews), this); while (!m_vTouchMovedsViewCache.empty()) { CAResponder* responder = m_vTouchMovedsViewCache.back(); CCPoint pointOffSet = CCPointZero; if (CAView* v = dynamic_cast<CAView*>(responder)) { pointOffSet = ccpSub(v->convertToNodeSpace(m_pTouch->getLocation()), v->convertToNodeSpace(m_pTouch->getPreviousLocation())); } else if (CAViewController* c = dynamic_cast<CAViewController*>(responder)) { pointOffSet = ccpSub(c->getView()->convertToNodeSpace(m_pTouch->getLocation()), c->getView()->convertToNodeSpace(m_pTouch->getPreviousLocation())); } else { pointOffSet = ccpSub(m_pTouch->getLocation(), m_pTouch->getPreviousLocation()); } pointOffSet.x = fabsf(pointOffSet.x); pointOffSet.y = fabsf(pointOffSet.y); do { CC_BREAK_IF(!responder->isTouchMovedListenHorizontal() && pointOffSet.x >= pointOffSet.y); CC_BREAK_IF(!responder->isTouchMovedListenVertical() && pointOffSet.x < pointOffSet.y); m_vTouchMovedsView.pushBack(m_vTouchMovedsViewCache.back()); } while (0); m_vTouchMovedsViewCache.popBack(); } CAVector<CAResponder * > tTouchesViews = m_vTouchesViews; if (!m_vTouchMovedsView.empty()) { if (!isScheduledPassing) { CAVector<CAResponder*>::iterator itr; // for (itr = m_vTouchMovedsView.begin(); itr != m_vTouchMovedsView.end(); itr++) { m_vTouchesViews.eraseObject(*itr, true); } // for (itr=m_vTouchesViews.begin(); itr!=m_vTouchesViews.end(); itr++) { (*itr)->ccTouchCancelled(m_pTouch, m_pEvent); } } { m_vTouchesViews.clear(); for (int i=0; i<m_vTouchMovedsView.size(); i++) { CAResponder* responder = m_vTouchMovedsView.at(i); CCPoint pointOffSet = CCPointZero; if (CAView* v = dynamic_cast<CAView*>(responder)) { pointOffSet = ccpSub(v->convertToNodeSpace(m_pTouch->getLocation()), v->convertToNodeSpace(m_pTouch->getPreviousLocation())); } else if (CAViewController* c = dynamic_cast<CAViewController*>(responder)) { pointOffSet = ccpSub(c->getView()->convertToNodeSpace(m_pTouch->getLocation()), c->getView()->convertToNodeSpace(m_pTouch->getPreviousLocation())); } else { pointOffSet = ccpSub(m_pTouch->getLocation(), m_pTouch->getPreviousLocation()); } if (responder->isTouchMovedListenHorizontal() && fabsf(pointOffSet.x) >= fabsf(pointOffSet.y)) { CC_CONTINUE_IF(responder->isSlidingMinX() && pointOffSet.x > 0); CC_CONTINUE_IF(responder->isSlidingMaxX() && pointOffSet.x < 0); } if (responder->isTouchMovedListenVertical() && fabsf(pointOffSet.x) < fabsf(pointOffSet.y)) { CC_CONTINUE_IF(responder->isSlidingMinY() && pointOffSet.y > 0); CC_CONTINUE_IF(responder->isSlidingMaxY() && pointOffSet.y < 0); } m_vTouchesViews.pushBack(responder); if (tTouchesViews.contains(responder)==false) { responder->ccTouchBegan(m_pTouch, m_pEvent); } break; } if (m_vTouchesViews.empty()) { m_vTouchesViews.pushBack(m_vTouchMovedsView.front()); if (tTouchesViews.contains(m_vTouchesViews.back())==false) { m_vTouchesViews.back()->ccTouchBegan(m_pTouch, m_pEvent);// } } } } } CAView* view = dynamic_cast<CAView*>(CAApplication::getApplication()->getTouchDispatcher()->getFirstResponder()); bool isContainsFirstPoint = view && view->convertRectToWorldSpace(view->getBounds()).containsPoint(m_tFirstPoint); if (!isContainsFirstPoint && view) { view->ccTouchMoved(m_pTouch, m_pEvent); } CAVector<CAResponder*>::iterator itr; for (itr=m_vTouchesViews.begin(); itr!=m_vTouchesViews.end(); itr++) { (*itr)->ccTouchMoved(m_pTouch, m_pEvent); } }
CAView* HeroViewController::tableViewSectionViewForHeaderInSection(CATableView* table, const CCSize& viewSize, unsigned int section) { if (section ==0) { return NULL; } m_pClassView = CAView::createWithColor(COLOR_GRAY); CALabel* label = CALabel::createWithFrame(CCRect(10,0,viewSize.width/10,viewSize.height)); label->setTextAlignment(CATextAlignmentLeft); label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); label->setText(UTF8("本地数据")); label->setFontSize(_px(13)); m_pClassView->addSubview(label); // m_pSegmented = CASegmentedControl::createWithFrame(CCRect(viewSize.width/10*6,_px(0),viewSize.width/10*3,viewSize.height/2),4); // //m_pSegmented->setSegmentItemBackgroundImage() // //m_pSegmented->setContentOffsetForSegmentAtIndex() // // m_pSegmented->setImageForSegmentAtIndex(CAImage::create("hero/All_Class.png"), 0, CAControlStateNormal); // m_pSegmented->setImageForSegmentAtIndex(CAImage::create("hero/All_Class1.png"), 0, CAControlStateSelected); // m_pSegmented->setImageForSegmentAtIndex(CAImage::create("hero/Power_Class.png"), 1, CAControlStateNormal); // m_pSegmented->setImageForSegmentAtIndex(CAImage::create("hero/Power_Class1.png"), 1, CAControlStateSelected); // m_pSegmented->setImageForSegmentAtIndex(CAImage::create("hero/Agile_Class.png"), 2, CAControlStateNormal); // m_pSegmented->setImageForSegmentAtIndex(CAImage::create("hero/Agile_Class1.png"), 2, CAControlStateSelected); // m_pSegmented->setImageForSegmentAtIndex(CAImage::create("hero/Puzzle_Class.png"), 3, CAControlStateNormal); // m_pSegmented->setImageForSegmentAtIndex(CAImage::create("hero/Puzzle_Class1.png"), 3, CAControlStateSelected); // m_pSegmented->setBackgroundView(CAView::createWithColor(COLOR_GRAY)); // m_pSegmented->setBackgroundImage(NULL); // m_pSegmented->setSelectedAtIndex(0); // // //m_pSegmented->addTarget() // m_pClassView->addSubview(m_pSegmented); CAVector<CATabBarItem*> items; CATabBarItem* tabBarItem1 = CATabBarItem::create("", CAImage::create("hero/All_Class.png"), CAImage::create("hero/All_Class1.png")); CATabBarItem* tabBarItem2 = CATabBarItem::create("", CAImage::create("hero/Power_Class.png"), CAImage::create("hero/Power_Class1.png")); CATabBarItem* tabBarItem3 = CATabBarItem::create("", CAImage::create("hero/Agile_Class.png"), CAImage::create("hero/Agile_Class1.png")); CATabBarItem* tabBarItem4 = CATabBarItem::create("", CAImage::create("hero/Puzzle_Class.png"), CAImage::create("hero/Puzzle_Class1.png")); items.pushBack(tabBarItem1); items.pushBack(tabBarItem2); items.pushBack(tabBarItem3); items.pushBack(tabBarItem4); m_pClassTabBar = CATabBar::create(items, CCSize(160, 40)); m_pClassTabBar->setTag(101); m_pClassTabBar->setSelectedAtIndex(selectNum); m_pClassTabBar->setBackGroundColor(COLOR_GRAY); m_pClassTabBar->setSelectedBackGroundColor(COLOR_GRAY); m_pClassTabBar->setDelegate(this); m_pClassTabBar->setCenterOrigin(CCPoint(viewSize.width / 10 * 8, _px(viewSize.height / 2))); m_pClassView->addSubview(m_pClassTabBar); return m_pClassView; }
void CDShowNewsImage::initNewsImageView(newsImage _image) { m_image = _image; CAVector<CAView* > viewList; for (int i=0; i<m_image.m_imageUrl.size(); i++) { CommonUrlImageView* temImage = CommonUrlImageView::createWithLayout(DLayoutFill); temImage->setImageViewScaleType(CAImageViewScaleTypeFitImageInside); temImage->setImage(CAImage::create("HelloWorld.png")); temImage->setUrl(m_image.m_imageUrl[i]); CAScrollView* p_ScrollView = CAScrollView::createWithLayout(DLayoutFill); p_ScrollView->setMinimumZoomScale(1.0f); p_ScrollView->setMaximumZoomScale(2.5f); p_ScrollView->setMultitouchGesture(CAScrollView::MultitouchGesture::Zoom); p_ScrollView->setBackgroundColor(CAColor_clear); p_ScrollView->setShowsScrollIndicators(false); p_ScrollView->setBounceVertical(false); p_ScrollView->setScrollViewDelegate(this); p_ScrollView->addSubview(temImage); viewList.pushBack(p_ScrollView); } p_PageView = CAPageView::createWithLayout(DLayoutFill, CAPageView::Horizontal); p_PageView->setViews(viewList); p_PageView->setPageViewDelegate(this); p_PageView->setBackgroundColor(CAColor_black); p_PageView->setPageViewDelegate(this); p_PageView->setSpacing(40); this->getView()->addSubview(p_PageView); p_bg = CAView::createWithColor(ccc4(0,0,0,200)); p_bg->setLayout(DLayout(DHorizontalLayoutFill, DVerticalLayout_B_C(0, 0.85))); this->getView()->addSubview(p_bg); p_title = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(10, 80), DVerticalLayout_T_H(10, 50))); p_title->setText(m_image.m_title); p_title->setColor(CAColor_white); p_title->setFontSize(34); p_title->setBold(true); p_bg->addSubview(p_title); char temp[10]; sprintf(temp, "1/%lu",m_image.m_imageUrl.size()); p_index = CALabel::createWithLayout(DLayout(DHorizontalLayout_R_W(0, 70), DVerticalLayout_T_H(10, 50))); p_index->setText(temp); p_index->setColor(CAColor_white); p_index->setFontSize(30); p_index->setBold(true); p_bg->addSubview(p_index); p_des = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(10, 20), DVerticalLayoutFill)); p_des->setText(m_image.m_imageDesc[4]); p_des->setColor(ccc4(200, 200, 200, 255)); p_des->setFontSize(26); CAScrollView* ps = CAScrollView::createWithLayout(DLayout(DHorizontalLayoutFill, DVerticalLayout_T_H(70, 200))); ps->setBackgroundColor(CAColor_clear); ps->setShowsVerticalScrollIndicator(false); ps->setShowsHorizontalScrollIndicator(false); ps->setBounceHorizontal(false); ps->addSubview(p_des); p_bg->addSubview(ps); }