本文整理汇总了C++中nuiRect::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ nuiRect::GetWidth方法的具体用法?C++ nuiRect::GetWidth怎么用?C++ nuiRect::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nuiRect
的用法示例。
在下文中一共展示了nuiRect::GetWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BlurRect
void nuiGLDrawContext::BlurRect(const nuiRect& rRect, uint Strength)
{
nuiRect Rect = rRect;
if (mClippingRect.mEnabled)
Rect.Intersect(mClippingRect,rRect);
nuiRect size = Rect.Size();
nuiTexture* pScratchPad = GetScratchPad(ToZero(size.GetWidth()), ToZero(size.GetHeight()));
if (!pScratchPad)
return;
SetTexture(pScratchPad);
glPushMatrix();
glLoadIdentity();
EnableBlending(true);
EnableTexture2D(true);
SetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
do
{
glCopyTexSubImage2D(
GL_TEXTURE_2D, 0,
0, 0,
ToZero(rRect.mLeft), ToZero(mHeight) - 1 - ToZero(rRect.mTop) - ToZero(rRect.GetHeight()),
ToZero(rRect.GetWidth()), ToZero(rRect.GetHeight())
);
SetFillColor(nuiColor(1,1,1,.15f));
nuiRect rect = Rect;
rect.Move(-1,-1);
DrawImage(rect,size);
rect.Move(1,0);
DrawImage(rect,size);
rect.Move(1,0);
DrawImage(rect,size);
rect.Move(-2,1);
DrawImage(rect,size);
rect.Move(1,0);
DrawImage(rect,size);
rect.Move(1,0);
DrawImage(rect,size);
rect.Move(-2,1);
DrawImage(rect,size);
rect.Move(0,1);
DrawImage(rect,size);
rect.Move(0,1);
DrawImage(rect,size);
} while ((long)(Strength--) > 0);
EnableBlending(false);
EnableTexture2D(false);
glPopMatrix();
}
示例2: LoadProjectionMatrix
void nuiDrawContext::Set2DProjectionMatrix(const nuiRect& rRect)
{
//printf("Set2DProjectionMatrix: %s\n", rRect.GetValue().GetChars());
nuiMatrix m;
m.Translate(-1.0f, 1.0f, 0.0f);
m.Scale(2.0f/rRect.GetWidth(), -2.0f/rRect.GetHeight(), 1.0f);
LoadProjectionMatrix(rRect, m);
}
示例3: nuiPainter
nuiSoftwarePainter::nuiSoftwarePainter(const nuiRect& rRect, nglContext* pContext)
: nuiPainter(rRect, pContext)
{
mWidth = ToNearest(rRect.GetWidth());
mHeight = ToNearest(rRect.GetHeight());
mpRasterizer = new nuiRasterizer(mWidth, mHeight);
AddNeedTextureBackingStore();
}
示例4: SetRect
bool nuiLabel::SetRect(const nuiRect& rRect)
{
bool needRecalcLayout = false;
if (mUseEllipsis || mWrapping)
needRecalcLayout = (rRect.GetWidth() != mRect.GetWidth());
nuiWidget::SetRect(rRect);
nuiRect ideal(mIdealLayoutRect);
if (needRecalcLayout || ideal.GetWidth() > mRect.GetWidth())
{
if (mUseEllipsis)
{
CalcLayout();
nuiSize diff = ideal.GetWidth() - mRect.GetWidth();
int NbLetterToRemove = ToNearest(diff / (ideal.GetWidth() / mText.GetLength())) + 3;
nglString text = mText;
if (NbLetterToRemove > 0)
{
int len = text.GetLength();
text.DeleteRight(MIN(NbLetterToRemove, len));
text.Append(_T("..."));
}
delete mpLayout;
mpLayout = new nuiTextLayout(mpFont);
mpLayout->SetWrapX(0);
mpLayout->Layout(text);
GetLayoutRect();
}
else if (mWrapping)
{
CalcLayout();
delete mpLayout;
mpLayout = new nuiTextLayout(mpFont);
delete mpIdealLayout;
mpIdealLayout = new nuiTextLayout(mpFont);
mpLayout->SetWrapX(mRect.GetWidth() - mBorderLeft - mBorderRight);
mpIdealLayout->SetWrapX(mRect.GetWidth() - mBorderLeft - mBorderRight);
mpLayout->Layout(mText);
mpIdealLayout->Layout(mText);
GetLayoutRect();
}
SetToolTip(mText);
}
else
{
if (GetToolTip() == mText)
SetToolTip(nglString::Empty);
}
return true;
}
示例5: LoadProjectionMatrix
void nuiMetaPainter::LoadProjectionMatrix(const nuiRect& rViewport, const nuiMatrix& rMatrix)
{
StoreOpCode(eLoadProjectionMatrix);
StoreFloat(rViewport.Left());
StoreFloat(rViewport.Top());
StoreFloat(rViewport.GetWidth());
StoreFloat(rViewport.GetHeight());
StoreBuffer(rMatrix.Array, sizeof(nuiSize), 16);
nuiPainter::LoadProjectionMatrix(rViewport, rMatrix);
}
示例6: CalcTreeSize
void nuiPopupMenu::CalcTreeSize(nuiRect& rRect, nuiTreeNode* pTree, uint32& cpt)
{
NGL_ASSERT(pTree); // no chance to happen
cpt++;
nuiRect rect(0,0,0,0);
nuiWidgetPtr pWidget;
nuiRect WidgetRect;
uint32 depth = cpt;
uint32 count = pTree->GetChildrenCount();
if (count <= 0)
return;
bool HasNonEmpty = false;
for (uint32 i = 0; i < count; i++)
{
nuiTreeNode* pNode = dynamic_cast<nuiTreeNode*>(pTree->GetChild(i));
NGL_ASSERT(pNode);
pWidget = pNode->GetElement();
NGL_ASSERT(pWidget);
WidgetRect = pWidget->GetIdealRect();
rect.SetSize(MAX(rect.GetWidth(), WidgetRect.GetWidth()), rect.GetHeight() + WidgetRect.GetHeight());
if (!pNode->IsEmpty())
{
HasNonEmpty = true;
}
if (pNode->IsOpened())
{
if (mRects.size() <= depth + 1) // ensure that there is a rect for the next node
{
nuiMenuRect* pMenuRect = new nuiMenuRect(this, cpt+1);
mRects.push_back(pMenuRect);
mPopupTreeSink.Connect(pMenuRect->mpSBar->ValueChanged, &nuiPopupMenu::OnScrollBarChange, pMenuRect);
}
mRects[depth+1]->mpFromNode = pNode;
CalcTreeSize(rRect, pNode, cpt);
}
}
if (HasNonEmpty)
{
mRects[depth]->mHasNonEmpty = true;
rect.SetSize(rect.GetWidth() + NUI_POPUP_TREE_HANDLE_SIZE * 2, rect.GetHeight());
}
else
{
mRects[depth]->mHasNonEmpty = false;
}
mRects[depth]->mRect = rect;
NGL_ASSERT(mRects.size() >= depth+1);
rRect.SetSize(rect.GetWidth()+rRect.GetWidth(), rect.GetHeight()+rRect.GetHeight());
}
示例7:
/****************************************************************************
*
* Constructor / Destructor
*
****************************************************************************/
nuiDrawContext::nuiDrawContext(const nuiRect& rRect)
{
mWidth = rRect.GetWidth();
mHeight = rRect.GetHeight();
mClipOffsetX = mClipOffsetY = 0;
mPermitAntialising = true;
mpPainter = NULL;
mpMainPainter = NULL;
mpSavedPainter = NULL;
mpAATexture = nuiTexture::GetAATexture();
mStateChanges = 1;
}
示例8: ResetStats
///////////////////////////////////
// nuiPainter implementation:
nuiPainter::nuiPainter(const nuiRect& rRect, nglContext* pContext)
{
ResetStats();
mWidth = ToNearest(rRect.GetWidth());
mHeight = ToNearest(rRect.GetHeight());
mMatrixStack.push(nuiMatrix());
mProjectionMatrixStack.push(nuiMatrix());
mProjectionViewportStack.push(nuiRect());
mDummyMode = false;
mpSurface = NULL;
mAngle=0;
mEnableDrawArray = true;
}
示例9: Draw
void nuiImageDecoration::Draw(nuiDrawContext* pContext, nuiWidget* pWidget, const nuiRect& rDestRect)
{
if (!mpTexture || !mpTexture->GetImage() || !mpTexture->GetImage()->GetPixelSize())
return;
pContext->PushState();
pContext->ResetState();
nuiRect rect = mClientRect;
rect.SetPosition(mPosition, rDestRect);
rect.RoundToBelow();
pContext->EnableTexturing(true);
pContext->EnableBlending(true);
pContext->SetBlendFunc(nuiBlendTransp);
pContext->SetTexture(mpTexture);
nuiColor col(mColor);
if (mUseWidgetAlpha && pWidget)
col.Multiply(pWidget->GetMixedAlpha());
pContext->SetFillColor(col);
nuiRect srcrect(mClientRect);
if (mRepeatX)
{
srcrect.SetWidth(rDestRect.GetWidth());
srcrect.MoveTo(0, srcrect.Top());
}
if (mRepeatY)
{
srcrect.SetHeight(rDestRect.GetHeight());
srcrect.MoveTo(srcrect.Left(), 0);
}
if (mRepeatX || mRepeatY)
rect = rDestRect;
pContext->DrawImage(rect, srcrect);
//pContext->DrawRect(rDestRect, eStrokeShape);
pContext->PopState();
}
示例10: SetRect
bool nuiPositioner::SetRect(const nuiRect& rRect)
{
nuiWidget::SetRect(rRect);
//NGL_OUT(_T("nuiPositioner::SetRect: %d x %d\n"),(int)rRect.GetWidth(),(int)rRect.GetHeight());
nuiWidget::LayoutConstraint contraint;
contraint.mMaxWidth = rRect.GetWidth();
contraint.mMaxHeight = rRect.GetHeight();
IteratorPtr pIt;
for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
{
nuiWidgetPtr pItem = pIt->GetWidget();
pItem->SetLayoutConstraint(contraint);
}
delete pIt;
mIdealRect = CalcIdealSize();
nuiRect mainrect(rRect.Size());
pIt = NULL;
for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
{
nuiWidgetPtr pItem = pIt->GetWidget();
nuiRect rect = pItem->GetIdealRect().Size();
if (mExpandWidth)
rect.SetSize(mainrect.GetWidth(), rect.GetHeight());
if (mExpandHeight)
rect.SetSize(rect.GetWidth(), mainrect.GetHeight());
rect.SetPosition(mPPosition, mainrect);
if (mLimitBounds)
rect.Intersect(rect, mainrect);
rect.RoundToBiggest();
pItem->SetLayout(rect);
}
delete pIt;
return true;
}
示例11: SetRectHorizontal
//*******************************************
//
// ORIENTATION HORIZONTAL
//
bool nuiSplitter::SetRectHorizontal(const nuiRect& rRect)
{
nuiSize Height = rRect.GetHeight();
nuiSize Width = rRect.GetWidth();
nuiRect Rect;
nuiWidgetList::iterator it;
nuiWidgetList::iterator end = mpChildren.end();
list<nuiRect>::iterator rit = mPositions.begin();
Rect = (*rit);
++rit;
// First Child:
nuiWidgetPtr pItem;
Height = 0;
// We only care about the first two widgets!
int i;
it = mpChildren.begin();
i = 0;
nuiSize h;
// don't process the splitter handle before the first child (we need the size of the first child)
if (it != end)
{
pItem = (*it);
if (pItem == mpHandle)
++it;
}
if (it != end)
{
pItem = (*it);
//*****************************************************
//
// MASTERCHILD TRUE
if (mMasterChild)
{
h = pItem->GetIdealRect().GetHeight();
mHandlePos = h;
if (mMode == eModePercentage)
{
mHandlePos = (mHandlePos / (rRect.GetHeight() * (mHandlePosMax / 100.0f))) * 100.0f;
h = mHandlePos;
}
Rect.Set(0.f, Height, Width, h);
Rect.RoundToBelow();
}
// MASTERCHILD FALSE
else
{
h = mHandlePos;
if (mMode == eModePercentage)
h = mRect.GetHeight() * (h / 100.0f);
h = MAX(h, mFirstWidgetMinPixels);
if (h + mSeconWidgetMinPixels > mRect.GetHeight())
{
h = mRect.GetHeight() - mSeconWidgetMinPixels;
mHandlePos = h;
if (mMode == eModePercentage)
mHandlePos = ((h / mRect.GetHeight()) * 100.f);
}
Rect.Set(0.f, Height, Width, h);
Rect.RoundToBelow();
}
Height += h;
pItem->SetLayout(Rect);
}
//******************************************
//
// handle
nuiSize handleSize =0;
if (mpHandle)
{
const nuiRect& handleRect = mpHandle->GetIdealRect();
handleSize = handleRect.GetHeight();
Rect.Set(0.0f, Height, rRect.GetWidth(), handleSize);
Rect.RoundToBelow();
mpHandle->SetLayout(Rect);
Height += handleSize;
//.........这里部分代码省略.........
示例12: SetPosition
void nuiRect::SetPosition(nuiPosition Position, const nuiRect& Inside)
{
nuiSize x,y,w,h;
nuiSize rx,ry,rw,rh;
rx = Inside.mLeft;
ry = Inside.mTop;
rw = Inside.GetWidth();
rh = Inside.GetHeight();
w = GetWidth();
h = GetHeight();
x = (rw - w) / 2.f;
y = (rh - h) / 2.f;
switch (Position)
{
case nuiCenter:
mLeft = x;
mRight = x+w;
mTop = y;
mBottom = y+h;
break;
case nuiFill:
mLeft=0;
mRight=rw;
mTop=0;
mBottom=rh;
break;
case nuiFillHorizontal:
mLeft=0;
mRight=rw;
mTop=y;
mBottom=y+h;
break;
case nuiFillVertical:
mLeft=x;
mRight=x+w;
mTop=0;
mBottom=rh;
break;
case nuiFillLeft:
mLeft=0;
mRight=w;
mTop=0;
mBottom=rh;
break;
case nuiFillRight:
mLeft = rw-w;
mRight = rw;
mTop = 0;
mBottom = rh;
break;
case nuiFillTop:
mLeft = 0;
mRight = rw;
mTop = 0;
mBottom = h;
break;
case nuiFillBottom:
mLeft = 0;
mRight = rw;
mTop = rh - h;
mBottom = rh;
break;
case nuiLeft:
mLeft=0;
mTop =y;
mRight=w;
mBottom=y+h;
break;
case nuiRight:
mLeft=rw-w;
mTop =y;
mRight=rw;
mBottom=y+h;
break;
case nuiTop:
mLeft=x;
mTop =0;
mRight=x+w;
mBottom=h;
break;
case nuiBottom:
mLeft=x;
mTop =rh-h;
mRight=x+w;
mBottom=rh;
break;
case nuiTopLeft:
mLeft=0;
mRight=w;
mTop=0;
mBottom=h;
break;
case nuiTopRight:
mLeft=rw-w;
mRight=rw;
mTop=0;
mBottom=h;
break;
case nuiBottomLeft:
//.........这里部分代码省略.........
示例13: SetRect
bool nuiZoomView::SetRect(const nuiRect& rRect)
{
nuiWidget::SetRect(rRect);
nuiSize XOffset = 0;
nuiSize YOffset = 0;
if (mpHorizontalScrollbar)
XOffset = (nuiSize)ToNearest(mpHorizontalScrollbar->GetRange().GetValue());
if (mpVerticalScrollbar)
YOffset = (nuiSize)ToNearest(mpVerticalScrollbar->GetRange().GetValue());
nuiSize HorizontalZoomLevel = mHorizontalZoomLevel;
nuiSize VerticalZoomLevel = mVerticalZoomLevel;
if (mpVerticalSlider)
VerticalZoomLevel = mpVerticalSlider->GetRange().GetValue();
if (mpHorizontalSlider)
HorizontalZoomLevel = mpHorizontalSlider->GetRange().GetValue();
nuiSize x;
nuiSize y;
nuiSize xx = rRect.GetWidth();
nuiSize yy = rRect.GetHeight();
if (mCalcWidthFromIdealSize)
x = GetIdealRect().GetWidth();
else
x = xx * HorizontalZoomLevel;
if (mCalcHeightFromIdealSize)
y = GetIdealRect().GetHeight();
else
y = yy * VerticalZoomLevel;
bool needv = y > yy;
bool needh = x > xx;
if (mpHorizontalScrollbar)
{
nuiRange& hrange = mpHorizontalScrollbar->GetRange();
hrange.SetRange(0,x);
hrange.SetPageSize(MAX(0, xx));
hrange.SetIncrement(16.0f);
hrange.SetPageIncrement(MAX(0, xx - xx / 8.f)); // 1/8th of page skip overlaps with the next and previous
hrange.EnableEvents(false);
hrange.SetValue(XOffset);
hrange.EnableEvents(true);
XOffset = hrange.GetValue();
}
if (mpVerticalScrollbar)
{
nuiRange& vrange = mpVerticalScrollbar->GetRange();
vrange.SetRange(0,y);
vrange.SetPageSize(MAX(0, yy));
vrange.SetIncrement(16.0f);
vrange.SetPageIncrement(MAX(0, yy - yy / 8.f)); // 1/8th of page skip overlaps with the next and previous
vrange.EnableEvents(false);
vrange.SetValue(YOffset);
vrange.EnableEvents(true);
YOffset = vrange.GetValue();
}
if (x < xx)
x = xx;
if (y < yy)
y = yy;
IteratorPtr pIt;
for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
{
nuiWidgetPtr pItem = pIt->GetWidget();
nuiRect rect(-XOffset, -YOffset, x, y);
pItem->SetLayout(rect);
}
delete pIt;
needv = needv | mAlwaysDisplayVScrollbar;
needh = needh | mAlwaysDisplayHScrollbar;
if (mpVerticalScrollbar)
mpVerticalScrollbar->SetVisible(needv);
if (mpHorizontalScrollbar)
mpHorizontalScrollbar->SetVisible(needh);
return true;
}
示例14: SetRectVertical
//*******************************************
//
// ORIENTATION VERTICAL
//
bool nuiSplitter::SetRectVertical(const nuiRect& rRect)
{
nuiSize Height = rRect.GetHeight();
// nuiSize Width = rRect.GetWidth();
nuiSize left;
nuiRect Rect;
nuiSize handleSize = 0;
if (mpHandle)
{
const nuiRect& handleRect = mpHandle->GetIdealRect();
handleSize = handleRect.GetWidth();
}
nuiWidgetPtr pItem = NULL;
nuiWidgetList::iterator it;
nuiWidgetList::iterator end = mpChildren.end();
list<nuiRect>::iterator rit=mPositions.begin();
Rect=(*rit);
++rit;
left = 0;
nuiSize w=0;
int i;
it=mpChildren.begin();
i=0;
// don't process the splitter handle before the first child (we need the size of the first child)
if (it != end)
{
pItem = (*it);
if (pItem == mpHandle)
{
++it;
i++;
}
}
//******************************************
//
// First Child:
if (it != end)
{
pItem = (*it);
if (mMasterChild)
{
w = pItem->GetIdealRect().GetWidth();
mHandlePos = (mMode == eModePercentage) ? ((w / rRect.GetWidth()) * 100.0f) : w;
Rect.Set(left, 0.f, w, Height);
Rect.RoundToBelow();
}
else
{
w = (mMode == eModePercentage) ? MAX((mRect.GetWidth() * (mHandlePos/100.0f)), mFirstWidgetMinPixels) : MAX(mHandlePos, mFirstWidgetMinPixels);
if (w + mSeconWidgetMinPixels > mRect.GetWidth())
{
w = mRect.GetWidth() - mSeconWidgetMinPixels;
mHandlePos = (mMode == eModePercentage) ? (w / mRect.GetWidth() * 100.0f) : w;
}
Rect.Set(left, 0.f, w, Height);
Rect.RoundToBelow();
}
pItem->SetLayout(Rect);
left += w;
}
// no child
else
{
if (mMasterChild)
{
left = (mMode == eModePercentage) ? ((mHandlePos / rRect.GetWidth()) * 100.0f) : mHandlePos;
}
else
{
left = (mMode == eModePercentage) ? MAX((mRect.GetWidth() * (mHandlePos/100.0f)), mFirstWidgetMinPixels) : MAX(mHandlePos, mFirstWidgetMinPixels);
}
}
//.........这里部分代码省略.........
示例15: SetRect
bool nuiList::SetRect(const nuiRect& rRect)
{
nuiWidget::SetRect(rRect);
nuiSize Height = (nuiSize)rRect.GetHeight();
nuiSize Width = (nuiSize)rRect.GetWidth();
nuiSize pageincr = 0, value = 0;
nuiRect Rect;
nuiSize w,h;
list<nuiRect>::iterator rit=mPositions.begin();
Rect=(*rit);
++rit;
if (mOrientation == nuiVertical)
{
pageincr = rRect.GetHeight() - 2.0f;
Height = (nuiSize)-value;
IteratorPtr pIt;
for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
{
nuiWidgetPtr pItem = pIt->GetWidget();
Rect=(*rit);
if (mFixedAspectRatio)
{
nuiSize rratio,rw,rh;
rratio = (nuiSize)Rect.GetWidth() / (nuiSize)Rect.GetHeight();
rw = (nuiSize)Width;
rh = rw / rratio;
h=rh;
}
else
{
h=(nuiSize)Rect.GetHeight();
}
Rect.Set(mBorderSize, Height, Width - 2 * mBorderSize, h);
Rect.RoundToAbove();
Height += h + mBorderSize;
Height = (nuiSize)ToAbove(Height);
pItem->SetLayout(Rect);
mRects[pItem] = Rect;
++rit;
}
delete pIt;
}
else
{
pageincr = rRect.GetWidth() - 2.0f;
Width = (nuiSize) -value;
IteratorPtr pIt;
for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
{
nuiWidgetPtr pItem = pIt->GetWidget();
Rect=(*rit);
if (mFixedAspectRatio)
{
nuiSize rratio,rw,rh;
rratio = (nuiSize)Rect.GetWidth() / (nuiSize)Rect.GetHeight();
rh = (nuiSize)Height;
rw = rh * rratio;
w=rw;
}
else
{
w=(nuiSize)(int)((nuiSize)Rect.GetWidth());
}
Rect.Set(Width, mBorderSize, w, Height - 2 * mBorderSize);
Rect.RoundToAbove();
Width += w + mBorderSize;
Width = (nuiSize)ToAbove(Width);
pItem->SetLayout(Rect);
mRects[pItem] = Rect;
++rit;
}
delete pIt;
}
return true;
}