本文整理汇总了C++中CAButton::setFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ CAButton::setFrame方法的具体用法?C++ CAButton::setFrame怎么用?C++ CAButton::setFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAButton
的用法示例。
在下文中一共展示了CAButton::setFrame方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initWithCenter
bool CASegmentedControl::initWithCenter(const CCRect& rect)
{
if (!CAControl::init())
{
return false;
}
this->setCenter(rect);
m_selectedIndex = 0;
this->removeAllSegments();
const float elemWidth = rect.size.width / m_nItemsCount;
m_itemSize = CCSize(elemWidth, rect.size.height);
CCRect elemFrame = CCRect(0, 0, m_itemSize.width, m_itemSize.height);
for (int i = 0; i < m_nItemsCount; ++i)
{
CAButton *btn = this->createDefaultSegment();
if (btn)
{
btn->setFrame(elemFrame);
char tmp[8] = {0};
snprintf(tmp, 8, "%d", i);
btn->setTitleForState(CAControlStateNormal, tmp);
btn->setTitleForState(CAControlStateSelected, tmp);
btn->setTitleForState(CAControlStateHighlighted, tmp);
m_segments.push_back(btn);
this->addSubview(btn);
btn->setControlState((m_selectedIndex == i) ? CAControlStateSelected : CAControlStateNormal);
}
elemFrame.origin.x += elemWidth;
}
return true;
}
示例2: show
void CATextToolBarView::show(CAView* pView)
{
CCSize winSize = CAApplication::getApplication()->getWinSize();
float alertViewButtonHeight = 88;
float alertViewWidth = winSize.width * 2 / 3;
CCRect rect = CCRect(winSize.width / 2, winSize.height / 2 - alertViewButtonHeight, alertViewWidth, alertViewButtonHeight);
m_pBackView = CAClippingView::create();
m_pBackView->setCenter(rect);
this->addSubview(m_pBackView);
this->setTextTag("CATextToolBarView");
m_pBackView->setAlphaThreshold(0.5f);
CAScale9ImageView *backgroundImageView = CAScale9ImageView::createWithFrame(m_pBackView->getBounds());
backgroundImageView->setImage(CAImage::create("source_material/alert_back.png"));
m_pBackView->addSubview(backgroundImageView);
m_pBackView->setStencil(backgroundImageView->copy());
size_t btnCount = m_CallbackTargets.size();
for (int i = 0; i < btnCount; i++)
{
CAButton* btn = CAButton::create(CAButtonTypeSquareRect);
btn->setTitleForState(CAControlStateAll, m_CallbackTargets[i].cszButtonText.c_str());
btn->setTitleColorForState(CAControlStateAll, ccc4(3, 100, 255, 255));
btn->setBackGroundViewForState(CAControlStateNormal, CAView::createWithColor(CAColor_clear));
btn->setBackGroundViewForState(CAControlStateHighlighted, CAView::createWithColor(ccc4(226, 226, 226, 225)));
btn->setTag(i);
btn->addTarget(this, CAControl_selector(CATextToolBarView::alertViewCallback), CAControlEventTouchUpInSide);
btn->setFrame(CCRect(i*alertViewWidth / btnCount, 0, alertViewWidth / btnCount, alertViewButtonHeight));
m_pBackView->addSubview(btn);
if (i>0)
{
addGrayLine(alertViewWidth/btnCount * i);
}
}
if (CAWindow *rootWindow = CAApplication::getApplication()->getRootWindow())
{
rootWindow->insertSubview(this, CAWindowZOderTop);
}
becomeFirstResponder();
m_pControlView = pView;
}
示例3: layoutSubviews
void CASegmentedControl::layoutSubviews()
{
const CCSize controlSize = this->getBounds().size;
const int totalCount = this->getItemCount();
const float elemWidth = controlSize.width / totalCount;
m_itemSize = CCSize(elemWidth, controlSize.height);
CCRect elemFrame = CCRect(0, 0, m_itemSize.width, m_itemSize.height);
for (int i = 0; i < totalCount; ++i)
{
CAButton *btn = m_segments.at(i);
if (btn)
{
btn->setFrame(elemFrame);
btn->setControlState((m_selectedIndex == i) ? CAControlStateSelected : CAControlStateNormal);
}
elemFrame.origin.x += elemWidth;
}
}
示例4: initWithCenter
bool CASegmentedControl::initWithCenter(const CCRect& rect)
{
if (!CAControl::initWithCenter(rect))
{
return false;
}
this->removeAllSegments();
const float elemWidth = this->getBounds().size.width / m_nItemsCount;
m_itemSize = CCSizeMake(elemWidth, this->getBounds().size.height);
CCRect elemFrame = CCRectMake(0, 0, m_itemSize.width, m_itemSize.height);
for (int i = 0; i < m_nItemsCount; ++i)
{
CAButton *btn = this->createDefaultSegment();
if (btn)
{
btn->setFrame(elemFrame);
m_segments.push_back(btn);
this->insertSubview(btn, 1);
}
elemFrame.origin.x += elemWidth;
}
return true;
}