summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-10-19 07:48:05 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-19 07:48:05 -0700
commitc273e8f5006aa7d91d37a5da021dbbabb8721e5b (patch)
tree27ca349823fb3fb6f86db50305421ae2302db1db
parent09bad1cf251c68d1492af4049e1324a46d9c9725 (diff)
downloadpdfium-c273e8f5006aa7d91d37a5da021dbbabb8721e5b.tar.xz
Remove FWL theme subclasses
The CFWL_CheckBoxTP and CFWL_EditTP are subclassed with the CXFA_FWLEditTP and CXFA_FWLCheckBoxTP. The super classes are never instantiated or used, so fold the subclasses back to the parent and use them directly. Review-Url: https://chromiumcodereview.appspot.com/2418413005
-rw-r--r--xfa/fwl/theme/cfwl_checkboxtp.cpp238
-rw-r--r--xfa/fwl/theme/cfwl_checkboxtp.h24
-rw-r--r--xfa/fwl/theme/cfwl_edittp.cpp20
-rw-r--r--xfa/fxfa/app/xfa_fwltheme.cpp81
-rw-r--r--xfa/fxfa/app/xfa_fwltheme.h24
5 files changed, 75 insertions, 312 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);
diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp
index abc1f74fa4..6826950042 100644
--- a/xfa/fxfa/app/xfa_fwltheme.cpp
+++ b/xfa/fxfa/app/xfa_fwltheme.cpp
@@ -44,11 +44,11 @@ CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget) {
}
CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp)
- : m_pCheckBoxTP(new CXFA_FWLCheckBoxTP),
+ : m_pCheckBoxTP(new CFWL_CheckBoxTP),
m_pListBoxTP(new CFWL_ListBoxTP),
m_pPictureBoxTP(new CFWL_PictureBoxTP),
m_pSrollBarTP(new CFWL_ScrollBarTP),
- m_pEditTP(new CXFA_FWLEditTP),
+ m_pEditTP(new CFWL_EditTP),
m_pComboBoxTP(new CFWL_ComboBoxTP),
m_pMonthCalendarTP(new CFWL_MonthCalendarTP),
m_pDateTimePickerTP(new CFWL_DateTimePickerTP),
@@ -390,80 +390,3 @@ CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(IFWL_Widget* pWidget) {
return nullptr;
}
}
-
-CXFA_FWLCheckBoxTP::CXFA_FWLCheckBoxTP() {}
-
-FX_BOOL CXFA_FWLCheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
- if (pParams->m_iPart != CFWL_Part::CheckBox) {
- return TRUE;
- }
- 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 TRUE;
-}
-
-void CXFA_FWLCheckBoxTP::DrawCheckSign(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- const CFX_RectF* pRtBox,
- int32_t iState,
- CFX_Matrix* pMatrix) {
- CFX_RectF rtSign(*pRtBox);
- uint32_t dwColor = 0xFF000000;
- if (iState & CFWL_PartState_Neutral)
- dwColor = 0xFFA9A9A9;
-
- {
- 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;
- }
- }
-}
-
-CXFA_FWLEditTP::CXFA_FWLEditTP() {}
-
-CXFA_FWLEditTP::~CXFA_FWLEditTP() {}
-
-FX_BOOL CXFA_FWLEditTP::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;
- }
- return CFWL_EditTP::DrawBackground(pParams);
-}
diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h
index 8c045de791..8243df271f 100644
--- a/xfa/fxfa/app/xfa_fwltheme.h
+++ b/xfa/fxfa/app/xfa_fwltheme.h
@@ -63,28 +63,6 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider {
CFX_SizeF m_SizeAboveBelow;
};
-class CXFA_FWLCheckBoxTP : public CFWL_CheckBoxTP {
- public:
- CXFA_FWLCheckBoxTP();
-
- // CFWL_CheckBoxTP
- FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
-
- protected:
- void DrawCheckSign(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- const CFX_RectF* pRtBox,
- int32_t iState,
- CFX_Matrix* pMatrix);
-};
-
-class CXFA_FWLEditTP : public CFWL_EditTP {
- public:
- CXFA_FWLEditTP();
- ~CXFA_FWLEditTP() override;
-
- // CFWL_EditTP
- FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
-};
+CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget);
#endif // XFA_FXFA_APP_XFA_FWLTHEME_H_