void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics* pGraphics, const CFX_RectF* pRtSign, FX_ARGB argbFill, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); FX_FLOAT fBottom = pRtSign->bottom(); FX_FLOAT fRadius = (pRtSign->top - fBottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f)); CFX_PointF ptCenter((pRtSign->left + pRtSign->right()) / 2.0f, (pRtSign->top + fBottom) / 2.0f); FX_FLOAT px[5], py[5]; FX_FLOAT fAngel = FX_PI / 10.0f; for (int32_t i = 0; i < 5; i++) { px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel); py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel); fAngel += FX_PI * 2 / 5.0f; } path.MoveTo(px[0], py[0]); int32_t nNext = 0; for (int32_t j = 0; j < 5; j++) { nNext += 2; if (nNext >= 5) { nNext -= 5; } path.LineTo(px[nNext], py[nNext]); } CFX_Color crFill(argbFill); pGraphics->SaveGraphState(); pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pGraphics->RestoreGraphState(); }
void CFWL_CheckBoxTP::DrawSignDiamond(CFX_Graphics* pGraphics, const CFX_RectF* pRtSign, FX_ARGB argbFill, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); FX_FLOAT fWidth = pRtSign->width; FX_FLOAT fHeight = pRtSign->height; FX_FLOAT fBottom = pRtSign->bottom(); path.MoveTo(pRtSign->left + fWidth / 2, pRtSign->top); path.LineTo(pRtSign->left, pRtSign->top + fHeight / 2); path.LineTo(pRtSign->left + fWidth / 2, fBottom); path.LineTo(pRtSign->right(), pRtSign->top + fHeight / 2); path.LineTo(pRtSign->left + fWidth / 2, pRtSign->top); CFX_Color crFill(argbFill); pGraphics->SaveGraphState(); pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pGraphics->RestoreGraphState(); }
void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, const CFX_RectF* pRect, FX_BOOL bVert, FWLTHEME_STATE eState, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); if (bVert) { FX_FLOAT fPawLen = kPawLength; if (pRect->width / 2 <= fPawLen) { fPawLen = (pRect->width - 6) / 2; } FX_FLOAT fX = pRect->left + pRect->width / 4; FX_FLOAT fY = pRect->top + pRect->height / 2; path.MoveTo(fX, fY - 4); path.LineTo(fX + fPawLen, fY - 4); path.MoveTo(fX, fY - 2); path.LineTo(fX + fPawLen, fY - 2); path.MoveTo(fX, fY); path.LineTo(fX + fPawLen, fY); path.MoveTo(fX, fY + 2); path.LineTo(fX + fPawLen, fY + 2); CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]); pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor(&clrLight); pGraphics->StrokePath(&path); fX++; path.Clear(); path.MoveTo(fX, fY - 3); path.LineTo(fX + fPawLen, fY - 3); path.MoveTo(fX, fY - 1); path.LineTo(fX + fPawLen, fY - 1); path.MoveTo(fX, fY + 1); path.LineTo(fX + fPawLen, fY + 1); path.MoveTo(fX, fY + 3); path.LineTo(fX + fPawLen, fY + 3); CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor(&clrDark); pGraphics->StrokePath(&path, pMatrix); } else { FX_FLOAT fPawLen = kPawLength; if (pRect->height / 2 <= fPawLen) { fPawLen = (pRect->height - 6) / 2; } FX_FLOAT fX = pRect->left + pRect->width / 2; FX_FLOAT fY = pRect->top + pRect->height / 4; path.MoveTo(fX - 4, fY); path.LineTo(fX - 4, fY + fPawLen); path.MoveTo(fX - 2, fY); path.LineTo(fX - 2, fY + fPawLen); path.MoveTo(fX, fY); path.LineTo(fX, fY + fPawLen); path.MoveTo(fX + 2, fY); path.LineTo(fX + 2, fY + fPawLen); CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]); pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor(&clrLight); pGraphics->StrokePath(&path, pMatrix); fY++; path.Clear(); path.MoveTo(fX - 3, fY); path.LineTo(fX - 3, fY + fPawLen); path.MoveTo(fX - 1, fY); path.LineTo(fX - 1, fY + fPawLen); path.MoveTo(fX + 1, fY); path.LineTo(fX + 1, fY + fPawLen); path.MoveTo(fX + 3, fY); path.LineTo(fX + 3, fY + fPawLen); CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor(&clrDark); pGraphics->StrokePath(&path, pMatrix); } }
void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, const CFX_RectF* pRect, FWLTHEME_DIRECTION eDict, FX_ARGB argSign, CFX_Matrix* pMatrix) { bool bVert = (eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down); FX_FLOAT fLeft = (FX_FLOAT)(((pRect->width - (bVert ? 9 : 6)) / 2 + pRect->left) + 0.5); FX_FLOAT fTop = (FX_FLOAT)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5); CFX_Path path; switch (eDict) { case FWLTHEME_DIRECTION_Down: { path.MoveTo(CFX_PointF(fLeft, fTop + 1)); path.LineTo(CFX_PointF(fLeft + 4, fTop + 5)); path.LineTo(CFX_PointF(fLeft + 8, fTop + 1)); path.LineTo(CFX_PointF(fLeft + 7, fTop)); path.LineTo(CFX_PointF(fLeft + 4, fTop + 3)); path.LineTo(CFX_PointF(fLeft + 1, fTop)); break; } case FWLTHEME_DIRECTION_Up: { path.MoveTo(CFX_PointF(fLeft, fTop + 4)); path.LineTo(CFX_PointF(fLeft + 4, fTop)); path.LineTo(CFX_PointF(fLeft + 8, fTop + 4)); path.LineTo(CFX_PointF(fLeft + 7, fTop + 5)); path.LineTo(CFX_PointF(fLeft + 4, fTop + 2)); path.LineTo(CFX_PointF(fLeft + 1, fTop + 5)); break; } case FWLTHEME_DIRECTION_Right: { path.MoveTo(CFX_PointF(fLeft + 1, fTop)); path.LineTo(CFX_PointF(fLeft + 5, fTop + 4)); path.LineTo(CFX_PointF(fLeft + 1, fTop + 8)); path.LineTo(CFX_PointF(fLeft, fTop + 7)); path.LineTo(CFX_PointF(fLeft + 3, fTop + 4)); path.LineTo(CFX_PointF(fLeft, fTop + 1)); break; } case FWLTHEME_DIRECTION_Left: { path.MoveTo(CFX_PointF(fLeft, fTop + 4)); path.LineTo(CFX_PointF(fLeft + 4, fTop)); path.LineTo(CFX_PointF(fLeft + 5, fTop + 1)); path.LineTo(CFX_PointF(fLeft + 2, fTop + 4)); path.LineTo(CFX_PointF(fLeft + 5, fTop + 7)); path.LineTo(CFX_PointF(fLeft + 4, fTop + 8)); break; } } CFX_Color cr(argSign); pGraphics->SetFillColor(&cr); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); }
void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, const CFX_RectF* pRect, FWLTHEME_DIRECTION eDict, FX_ARGB argbFill, FX_BOOL bPressed, CFX_Matrix* pMatrix) { CFX_RectF rtArrow(*pRect); CFX_Path path; path.Create(); FX_FLOAT fBtn = std::min(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator; rtArrow.left = pRect->left + (pRect->width - fBtn) / 2; rtArrow.top = pRect->top + (pRect->height - fBtn) / 2; rtArrow.width = fBtn; rtArrow.height = fBtn; if (bPressed) { rtArrow.Offset(1, 1); } switch (eDict) { case FWLTHEME_DIRECTION_Up: { path.MoveTo(rtArrow.left, rtArrow.bottom()); path.LineTo(rtArrow.right(), rtArrow.bottom()); path.LineTo(rtArrow.left + fBtn / 2, rtArrow.top); path.LineTo(rtArrow.left, rtArrow.bottom()); break; } case FWLTHEME_DIRECTION_Left: { path.MoveTo(rtArrow.right(), rtArrow.top); path.LineTo(rtArrow.right(), rtArrow.bottom()); path.LineTo(rtArrow.left, rtArrow.top + fBtn / 2); path.LineTo(rtArrow.right(), rtArrow.top); break; } case FWLTHEME_DIRECTION_Right: { path.MoveTo(rtArrow.left, rtArrow.top); path.LineTo(rtArrow.left, rtArrow.bottom()); path.LineTo(rtArrow.right(), rtArrow.top + fBtn / 2); path.LineTo(rtArrow.left, rtArrow.top); break; } case FWLTHEME_DIRECTION_Down: default: { path.MoveTo(rtArrow.left, rtArrow.top); path.LineTo(rtArrow.right(), rtArrow.top); path.LineTo(rtArrow.left + fBtn / 2, rtArrow.bottom()); path.LineTo(rtArrow.left, rtArrow.top); } } pGraphics->SaveGraphState(); CFX_Color cr(argbFill); pGraphics->SetFillColor(&cr); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pGraphics->RestoreGraphState(); }
void CFWL_WidgetTP::Draw3DRect(CFX_Graphics* pGraphics, FWLTHEME_EDGE eType, FX_FLOAT fWidth, const CFX_RectF* pRect, FX_ARGB cr1, FX_ARGB cr2, FX_ARGB cr3, FX_ARGB cr4, CFX_Matrix* pMatrix) { if (!pGraphics) return; if (!pRect) return; pGraphics->SaveGraphState(); if (eType == FWLTHEME_EDGE_Flat) { CFX_Path path; path.Create(); path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, pRect->height - 2); CFX_Color cr(ArgbEncode(255, 100, 100, 100)); pGraphics->SetFillColor(&cr); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); path.Clear(); path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, pRect->height - 2); path.AddRectangle(pRect->left + 2, pRect->top + 2, pRect->width - 4, pRect->height - 4); cr.Set(0xFFFFFFFF); pGraphics->SetFillColor(&cr); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } else { FX_FLOAT fLeft = pRect->left; FX_FLOAT fRight = pRect->right(); FX_FLOAT fTop = pRect->top; FX_FLOAT fBottom = pRect->bottom(); FX_FLOAT fHalfWidth = fWidth / 2.0f; CFX_Color crLT(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1); pGraphics->SetFillColor(&crLT); CFX_Path pathLT; pathLT.Create(); pathLT.MoveTo(fLeft, fBottom - fHalfWidth); pathLT.LineTo(fLeft, fTop); pathLT.LineTo(fRight - fHalfWidth, fTop); pathLT.LineTo(fRight - fHalfWidth, fTop + fHalfWidth); pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth); pathLT.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth); pathLT.LineTo(fLeft, fBottom - fHalfWidth); pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix); crLT = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2); pGraphics->SetFillColor(&crLT); pathLT.Clear(); pathLT.MoveTo(fLeft + fHalfWidth, fBottom - fWidth); pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth); pathLT.LineTo(fRight - fWidth, fTop + fHalfWidth); pathLT.LineTo(fRight - fWidth, fTop + fWidth); pathLT.LineTo(fLeft + fWidth, fTop + fWidth); pathLT.LineTo(fLeft + fWidth, fBottom - fWidth); pathLT.LineTo(fLeft + fHalfWidth, fBottom - fWidth); pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix); CFX_Color crRB(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3); pGraphics->SetFillColor(&crRB); CFX_Path pathRB; pathRB.Create(); pathRB.MoveTo(fRight - fHalfWidth, fTop + fHalfWidth); pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth); pathRB.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth); pathRB.LineTo(fLeft + fHalfWidth, fBottom - fWidth); pathRB.LineTo(fRight - fWidth, fBottom - fWidth); pathRB.LineTo(fRight - fWidth, fTop + fHalfWidth); pathRB.LineTo(fRight - fHalfWidth, fTop + fHalfWidth); pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix); crRB = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4); pGraphics->SetFillColor(&crRB); pathRB.Clear(); pathRB.MoveTo(fRight, fTop); pathRB.LineTo(fRight, fBottom); pathRB.LineTo(fLeft, fBottom); pathRB.LineTo(fLeft, fBottom - fHalfWidth); pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth); pathRB.LineTo(fRight - fHalfWidth, fTop); pathRB.LineTo(fRight, fTop); pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix); } pGraphics->RestoreGraphState(); }
void CFWL_FormTP::DrawFormBorder(CFX_Graphics* pGraphics, const CFX_RectF* pRect, FWLTHEME_STATE eState, CFX_Matrix* pMatrix, int32_t iActive) { CFX_RectF rt; rt.Set(pRect->left, pRect->top, 1, pRect->height); FX_FLOAT fBottom, fRight; fBottom = pRect->bottom(); fRight = pRect->right(); CFX_Path path; path.Create(); CFX_Color clrLine; path.Clear(); path.MoveTo(pRect->left, pRect->top); path.LineTo(pRect->left, fBottom - 1); path.LineTo(fRight - 1, fBottom - 1); path.LineTo(fRight - 1, pRect->top); clrLine = m_pThemeData->clrFormBorder[iActive][2]; pGraphics->SetStrokeColor(&clrLine); pGraphics->StrokePath(&path, pMatrix); path.Clear(); path.MoveTo(pRect->left + 1, pRect->top); path.LineTo(pRect->left + 1, fBottom - 2); path.LineTo(fRight - 2, fBottom - 2); path.LineTo(fRight - 2, pRect->top); clrLine = m_pThemeData->clrFormBorder[iActive][1]; pGraphics->SetStrokeColor(&clrLine); pGraphics->StrokePath(&path, pMatrix); path.Clear(); path.MoveTo(pRect->left + 2, pRect->top); path.LineTo(pRect->left + 2, fBottom - 3); path.LineTo(fRight - 3, fBottom - 3); path.LineTo(fRight - 3, pRect->top); clrLine = m_pThemeData->clrFormBorder[iActive][0]; pGraphics->SetStrokeColor(&clrLine); pGraphics->StrokePath(&path, pMatrix); path.Clear(); path.MoveTo(pRect->left + 3, pRect->top); path.LineTo(pRect->left + 3, fBottom - 4); path.LineTo(fRight - 4, fBottom - 4); path.LineTo(fRight - 4, pRect->top); clrLine = m_pThemeData->clrFormBorder[iActive][4]; pGraphics->SetStrokeColor(&clrLine); pGraphics->StrokePath(&path, pMatrix); m_rtDisLBorder.Set(pRect->left, pRect->top + 29, 4, pRect->height - 29); m_rtDisRBorder.Set(pRect->right() - 4, pRect->top + 29, 4, pRect->height - 29); m_rtDisBBorder.Set(pRect->left, pRect->bottom() - 4, pRect->width, 4); m_rtDisCaption.Set(pRect->left, pRect->top, pRect->width, 29); }
FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { switch (pParams->m_iPart) { case CFWL_Part::Border: { DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); break; } case CFWL_Part::Edge: { DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix); break; } case CFWL_Part::Background: { CFX_RectF& rect = pParams->m_rtPart; FX_FLOAT fRight = rect.right(); FX_FLOAT fBottom = rect.bottom(); CFX_Path strokePath; strokePath.Create(); strokePath.MoveTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top); strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, rect.top); strokePath.LineTo(fRight, rect.top + PUSHBUTTON_SIZE_Corner); strokePath.LineTo(fRight, fBottom - PUSHBUTTON_SIZE_Corner); strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, fBottom); strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, fBottom); strokePath.LineTo(rect.left, fBottom - PUSHBUTTON_SIZE_Corner); strokePath.LineTo(rect.left, rect.top + PUSHBUTTON_SIZE_Corner); strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top); CFX_Path fillPath; fillPath.Create(); fillPath.AddSubpath(&strokePath); CFX_Graphics* pGraphics = pParams->m_pGraphics; pGraphics->SaveGraphState(); CFX_RectF rtInner(rect); rtInner.Deflate(PUSHBUTTON_SIZE_Corner + 1, PUSHBUTTON_SIZE_Corner + 1, PUSHBUTTON_SIZE_Corner, PUSHBUTTON_SIZE_Corner); fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); int32_t iColor = GetColorID(pParams->m_dwStates); DrawAxialShading(pGraphics, rect.left + PUSHBUTTON_SIZE_Corner, rect.top, rect.left + PUSHBUTTON_SIZE_Corner, rect.bottom(), m_pThemeData->clrStart[iColor], m_pThemeData->clrEnd[iColor], &fillPath, FXFILL_ALTERNATE, &pParams->m_matrix); CFX_Color crStroke(m_pThemeData->clrBorder[iColor]); pGraphics->SetStrokeColor(&crStroke); pGraphics->StrokePath(&strokePath, &pParams->m_matrix); fillPath.Clear(); fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); CFX_Color crFill(m_pThemeData->clrFill[iColor]); pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix); if (pParams->m_dwStates & CFWL_PartState_Focused) { rtInner.Inflate(1, 1, 0, 0); DrawFocus(pGraphics, &rtInner, &pParams->m_matrix); } pGraphics->RestoreGraphState(); break; } default: {} } return TRUE; }