OP_STATUS SVGCanvasState::SetDecorationPaint() { SVGCanvasState* decostate = GetDecorationState(); if (decostate == this) return OpStatus::OK; if (decostate != NULL) { SetFillColor(decostate->m_fillcolor); switch (decostate->m_use_fill) { #ifdef SVG_SUPPORT_PAINTSERVERS case USE_PSERVER: SVGPaintServer::IncRef(decostate->m_fill_pserver); SetFillPaintServer(decostate->m_fill_pserver); break; #endif // SVG_SUPPORT_PAINTSERVERS } EnableFill(decostate->m_use_fill); SetStrokeColor(decostate->m_strokecolor); switch (decostate->m_use_stroke) { #ifdef SVG_SUPPORT_PAINTSERVERS case USE_PSERVER: SVGPaintServer::IncRef(decostate->m_stroke_pserver); SetStrokePaintServer(decostate->m_stroke_pserver); break; #endif // SVG_SUPPORT_PAINTSERVERS } EnableStroke(decostate->m_use_stroke); } else { // Use default paint EnableFill(SVGCanvasState::USE_COLOR); SetFillColorRGB(0,0,0); SetFillOpacity(0xff); EnableStroke(SVGCanvasState::USE_NONE); } return OpStatus::OK; }
void REPainter::DrawTextInRect(const std::string& textUTF8, const RERect& rect, const std::string& fontNameUTF8, unsigned int flags, float size, const REColor& color) { if(!_painter) return; QFont::Weight weight = (flags & REPainter::Bold ? QFont::Bold : QFont::Normal); QFont font(QString::fromStdString(fontNameUTF8), size, weight, flags & REPainter::Italic); font.setPixelSize(size); _painter->setFont(font); SetStrokeColor(color); int qAlignFlags = 0; if(flags & REPainter::LeftAligned) qAlignFlags |= Qt::AlignLeft; else if(flags & REPainter::RightAligned) qAlignFlags |= Qt::AlignRight; else qAlignFlags |= Qt::AlignHCenter; int qflags = qAlignFlags | Qt::AlignTop | Qt::TextDontClip | Qt::TextSingleLine; QRectF rc = rect.ToQRectF(); _painter->setFont(font); _painter->drawText(rc, qflags, QString::fromStdString(textUTF8)); }
void CLabelUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if( _tcscmp(pstrName, _T("align")) == 0 ) { if( _tcsstr(pstrValue, _T("left")) != NULL ) { m_uTextStyle &= ~(DT_CENTER | DT_RIGHT | DT_SINGLELINE); m_uTextStyle |= DT_LEFT; } if( _tcsstr(pstrValue, _T("center")) != NULL ) { m_uTextStyle &= ~(DT_LEFT | DT_RIGHT ); m_uTextStyle |= DT_CENTER; } if( _tcsstr(pstrValue, _T("right")) != NULL ) { m_uTextStyle &= ~(DT_LEFT | DT_CENTER | DT_SINGLELINE); m_uTextStyle |= DT_RIGHT; } } else if( _tcscmp(pstrName, _T("valign")) == 0 ) { if( _tcsstr(pstrValue, _T("top")) != NULL ) { m_uTextStyle &= ~(DT_BOTTOM | DT_VCENTER); m_uTextStyle |= (DT_TOP | DT_SINGLELINE); } if( _tcsstr(pstrValue, _T("vcenter")) != NULL ) { m_uTextStyle &= ~(DT_TOP | DT_BOTTOM ); m_uTextStyle |= (DT_VCENTER | DT_SINGLELINE); } if( _tcsstr(pstrValue, _T("bottom")) != NULL ) { m_uTextStyle &= ~(DT_TOP | DT_VCENTER); m_uTextStyle |= (DT_BOTTOM | DT_SINGLELINE); } } else if( _tcscmp(pstrName, _T("endellipsis")) == 0 ) { if( _tcscmp(pstrValue, _T("true")) == 0 ) m_uTextStyle |= DT_END_ELLIPSIS; else m_uTextStyle &= ~DT_END_ELLIPSIS; } else if( _tcscmp(pstrName, _T("font")) == 0 ) SetFont(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("textcolor")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetTextColor(clrColor); } else if( _tcscmp(pstrName, _T("disabledtextcolor")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetDisabledTextColor(clrColor); } else if( _tcscmp(pstrName, _T("textpadding")) == 0 ) { RECT rcTextPadding = { 0 }; LPTSTR pstr = NULL; rcTextPadding.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcTextPadding.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcTextPadding.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcTextPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetTextPadding(rcTextPadding); } else if( _tcscmp(pstrName, _T("showhtml")) == 0 ) SetShowHtml(_tcscmp(pstrValue, _T("true")) == 0); else if( _tcscmp(pstrName, _T("enabledeffect")) == 0 ) SetEnabledEffect(_tcscmp(pstrValue, _T("true")) == 0); else if( _tcscmp(pstrName, _T("transshadow")) == 0 ) SetTransShadow(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("transtext")) == 0 ) SetTransText(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("transshadow1")) == 0 ) SetTransShadow1(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("transtext1")) == 0 ) SetTransText1(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("gradientangle")) == 0 ) SetGradientAngle(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("enabledstroke")) == 0 ) SetEnabledStroke(_tcscmp(pstrValue, _T("true")) == 0); else if( _tcscmp(pstrName, _T("enabledshadow")) == 0 ) SetEnabledShadow(_tcscmp(pstrValue, _T("true")) == 0); else if( _tcscmp(pstrName, _T("transstroke")) == 0 ) SetTransStroke(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("gradientlength")) == 0 ) SetGradientLength(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("shadowoffset")) == 0 ){ LPTSTR pstr = NULL; int offsetx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); int offsety = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetShadowOffset(offsetx,offsety); } else if( _tcscmp(pstrName, _T("textcolor1")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetTextColor1(clrColor); } else if( _tcscmp(pstrName, _T("textshadowcolora")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetTextShadowColorA(clrColor); } else if( _tcscmp(pstrName, _T("textshadowcolorb")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetTextShadowColorB(clrColor); } else if( _tcscmp(pstrName, _T("strokecolor")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetStrokeColor(clrColor); } else if( _tcscmp(pstrName, _T("autocalcwidth")) == 0 ) { SetAutoCalcWidth(_tcscmp(pstrValue, _T("true")) == 0); } else CControlUI::SetAttribute(pstrName, pstrValue); }
bool nuiPopupMenu::DrawTree(nuiDrawContext* pContext, nuiTreeNode* pTree, uint depth) { nuiTreeNode* pChildNode; nuiTreeNode* pOpenedNode = NULL; nuiWidget* pChildWidget; nuiRect WidgetRect; NGL_ASSERT(depth < mRects.size()); nuiMenuRect* pRect= mRects[depth]; NGL_ASSERT(pTree); nuiTheme* pTheme = GetTheme(); NGL_ASSERT(pTheme); if (pTree != mpTree) // then Draw a new rect for this depth { pTheme->DrawMenuWindow(pContext, pRect->mRect, this); if (pRect->mpSBar->IsVisible(false)) DrawChild(pContext, pRect->mpSBar); } uint32 count = pTree->GetChildrenCount(); for (uint32 i = 0; i < count; i++) { pChildNode = dynamic_cast<nuiTreeNode*>(pTree->GetChild(i)); pChildWidget = pChildNode->GetElement(); WidgetRect = pChildWidget->GetRect(); if (pChildNode->IsSelected() || pChildNode->IsOpened()) { nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f; nuiRect r = WidgetRect; r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight()); pTheme->DrawSelectionBackground(pContext, r, this); } if (!pChildNode->IsEmpty()) { nuiRect r = WidgetRect; r.Move(WidgetRect.GetWidth(), 0); r.SetSize(NUI_POPUP_TREE_HANDLE_SIZE-4.f, r.GetHeight()); pContext->SetFillColor(GetColor(eTreeViewHandle)); pTheme->DrawTreeHandle(pContext, r, false, NUI_POPUP_TREE_HANDLE_SIZE-4.f); } DrawChild(pContext, pChildWidget); if (pChildNode->IsSelected() || pChildNode->IsOpened()) { nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f; nuiRect r = WidgetRect; r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight()); pTheme->DrawSelectionForeground(pContext, r, this); } if (pChildNode->IsOpened()) { pOpenedNode = pChildNode; } } if (pRect->mpSBar->IsVisible(false)) { SetFillColor(pContext, eMenuBg); SetStrokeColor(pContext, eNormalTextFg); pContext->EnableBlending(true); nuiGradient grad; nuiColor bg(GetColor(eMenuBg)); grad.AddStop(bg, 1); bg.Multiply(0); grad.AddStop(bg, 0); if (pRect->mpSBar->GetRange().GetValue() + pRect->mpSBar->GetRange().GetPageSize() < pRect->mpSBar->GetRange().GetMaximum()) { nuiRect r(pRect->mRect.Left() + 2, mRect.Bottom() - AUTOSCROLL_HEIGHT * 2, pRect->mRect.GetWidth() - SB_WIDTH - 2, AUTOSCROLL_HEIGHT * 2); pContext->DrawGradient(grad, r, 0, mRect.Bottom() - AUTOSCROLL_HEIGHT * 2, 0, mRect.Bottom()); float w = pRect->mRect.GetWidth() - SB_WIDTH; float x = pRect->mRect.Left(); float y = mRect.Bottom() - AUTOSCROLL_HEIGHT; float s = 8; pContext->DrawLine(x + w/2 - s, y + 4, x + w/2 + s, y + 4); pContext->DrawLine(x + w/2 + s, y + 4, x + w/2, y + 4 + s); pContext->DrawLine(x + w/2, y + 4 + s, x + w/2 - s, y + 4); } if (pRect->mpSBar->GetRange().GetValue() > pRect->mpSBar->GetRange().GetMinimum()) { nuiRect r(pRect->mRect.Left() + 2, 0.0f, pRect->mRect.GetWidth() - SB_WIDTH - 2, AUTOSCROLL_HEIGHT * 2); pContext->DrawGradient(grad, r, 0, AUTOSCROLL_HEIGHT * 2, 0, 0); float w = pRect->mRect.GetWidth() - SB_WIDTH; float x = pRect->mRect.Left(); float s = 8; pContext->DrawLine(x + w/2, 4, x + w/2 - s, 4 + s); pContext->DrawLine(x + w/2 - s, 4 + s, x + w/2 + s, 4 + s); pContext->DrawLine(x + w/2 + s, 4 + s, x + w/2, 4); } pContext->EnableBlending(false); } if (pOpenedNode) DrawTree(pContext, pOpenedNode, depth+1); pTheme->Release(); return true; }