本文整理汇总了C++中DRect类的典型用法代码示例。如果您正苦于以下问题:C++ DRect类的具体用法?C++ DRect怎么用?C++ DRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeHeader
pugi::xml_node SvgPrinter::writeHeader(pugi::xml_document &doc)
{
pugi::xml_node rootNode = doc.append_child("svg");
rootNode.append_attribute("xmlns") = "http://www.w3.org/2000/svg";
rootNode.append_attribute("xmlns:xlink") = "http://www.w3.org/1999/xlink";
rootNode.append_attribute("xmlns:ev") = "http://www.w3.org/2001/xml-events";
rootNode.append_attribute("version") = "1.1";
rootNode.append_attribute("baseProfile") = "full";
if(!m_settings.width().empty()) {
rootNode.append_attribute("width") = m_settings.width().c_str();
}
if(!m_settings.height().empty()) {
rootNode.append_attribute("height") = m_settings.height().c_str();
}
DRect box = m_clsAttr ? m_clsAttr->boundingBox() : m_attr.boundingBox();
double margin = m_settings.margin();
std::stringstream is;
is << (box.p1().m_x - margin);
is << " " << (box.p1().m_y - margin);
is << " " << (box.width() + 2*margin);
is << " " << (box.height() + 2*margin);
rootNode.append_attribute("viewBox") = is.str().c_str();
pugi::xml_node style_node = rootNode.append_child("style");
style_node.text() = (".font_style {font: " + std::to_string(m_settings.fontSize()) + "px monospace;}").c_str();
return rootNode;
}
示例2: getCenter
DRect CAView::getCenter()
{
DRect rect = this->getFrame();
rect.origin = ccpAdd(rect.origin, ccpMult(rect.size, 0.5f));
rect.setCenter(true);
return rect;
}
示例3: getContentOffset
void CAListView::recoveryCollectionCell()
{
DRect rect = this->getBounds();
rect.origin = getContentOffset();
rect.origin.y -= rect.size.height * 0.1f;
rect.size.height *= 1.2f;
std::map<unsigned int, CAListViewCell*>::iterator itr;
for (itr = m_mpUsedListCells.begin(); itr != m_mpUsedListCells.end(); itr++)
{
CAListViewCell* cell = itr->second;
CC_CONTINUE_IF(cell == NULL);
DRect cellRect = cell->getFrame();
CC_CONTINUE_IF(rect.intersectsRect(cellRect));
m_mpFreedListCells[cell->getReuseIdentifier()].pushBack(cell);
cell->removeFromSuperview();
cell->resetListViewCell();
itr->second = NULL;
m_vpUsedListCells.eraseObject(cell);
CAView* line = m_pUsedLines[itr->first];
CC_CONTINUE_IF(line == NULL);
m_pFreedLines.pushBack(line);
line->removeFromSuperview();
m_pUsedLines[itr->first] = NULL;
}
}
示例4: updateSectionHeaderAndFooterRects
void CAAutoCollectionView::updateSectionHeaderAndFooterRects()
{
DRect rect = this->getBounds();
rect.origin = getContentOffset();
for (int i = 0; i < m_rCollectionViewSection.size(); i++)
{
CollectionViewSection& cvs = m_rCollectionViewSection[i];
CC_CONTINUE_IF(!rect.intersectsRect(cvs.rSectionRect));
CAView* header = cvs.pSectionHeaderView;
CAView* footer = cvs.pSectionFooterView;
float headerHeight = cvs.nSectionHeaderHeight;
float footerHeight = cvs.nSectionFooterHeight;
if (header && m_bAlwaysTopSectionHeader)
{
DPoint p1 = rect.origin;
p1.y = MAX(p1.y, cvs.rSectionRect.origin.y);
p1.y = MIN(p1.y, cvs.rSectionRect.origin.y + cvs.rSectionRect.size.height
- headerHeight - footerHeight);
header->setFrameOrigin(p1);
}
if (footer && m_bAlwaysBottomSectionFooter)
{
DPoint p2 = DPointZero;
p2.y = MIN(rect.origin.y + this->getBounds().size.height - footerHeight,
cvs.rSectionRect.origin.y + cvs.rSectionRect.size.height - footerHeight);
p2.y = MAX(p2.y, cvs.rSectionRect.origin.y + headerHeight);
footer->setFrameOrigin(p2);
}
}
}
示例5: intersectsRect
bool DRect::intersectsRect(const DRect& rect) const
{
return !( getMaxX() < rect.getMinX()
|| rect.getMaxX() < getMinX()
|| getMaxY() < rect.getMinY()
|| rect.getMaxY() < getMinY());
}
示例6: setMarginLeft
void CATextField::setMarginLeft(int var)
{
m_iMarginLeft = var;
DRect r = this->getBounds();
r.InflateRect(-m_iMarginLeft, 0, -m_iMarginRight, 0);
((CATextFieldWin32*)m_pTextField)->setFrame(r);
delayShowImage();
}
示例7: setContentSize
void CATextField::setContentSize(const DSize& contentSize)
{
CAView::setContentSize(contentSize);
if (m_pTextField)
{
DRect r = this->getBounds();
r.InflateRect(-m_iMarginLeft, 0, -m_iMarginRight, 0);
((CATextFieldWin32*)m_pTextField)->setFrame(r);
}
}
示例8: getContentOffset
void CAListView::loadCell()
{
DRect rect = this->getBounds();
rect.origin = getContentOffset();
rect.origin.y -= rect.size.height * 0.1f;
rect.origin.x -= rect.size.width * 0.1f;
rect.size.width *= 1.2f;
rect.size.height *= 1.2f;
std::map<unsigned int, CAListViewCell*>::iterator itr;
for (itr = m_mpUsedListCells.begin(); itr != m_mpUsedListCells.end(); itr++)
{
CC_CONTINUE_IF(itr->second != NULL);
unsigned int index = itr->first;
DRect cellRect = m_rIndexRects[index];
CC_CONTINUE_IF(!rect.intersectsRect(cellRect));
CAListViewCell* cell = m_pListViewDataSource->listViewCellAtIndex(this, cellRect.size, index);
if (cell)
{
cell->m_nIndex = index;
cell->updateDisplayedAlpha(this->getAlpha());
addSubview(cell);
cell->setFrame(cellRect);
m_mpUsedListCells[index] = cell;
m_vpUsedListCells.pushBack(cell);
}
if (m_pSelectedListCells.count(index))
{
cell->setControlState(CAControlStateSelected);
}
if (m_pListViewDataSource)
{
m_pListViewDataSource->listViewWillDisplayCellAtIndex(this, cell, index);
}
CAView* view = this->dequeueReusableLine();
DRect lineRect = m_rLineRects[index];
if (view == NULL)
{
view = CAView::createWithFrame(lineRect, m_obSeparatorColor);
}
m_pUsedLines[index] = view;
this->insertSubview(view, 1);
view->setFrame(lineRect);
}
}
示例9: unify
void DPolyline::normalize(DPoint src, DPoint tgt)
{
if (empty())
return;
unify();
ListIterator<DPoint> iter, next, onext;
DPoint pCur = src;
DPoint pNext;
DPoint pNextNext;
for (iter = begin(); iter.valid(); ++iter) {
for( ; ; ) {
if (!iter.valid())
break;
next = iter;
pNext = *next;
next++;
if (!next.valid()) {
pNextNext = tgt;
}
else
pNextNext = *next;
DSegment s1(pCur, pNext);
DSegment s2(pNext, pNextNext);
DRect r (pCur, pNextNext);
// is *next on the way from *iter to *onext?
if (s1.slope() == s2.slope() && r.contains(pNext)) {
del(iter);
iter = next;
}
else
break; /* while */
}
if (iter.valid())
pCur = *iter;
else
break;
}
}
示例10: setContentSize
void CATextView::setContentSize(const DSize& contentSize)
{
CAView::setContentSize(contentSize);
if (m_pBackgroundView)
{
m_pBackgroundView->setFrame(this->getBounds());
}
if (m_pShowImageView)
{
m_pShowImageView->setFrame(this->getBounds());
}
if (m_pTextView)
{
DRect r = this->getBounds();
r.InflateRect(-5);
((CATextViewWin32*)m_pTextView)->setFrame(r);
}
}
示例11: getContentOffset
void CACollectionView::updateSectionHeaderAndFooterRects()
{
DRect rect = this->getBounds();
rect.origin = getContentOffset();
std::vector<DRect>::iterator itr;
for (itr = m_rSectionRects.begin(); itr != m_rSectionRects.end(); itr++)
{
CC_CONTINUE_IF(!rect.intersectsRect(*itr));
int i = (int)(itr - m_rSectionRects.begin());
CAView* header = NULL;
CAView* footer = NULL;
float headerHeight = 0;
float footerHeight = 0;
if (m_pSectionHeaderViews.find(i) != m_pSectionHeaderViews.end())
{
header = m_pSectionHeaderViews[i];
headerHeight = m_pSectionHeaderViews[i]->getFrame().size.height;
}
if (m_pSectionFooterViews.find(i) != m_pSectionFooterViews.end())
{
footer = m_pSectionFooterViews[i];
footerHeight = m_pSectionFooterViews[i]->getFrame().size.height;
}
if (header && m_bAlwaysTopSectionHeader)
{
DPoint p1 = rect.origin;
p1.y = MAX(p1.y, itr->origin.y);
p1.y = MIN(p1.y, itr->origin.y + itr->size.height
- headerHeight - footerHeight);
header->setFrameOrigin(p1);
}
if (footer && m_bAlwaysBottomSectionFooter)
{
DPoint p2 = DPointZero;
p2.y = MIN(rect.origin.y + this->getBounds().size.height - footerHeight,
itr->origin.y + itr->size.height - footerHeight);
p2.y = MAX(p2.y, itr->origin.y + headerHeight);
footer->setFrameOrigin(p2);
}
}
}
示例12: unite
void DRect::unite(const DRect &r)
{
if ( !r.isValid() ) return;
if ( !isValid() ) {
*this = r;
return;
}
_left = kMin(_left, r._left);
_right = kMax(_right, r._right);
_top = kMin(_top, r._top);
_bottom = kMax(_bottom, r._bottom);
}
示例13: equals
bool DRect::equals(const DRect& rect) const
{
if (fabsf(this->getMinX() - rect.getMinX()) >= 0.01f)
{
return false;
}
if (fabsf(this->getMaxX() - rect.getMaxX()) >= 0.01f)
{
return false;
}
if (fabsf(this->getMinY() - rect.getMinY()) >= 0.01f)
{
return false;
}
if (fabsf(this->getMaxY() - rect.getMaxY()) >= 0.01f)
{
return false;
}
return true;
}
示例14: setRect
DRect::DRect(const DRect& other)
:m_bCenter(other.isCenter())
{
setRect(other.origin.x, other.origin.y, other.size.width, other.size.height);
}
示例15: CC_RETURN_IF
void CACollectionView::reloadData()
{
CC_RETURN_IF(m_pCollectionViewDataSource == NULL);
this->reloadViewSizeData();
this->removeAllSubviews();
DRect winRect = this->getBounds();
winRect.origin = getContentOffset();
float width = winRect.size.width;
int y = 0;
if (m_nCollectionHeaderHeight > 0 && m_pCollectionHeaderView)
{
m_pCollectionHeaderView->setDisplayRange(true);
m_pCollectionHeaderView->setFrame(DRect(0, y, width, m_nCollectionHeaderHeight));
addSubview(m_pCollectionHeaderView);
y += m_nCollectionHeaderHeight;
}
;
int begin = (int)m_rSectionRects.size();
m_rSectionRects.resize(m_rSectionRects.size() + m_nSections);
for (int i = 0; i < m_nSections; i++)
{
unsigned int iSectionHeaderHeight = m_nSectionHeaderHeights.at(i);
DRect sectionHeaderRect = DRect(0, y, width, iSectionHeaderHeight);
if (iSectionHeaderHeight>0)
{
CAView* pSectionHeaderView = m_pCollectionViewDataSource->collectionViewSectionViewForHeaderInSection(this, sectionHeaderRect.size, i);
if (pSectionHeaderView != NULL)
{
pSectionHeaderView->setDisplayRange(true);
pSectionHeaderView->setFrame(sectionHeaderRect);
insertSubview(pSectionHeaderView, 1);
m_pSectionHeaderViews[i] = pSectionHeaderView;
y += iSectionHeaderHeight;
}
}
y += m_nVertInterval;
unsigned int rowCount = m_nRowsInSections.at(i);
for (int j = 0; j < rowCount; j++)
{
int iHeight = m_nRowHeightss.at(i).at(j);
unsigned int itemCount = m_pCollectionViewDataSource->numberOfItemsInRowsInSection(this, i, j);
unsigned int cellWidth = 0;
if (itemCount>0)
{
cellWidth = (width - m_nHoriInterval) / itemCount - m_nHoriInterval;
}
for (int k = 0; k < itemCount; k++)
{
CAIndexPath3E indexPath = CAIndexPath3E(i, j, k);
DRect cellRect = DRect(m_nHoriInterval + (cellWidth + m_nHoriInterval)*k, y, cellWidth, iHeight);
m_rUsedCollectionCellRects[indexPath] = cellRect;
std::pair<std::map<CAIndexPath3E, CACollectionViewCell*>::iterator, bool> itrResult =
m_mpUsedCollectionCells.insert(std::make_pair(indexPath, (CACollectionViewCell*)NULL));
CC_CONTINUE_IF(!winRect.intersectsRect(cellRect));
CACollectionViewCell* cell = m_pCollectionViewDataSource->collectionCellAtIndex(this, cellRect.size, i, j, k);
if (cell)
{
addSubview(cell);
cell->setFrame(cellRect);
cell->m_nSection = i;
cell->m_nRow = j;
cell->m_nItem = k;
itrResult.first->second = cell;
m_vpUsedCollectionCells.pushBack(cell);
if (m_pCollectionViewDataSource)
{
m_pCollectionViewDataSource->collectionViewWillDisplayCellAtIndex(this, cell, i, j, k);
}
}
}
y += (iHeight + m_nVertInterval);
}
unsigned int iSectionFooterHeight = m_nSectionFooterHeights.at(i);
DRect sectionFooterRect = DRect(0, y, width, iSectionFooterHeight);
if (iSectionFooterHeight > 0)
{
CAView* pSectionFooterView = m_pCollectionViewDataSource->collectionViewSectionViewForFooterInSection(this, sectionFooterRect.size, i);
if (pSectionFooterView != NULL)
{
pSectionFooterView->setDisplayRange(true);
pSectionFooterView->setFrame(sectionFooterRect);
insertSubview(pSectionFooterView, 1);
m_pSectionFooterViews[i] = pSectionFooterView;
y += iSectionFooterHeight;
}
}
//.........这里部分代码省略.........