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; }
void nuiLabel::CalcLayout() { if (mpFont) { if (mTextChanged || mFontChanged || !mpLayout) { delete mpLayout; delete mpIdealLayout; mpLayout = NULL; mpIdealLayout = NULL; mpLayout = new nuiTextLayout(mpFont, mOrientation); mpLayout->SetTextLayoutMode(mTextLayoutMode); mpLayout->SetUnderline(mUnderline); mpLayout->SetStrikeThrough(mStrikeThrough); mpIdealLayout = new nuiTextLayout(mpFont, mOrientation); mpIdealLayout->SetTextLayoutMode(mTextLayoutMode); mpIdealLayout->SetUnderline(mUnderline); mpIdealLayout->SetStrikeThrough(mStrikeThrough); mFontChanged = false; NGL_ASSERT(mpLayout); NGL_ASSERT(mpIdealLayout); if (mWrapping) { //NGL_OUT(_T("Setting wrapping to %f\n"), mConstraint.mMaxWidth); float wrap1 = mConstraint.mMaxWidth; float wrap2 = MAX(GetMaxIdealWidth(), GetUserWidth()); float wrap = 0; if (wrap1 > 0 && wrap2 > 0) wrap = MIN(wrap1, wrap2); else wrap = MAX(wrap1, wrap2); NGL_ASSERT(mpLayout); NGL_ASSERT(mpIdealLayout); mpLayout->SetWrapX(wrap - mBorderLeft - mBorderRight); mpIdealLayout->SetWrapX(wrap - mBorderLeft - mBorderRight); } else { NGL_ASSERT(mpLayout); NGL_ASSERT(mpIdealLayout); mpLayout->SetWrapX(0); mpIdealLayout->SetWrapX(0); } NGL_ASSERT(mpLayout); NGL_ASSERT(mpIdealLayout); mpLayout->Layout(mText); mpIdealLayout->Layout(mText); GetLayoutRect(); mTextChanged = false; mFontChanged = false; } } }
void CWndWindow::Draw() { if (!s_showGrid) return; const QSize clientSize = m_clientRect.size(); if (!HasFlag(WBS_NOFRAME)) m_render2D->RenderRect(GetLayoutRect(), 0xff808080); else m_render2D->RenderRect(QRect(QPoint(8, 8), m_clientRect.size() - QSize(16, 16)), 0xff808080); int y; for (int x = 0; x < clientSize.width(); x += s_gridSize * 10) for (y = 0; y < clientSize.height(); y += s_gridSize * 10) m_render2D->RenderPoint(QPoint(x, y), 0xff808080); }
BOOL CWndGuideTextMgr::OnEraseBkgnd( C2DRender* p2DRender ) { CWndGuideSystem* pWndGuide = (CWndGuideSystem*)GetWndBase( APP_GUIDE ); if( !pWndGuide ) return FALSE; CRect rect = GetLayoutRect(); rect.bottom = rect.bottom+5; p2DRender->m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); if(m_pTextureBG) m_pTextureBG->Render( p2DRender, CPoint(8,0), CPoint( rect.right, rect.bottom ), 200 ); //p2DRender->RenderFillRect( CRect( 8, -8, rect.right, rect.bottom ), D3DXCOLOR( 1.0f, 1.0f, 1.0f, 0.8f ) ); //p2DRender->RenderFillRect( CRect( rect.right, 8, rect.right+3, rect.bottom+3 ), D3DXCOLOR( 0.0f, 0.0f, 0.0f, 1.0f ) ); //p2DRender->RenderFillRect( CRect( 8+3, rect.bottom, rect.right+3, rect.bottom+3 ), D3DXCOLOR( 0.0f, 0.0f, 0.0f, 1.0f ) ); return TRUE; }