summaryrefslogtreecommitdiff
path: root/xfa/fwl/theme/cfwl_checkboxtp.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-05-04 13:52:07 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-04 13:52:07 -0700
commitef43608928148bac9b73f6919188efd87feccf95 (patch)
treed3ea9363547fd7a00486c693442601c4d9dd6020 /xfa/fwl/theme/cfwl_checkboxtp.cpp
parent8f4bf9a8ac211e150f7fa4d8ed061f264cb3aa9e (diff)
downloadpdfium-ef43608928148bac9b73f6919188efd87feccf95.tar.xz
Convert some theme defines to values.
This Cl updates several of the theme defines to be constant values instead of defines. Some of the items were re-ordered so the calculations would work correctly. Review-Url: https://codereview.chromium.org/1945183004
Diffstat (limited to 'xfa/fwl/theme/cfwl_checkboxtp.cpp')
-rw-r--r--xfa/fwl/theme/cfwl_checkboxtp.cpp74
1 files changed, 36 insertions, 38 deletions
diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp
index a6d70eb452..b7d3d724b6 100644
--- a/xfa/fwl/theme/cfwl_checkboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp
@@ -14,9 +14,14 @@
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#define CHECKBOX_SIZE_SIGNMARGIN 3
-#define CHECKBOX_SIZE_SIGNBORDER 2
-#define CHECKBOX_SIZE_SIGNPATH 100
+namespace {
+
+const int kSignMargin = 3;
+const int kSignBorder = 2;
+const int kSignPath = 100;
+
+} // namespace
+
#define CHECKBOX_COLOR_BOXLT1 (ArgbEncode(255, 172, 168, 153))
#define CHECKBOX_COLOR_BOXLT2 (ArgbEncode(255, 113, 111, 100))
#define CHECKBOX_COLOR_BOXRB1 (ArgbEncode(255, 241, 239, 226))
@@ -120,10 +125,9 @@ void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget* pWidget,
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);
+ path.AddRectangle(pRect->left + kSignMargin, pRect->top + kSignMargin,
+ pRect->width - kSignMargin * 2,
+ pRect->height - kSignMargin * 2);
}
} else {
CFX_RectF rect(*pRect);
@@ -132,8 +136,7 @@ void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget* pWidget,
if (bClipSign) {
fillMode = FXFILL_ALTERNATE;
CFX_RectF rtClip(rect);
- rtClip.Deflate(CHECKBOX_SIZE_SIGNMARGIN - 1,
- CHECKBOX_SIZE_SIGNMARGIN - 1);
+ rtClip.Deflate(kSignMargin - 1, kSignMargin - 1);
path.AddEllipse(rtClip);
}
}
@@ -160,7 +163,7 @@ void CFWL_CheckBoxTP::DrawSign(IFWL_Widget* pWidget,
uint32_t dwStates,
CFX_Matrix* pMatrix) {
CFX_RectF rtSign(*pRtBox);
- rtSign.Deflate(CHECKBOX_SIZE_SIGNMARGIN, CHECKBOX_SIZE_SIGNMARGIN);
+ rtSign.Deflate(kSignMargin, kSignMargin);
uint32_t dwColor = m_pThemeData->clrSignCheck;
FX_BOOL bCheck = TRUE;
if ((dwStates & CFWL_PartState_Disabled) &&
@@ -345,8 +348,8 @@ void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget* pWidget,
break;
}
case FWL_STYLEEXT_CKB_ShapeSunkenSquare: {
- Draw3DRect(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER,
- pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2,
+ Draw3DRect(pGraphics, FWLTHEME_EDGE_Sunken, kSignBorder, pRtBox,
+ CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2,
CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix);
break;
}
@@ -357,8 +360,8 @@ void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget* pWidget,
break;
}
case FWL_STYLEEXT_CKB_ShapeSunkenCircle: {
- Draw3DCircle(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER,
- pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2,
+ Draw3DCircle(pGraphics, FWLTHEME_EDGE_Sunken, kSignBorder, pRtBox,
+ CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2,
CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix);
break;
}
@@ -436,9 +439,9 @@ void CFWL_CheckBoxTP::initCheckPath(FX_FLOAT fCheckLen) {
if (!m_pCheckPath) {
m_pCheckPath = new CFX_Path;
m_pCheckPath->Create();
- FX_FLOAT fWidth = CHECKBOX_SIZE_SIGNPATH;
- FX_FLOAT fHeight = -CHECKBOX_SIZE_SIGNPATH;
- FX_FLOAT fBottom = CHECKBOX_SIZE_SIGNPATH;
+ FX_FLOAT fWidth = kSignPath;
+ FX_FLOAT fHeight = -kSignPath;
+ FX_FLOAT fBottom = kSignPath;
CFX_PointF pt1(fWidth / 15.0f, fBottom + fHeight * 2 / 5.0f);
CFX_PointF pt2(fWidth / 4.5f, fBottom + fHeight / 16.0f);
CFX_PointF pt3(fWidth / 3.0f, fBottom);
@@ -461,43 +464,38 @@ void CFWL_CheckBoxTP::initCheckPath(FX_FLOAT fCheckLen) {
FX_FLOAT py1 = pt12.y - pt1.y;
FX_FLOAT px2 = pt21.x - pt2.x;
FX_FLOAT py2 = pt21.y - pt2.y;
- m_pCheckPath->BezierTo(pt1.x + px1 * FWLTHEME_BEZIER,
- pt1.y + py1 * FWLTHEME_BEZIER,
- pt2.x + px2 * FWLTHEME_BEZIER,
- pt2.y + py2 * FWLTHEME_BEZIER, pt2.x, pt2.y);
+ m_pCheckPath->BezierTo(pt1.x + px1 * FX_BEZIER, pt1.y + py1 * FX_BEZIER,
+ pt2.x + px2 * FX_BEZIER, pt2.y + py2 * FX_BEZIER,
+ pt2.x, pt2.y);
px1 = pt23.x - pt2.x;
py1 = pt23.y - pt2.y;
px2 = pt32.x - pt3.x;
py2 = pt32.y - pt3.y;
- m_pCheckPath->BezierTo(pt2.x + px1 * FWLTHEME_BEZIER,
- pt2.y + py1 * FWLTHEME_BEZIER,
- pt3.x + px2 * FWLTHEME_BEZIER,
- pt3.y + py2 * FWLTHEME_BEZIER, pt3.x, pt3.y);
+ m_pCheckPath->BezierTo(pt2.x + px1 * FX_BEZIER, pt2.y + py1 * FX_BEZIER,
+ pt3.x + px2 * FX_BEZIER, pt3.y + py2 * FX_BEZIER,
+ pt3.x, pt3.y);
px1 = pt34.x - pt3.x;
py1 = pt34.y - pt3.y;
px2 = pt43.x - pt4.x;
py2 = pt43.y - pt4.y;
- m_pCheckPath->BezierTo(pt3.x + px1 * FWLTHEME_BEZIER,
- pt3.y + py1 * FWLTHEME_BEZIER,
- pt4.x + px2 * FWLTHEME_BEZIER,
- pt4.y + py2 * FWLTHEME_BEZIER, pt4.x, pt4.y);
+ m_pCheckPath->BezierTo(pt3.x + px1 * FX_BEZIER, pt3.y + py1 * FX_BEZIER,
+ pt4.x + px2 * FX_BEZIER, pt4.y + py2 * FX_BEZIER,
+ pt4.x, pt4.y);
px1 = pt45.x - pt4.x;
py1 = pt45.y - pt4.y;
px2 = pt54.x - pt5.x;
py2 = pt54.y - pt5.y;
- m_pCheckPath->BezierTo(pt4.x + px1 * FWLTHEME_BEZIER,
- pt4.y + py1 * FWLTHEME_BEZIER,
- pt5.x + px2 * FWLTHEME_BEZIER,
- pt5.y + py2 * FWLTHEME_BEZIER, pt5.x, pt5.y);
+ m_pCheckPath->BezierTo(pt4.x + px1 * FX_BEZIER, pt4.y + py1 * FX_BEZIER,
+ pt5.x + px2 * FX_BEZIER, pt5.y + py2 * FX_BEZIER,
+ pt5.x, pt5.y);
px1 = pt51.x - pt5.x;
py1 = pt51.y - pt5.y;
px2 = pt15.x - pt1.x;
py2 = pt15.y - pt1.y;
- m_pCheckPath->BezierTo(pt5.x + px1 * FWLTHEME_BEZIER,
- pt5.y + py1 * FWLTHEME_BEZIER,
- pt1.x + px2 * FWLTHEME_BEZIER,
- pt1.y + py2 * FWLTHEME_BEZIER, pt1.x, pt1.y);
- FX_FLOAT fScale = fCheckLen / CHECKBOX_SIZE_SIGNPATH;
+ m_pCheckPath->BezierTo(pt5.x + px1 * FX_BEZIER, pt5.y + py1 * FX_BEZIER,
+ pt1.x + px2 * FX_BEZIER, pt1.y + py2 * FX_BEZIER,
+ pt1.x, pt1.y);
+ FX_FLOAT fScale = fCheckLen / kSignPath;
CFX_Matrix mt;
mt.Set(1, 0, 0, 1, 0, 0);
mt.Scale(fScale, fScale);