diff options
Diffstat (limited to 'xfa/fwl')
-rw-r--r-- | xfa/fwl/theme/cfwl_checkboxtp.cpp | 238 | ||||
-rw-r--r-- | xfa/fwl/theme/cfwl_checkboxtp.h | 24 | ||||
-rw-r--r-- | xfa/fwl/theme/cfwl_edittp.cpp | 20 |
3 files changed, 72 insertions, 210 deletions
diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp index 9a96eedb04..2eef204a25 100644 --- a/xfa/fwl/theme/cfwl_checkboxtp.cpp +++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp @@ -17,8 +17,6 @@ namespace { -const int kSignMargin = 3; -const int kSignBorder = 2; const int kSignPath = 100; } // namespace @@ -56,46 +54,6 @@ FX_BOOL CFWL_CheckBoxTP::DrawText(CFWL_ThemeText* pParams) { return CFWL_WidgetTP::DrawText(pParams); } -FX_BOOL CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - 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: { - FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, - &pParams->m_matrix); - if (pParams->m_dwStates & CFWL_PartState_Focused) { - pParams->m_rtPart = *(CFX_RectF*)pParams->m_pData; - DrawFocus(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - } - break; - } - case CFWL_Part::CheckBox: { - DrawBoxBk(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, - pParams->m_dwStates, &pParams->m_matrix); - if ((pParams->m_dwStates & CFWL_PartState_Checked) | - (pParams->m_dwStates & CFWL_PartState_Neutral)) { - DrawSign(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, - pParams->m_dwStates, &pParams->m_matrix); - } - DrawSignBorder( - pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, - pParams->m_dwStates & CFWL_PartState_Disabled, &pParams->m_matrix); - break; - } - default: { return FALSE; } - } - return TRUE; -} - FWL_Error CFWL_CheckBoxTP::Initialize() { InitTTO(); return CFWL_WidgetTP::Initialize(); @@ -106,123 +64,6 @@ FWL_Error CFWL_CheckBoxTP::Finalize() { return CFWL_WidgetTP::Finalize(); } -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_CheckBoxTP::DrawSign(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - uint32_t dwStates, - CFX_Matrix* pMatrix) { - CFX_RectF rtSign(*pRtBox); - rtSign.Deflate(kSignMargin, kSignMargin); - uint32_t dwColor = m_pThemeData->clrSignCheck; - bool bCheck = true; - if ((dwStates & CFWL_PartState_Disabled) && - (dwStates & CFWL_PartState_Checked)) { - dwColor = m_pThemeData->clrSignBorderDisable; - } else if (dwStates & CFWL_PartState_Neutral) { - if (dwStates & CFWL_PartState_Hovered) { - dwColor = m_pThemeData->clrSignNeutralHover; - } else if (dwStates & CFWL_PartState_Pressed) { - dwColor = m_pThemeData->clrSignNeutralPressed; - } else if (dwStates & CFWL_PartState_Disabled) { - dwColor = m_pThemeData->clrSignBorderDisable; - } else { - dwColor = m_pThemeData->clrSignNeutralNormal; - } - bCheck = false; - } - if (bCheck) { - uint32_t dwStyle = pWidget->GetStylesEx(); - switch (dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) { - case FWL_STYLEEXT_CKB_SignShapeCheck: { - DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeCircle: { - rtSign.Deflate(1, 1); - DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeCross: { - DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeDiamond: { - DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeSquare: { - DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeStar: { - DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - } - } else { - FillSoildRect(pGraphics, ArgbEncode(255, 33, 161, 33), &rtSign, pMatrix); - } -} - -void CFWL_CheckBoxTP::DrawSignNeutral(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - CFX_Matrix* pMatrix) { - ((CFX_RectF*)pRtSign)->Inflate(-3, -3); - FillSoildRect(pGraphics, m_pThemeData->clrSignNeutral, pRtSign, pMatrix); -} - void CFWL_CheckBoxTP::DrawSignCheck(CFX_Graphics* pGraphics, const CFX_RectF* pRtSign, FX_ARGB argbFill, @@ -343,39 +184,6 @@ void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics* pGraphics, pGraphics->RestoreGraphState(); } -void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - FX_BOOL bDisable, - CFX_Matrix* pMatrix) { - switch (pWidget->GetStylesEx() & FWL_STYLEEXT_CKB_ShapeMask) { - case FWL_STYLEEXT_CKB_ShapeSolidSquare: { - DrawAnnulusRect(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable - : m_pThemeData->clrSignBorderNormal, - pRtBox, 1, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_ShapeSunkenSquare: { - Draw3DRect(pGraphics, FWLTHEME_EDGE_Sunken, kSignBorder, pRtBox, - CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2, - CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_ShapeSolidCircle: { - DrawAnnulusCircle(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable - : m_pThemeData->clrSignBorderNormal, - pRtBox, 1, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_ShapeSunkenCircle: { - Draw3DCircle(pGraphics, FWLTHEME_EDGE_Sunken, kSignBorder, pRtBox, - CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2, - CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix); - break; - } - } -} - void CFWL_CheckBoxTP::SetThemeData(uint32_t dwID) { uint32_t* pData = (uint32_t*)&m_pThemeData->clrBoxBk; if (dwID) { @@ -513,3 +321,49 @@ void CFWL_CheckBoxTP::InitCheckPath(FX_FLOAT fCheckLen) { pData->Transform(&mt); } } + +FX_BOOL CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (pParams->m_iPart != CFWL_Part::CheckBox) { + return FALSE; + } + if ((pParams->m_dwStates & CFWL_PartState_Checked) || + (pParams->m_dwStates & CFWL_PartState_Neutral)) { + DrawCheckSign(pParams->m_pWidget, pParams->m_pGraphics, pParams->m_rtPart, + pParams->m_dwStates, &pParams->m_matrix); + } + return FALSE; +} + +void CFWL_CheckBoxTP::DrawCheckSign(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF& pRtBox, + int32_t iState, + CFX_Matrix* pMatrix) { + CFX_RectF rtSign(pRtBox); + uint32_t dwColor = iState & CFWL_PartState_Neutral ? 0xFFA9A9A9 : 0xFF000000; + + uint32_t dwStyle = pWidget->GetStylesEx(); + rtSign.Deflate(rtSign.width / 4, rtSign.height / 4); + switch (dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) { + case FWL_STYLEEXT_CKB_SignShapeCheck: + DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix); + break; + case FWL_STYLEEXT_CKB_SignShapeCircle: + DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix); + break; + case FWL_STYLEEXT_CKB_SignShapeCross: + DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix); + break; + case FWL_STYLEEXT_CKB_SignShapeDiamond: + DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix); + break; + case FWL_STYLEEXT_CKB_SignShapeSquare: + DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix); + break; + case FWL_STYLEEXT_CKB_SignShapeStar: + DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix); + break; + default: + break; + } +} diff --git a/xfa/fwl/theme/cfwl_checkboxtp.h b/xfa/fwl/theme/cfwl_checkboxtp.h index d6beae8573..cdc4ba1d57 100644 --- a/xfa/fwl/theme/cfwl_checkboxtp.h +++ b/xfa/fwl/theme/cfwl_checkboxtp.h @@ -37,19 +37,11 @@ class CFWL_CheckBoxTP : public CFWL_WidgetTP { FX_ARGB clrSignNeutralPressed; }; - void DrawBoxBk(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - uint32_t dwStates, - CFX_Matrix* pMatrix); - void DrawSign(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - uint32_t dwStates, - CFX_Matrix* pMatrix); - void DrawSignNeutral(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - CFX_Matrix* pMatrix); + void DrawCheckSign(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF& pRtBox, + int32_t iState, + CFX_Matrix* pMatrix); void DrawSignCheck(CFX_Graphics* pGraphics, const CFX_RectF* pRtSign, FX_ARGB argbFill, @@ -74,11 +66,7 @@ class CFWL_CheckBoxTP : public CFWL_WidgetTP { const CFX_RectF* pRtSign, FX_ARGB argbFill, CFX_Matrix* pMatrix); - void DrawSignBorder(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - FX_BOOL bDisable, - CFX_Matrix* pMatrix); + void SetThemeData(uint32_t dwID); void InitCheckPath(FX_FLOAT fCheckLen); diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp index 8e59a4d1f2..97f2fbc95c 100644 --- a/xfa/fwl/theme/cfwl_edittp.cpp +++ b/xfa/fwl/theme/cfwl_edittp.cpp @@ -9,6 +9,8 @@ #include "xfa/fwl/basewidget/ifwl_edit.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fxfa/app/xfa_fwltheme.h" +#include "xfa/fxfa/xfa_ffwidget.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" @@ -20,6 +22,24 @@ bool CFWL_EditTP::IsValidWidget(IFWL_Widget* pWidget) { } FX_BOOL CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (CFWL_Part::CombTextLine == pParams->m_iPart) { + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); + FX_ARGB cr = 0xFF000000; + FX_FLOAT fWidth = 1.0f; + if (CXFA_Border borderUI = pWidget->GetDataAcc()->GetUIBorder()) { + CXFA_Edge edge = borderUI.GetEdge(0); + if (edge) { + cr = edge.GetColor(); + fWidth = edge.GetThickness(); + } + } + CFX_Color crLine(cr); + pParams->m_pGraphics->SetStrokeColor(&crLine); + pParams->m_pGraphics->SetLineWidth(fWidth); + pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); + return TRUE; + } + switch (pParams->m_iPart) { case CFWL_Part::Border: { DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); |