summaryrefslogtreecommitdiff
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
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
-rw-r--r--xfa/fwl/theme/cfwl_checkboxtp.cpp74
-rw-r--r--xfa/fwl/theme/cfwl_comboboxtp.cpp8
-rw-r--r--xfa/fwl/theme/cfwl_formtp.cpp90
-rw-r--r--xfa/fwl/theme/cfwl_monthcalendartp.cpp132
-rw-r--r--xfa/fwl/theme/cfwl_utils.h11
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.cpp36
6 files changed, 171 insertions, 180 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);
diff --git a/xfa/fwl/theme/cfwl_comboboxtp.cpp b/xfa/fwl/theme/cfwl_comboboxtp.cpp
index 131e6388f7..b02caf8a3e 100644
--- a/xfa/fwl/theme/cfwl_comboboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_comboboxtp.cpp
@@ -13,7 +13,11 @@
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#define FWLTHEME_CAPACITY_ComboFormHandler 8.0f
+namespace {
+
+const float kComboFormHandler = 8.0f;
+
+} // namespace
CFWL_ComboBoxTP::CFWL_ComboBoxTP() {
m_dwThemeID = 0;
@@ -85,7 +89,7 @@ void CFWL_ComboBoxTP::DrawStrethHandler(CFWL_ThemeBackground* pParams,
void* CFWL_ComboBoxTP::GetCapacity(CFWL_ThemePart* pThemePart,
CFWL_WidgetCapacity dwCapacity) {
if (dwCapacity == CFWL_WidgetCapacity::ComboFormHandler) {
- m_fValue = FWLTHEME_CAPACITY_ComboFormHandler;
+ m_fValue = kComboFormHandler;
return &m_fValue;
}
return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
diff --git a/xfa/fwl/theme/cfwl_formtp.cpp b/xfa/fwl/theme/cfwl_formtp.cpp
index 4a18ea0cc4..65d070b6b7 100644
--- a/xfa/fwl/theme/cfwl_formtp.cpp
+++ b/xfa/fwl/theme/cfwl_formtp.cpp
@@ -16,16 +16,20 @@
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#define FWLTHEME_CAPACITY_CXFormBorder 3
-#define FWLTHEME_CAPACITY_CYFormBorder 3
-#define FWLTHEME_CAPACITY_CYNarrowCaption 18
-#define FWLTHEME_CAPACITY_CYCaption 29
-#define FWLTHEME_CAPACITY_BigIconSize 32
-#define FWLTHEME_CAPACITY_SmallIconSize 16
-#define FWLTHEME_CAPACITY_FormTextColor 0xFFFFFFFF
-#define FWLTHEME_FORMBTN_Margin 5
-#define FWLTHEME_FORMBTN_Span 2
-#define FWLTHEME_FORMBTN_Size 21
+namespace {
+
+const int kCXFormBorder = 3;
+const int kCYFormBorder = 3;
+const int kCYCaption = 29;
+const int kFormBigIconSize = 32;
+const int kFormSmallIconSize = 16;
+const uint32_t kFormTextColor = 0xFFFFFFFF;
+
+const int kButtonSize = 21;
+const int kButtonMargin = 5;
+const int kButtonSpan = 2;
+
+} // namespace
CFWL_FormTP::CFWL_FormTP() : m_pActiveBitmap(NULL), m_pDeactivebitmap(NULL) {
m_pThemeData = new SBThemeData;
@@ -161,32 +165,32 @@ void* CFWL_FormTP::GetCapacity(CFWL_ThemePart* pThemePart,
FX_BOOL bDwordVal = FALSE;
switch (dwCapacity) {
case CFWL_WidgetCapacity::CXBorder: {
- m_fValue = FWLTHEME_CAPACITY_CXFormBorder;
+ m_fValue = kCXFormBorder;
break;
}
case CFWL_WidgetCapacity::CYBorder: {
- m_fValue = FWLTHEME_CAPACITY_CYFormBorder;
+ m_fValue = kCYFormBorder;
break;
}
case CFWL_WidgetCapacity::CYCaption: {
- m_fValue = FWLTHEME_CAPACITY_CYCaption;
+ m_fValue = kCYCaption;
break;
}
case CFWL_WidgetCapacity::CYNarrowCaption: {
- m_fValue = FWLTHEME_CAPACITY_CYCaption;
+ m_fValue = kCYCaption;
break;
}
case CFWL_WidgetCapacity::TextColor: {
bDwordVal = TRUE;
- m_dwValue = FWLTHEME_CAPACITY_FormTextColor;
+ m_dwValue = kFormTextColor;
break;
}
case CFWL_WidgetCapacity::BigIcon: {
- m_fValue = FWLTHEME_CAPACITY_BigIconSize;
+ m_fValue = kFormBigIconSize;
break;
}
case CFWL_WidgetCapacity::SmallIcon: {
- m_fValue = FWLTHEME_CAPACITY_SmallIconSize;
+ m_fValue = kFormSmallIconSize;
break;
}
default: { bDefPro = TRUE; }
@@ -232,12 +236,11 @@ void CFWL_FormTP::CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
pWidget->GetWidgetRect(rtWidget);
rtWidget.Offset(-rtWidget.left, -rtWidget.top);
if (dwStyles & FWL_WGTSTYLE_CloseBox) {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
- FWLTHEME_FORMBTN_Size);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSpan,
+ rtWidget.top + kButtonMargin, kButtonSize, kButtonSize);
} else {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSpan,
+ rtWidget.top + kButtonMargin, 0, 0);
}
}
void CFWL_FormTP::CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
@@ -246,14 +249,11 @@ void CFWL_FormTP::CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
pWidget->GetWidgetRect(rtWidget);
rtWidget.Offset(-rtWidget.left, -rtWidget.top);
if (dwStyles & FWL_WGTSTYLE_MaximizeBox) {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size +
- FWLTHEME_FORMBTN_Span * 2,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
- FWLTHEME_FORMBTN_Size);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSize + kButtonSpan * 2,
+ rtWidget.top + kButtonMargin, kButtonSize, kButtonSize);
} else {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size +
- FWLTHEME_FORMBTN_Span * 2,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSize + kButtonSpan * 2,
+ rtWidget.top + kButtonMargin, 0, 0);
}
}
void CFWL_FormTP::CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
@@ -262,24 +262,20 @@ void CFWL_FormTP::CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
pWidget->GetWidgetRect(rtWidget);
rtWidget.Offset(-rtWidget.left, -rtWidget.top);
if (dwStyles & FWL_WGTSTYLE_MinimizeBox) {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin +
- FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
- FWLTHEME_FORMBTN_Size);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSize * 2 + kButtonSpan * 3,
+ rtWidget.top + kButtonMargin, kButtonSize, kButtonSize);
} else {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin +
- FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSize * 2 + kButtonSpan * 3,
+ rtWidget.top + kButtonMargin, 0, 0);
}
}
void CFWL_FormTP::CalCaption(IFWL_Widget* pWidget, CFX_RectF& rect) {
CFX_RectF rtWidget;
pWidget->GetWidgetRect(rtWidget);
rtWidget.Offset(-rtWidget.left, -rtWidget.top);
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin,
- rtWidget.top + FWLTHEME_FORMBTN_Margin - 2,
- rtWidget.width - FWLTHEME_FORMBTN_Margin * 2,
- FWLTHEME_FORMBTN_Size + 2 * FWLTHEME_FORMBTN_Margin + 4);
+ rect.Set(rtWidget.left + kButtonMargin, rtWidget.top + kButtonMargin - 2,
+ rtWidget.width - kButtonMargin * 2,
+ kButtonSize + 2 * kButtonMargin + 4);
}
void CFWL_FormTP::CalIcon(IFWL_Widget* pWidget, CFX_RectF& rect) {}
void CFWL_FormTP::DrawFormBorder(CFX_Graphics* pGraphics,
@@ -849,7 +845,7 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) {
path.Create();
delete m_pActiveBitmap;
m_pActiveBitmap = new CFX_DIBitmap;
- m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb);
+ m_pActiveBitmap->Create(1, kCYCaption, FXDIB_Argb);
dev.Attach(m_pActiveBitmap);
gs.Create(&dev);
path.AddRectangle(0, 0, 1, 5);
@@ -860,9 +856,8 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) {
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],
+ path.AddRectangle(0, 20, 1, kCYCaption - 19);
+ DrawAxialShading(&gs, 0, 20, 0, kCYCaption, m_pThemeData->clrHeadBK[0][2],
m_pThemeData->clrHeadBK[0][3], &path);
} else {
CFX_FxgeDevice dev;
@@ -871,7 +866,7 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) {
path.Create();
delete m_pDeactivebitmap;
m_pDeactivebitmap = new CFX_DIBitmap;
- m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb);
+ m_pDeactivebitmap->Create(1, kCYCaption, FXDIB_Argb);
dev.Attach(m_pDeactivebitmap);
gs.Create(&dev);
path.AddRectangle(0, 0, 1, 5);
@@ -882,9 +877,8 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) {
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],
+ path.AddRectangle(0, 20, 1, kCYCaption - 19);
+ DrawAxialShading(&gs, 0, 20, 0, kCYCaption, m_pThemeData->clrHeadBK[1][2],
m_pThemeData->clrHeadBK[1][3], &path);
}
}
diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/xfa/fwl/theme/cfwl_monthcalendartp.cpp
index 169905824f..8b10fb993c 100644
--- a/xfa/fwl/theme/cfwl_monthcalendartp.cpp
+++ b/xfa/fwl/theme/cfwl_monthcalendartp.cpp
@@ -15,49 +15,39 @@
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#define FWL_THEMECAPACITY_MC_HEADER_WIDTH 200
-#define FWL_THEMECAPACITY_MC_HEADER_HEIGHT 30
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH 18
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT 16
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN 5
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN \
- (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - \
- FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT) / \
- 2
-#define FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT 100
-#define FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT 20
-#define FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN \
- (FWL_THEMECAPACITY_MC_HEADER_WIDTH - \
- FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT) / \
- 2
-#define FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN \
- (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - \
- FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT) / \
- 2
-#define FWL_THEMECAPACITY_MC_HSEP_WIDTH (FWL_THEMECAPACITY_MC_WEEK_WIDTH - 10)
-#define FWL_THEMECAPACITY_MC_HSEP_HEIGHT 1
-#define FWL_THEMECAPACITY_MC_VSEP_WIDTH 1
-#define FWL_THEMECAPACITY_MC_VSEP_HEIGHT FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT
-#define FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH 26
-#define FWL_THEMECAPACITY_MC_SEP_DOFFSET -4
-#define FWL_THEMECAPACITY_MC_SEP_X 3
-#define FWL_THEMECAPACITY_MC_SEP_Y \
- (FWL_THEMECAPACITY_MC_HEADER_HEIGHT + FWL_THEMECAPACITY_MC_WEEK_HEIGHT + \
- FWL_THEMECAPACITY_MC_SEP_DOFFSET)
-#define FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT \
- (6 * FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT)
-#define FWL_THEMECAPACITY_MC_WEEK_WIDTH \
- (FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH * 7)
-#define FWL_THEMECAPACITY_MC_WEEK_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT
-#define FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH \
- (FWL_THEMECAPACITY_MC_HEADER_WIDTH / 7)
-#define FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT 16
-#define FWL_THEMECAPACITY_MC_TODAY_WIDHT FWL_THEMECAPACITY_MC_HEADER_WIDTH
-#define FWL_THEMECAPACITY_MC_TODAY_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT
-#define FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT \
- FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH
-#define FWL_MC_WIDTH 200
-#define FWL_MC_HEIGHT 160
+namespace {
+
+const int kWidth = 200;
+const int kHeight = 160;
+
+const int kHeaderWidth = 200;
+const int kHeaderHeight = 30;
+
+const int kButtonWidth = 18;
+const int kButtonHeight = 16;
+const int kButtonHorizontalMargin = 5;
+const int kButtonVerticalMargin = (kHeaderHeight - kButtonHeight) / 2;
+
+const int kHeaderTextWidth = 100;
+const int kHeaderTextHeight = 20;
+const int kHeaderTextHorizontalMargin = (kHeaderWidth - kHeaderTextWidth) / 2;
+const int kHeaderTextVerticalMargin = (kHeaderHeight - kHeaderTextHeight) / 2;
+
+const int kDatesCellWidth = (kHeaderWidth / 7);
+const int kDatesCellHeight = 16;
+const int kWeekWidth = kDatesCellWidth * 7;
+const int kWeekNumWidth = 26;
+const int kWeekNumHeight = (6 * kDatesCellHeight);
+
+const int kHorizontalSeparatorWidth = kWeekWidth - 10;
+const int kHorizontalSeparatorHeight = 1;
+const int kVerticalSeparatorWidth = 1;
+const int kVerticalSeparatorHeight = kWeekNumHeight;
+const int kSeparatorDOffset = -4;
+const int kSeparatorX = 3;
+const int kSeparatorY = kHeaderHeight + kDatesCellHeight + kSeparatorDOffset;
+
+} // namespace
CFWL_MonthCalendarTP::CFWL_MonthCalendarTP() {
m_pThemeData = new MCThemeData;
@@ -157,116 +147,116 @@ void* CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart* pThemePart,
FX_BOOL bDwordVal = FALSE;
switch (dwCapacity) {
case CFWL_WidgetCapacity::HeaderWidth: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_WIDTH;
+ m_fValue = kHeaderWidth;
break;
}
case CFWL_WidgetCapacity::HeaderHeight: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_HEIGHT;
+ m_fValue = kHeaderHeight;
break;
}
case CFWL_WidgetCapacity::HeaderBtnWidth: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH;
+ m_fValue = kButtonWidth;
break;
}
case CFWL_WidgetCapacity::HeaderBtnHeight: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT;
+ m_fValue = kButtonHeight;
break;
}
case CFWL_WidgetCapacity::HeaderBtnHMargin: {
bDwordVal = TRUE;
- m_dwValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN;
+ m_dwValue = kButtonHorizontalMargin;
break;
}
case CFWL_WidgetCapacity::HeaderBtnVMargin: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN;
+ m_fValue = kButtonVerticalMargin;
break;
}
case CFWL_WidgetCapacity::HeaderTextWidth: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT;
+ m_fValue = kHeaderTextWidth;
break;
}
case CFWL_WidgetCapacity::HeaderTextHeight: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT;
+ m_fValue = kHeaderTextHeight;
break;
}
case CFWL_WidgetCapacity::HeaderTextHMargin: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN;
+ m_fValue = kHeaderTextHorizontalMargin;
break;
}
case CFWL_WidgetCapacity::HeaderTextVMargin: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN;
+ m_fValue = kHeaderTextVerticalMargin;
break;
}
case CFWL_WidgetCapacity::HSepWidth: {
- m_fValue = FWL_THEMECAPACITY_MC_HSEP_WIDTH;
+ m_fValue = kHorizontalSeparatorWidth;
break;
}
case CFWL_WidgetCapacity::HSepHeight: {
- m_fValue = FWL_THEMECAPACITY_MC_HSEP_HEIGHT;
+ m_fValue = kHorizontalSeparatorHeight;
break;
}
case CFWL_WidgetCapacity::VSepWidth: {
- m_fValue = FWL_THEMECAPACITY_MC_VSEP_WIDTH;
+ m_fValue = kVerticalSeparatorWidth;
break;
}
case CFWL_WidgetCapacity::VSepHeight: {
- m_fValue = FWL_THEMECAPACITY_MC_VSEP_HEIGHT;
+ m_fValue = kVerticalSeparatorHeight;
break;
}
case CFWL_WidgetCapacity::WeekNumWidth: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH;
+ m_fValue = kWeekNumWidth;
break;
}
case CFWL_WidgetCapacity::WeekNumHeight: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT;
+ m_fValue = kWeekNumHeight;
break;
}
case CFWL_WidgetCapacity::WeekWidth: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEK_WIDTH;
+ m_fValue = kWeekWidth;
break;
}
case CFWL_WidgetCapacity::WeekHeight: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEK_HEIGHT;
+ m_fValue = kDatesCellHeight;
break;
}
case CFWL_WidgetCapacity::SepDOffset: {
- m_fValue = FWL_THEMECAPACITY_MC_SEP_DOFFSET;
+ m_fValue = kSeparatorDOffset;
break;
}
case CFWL_WidgetCapacity::SepX: {
- m_fValue = FWL_THEMECAPACITY_MC_SEP_X;
+ m_fValue = kSeparatorX;
break;
}
case CFWL_WidgetCapacity::SepY: {
- m_fValue = FWL_THEMECAPACITY_MC_SEP_Y;
+ m_fValue = kSeparatorY;
break;
}
case CFWL_WidgetCapacity::DatesCellWidth: {
- m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH;
+ m_fValue = kDatesCellWidth;
break;
}
case CFWL_WidgetCapacity::DatesCellHeight: {
- m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT;
+ m_fValue = kDatesCellHeight;
break;
}
case CFWL_WidgetCapacity::TodayWidth: {
- m_fValue = FWL_THEMECAPACITY_MC_TODAY_WIDHT;
+ m_fValue = kHeaderWidth;
break;
}
case CFWL_WidgetCapacity::TodayHeight: {
- m_fValue = FWL_THEMECAPACITY_MC_TODAY_HEIGHT;
+ m_fValue = kDatesCellHeight;
break;
}
case CFWL_WidgetCapacity::TodayFlagWidth: {
- m_fValue = FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT;
+ m_fValue = kDatesCellWidth;
break;
}
case CFWL_WidgetCapacity::Width: {
- m_fValue = FWL_MC_WIDTH;
+ m_fValue = kWidth;
break;
}
case CFWL_WidgetCapacity::Height: {
- m_fValue = FWL_MC_HEIGHT;
+ m_fValue = kHeight;
break;
}
case CFWL_WidgetCapacity::Sun: {
diff --git a/xfa/fwl/theme/cfwl_utils.h b/xfa/fwl/theme/cfwl_utils.h
index 701b647174..cdd768a878 100644
--- a/xfa/fwl/theme/cfwl_utils.h
+++ b/xfa/fwl/theme/cfwl_utils.h
@@ -29,22 +29,13 @@ enum FWLTHEME_DIRECTION {
FWLTHEME_DIRECTION_Right
};
-#define FWLTHEME_BEZIER FX_BEZIER
-#define FWLTHEME_PI FX_PI
#define FWLTHEME_COLOR_EDGERB1 (ArgbEncode(255, 241, 239, 226))
#define FWLTHEME_COLOR_Background (ArgbEncode(255, 236, 233, 216))
#define FWLTHEME_COLOR_BKSelected (ArgbEncode(255, 153, 193, 218))
#define FWLTHEME_COLOR_Green_BKSelected (ArgbEncode(255, 147, 160, 112))
-#define FWLTHEME_CAPACITY_EdgeFlat 2.0f
-#define FWLTHEME_CAPACITY_EdgeRaised 2.0f
-#define FWLTHEME_CAPACITY_EdgeSunken 2.0f
+
#define FWLTHEME_CAPACITY_FontSize 12.0f
-#define FWLTHEME_CAPACITY_LineHeight 12.0f
#define FWLTHEME_CAPACITY_TextColor (ArgbEncode(255, 0, 0, 0))
-#define FWLTHEME_CAPACITY_TextSelColor (ArgbEncode(255, 153, 193, 218))
#define FWLTHEME_CAPACITY_TextDisColor (ArgbEncode(255, 172, 168, 153))
-#define FWLTHEME_CAPACITY_ScrollBarWidth 17.0f
-#define FWLTHEME_CAPACITY_CXBorder 1.0f
-#define FWLTHEME_CAPACITY_CYBorder 1.0f
#endif // XFA_FWL_THEME_CFWL_UTILS_H_
diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp
index 1ff241636f..6664bbed52 100644
--- a/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -20,6 +20,20 @@
#include "xfa/fxgraphics/cfx_path.h"
#include "xfa/fxgraphics/cfx_shading.h"
+namespace {
+
+const float kEdgeFlat = 2.0f;
+const float kEdgeRaised = 2.0f;
+const float kEdgeSunken = 2.0f;
+const float kLineHeight = 12.0f;
+const float kScrollBarWidth = 17.0f;
+const float kCXBorder = 1.0f;
+const float kCYBorder = 1.0f;
+
+#define FWLTHEME_CAPACITY_TextSelColor (ArgbEncode(255, 153, 193, 218))
+
+} // namespace
+
static void FWL_SetChildThemeID(IFWL_Widget* pParent, uint32_t dwThemeID) {
IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr();
IFWL_Widget* pChild =
@@ -86,23 +100,23 @@ void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart,
CFWL_WidgetCapacity dwCapacity) {
switch (dwCapacity) {
case CFWL_WidgetCapacity::CXBorder: {
- m_fValue = FWLTHEME_CAPACITY_CXBorder;
+ m_fValue = kCXBorder;
break;
}
case CFWL_WidgetCapacity::CYBorder: {
- m_fValue = FWLTHEME_CAPACITY_CYBorder;
+ m_fValue = kCYBorder;
break;
}
case CFWL_WidgetCapacity::EdgeFlat: {
- m_fValue = FWLTHEME_CAPACITY_EdgeFlat;
+ m_fValue = kEdgeFlat;
break;
}
case CFWL_WidgetCapacity::EdgeRaised: {
- m_fValue = FWLTHEME_CAPACITY_EdgeRaised;
+ m_fValue = kEdgeRaised;
break;
}
case CFWL_WidgetCapacity::EdgeSunken: {
- m_fValue = FWLTHEME_CAPACITY_EdgeSunken;
+ m_fValue = kEdgeSunken;
break;
}
case CFWL_WidgetCapacity::FontSize: {
@@ -114,7 +128,7 @@ void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart,
return &m_dwValue;
}
case CFWL_WidgetCapacity::ScrollBarWidth: {
- m_fValue = FWLTHEME_CAPACITY_ScrollBarWidth;
+ m_fValue = kScrollBarWidth;
break;
}
case CFWL_WidgetCapacity::Font: {
@@ -126,7 +140,7 @@ void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart,
return &m_dwValue;
}
case CFWL_WidgetCapacity::LineHeight: {
- m_fValue = FWLTHEME_CAPACITY_LineHeight;
+ m_fValue = kLineHeight;
break;
}
case CFWL_WidgetCapacity::UIMargin: {
@@ -353,7 +367,7 @@ void CFWL_WidgetTP::Draw3DCircle(CFX_Graphics* pGraphics,
CFX_Path path;
path.Create();
path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height,
- FWLTHEME_PI * 3 / 4, FWLTHEME_PI);
+ FX_PI * 3 / 4, FX_PI);
CFX_Color crFill1(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1);
pGraphics->SetStrokeColor(&crFill1);
pGraphics->StrokePath(&path, pMatrix);
@@ -361,18 +375,18 @@ void CFWL_WidgetTP::Draw3DCircle(CFX_Graphics* pGraphics,
rtInner.Deflate(pRect->width / 4, pRect->height / 4);
path.Clear();
path.AddArc(rtInner.left, rtInner.top, rtInner.width, rtInner.height,
- FWLTHEME_PI * 3 / 4, FWLTHEME_PI);
+ FX_PI * 3 / 4, FX_PI);
CFX_Color crFill2(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2);
pGraphics->SetStrokeColor(&crFill2);
pGraphics->StrokePath(&path, pMatrix);
path.Clear();
path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height,
- FWLTHEME_PI * 7 / 4, FWLTHEME_PI);
+ FX_PI * 7 / 4, FX_PI);
CFX_Color crFill3(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3);
pGraphics->SetStrokeColor(&crFill3);
pGraphics->StrokePath(&path, pMatrix);
path.AddArc(rtInner.left, rtInner.top, rtInner.width, rtInner.height,
- FWLTHEME_PI * 7 / 4, FWLTHEME_PI);
+ FX_PI * 7 / 4, FX_PI);
CFX_Color crFill4(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4);
pGraphics->SetStrokeColor(&crFill4);
pGraphics->StrokePath(&path, pMatrix);