本文整理汇总了C++中DRect函数的典型用法代码示例。如果您正苦于以下问题:C++ DRect函数的具体用法?C++ DRect怎么用?C++ DRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tableCellAtIndex
CATableViewCell* MenuViewController::tableCellAtIndex(CATableView* table, const DSize& cellSize, unsigned int section, unsigned int row)
{
DSize _size = cellSize;
CATableViewCell* cell = table->dequeueReusableCellWithIdentifier("CrossApp");
if (cell == NULL)
{
cell = CATableViewCell::create("CrossApp");
cell->setBackgroundView(NULL);
CALabel* test = CALabel::createWithCenter(DRect(_size.width/2+30,
_size.height/2,
_size.width,
_size.height));
test->setTextAlignment(CATextAlignmentLeft);
test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
test->setFontSize(_px(32));
test->setColor(CAColor_white);
test->setTag(100);
cell->addSubview(test);
CAImageView* arrow = CAImageView::createWithCenter(DRect(_size.width-64,_size.height/2,64,64));
arrow->setTag(101);
cell->addSubview(arrow);
}
CALabel* test = (CALabel*)cell->getSubviewByTag(100);
test->setText(unicode_to_utf8(menuList[row]));// menuList[row]);
CAImageView* arrow = (CAImageView*)cell->getSubviewByTag(101);
arrow->setImage(CAImage::create("source_material/cell_btn_right.png"));
return cell;
}
示例2: getZZCRect
std::vector<DRect> getZZCRect()
{
DSize size = getFrame().size;
std::pair<int, int> t1 = getLineAndPos(m_curSelCharRange.first);
std::pair<int, int> t2 = getLineAndPos(m_curSelCharRange.second);
std::string s1 = m_szText.substr(t1.second, m_curSelCharRange.first - t1.second);
if (!s1.empty() && s1[0] == '\n') s1.erase(0, 1);
int l1 = getStringLength(s1);
std::string s2 = m_szText.substr(t2.second, m_curSelCharRange.second - t2.second);
if (!s2.empty() && s2[0] == '\n') s2.erase(0, 1);
int l2 = getStringLength(s2);
std::vector<DRect> vr;
if (t1.first == t2.first)
{
vr.push_back(DRect(l1, m_iLineHeight*1.25f*t1.first, l2 - l1, m_iLineHeight));
}
else
{
vr.push_back(DRect(l1, m_iLineHeight*1.25f*t1.first, size.width - l1, m_iLineHeight*1.25f));
int i = t1.first + 1;
for (; i < t2.first; i++)
{
vr.push_back(DRect(0, m_iLineHeight*1.25f*i, size.width, m_iLineHeight*1.25f));
}
vr.push_back(DRect(0, m_iLineHeight*1.25f*i, l2, m_iLineHeight));
}
return vr;
}
示例3: _px
void SessionsViewController::showAlert()
{
if (p_alertView) {
this->getView()->removeSubview(p_alertView);
p_alertView = NULL;
}
p_alertView = CAView::createWithFrame(this->getView()->getBounds());
this->getView()->addSubview(p_alertView);
CAImageView* bg = CAImageView::createWithFrame(DRect(_px(0), _px(120), m_winSize.width, m_winSize.height - _px(120)));
bg->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
bg->setImage(CAImage::create("common/bg.png"));
CAButton* btn5 = CAButton::create(CAButtonTypeSquareRect);
btn5->setTag(100);
btn5->setFrame(DRect(_px(0), _px(120), m_winSize.width, m_winSize.height - _px(120)));
btn5->setTitleColorForState(CAControlStateNormal, CAColor_white);
btn5->setBackGroundViewForState(CAControlStateNormal, bg);
btn5->setBackGroundViewForState(CAControlStateHighlighted, bg);
btn5->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
p_alertView->addSubview(btn5);
CALabel* test = CALabel::createWithCenter(DRect(m_winSize.width / 2, (m_winSize.height - _px(120)) / 2, m_winSize.width, m_winSize.height - _px(120)));
test->setColor(CAColor_gray);
test->setTextAlignment(CATextAlignmentCenter);
test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
test->setFontSize(_px(24));
test->setText("Network cannot connected !");
p_alertView->addSubview(test);
}
示例4: DRect
bool CATextView::init()
{
if (!CAView::init())
{
return false;
}
this->setColor(CAColor_clear);
CAImage* image = CAImage::create("source_material/textField_bg.png");
DRect capInsets = DRect(image->getPixelsWide()/2 ,image->getPixelsHigh()/2 , 1, 1);
m_pBackgroundView = CAScale9ImageView::createWithImage(image);
m_pBackgroundView->setCapInsets(capInsets);
m_pBackgroundView->setImage(image);
this->insertSubview(m_pBackgroundView, -1);
m_pShowImageView = CAImageView::createWithFrame(DRect(0, 0, 1, 1));
m_pShowImageView->setTextTag("textView");
this->addSubview(m_pShowImageView);
CATextViewWin32 *text = new CATextViewWin32(this);
text->initWithFrame(DRect(0, 0, 1, 1));
text->autorelease();
this->addSubview(text);
m_pTextView = (CATextViewWin32*)text;
return true;
}
示例5: initWithCell
void CDNewsTableCell::initWithCell()
{
DSize _size = this->getFrame().size;
theTitle = CALabel::createWithFrame(DRect(240, 20, _size.width/2+50, 40));
theTitle->setColor(CAColor_black);
theTitle->setTextAlignment(CATextAlignmentLeft);
theTitle->setVerticalTextAlignmet(CAVerticalTextAlignmentTop);
theTitle->setFontSize(_px(32));
theTitle->setTag(100);
this->getContentView()->addSubview(theTitle);
theDesc = CALabel::createWithFrame(DRect(240, 65, _size.width/2, 40));
theDesc->setColor(CAColor_black);
theDesc->setTextAlignment(CATextAlignmentLeft);
theDesc->setVerticalTextAlignmet(CAVerticalTextAlignmentTop);
theDesc->setFontSize(_px(24));
theDesc->setTag(102);
theDesc->setColor(CAColor_gray);
theDesc->setLineSpacing(10);
this->getContentView()->addSubview(theDesc);
theImage = CommonUrlImageView::createWithCenter(DRect(120, _size.height/2, 200, _size.height-40));
theImage->setTag(101);
theImage->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
theImage->setImage(CAImage::create("image/HelloWorld.png"));
this->getContentView()->addSubview(theImage);
}
示例6: DRect
void CADrawerController::viewDidLoad()
{
m_rHideFrame[0] = DRect(-m_fDivision, 0, m_fDivision, this->getView()->getBounds().size.height);
m_rHideFrame[1] = DRect(0 , 0, this->getView()->getBounds().size.width, this->getView()->getBounds().size.height);
m_rShowFrame[0] = DRect(0, 0, m_fDivision, this->getView()->getBounds().size.height);
m_rShowFrame[1] = DRect(m_fDivision , 0, this->getView()->getBounds().size.width, this->getView()->getBounds().size.height);
for (int i=0; i<2; i++)
{
m_pContainer[i] = new CAView();
m_pContainer[i]->setFrame(m_rHideFrame[i]);
this->getView()->addSubview(m_pContainer[i]);
m_pContainer[i]->release();
}
m_pContainer[0]->setAnchorPoint(DPoint(1.0f, 0.5f));
m_pContainer[1]->setAnchorPoint(DPoint(0.0f, 0.5f));
m_pLeftViewController->addViewFromSuperview(m_pContainer[0]);
m_pRightViewController->addViewFromSuperview(m_pContainer[1]);
m_bShow = true;
this->hideLeftViewController(false);
if (m_pBackgroundView)
{
m_pBackgroundView->setFrame(this->getView()->getBounds());
}
}
示例7: DRect
void CAScrollView::updateIndicator()
{
if (m_pIndicatorHorizontal == NULL)
{
m_pIndicatorHorizontal = CAIndicator::create(CAIndicator::CAIndicatorTypeHorizontal, this);
m_vChildInThis.pushBack(m_pIndicatorHorizontal);
this->insertSubview(m_pIndicatorHorizontal, 1);
}
if (m_pIndicatorVertical == NULL)
{
m_pIndicatorVertical = CAIndicator::create(CAIndicator::CAIndicatorTypeVertical, this);
m_vChildInThis.pushBack(m_pIndicatorVertical);
this->insertSubview(m_pIndicatorVertical, 1);
}
const char indicatorSize = 6;
const DRect indicatorHorizontalFrame = DRect(indicatorSize * 2,
this->getBounds().size.height - indicatorSize * 2,
this->getBounds().size.width - indicatorSize * 4,
indicatorSize);
m_pIndicatorHorizontal->setFrame(indicatorHorizontalFrame);
const DRect indicatorVerticalFrame = DRect(this->getBounds().size.width - indicatorSize * 2,
indicatorSize * 2,
indicatorSize,
this->getBounds().size.height - indicatorSize * 4);
m_pIndicatorVertical->setFrame(indicatorVerticalFrame);
}
示例8: layoutPullToRefreshView
void CAScrollView::layoutPullToRefreshView()
{
DSize viewSize = this->getViewSize();
if (m_pHeaderRefreshView)
{
m_pHeaderRefreshView->setFrame(DRect(0, -128.0f, viewSize.width, 128.0f));
if (m_pHeaderRefreshView->getSuperview() == NULL)
{
m_pContainer->addSubview(m_pHeaderRefreshView);
}
if (m_pHeaderRefreshView->isLayoutFinish() == false)
{
m_pHeaderRefreshView->startLayout();
}
this->endHeaderRefresh();
}
if (m_pFooterRefreshView)
{
m_pFooterRefreshView->setFrame(DRect(0, viewSize.height, viewSize.width, 128.0f));
if (m_pFooterRefreshView->getSuperview() == NULL)
{
m_pContainer->addSubview(m_pFooterRefreshView);
}
if (m_pFooterRefreshView->isLayoutFinish() == false)
{
m_pFooterRefreshView->startLayout();
}
this->endFooterRefresh();
}
}
示例9: CAControl_selector
/*
void MainViewController::initPageView()
{
}
*/
void MainViewController::showAlert()
{
if (p_alertView) {
this->getView()->removeSubview(p_alertView);
p_alertView = NULL;
}
p_alertView = CAView::createWithFrame(DRect((0), (120), m_winSize.width, m_winSize.height - (220)));
this->getView()->addSubview(p_alertView);
CAImageView* bg = CAImageView::createWithFrame(DRect((0), (0), m_winSize.width, m_winSize.height - (220)));
bg->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
bg->setImage(CAImage::create("common/bg.png"));
bg->setTouchEnabled(false);
CAButton* btn5 = CAButton::create(CAButtonTypeSquareRect);
btn5->setTag(100);
btn5->setFrame(DRect((0), (0), m_winSize.width, m_winSize.height - (220)));
btn5->setTitleColorForState(CAControlStateNormal, CAColor_white);
btn5->setBackgroundViewForState(CAControlStateNormal, bg);
btn5->setBackgroundViewForState(CAControlStateHighlighted, bg);
btn5->addTarget(this, CAControl_selector(MainViewController::buttonCallBack), CAControlEventTouchUpInSide);
p_alertView->addSubview(btn5);
CALabel* test = CALabel::createWithFrame(DRect(0, m_winSize.height - (300), m_winSize.width, (40)));
test->setColor(CAColor_gray);
test->setTextAlignment(CATextAlignmentCenter);
test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
test->setFontSize((30));
test->setText("Network cannot connect!");
p_alertView->addSubview(test);
}
示例10: CAControl_selector
void CDNewsImageController::showAlert()
{
p_alertView = CAView::createWithFrame(this->getView()->getBounds());
this->getView()->addSubview(p_alertView);
CAImageView* bg = CAImageView::createWithFrame(DRect(0,0,winSize.width,winSize.height));
bg->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
bg->setImage(CAImage::create("image/HelloWorld.png"));
CAButton* btn5 = CAButton::create(CAButtonTypeSquareRect);
btn5->setTag(100);
btn5->setCenter(DRect(winSize.width/2, winSize.height/2, winSize.width, winSize.height));
btn5->setTitleColorForState(CAControlStateNormal,CAColor_white);
btn5->setBackgroundViewForState(CAControlStateNormal, bg);
btn5->setBackgroundViewForState(CAControlStateHighlighted, bg);
btn5->addTarget(this, CAControl_selector(CDNewsImageController::buttonCallBack), CAControlEventTouchUpInSide);
p_alertView->addSubview(btn5);
CALabel* test = CALabel::createWithCenter(DRect(winSize.width/2,
winSize.height-100,
winSize.width,
40));
test->setColor(CAColor_gray);
test->setTextAlignment(CATextAlignmentCenter);
test->setVerticalTextAlignmet(CAVerticalTextAlignmentTop);
test->setFontSize(24);
test->setText("网络不给力,请点击屏幕重新加载~");
p_alertView->addSubview(test);
}
示例11: CAControl_selector
void SessionsViewController::viewDidLoad()
{
// Do any additional setup after loading the view from its nib.
m_winSize = this->getView()->getBounds().size;
CAScale9ImageView* sView = CAScale9ImageView::createWithImage(CAImage::create("common/sky_bg.png"));
sView->setFrame(DRect((0), (0), m_winSize.width, (120)));
this->getView()->addSubview(sView);
CAButton* button = CAButton::createWithFrame(DRect((0), (20), (100), (100)), CAButtonTypeCustom);
CAImageView* imageView = CAImageView::createWithImage(CAImage::create("common/nav_search.png"));
imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
button->setBackgroundViewForState(CAControlStateAll, imageView);
button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
button->setTag(20);
this->getView()->addSubview(button);
FSegmentView* seg = FSegmentView::createWithFrame(DRect(m_winSize.width - 240, 45, 200, 50), 2);
seg->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
imageView = CAImageView::createWithImage(CAImage::create("common/nav_time.png"));
seg->setItemBackgroundImage(imageView, 0);
imageView = CAImageView::createWithImage(CAImage::create("common/nav_type.png"));
seg->setItemBackgroundImage(imageView, 1);
seg->setTag(200, 0);
seg->setTag(201, 1);
this->getView()->addSubview(seg);
m_navType = 0;
m_navTimeType = 0;
m_navFormatType = 0;
CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 2, (75), m_winSize.width, (50)));
label->setTextAlignment(CATextAlignmentCenter);
label->setColor(CAColor_white);
label->setFontSize(SAP_TITLE_FONT_SIZE);
label->setText("Agenda");
label->setFontName(SAP_FONT_ARIAL);
sView->addSubview(label);
if (m_msg->empty())
{
requestMsg();
{
p_pLoading = CAActivityIndicatorView::createWithCenter(DRect(m_winSize.width / 2, m_winSize.height / 2, 50, 50));
this->getView()->insertSubview(p_pLoading, CAWindowZOderTop);
p_pLoading->setLoadingMinTime(0.5f);
p_pLoading->setTargetOnCancel(this, callfunc_selector(SessionsViewController::initMsgTableView));
}
}
else
{
initMsgTableView();
}
CCLog("%f", CAApplication::getApplication()->getWinSize().width);
}
示例12: initPageView
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);
}
示例13: getContentOffset
void CAAutoCollectionView::reloadData()
{
if (m_pCollectionViewDataSource == NULL)
return;
this->reloadViewSizeData();
this->removeAllSubviews();
DRect winRect = this->getBounds();
winRect.origin = getContentOffset();
int dw = winRect.size.width - 2 * ((m_pCollectionViewOrientation == CACollectionViewOrientationVertical) ? m_iHoriMargins : m_iVertMargins);
if (m_nCollectionHeaderHeight > 0 && m_pCollectionHeaderView)
{
m_pCollectionHeaderView->setDisplayRange(true);
if (m_pCollectionViewOrientation == CACollectionViewOrientationVertical)
{
m_pCollectionHeaderView->setFrame(DRect(m_iHoriMargins, m_iVertMargins, dw, m_nCollectionHeaderHeight));
}
else
{
m_pCollectionHeaderView->setFrame(DRect(m_iHoriMargins, m_iVertMargins, m_nCollectionHeaderHeight, dw));
}
addSubview(m_pCollectionHeaderView);
}
int dwValue = calculateAllRects();
if (m_nCollectionFooterHeight > 0 && m_pCollectionFooterView)
{
if (m_pCollectionViewOrientation == CACollectionViewOrientationVertical)
{
m_pCollectionFooterView->setFrame(DRect(m_iHoriMargins, dwValue, dw, m_nCollectionFooterHeight));
}
else
{
m_pCollectionFooterView->setFrame(DRect(dwValue, m_iVertMargins, m_nCollectionFooterHeight, dw));
}
addSubview(m_pCollectionFooterView);
}
this->updateSectionHeaderAndFooterRects();
this->layoutPullToRefreshView();
this->startDeaccelerateScroll();
this->loadCollectionCell();
}
示例14: getContentOffset
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));
}
}
示例15: showAlert
void CDNewsImageController::initImageTableView()
{
if (m_ImageMsg.empty()) {
showAlert();
return;
}
if (p_TableView!=NULL)
{
this->getView()->removeSubview(p_TableView);
p_TableView = NULL;
}
p_TableView= CATableView::createWithFrame(DRect(0, 0, winSize.width, winSize.height));
p_TableView->setTableViewDataSource(this);
p_TableView->setTableViewDelegate(this);
p_TableView->setAllowsSelection(true);
p_TableView->setScrollViewDelegate(this);
p_TableView->setAllowsMultipleSelection(false);
p_TableView->setSeparatorViewHeight(40);
p_TableView->setSeparatorColor(ccc4(240,240,240,255));
this->getView()->addSubview(p_TableView);
CAPullToRefreshView *refreshDiscount = CAPullToRefreshView::create(CAPullToRefreshView::CAPullToRefreshTypeFooter);
refreshDiscount->setLabelColor(CAColor_black);
CAPullToRefreshView *refreshDiscount1 = CAPullToRefreshView::create(CAPullToRefreshView::CAPullToRefreshTypeHeader);
refreshDiscount1->setLabelColor(CAColor_black);
p_TableView->setFooterRefreshView(refreshDiscount);
p_TableView->setHeaderRefreshView(refreshDiscount1);
}