void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics, const CFX_RectF* pRect, FX_BOOL bVert, FWLTHEME_STATE eState, FX_BOOL bLowerTrack, CFX_Matrix* pMatrix) { if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) { return; } pGraphics->SaveGraphState(); CFX_Color colorLine(ArgbEncode(255, 238, 237, 229)); CFX_Path path; path.Create(); FX_FLOAT fRight = pRect->right(); FX_FLOAT fBottom = pRect->bottom(); if (bVert) { path.AddRectangle(pRect->left, pRect->top, 1, pRect->height); path.AddRectangle(fRight - 1, pRect->top, 1, pRect->height); } else { path.AddRectangle(pRect->left, pRect->top, pRect->width, 1); path.AddRectangle(pRect->left, fBottom - 1, pRect->width, 1); } pGraphics->SetFillColor(&colorLine); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); path.Clear(); path.AddRectangle(pRect->left + 1, pRect->top, pRect->width - 2, pRect->height); FX_FLOAT x1 = bVert ? pRect->left + 1 : pRect->left; FX_FLOAT y1 = bVert ? pRect->top : pRect->top + 1; FX_FLOAT x2 = bVert ? fRight - 1 : pRect->left; FX_FLOAT y2 = bVert ? pRect->top : fBottom - 1; pGraphics->RestoreGraphState(); DrawAxialShading(pGraphics, x1, y1, x2, y2, m_pThemeData->clrTrackBKStart, m_pThemeData->clrTrackBKEnd, &path, FXFILL_WINDING, pMatrix); }
void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics, const CFX_RectF* pRect, FX_BOOL bVert, FWLTHEME_STATE eState, FX_BOOL bPawButton, CFX_Matrix* pMatrix) { if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) { return; } CFX_Path path; path.Create(); CFX_RectF rect(*pRect); if (bVert) { rect.Deflate(1, 0); if (rect.IsEmpty(0.1f)) { return; } path.AddRectangle(rect.left, rect.top, rect.width, rect.height); DrawAxialShading(pGraphics, rect.left, rect.top, rect.right(), rect.top, m_pThemeData->clrBtnBK[eState - 1][0], m_pThemeData->clrBtnBK[eState - 1][1], &path, FXFILL_WINDING, pMatrix); CFX_Color rcStroke; rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]); pGraphics->SaveGraphState(); pGraphics->SetStrokeColor(&rcStroke); pGraphics->StrokePath(&path, pMatrix); pGraphics->RestoreGraphState(); } else { rect.Deflate(0, 1); if (rect.IsEmpty(0.1f)) { return; } path.AddRectangle(rect.left, rect.top, rect.width, rect.height); DrawAxialShading(pGraphics, rect.left, rect.top, rect.left, rect.bottom(), m_pThemeData->clrBtnBK[eState - 1][0], m_pThemeData->clrBtnBK[eState - 1][1], &path, FXFILL_WINDING, pMatrix); CFX_Color rcStroke; rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]); pGraphics->SaveGraphState(); pGraphics->SetStrokeColor(&rcStroke); pGraphics->StrokePath(&path, pMatrix); pGraphics->RestoreGraphState(); } }
void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget* pWidget, CFX_Graphics* pGraphics, const CFX_RectF* pRect, uint32_t dwStates, CFX_Matrix* pMatrix) { dwStates &= 0x03; int32_t fillMode = FXFILL_WINDING; uint32_t dwStyleEx = pWidget->GetStylesEx(); dwStyleEx &= FWL_STYLEEXT_CKB_ShapeMask; CFX_Path path; path.Create(); FX_FLOAT fRight = pRect->right(); FX_FLOAT fBottom = pRect->bottom(); bool bClipSign = !!(dwStates & CFWL_PartState_Hovered); if ((dwStyleEx == FWL_STYLEEXT_CKB_ShapeSolidSquare) || (dwStyleEx == FWL_STYLEEXT_CKB_ShapeSunkenSquare)) { path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); if (bClipSign) { fillMode = FXFILL_ALTERNATE; path.AddRectangle(pRect->left + kSignMargin, pRect->top + kSignMargin, pRect->width - kSignMargin * 2, pRect->height - kSignMargin * 2); } } else { CFX_RectF rect(*pRect); rect.Deflate(0, 0, 1, 1); path.AddEllipse(rect); if (bClipSign) { fillMode = FXFILL_ALTERNATE; CFX_RectF rtClip(rect); rtClip.Deflate(kSignMargin - 1, kSignMargin - 1); path.AddEllipse(rtClip); } } int32_t iTheme = 1; if (dwStates & CFWL_PartState_Hovered) { iTheme = 2; } else if (dwStates & CFWL_PartState_Pressed) { iTheme = 3; } else if (dwStates & CFWL_PartState_Disabled) { iTheme = 4; } if (dwStates & CFWL_PartState_Checked) { iTheme += 4; } else if (dwStates & CFWL_PartState_Neutral) { iTheme += 8; } DrawAxialShading(pGraphics, pRect->left - 1, pRect->top - 1, fRight, fBottom, m_pThemeData->clrBoxBk[iTheme][0], m_pThemeData->clrBoxBk[iTheme][1], &path, fillMode, pMatrix); }
void CFWL_FormTP::DrawMinMaxBoxCommon(CFX_Graphics* pGraphics, const CFX_RectF* pRect, FWLTHEME_STATE eState, CFX_Matrix* pMatrix, int32_t iActive) { pGraphics->SaveGraphState(); FX_FLOAT fRight = pRect->right(); FX_FLOAT fBottom = pRect->bottom(); FX_FLOAT fWidth = pRect->width; FX_FLOAT fHeight = pRect->height; CFX_RectF rt(*pRect); pGraphics->SetLineWidth(1.0f); CFX_Path path; path.Create(); path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1); path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2); path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2); path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1); CFX_Color crFill; crFill = m_pThemeData->clrBtnEdgeOut[iActive]; pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); path.Clear(); path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1); path.AddRectangle(fRight - 2, rt.top + 1, 1, 1); path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1); path.AddRectangle(fRight - 2, fBottom - 2, 1, 1); crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1]; pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); path.Clear(); path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1); path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4); crFill = m_pThemeData->clrNormalBtEdgeLight[iActive][eState - 1]; pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); path.Clear(); path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4); path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1); crFill = m_pThemeData->clrNormalBtEdgeDark[iActive][eState - 1]; pGraphics->SetFillColor(&crFill); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pGraphics->RestoreGraphState(); path.Clear(); path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4); DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2, fBottom - 2, m_pThemeData->clrNormalBtBKStart[iActive][eState - 1], m_pThemeData->clrNormalBtBKEnd[iActive][eState - 1], &path, FXFILL_WINDING, pMatrix); }
void CFWL_FormTP::InitCaption(FX_BOOL bActive) { if (bActive) { CFX_FxgeDevice dev; CFX_Graphics gs; CFX_Path path; path.Create(); if (m_pActiveBitmap) { delete m_pActiveBitmap; m_pActiveBitmap = NULL; } m_pActiveBitmap = new CFX_DIBitmap; m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); dev.Attach(m_pActiveBitmap); gs.Create(&dev); path.AddRectangle(0, 0, 1, 5); DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[0][0], m_pThemeData->clrHeadBK[0][1], &path); path.Clear(); path.AddRectangle(0, 5, 1, 15); DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[0][1], m_pThemeData->clrHeadBK[0][2], &path); path.Clear(); path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19); DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption, m_pThemeData->clrHeadBK[0][2], m_pThemeData->clrHeadBK[0][3], &path); } else { CFX_FxgeDevice dev; CFX_Graphics gs; CFX_Path path; path.Create(); if (m_pDeactivebitmap) { delete m_pDeactivebitmap; m_pDeactivebitmap = NULL; } m_pDeactivebitmap = new CFX_DIBitmap; m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); dev.Attach(m_pDeactivebitmap); gs.Create(&dev); path.AddRectangle(0, 0, 1, 5); DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[1][0], m_pThemeData->clrHeadBK[1][1], &path); path.Clear(); path.AddRectangle(0, 5, 1, 15); DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[1][1], m_pThemeData->clrHeadBK[1][2], &path); path.Clear(); path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19); DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption, m_pThemeData->clrHeadBK[1][2], m_pThemeData->clrHeadBK[1][3], &path); } }
void CFWL_WidgetTP::DrawBtn(CFX_Graphics* pGraphics, const CFX_RectF* pRect, FWLTHEME_STATE eState, CFX_Matrix* pMatrix) { CFX_Path path; InitializeArrowColorData(); FX_FLOAT fRight = pRect->right(); FX_FLOAT fBottom = pRect->bottom(); path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); DrawAxialShading(pGraphics, pRect->left, pRect->top, fRight, fBottom, m_pColorData->clrStart[eState - 1], m_pColorData->clrEnd[eState - 1], &path, FXFILL_WINDING, pMatrix); CFX_Color rcStroke; rcStroke.Set(m_pColorData->clrBorder[eState - 1]); pGraphics->SetStrokeColor(&rcStroke); pGraphics->StrokePath(&path, pMatrix); }
void CFWL_WidgetTP::DrawBtn(CFX_Graphics* pGraphics, const CFX_RectF* pRect, FWLTHEME_STATE eState, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); if (!CFWL_ArrowData::IsInstance()) { CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID)); } CFWL_ArrowData::CColorData* pColorData = CFWL_ArrowData::GetInstance()->m_pColorData; FX_FLOAT fRight = pRect->right(); FX_FLOAT fBottom = pRect->bottom(); path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); DrawAxialShading(pGraphics, pRect->left, pRect->top, fRight, fBottom, pColorData->clrStart[eState - 1], pColorData->clrEnd[eState - 1], &path, FXFILL_WINDING, pMatrix); CFX_Color rcStroke; rcStroke.Set(pColorData->clrBorder[eState - 1]); pGraphics->SetStrokeColor(&rcStroke); pGraphics->StrokePath(&path, pMatrix); }
void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, CFX_Matrix* pMatrix, FX_RECT& clip_rect, int alpha, FX_BOOL bAlphaMode) { CPDF_Function** pFuncs = pPattern->m_pFunctions; int nFuncs = pPattern->m_nFuncs; CPDF_Dictionary* pDict = pPattern->m_pShadingObj->GetDict(); CPDF_ColorSpace* pColorSpace = pPattern->m_pCS; if (!pColorSpace) { return; } FX_ARGB background = 0; if (!pPattern->m_bShadingObj && pPattern->m_pShadingObj->GetDict()->KeyExist("Background")) { CPDF_Array* pBackColor = pPattern->m_pShadingObj->GetDict()->GetArray("Background"); if (pBackColor && pBackColor->GetCount() >= (FX_DWORD)pColorSpace->CountComponents()) { CFX_FixedBufGrow<FX_FLOAT, 16> comps(pColorSpace->CountComponents()); for (int i = 0; i < pColorSpace->CountComponents(); i++) { comps[i] = pBackColor->GetNumber(i); } FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; pColorSpace->GetRGB(comps, R, G, B); background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255), (int32_t)(B * 255)); } } if (pDict->KeyExist("BBox")) { CFX_FloatRect rect = pDict->GetRect("BBox"); rect.Transform(pMatrix); clip_rect.Intersect(rect.GetOutterRect()); } CPDF_DeviceBuffer buffer; buffer.Initialize(m_pContext, m_pDevice, &clip_rect, m_pCurObj, 150); CFX_Matrix FinalMatrix = *pMatrix; FinalMatrix.Concat(*buffer.GetMatrix()); CFX_DIBitmap* pBitmap = buffer.GetBitmap(); if (!pBitmap->GetBuffer()) { return; } pBitmap->Clear(background); int fill_mode = m_Options.m_Flags; switch (pPattern->m_ShadingType) { case kInvalidShading: case kMaxShading: return; case kFunctionBasedShading: DrawFuncShading(pBitmap, &FinalMatrix, pDict, pFuncs, nFuncs, pColorSpace, alpha); break; case kAxialShading: DrawAxialShading(pBitmap, &FinalMatrix, pDict, pFuncs, nFuncs, pColorSpace, alpha); break; case kRadialShading: DrawRadialShading(pBitmap, &FinalMatrix, pDict, pFuncs, nFuncs, pColorSpace, alpha); break; case kFreeFormGouraudTriangleMeshShading: { DrawFreeGouraudShading(pBitmap, &FinalMatrix, ToStream(pPattern->m_pShadingObj), pFuncs, nFuncs, pColorSpace, alpha); } break; case kLatticeFormGouraudTriangleMeshShading: { DrawLatticeGouraudShading(pBitmap, &FinalMatrix, ToStream(pPattern->m_pShadingObj), pFuncs, nFuncs, pColorSpace, alpha); } break; case kCoonsPatchMeshShading: case kTensorProductPatchMeshShading: { DrawCoonPatchMeshes( pPattern->m_ShadingType == kTensorProductPatchMeshShading, pBitmap, &FinalMatrix, ToStream(pPattern->m_pShadingObj), pFuncs, nFuncs, pColorSpace, fill_mode, alpha); } break; } if (bAlphaMode) { pBitmap->LoadChannel(FXDIB_Red, pBitmap, FXDIB_Alpha); } if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) { pBitmap->ConvertColorScale(m_Options.m_ForeColor, m_Options.m_BackColor); } buffer.OutputToDevice(); }
void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget* pWidget, CFX_Graphics* pGraphics, const CFX_RectF* pRect, FX_DWORD dwStates, CFX_Matrix* pMatrix) { dwStates &= 0x03; int32_t fillMode = FXFILL_WINDING; FX_DWORD dwStyleEx = pWidget->GetStylesEx(); dwStyleEx &= FWL_STYLEEXT_CKB_ShapeMask; CFX_Path path; path.Create(); FX_FLOAT fRight = pRect->right(); FX_FLOAT fBottom = pRect->bottom(); FX_BOOL bClipSign = (dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered; if ((dwStyleEx == FWL_STYLEEXT_CKB_ShapeSolidSquare) || (dwStyleEx == FWL_STYLEEXT_CKB_ShapeSunkenSquare)) { path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); if (bClipSign) { fillMode = FXFILL_ALTERNATE; path.AddRectangle(pRect->left + CHECKBOX_SIZE_SIGNMARGIN, pRect->top + CHECKBOX_SIZE_SIGNMARGIN, pRect->width - CHECKBOX_SIZE_SIGNMARGIN * 2, pRect->height - CHECKBOX_SIZE_SIGNMARGIN * 2); } } else { #ifdef CHECKBOX_FXGE_CoordinatesAdjust CFX_RectF rect(*pRect); rect.Deflate(0, 0, 1, 1); path.AddEllipse(rect); #else path.AddEllipse(*pRect); #endif if (bClipSign) { fillMode = FXFILL_ALTERNATE; #ifdef CHECKBOX_FXGE_CoordinatesAdjust CFX_RectF rtClip(rect); #else CFX_RectF rtClip(*pRect); #endif rtClip.Deflate(CHECKBOX_SIZE_SIGNMARGIN - 1, CHECKBOX_SIZE_SIGNMARGIN - 1); path.AddEllipse(rtClip); } } int32_t iTheme = 1; if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered) { iTheme = 2; } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Pressed) { iTheme = 3; } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled) { iTheme = 4; } if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) { iTheme += 4; } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Neutral) { iTheme += 8; } DrawAxialShading(pGraphics, pRect->left - 1, pRect->top - 1, fRight, fBottom, m_pThemeData->clrBoxBk[iTheme][0], m_pThemeData->clrBoxBk[iTheme][1], &path, fillMode, pMatrix); }
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; }