void CAPageView::setViews(const CADeque<CAView*>& vec) { if (!m_pViews.empty()) { m_pContainer->removeAllSubviews(); m_pViews.clear(); } m_pViews = CADeque<CAView*>(vec); if (m_ePageViewDirection == CAPageViewDirectionHorizontal) { this->setViewSize(DSize(this->getBounds().size.width * m_pViews.size() + m_fSpacing * (m_pViews.size() - 1), m_obViewSize.height)); } else { this->setViewSize(DSize(m_obViewSize.width, this->getBounds().size.height * m_pViews.size() + m_fSpacing * (m_pViews.size() - 1))); } for (size_t i=0; i<m_pViews.size(); i++) { DRect rect = this->getBounds(); if (m_ePageViewDirection == CAPageViewDirectionHorizontal) { rect.origin.x = (rect.size.width + m_fSpacing) * i; } else { rect.origin.y = (rect.size.height + m_fSpacing) * i; } m_pContainer->addSubview(m_pViews.at(i)); m_pViews.at(i)->setFrame(rect); } }
ExtendibleHash::ExtendibleHash(const int & notFound, int b, int LSize) : bits(b), LeafSize(LSize) { notfound = notFound; setKeys(b); bits = b; Directory = new ExtendibleLeaf*[DSize(bits)]; ExtendibleLeaf *leafPtr = new ExtendibleLeaf(LSize); for(int i=0; i< DSize(b); i++) Directory[i] = leafPtr;//makes the initial directory poinmt to an empty leaf /* TO TEST WHETHER OR NOT ALL DIRECTORIES INITIALLY POINT AT ONE LEAF for(int i=0; i<LSize; i++) leafPtr->binaryNode[i]=i; for(int j = 0; j< DSize(b); j++) { A A for(int i=0; i< LSize; i++) B { cout<< Directory[j]->binaryNode[i]<< " "; } cout<< endl; } */ } // ExtendibleHash()
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; }
void CAListView::reloadViewSizeData() { DRect winRect = this->getBounds(); winRect.origin = getContentOffset(); float width = winRect.size.width; float height = winRect.size.height; clearData(); int iStartPosition = 0; if (m_nListHeaderHeight > 0) { m_rHeaderRect = (m_pListViewOrientation == CAListViewOrientationVertical) ? DRect(0, iStartPosition, width, m_nListHeaderHeight) : DRect(iStartPosition, 0, m_nListHeaderHeight, height); iStartPosition += m_nListHeaderHeight; } m_nIndexs = m_pListViewDataSource->numberOfIndex(this); m_rIndexRects.resize(m_nIndexs); m_rLineRects.resize(m_nIndexs); for (unsigned i = 0; i < m_nIndexs; i++) { unsigned int cellHeight = m_pListViewDataSource->listViewHeightForIndex(this, i); if (cellHeight > 0) { DRect cellRect = (m_pListViewOrientation == CAListViewOrientationVertical) ? DRect(0, iStartPosition, width, cellHeight) : DRect(iStartPosition, 0, cellHeight, height); m_rIndexRects[i] = cellRect; iStartPosition += cellHeight; } if (m_nSeparatorViewHeight > 0) { m_rLineRects[i] = (m_pListViewOrientation == CAListViewOrientationVertical) ? DRect(0, iStartPosition, width, m_nSeparatorViewHeight) : DRect(iStartPosition, 0, m_nSeparatorViewHeight, height); iStartPosition += m_nSeparatorViewHeight; } } if (m_nListFooterHeight > 0) { m_rFooterRect = (m_pListViewOrientation == CAListViewOrientationVertical) ? DRect(0, iStartPosition, width, m_nListFooterHeight) : DRect(iStartPosition, 0, m_nListFooterHeight, height); iStartPosition += m_nListFooterHeight; } if (m_pListViewOrientation == CAListViewOrientationVertical) { this->setViewSize(DSize(width, iStartPosition)); } else { this->setViewSize(DSize(iStartPosition, height)); } }
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; } }
void CAGifView::updateGifSize() { if(m_pGif) { DSize viewSize = m_obContentSize; DSize imageSize = DSize(m_pGif->getWidth(),m_pGif->getHeight()); float viewRatio = viewSize.width / viewSize.height; float imageRatio = imageSize.width / imageSize.height; m_fLeft = 0; m_fTop = 0; m_fRight = viewSize.width; m_fBottom = viewSize.height; if (imageRatio > viewRatio) { m_fTop = (viewSize.height - viewSize.width / imageRatio) / 2; m_fBottom = m_fTop + viewSize.width / imageRatio; } else if (imageRatio < viewRatio) { m_fLeft = (viewSize.width - viewSize.height * imageRatio) / 2; m_fRight = m_fLeft + viewSize.height * imageRatio; } } }
void CAImageView::setContentSize(const DSize & size) { if (CAViewAnimation::areAnimationsEnabled() && CAViewAnimation::areBeginAnimations()) { CAViewAnimation::getInstance()->setContentSize(size, this); } else if (!size.equals(m_obContentSize)) { m_obContentSize = size; m_obAnchorPointInPoints = DPoint(m_obContentSize.width * m_obAnchorPoint.x, m_obContentSize.height * m_obAnchorPoint.y ); m_obFrameRect.size = DSize(m_obContentSize.width * m_fScaleX, m_obContentSize.height * m_fScaleY); this->updateByImageViewScaleType(); if(!m_obSubviews.empty()) { CAVector<CAView*>::iterator itr; for (itr=m_obSubviews.begin(); itr!=m_obSubviews.end(); itr++) { (*itr)->reViewlayout(); } } this->updateDraw(); } }
void ExtendibleHash::extend(const int &object) { int directorySize = DSize(bits); int newDirectorySize = DSize(bits+1); bits++; ExtendibleLeaf** newDirectory = new ExtendibleLeaf*[newDirectorySize]; for(int iter=0; iter<directorySize; iter++) { newDirectory[1 + 2*iter] = Directory[iter]; newDirectory[2*iter] = Directory[iter]; } ExtendibleLeaf** temp = Directory; Directory = newDirectory; delete temp; setKeys(bits); } // extednd()
void CAView::setContentSize(const DSize & contentSize) { if (CAViewAnimation::areAnimationsEnabled() && CAViewAnimation::areBeginAnimations()) { CAViewAnimation::getInstance()->setContentSize(contentSize, this); } else if (!contentSize.equals(m_obContentSize)) { m_obContentSize = contentSize; float anchorPointInPointsX = m_obContentSize.width * m_obAnchorPoint.x; float anchorPointInPointsY = m_obContentSize.height * m_obAnchorPoint.y; m_obAnchorPointInPoints = DPoint(anchorPointInPointsX, anchorPointInPointsY); float frameRectWidth = m_obContentSize.width * m_fScaleX; float frameRectHeight = m_obContentSize.height * m_fScaleY; m_obFrameRect.size = DSize(frameRectWidth, frameRectHeight); this->updateImageRect(); if(!m_obSubviews.empty()) { CAVector<CAView*>::iterator itr; for (itr=m_obSubviews.begin(); itr!=m_obSubviews.end(); itr++) { (*itr)->reViewlayout(); } } this->updateDraw(); } }
TWidgetControl *__cdecl CreateField_intern (char *name, PropertyHandle *control_ph, TWidgetControl *parent_field, DSize dsize, DPoint position, int16 dsp_level, logical as_collection, int resource_id, ODataSource *pODataSource, logical active_f ) { TControl *tc; TWidgetControl *control = NULL; OField *fi; BEGINSEQ // Read Control-Info fi = ADKFACTORY(NULL,OField); if ( fi->Read_intern(control_ph) ) ERROR if ( dsize != DSize(0,0) ) fi->set_size(dsize); if ( position != DPoint(0,0) ) fi->set_position(position); fi->get_align().SetGrow(); fi->set_accept_drop(YES); fi->set_name(name); fi->get_dataSource().set_referenceType(DRT_UserDefined); fi->get_dataSource().set_isCollection(as_collection); fi->SetDisplayLevel(dsp_level); if ( resource_id != AUTO ) fi->set_res_id(resource_id); if ( pODataSource ) fi->get_dataSource() = *pODataSource; tc = fi->Open(parent_field,active_f); control = OI_CAST(TWidgetControl,tc); RECOVER control = NULL; ENDSEQ return(control); }
void CAView::setCenter(const DRect& rect) { float width = rect.size.width / m_fScaleX; float height = rect.size.height / m_fScaleY; DSize contentSize = DSize(width, height); DSize originalSize = m_obContentSize; if (CAViewAnimation::areAnimationsEnabled() && CAViewAnimation::areBeginAnimations()) { CAViewAnimation::getInstance()->setContentSize(contentSize, this); m_obContentSize = contentSize; m_obAnchorPointInPoints = m_obContentSize; m_obAnchorPointInPoints.x *= m_obAnchorPoint.x; m_obAnchorPointInPoints.y *= m_obAnchorPoint.y; } else { this->setContentSize(contentSize); } this->setCenterOrigin(rect.origin); if (CAViewAnimation::areAnimationsEnabled() && CAViewAnimation::areBeginAnimations()) { m_obContentSize = originalSize; m_obAnchorPointInPoints = m_obContentSize; m_obAnchorPointInPoints.x *= m_obAnchorPoint.x; m_obAnchorPointInPoints.y *= m_obAnchorPoint.y; } }
DSize DSize :: operator+ (const DSize &rcDSize ) { return ( DSize(Width + rcDSize.Width, Height + rcDSize.Height) ); }
void CAProgress::setContentSize(const DSize & var) { CAView::setContentSize(DSize(var.width, MAX(var.height, 6))); m_pTarckImageView->setFrame(this->getBounds()); DRect rect = DRect(0, 0, m_pIndicator->getFrameOrigin().x, this->getBounds().size.height); m_pProgressImageView->setFrame(rect); this->setProgress(m_fProgress); }
DSize OButtonControl :: GetFrameSize (DSize dsize, DMargin &field_margin ) { int margin = align.get_margin().Maximum(); return( DSize(dsize.Width + align.get_margin().Left+align.get_margin().Right, dsize.Height + align.get_margin().Top+align.get_margin().Bottom) ); return(dsize); }
void CCEGLViewProtocol::setFrameSize(float width, float height) { m_obScreenSize = DSize(width, height); m_obDesignResolutionSize.setSize(s_px_to_dip(width), s_px_to_dip(height)); m_fScale = s_dip_to_px(1.0f); m_obViewPortRect.setRect(0, 0, m_obScreenSize.width, m_obScreenSize.height); }
ExtendibleLeaf* ExtendibleHash::searchIndex(const int &object, int bits) { int compare = Ehash(object, bits); for(int indexIter = 0; indexIter < DSize(bits); indexIter++) { if(compare == binaryKey[indexIter]) return Directory[indexIter]; } }//returns a directory pointer to the array you are searching for
bool CATextField::becomeFirstResponder() { if (m_pDelegate &&( !m_pDelegate->textFieldShouldBeginEditing(this))) { return false; } bool result = CAView::becomeFirstResponder(); if (m_eClearBtn == WhileEditing) { setMarginImageRight(DSize(getBounds().size.height, getBounds().size.height), "source_material/clearbtn.png"); } return result; }
bool CATextField::resignFirstResponder() { if (m_pDelegate && (!m_pDelegate->textFieldShouldEndEditing(this))) { return false; } bool result = CAView::resignFirstResponder(); if (m_eClearBtn == WhileEditing) { setMarginImageRight(DSize(10,0), ""); } return result; }
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 FirstViewController::viewDidLoad() { // Do any additional setup after loading the view from its nib. DRect winRect = this->getView()->getBounds(); CAImageView* imageView = CAImageView::createWithImage(CAImage::create("r/HelloWorld.png")); imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop); imageView->setFrame(winRect); this->getView()->addSubview(imageView); DRect rect; rect.size = DSize(600, 200); rect.origin = winRect.size/2; rect.origin.y -= 360; CALabel* label = CALabel::createWithCenter(rect); label->setTextAlignment(CATextAlignmentCenter); label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); label->setFontSize(72); label->setText("Hello World!"); label->setColor(CAColor_white); this->getView()->addSubview(label); }
TWidgetControl *__cdecl CreateInputHelp (char *class_names, char *ctl_names, TWidgetControl *parent_field ) { PropertyHandle class_names_ph(class_names); PropertyHandle ctl_names_ph(ctl_names); PropertyHandle *control_ph = NULL; TWidgetControl *control = NULL; BEGINSEQ PropertyHandle class_ph(TProjectManager::TPM->UCB()->sdbures->dbhandle,"ADK_Class",PI_Read); control_ph = class_ph.GPH("controls"); if ( !class_ph.Get(class_names_ph) ) OADIERR(100) if ( !control_ph->Get(ctl_names_ph) ) OADIERR(101) if ( !(control = CreateField_intern("InputHelp",control_ph,parent_field, DSize(),DPoint(),0,YES,AUTO,NULL,YES)) ) ERROR RECOVER control = NULL; ENDSEQ return(control); }
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(); }
DSize DSize::operator/(float a) const { CCAssert(a, "DSize division by 0."); return DSize(this->width / a, this->height / a); }
DSize DSize::operator*(float a) const { return DSize(this->width * a, this->height * a); }
DSize DSize::operator-(const DSize& right) const { return DSize(this->width - right.width, this->height - right.height); }
void updateImage() { const std::string& sPlaceHolder = m_pTextFieldX->getPlaceHolderText(); CAColor4B cFontColor; std::string text; if (m_sText.empty()) { text = sPlaceHolder; cFontColor = m_pTextFieldX->getPlaceHolderColor(); } else { text = m_sText; cFontColor = m_pTextFieldX->getTextColor(); } if (m_pTextFieldX->isSecureTextEntry()) { std::string password; for (std::string::size_type i = 0; i < m_sText.length(); i++) { password.append("*"); } if (password.empty()) { text = sPlaceHolder; } else { text = password; } } int fontSize = m_pTextFieldX->getFontSize(); m_iFontHeight = CAImage::getFontHeight(m_szFontName.c_str(), fontSize); DSize size = DSize(0, m_iFontHeight); CAImage* image = CAImage::createWithString(text.c_str(), cFontColor, m_szFontName.c_str(), fontSize, size, CATextAlignmentLeft, CAVerticalTextAlignmentCenter, true); DRect rect = DRectZero; if (sPlaceHolder.length() == 0) { this->setImage(image); this->setImageRect(rect); } CC_RETURN_IF(image == NULL); rect.size.height = image->getContentSize().height; rect.size.width = MIN(m_iLabelWidth, image->getContentSize().width); if (text.empty()) { m_cImageSize = DSizeZero; } else { m_cImageSize = image->getContentSize(); } this->setImage(image); rect.origin.x = -m_iString_o_length; this->setImageRect(rect); }
void ExtendibleHash::setKeys(int bits) { binaryKey.clear(); for(int i = 0; i< DSize(bits); i++) binaryKey.push_back(i); }
void CAImageView::updateByImageViewScaleType() { CC_RETURN_IF(m_pobImage == NULL); CC_RETURN_IF(m_bUpdateByImageViewScaleType); m_bUpdateByImageViewScaleType = true; DSize viewSize = DSize(m_obContentSize); DRect rect = DRect(m_obRect); DSize imageSize = m_obRect.size; float viewRatio = viewSize.width / viewSize.height; float imageRatio = imageSize.width / imageSize.height; switch (m_eImageViewScaleType) { case CAImageViewScaleTypeFitViewByHorizontal: { viewSize.width = viewSize.height * imageRatio; } break; case CAImageViewScaleTypeFitViewByVertical: { viewSize.height = viewSize.width / imageRatio; } break; default: break; } m_fLeft = 0; m_fTop = 0; m_fRight = viewSize.width; m_fBottom = viewSize.height; switch (m_eImageViewScaleType) { case CAImageViewScaleTypeFitImageCrop: { if (imageRatio > viewRatio) { rect.size.width = imageSize.height * viewRatio; rect.origin.x = (imageSize.width - rect.size.width) / 2; } else if (imageRatio < viewRatio) { rect.size.height = imageSize.width / viewRatio; rect.origin.y = (imageSize.height - rect.size.height) / 2; } } break; case CAImageViewScaleTypeFitImageInside: { if (imageRatio > viewRatio) { m_fTop = (viewSize.height - viewSize.width / imageRatio) / 2; m_fBottom = m_fTop + viewSize.width / imageRatio; } else if (imageRatio < viewRatio) { m_fLeft = (viewSize.width - viewSize.height * imageRatio) / 2; m_fRight = m_fLeft + viewSize.height * imageRatio; } } break; default: break; } this->setImageRect(rect); if (!viewSize.equals(m_obContentSize)) { if (m_bFrame) { DRect rect = this->getFrame(); rect.size = viewSize; this->setFrame(rect); } else { DRect rect = this->getCenter(); rect.size = viewSize; this->setCenter(rect); } } m_bUpdateByImageViewScaleType = false; }
void CARenderImage::setContentSize(const DSize& contentSize) { CAView::setContentSize(DSize(m_uPixelsWide, m_uPixelsHigh)); }
void CALabel::updateImage() { int fontHeight = CAImage::getFontHeight(m_nfontName.c_str(), m_nfontSize); int defaultLineSpace = fontHeight / 4; unsigned int linenumber = (int)this->getBounds().size.height / fontHeight; DSize size = DSizeZero; if (m_bFitFlag) { float width = CAImage::getStringWidth(m_nfontName.c_str(), m_nfontSize, m_nText); if (width > m_obContentSize.width) { if (m_nNumberOfLine > 1) { size = DSize(this->getBounds().size.width, (defaultLineSpace + m_iLineSpacing + fontHeight) * m_nNumberOfLine); } else if (m_nNumberOfLine == 1) { size = DSize(width, fontHeight); } else { size.width = this->getBounds().size.width; size.height = CAImage::getStringHeight(m_nfontName.c_str(), m_nfontSize, m_nText, size.width, m_iLineSpacing, m_bWordWrap); } } else { size.height = fontHeight; size.width = width; } } else { if (linenumber == 0) { size = this->getBounds().size; } else { if (m_nNumberOfLine > 0) { size = DSize(this->getBounds().size.width, (defaultLineSpace + m_iLineSpacing + fontHeight) * MIN(m_nNumberOfLine, linenumber)); } else { size = DSize(this->getBounds().size.width, (defaultLineSpace + m_iLineSpacing + fontHeight) * linenumber); } } } CAImage* image = CAImage::createWithString(m_nText.c_str(), m_cFontColor, m_nfontName.c_str(), m_nfontSize, size, m_nTextAlignment, m_nVerticalTextAlignmet, m_bWordWrap, m_iLineSpacing, m_bBold, m_bItalics, m_bUnderLine); this->setImage(image); CC_RETURN_IF(image == NULL); m_cLabelSize = size; DRect rect = DRectZero; rect.size.width = this->getBounds().size.width; rect.size.height = size.height; float width = m_bFitFlag ? image->getContentSize().width : MIN(this->getBounds().size.width, image->getContentSize().width); rect.size.width = width; switch (m_nVerticalTextAlignmet) { case CAVerticalTextAlignmentTop: pTextHeight = 0; break; case CAVerticalTextAlignmentCenter: pTextHeight = (this->getBounds().size.height - rect.size.height) / 2; break; case CAVerticalTextAlignmentBottom: pTextHeight = this->getBounds().size.height - rect.size.height; break; default: break; } if (m_bFitFlag) { if (!size.equals(m_obContentSize)) { if (m_bFrame) { DRect rect = this->getFrame(); rect.size = size; this->setFrame(rect); } else { DRect rect = this->getCenter(); rect.size = size; this->setCenter(rect); } } } this->setImageRect(rect); }