本文整理汇总了C++中CAImageView::getBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ CAImageView::getBounds方法的具体用法?C++ CAImageView::getBounds怎么用?C++ CAImageView::getBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAImageView
的用法示例。
在下文中一共展示了CAImageView::getBounds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initWithSize
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);
}
示例2: toast
void UtilManager::toast(string text, string image, bool isSmall) {
CAApplication::getApplication()->getRootWindow()->removeSubviewByTag(TOAST_VIEW_TAG);
CCSize winSize = CAApplication::getApplication()->getWinSize();
CAImageView *back = CAImageView::create();
if (isSmall == false) {
//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
back->setCenter(CCRect(winSize.width*0.5, winSize.height*0.55, _px(120), _px(120)));
}
else {
back->setCenter(CCRect(winSize.width*0.5, winSize.height*0.4, _px(120), _px(120)));
}
back->setTag(TOAST_VIEW_TAG);
back->setImage(CAImage::create("image/scape_storage.png"));
//back->setColor(ccc4(31, 31, 31, 200));//40
CALabel *title = CALabel::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),
_dip(back->getBounds().size.height*0.8), 100, 100));
//title->setText(UTF8ToGBK::transferToGbk(text));
//title->setFontName(getChineseFont());
title->setColor(CAColor_white);
title->setTextAlignment(CATextAlignmentCenter);
title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
title->setFontSize(_px(22));
back->addSubview(title);
CAImageView *icon = CAImageView::create();
if (isSmall == false) {
//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
icon->setCenter(CADipRect(_dip(back->getBounds().size.width*0.5), _dip(back->getBounds().size.height*0.4), 90 / 1.5, 68 / 1.5));
}
else {
icon->setCenter(CADipRect(_dip(back->getBounds().size.width*0.5), _dip(back->getBounds().size.height*0.4), 72 / 1.5, 72 / 1.5));
}
//CAImageView *icon = CAImageView::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),_dip(back->getBounds().size.height*0.4), 105/1.5, 95/1.5));
icon->setImage(CAImage::create(image));
back->addSubview(icon);
CAApplication::getApplication()->getRootWindow()->addSubview(back);
//CCLog("%s", get_date_now().c_str());
icon->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.3), CCFadeOut::create(TOAST_TIME / 2.0)));
back->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.3), CCFadeOut::create(TOAST_TIME)));
scheduleOnce(schedule_selector(UtilManager::removeToast), this, TOAST_TIME);
}
示例3: showItems
void CATabBar::showItems()
{
do
{
CC_BREAK_IF(m_pViews.empty() == false);
unsigned int count = MIN(m_nMaxShowCount, m_pItems.size());
float width = m_obContentSize.width / count;
float height = m_obContentSize.height;
m_cItemSize = CCSize(width, height);
for (unsigned int i=0; i<count; i++)
{
CAView* view = CAView::createWithFrame(CCRect(i * width, 0, width, height), ccc4(0, 0, 0, 0));
this->insertSubview(view, 3);
view->setDisplayRange(false);
m_pViews.push_back(view);
CAImageView* imageView = NULL;
CCLabelTTF* title = NULL;
if (m_pItems.at(i)->getImage())
{
imageView = CAImageView::createWithImage(m_pItems.at(i)->getImage());
imageView->setTag(0xffff);
view->addSubview(imageView);
}
if (m_pItems.at(i)->getTitle().compare("") != 0)
{
int fontSize = this->getContentSize().height / 5.0f;
title = CCLabelTTF::create(m_pItems.at(i)->getTitle().c_str(), "Arial", fontSize);
title->setTag(0xfffe);
view->addSubview(title);
}
if (imageView && title == NULL)
{
CCSize imageViewSize = imageView->getBounds().size;
float scaleX = width / imageViewSize.width * 2/3.0f;
float scaleY = height / imageViewSize.height * 2/3.0f;
float scale = MIN(scaleX, scaleY);
scale = MIN(scale, 1.0f);
imageViewSize = ccpMult(imageViewSize, scale);
CCRect rect;
rect.origin = view->getBounds().size/2;
rect.size = imageViewSize;
imageView->setCenter(rect);
}
else if (title && imageView == NULL)
{
int fontSize = this->getContentSize().height / 2.0f;
title->setFontSize(fontSize);
CCSize titleSize = title->getBounds().size;
float titleScale = height / titleSize.height * 1/2.0f;
titleSize = ccpMult(titleSize, titleScale);
CCRect rect;
rect.origin = view->getBounds().size/2;
rect.size = titleSize;
title->setCenter(rect);
}
else if (title && imageView)
{
CCSize imageViewSize = imageView->getBounds().size;
float scaleX = width / imageViewSize.width * 1/2.0f;
float scaleY = height / imageViewSize.height * 1/2.0f;
float scale = MIN(scaleX, scaleY);
scale = MIN(scale, 1.0f);
imageViewSize = ccpMult(imageViewSize, scale);
CCRect rect;
rect.size = imageViewSize;
rect.origin = view->getBounds().size;
rect.origin.x *= 1/2.0f;
rect.origin.y *= 7/20.0f;
imageView->setCenter(rect);
CCSize titleSize = title->getBounds().size;
float titleScale = height / titleSize.height * 3/10;
titleSize = ccpMult(titleSize, titleScale);
CCRect rect2;
rect2.size = titleSize;
rect2.origin = view->getBounds().size;
rect2.origin.x *= 1/2.0f;
rect2.origin.y *= 15/20.0f;
title->setCenter(rect2);
}
}
//.........这里部分代码省略.........