Convert some FWL defines to enums.
This CL converts FWL_WGTCAPACITY_* defines to the CFWL_WidgetCapacity enum
class. The FWL_PART_* defines to the FWL_Part enum class and the
FWL_PartState_* defines to an enum.
Review URL: https://codereview.chromium.org/1898713003
diff --git a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp
index 23bda25..8812076 100644
--- a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp
+++ b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp
@@ -75,11 +75,11 @@
m_fStepSize(0),
m_fPos(0),
m_fTrackPos(0),
- m_iMinButtonState(FWL_PARTSTATE_SCB_Normal),
- m_iMaxButtonState(FWL_PARTSTATE_SCB_Normal),
- m_iThumbButtonState(FWL_PARTSTATE_SCB_Normal),
- m_iMinTrackState(FWL_PARTSTATE_SCB_Normal),
- m_iMaxTrackState(FWL_PARTSTATE_SCB_Normal),
+ m_iMinButtonState(CFWL_PartState_Normal),
+ m_iMaxButtonState(CFWL_PartState_Normal),
+ m_iThumbButtonState(CFWL_PartState_Normal),
+ m_iMinTrackState(CFWL_PartState_Normal),
+ m_iMaxTrackState(CFWL_PartState_Normal),
m_fLastTrackPos(0),
m_cpTrackPointX(0),
m_cpTrackPointY(0),
@@ -122,7 +122,7 @@
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
FX_FLOAT* pfMinWidth = static_cast<FX_FLOAT*>(
- GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
if (!pfMinWidth)
return FWL_ERR_Indefinite;
if (IsVertical()) {
@@ -154,10 +154,10 @@
return FWL_ERR_Indefinite;
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_SCB_Border, pTheme, pMatrix);
+ DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_SCB_Edge, pTheme, pMatrix);
+ DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
}
DrawTrack(pGraphics, pTheme, TRUE, pMatrix);
DrawTrack(pGraphics, pTheme, FALSE, pMatrix);
@@ -247,9 +247,9 @@
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = bLower ? FWL_PART_SCB_LowerTrack : FWL_PART_SCB_UpperTrack;
+ param.m_iPart = bLower ? CFWL_Part::LowerTrack : CFWL_Part::UpperTrack;
param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_SCB_Disabled
+ ? CFWL_PartState_Disabled
: (bLower ? m_iMinTrackState : m_iMaxTrackState);
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
@@ -262,9 +262,9 @@
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = bMinBtn ? FWL_PART_SCB_ForeArrow : FWL_PART_SCB_BackArrow;
+ param.m_iPart = bMinBtn ? CFWL_Part::ForeArrow : CFWL_Part::BackArrow;
param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_SCB_Disabled
+ ? CFWL_PartState_Disabled
: (bMinBtn ? m_iMinButtonState : m_iMaxButtonState);
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
@@ -280,9 +280,9 @@
}
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_SCB_Thumb;
+ param.m_iPart = CFWL_Part::Thumb;
param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_SCB_Disabled
+ ? CFWL_PartState_Disabled
: m_iThumbButtonState;
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
@@ -294,7 +294,7 @@
CFWL_ThemePart part;
part.m_pWidget = m_pInterface;
m_fMinThumb = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_CAPACITY_SCB_Size));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Size));
m_bCustomLayout = pTheme->IsCustomizedLayout(m_pInterface);
GetClientRect(m_rtClient);
CalcButtonLen();
@@ -320,9 +320,9 @@
CFWL_ThemePart pPart;
pPart.m_rtPart = m_rtMinBtn;
pPart.m_pWidget = m_pInterface;
- pPart.m_iPart = FWL_PART_SCB_ForeArrow;
+ pPart.m_iPart = CFWL_Part::ForeArrow;
pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_SCB_Disabled
+ ? CFWL_PartState_Disabled
: m_iMinButtonState;
pTheme->GetPartRect(&pPart, rect);
} else {
@@ -338,9 +338,9 @@
CFWL_ThemePart pPart;
pPart.m_rtPart = m_rtMaxBtn;
pPart.m_pWidget = m_pInterface;
- pPart.m_iPart = FWL_PART_SCB_BackArrow;
+ pPart.m_iPart = CFWL_Part::BackArrow;
pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_SCB_Disabled
+ ? CFWL_PartState_Disabled
: m_iMaxButtonState;
pTheme->GetPartRect(&pPart, rect);
} else {
@@ -592,19 +592,19 @@
}
}
FX_BOOL CFWL_ScrollBarImp::SendEvent() {
- if (m_iMinButtonState == FWL_PARTSTATE_SCB_Pressed) {
+ if (m_iMinButtonState == CFWL_PartState_Pressed) {
DoScroll(FWL_SCBCODE_StepBackward, m_fTrackPos);
return FALSE;
}
- if (m_iMaxButtonState == FWL_PARTSTATE_SCB_Pressed) {
+ if (m_iMaxButtonState == CFWL_PartState_Pressed) {
DoScroll(FWL_SCBCODE_StepForward, m_fTrackPos);
return FALSE;
}
- if (m_iMinTrackState == FWL_PARTSTATE_SCB_Pressed) {
+ if (m_iMinTrackState == CFWL_PartState_Pressed) {
DoScroll(FWL_SCBCODE_PageBackward, m_fTrackPos);
return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
}
- if (m_iMaxTrackState == FWL_PARTSTATE_SCB_Pressed) {
+ if (m_iMaxTrackState == CFWL_PartState_Pressed) {
DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos);
return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
}
@@ -748,10 +748,10 @@
if (!rtItem.Contains(fx, fy)) {
return;
}
- if (iState == FWL_PARTSTATE_SCB_Pressed) {
+ if (iState == CFWL_PartState_Pressed) {
return;
}
- iState = FWL_PARTSTATE_SCB_Pressed;
+ iState = CFWL_PartState_Pressed;
m_pOwner->Repaint(&rtItem);
}
void CFWL_ScrollBarImpDelegate::DoMouseUp(int32_t iItem,
@@ -759,8 +759,8 @@
int32_t& iState,
FX_FLOAT fx,
FX_FLOAT fy) {
- int32_t iNewState = rtItem.Contains(fx, fy) ? FWL_PARTSTATE_SCB_Hovered
- : FWL_PARTSTATE_SCB_Normal;
+ int32_t iNewState =
+ rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered : CFWL_PartState_Normal;
if (iState == iNewState) {
return;
}
@@ -774,15 +774,15 @@
FX_FLOAT fx,
FX_FLOAT fy) {
if (!m_pOwner->m_bMouseDown) {
- int32_t iNewState = rtItem.Contains(fx, fy) ? FWL_PARTSTATE_SCB_Hovered
- : FWL_PARTSTATE_SCB_Normal;
+ int32_t iNewState = rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered
+ : CFWL_PartState_Normal;
if (iState == iNewState) {
return;
}
iState = iNewState;
m_pOwner->Repaint(&rtItem);
} else if ((2 == iItem) &&
- (m_pOwner->m_iThumbButtonState == FWL_PARTSTATE_SCB_Pressed)) {
+ (m_pOwner->m_iThumbButtonState == CFWL_PartState_Pressed)) {
FX_FLOAT fPos = m_pOwner->GetTrackPointPos(fx, fy);
m_pOwner->m_fTrackPos = fPos;
m_pOwner->OnScroll(FWL_SCBCODE_TrackPos, fPos);
@@ -791,18 +791,18 @@
void CFWL_ScrollBarImpDelegate::DoMouseLeave(int32_t iItem,
const CFX_RectF& rtItem,
int32_t& iState) {
- if (iState == FWL_PARTSTATE_SCB_Normal) {
+ if (iState == CFWL_PartState_Normal) {
return;
}
- iState = FWL_PARTSTATE_SCB_Normal;
+ iState = CFWL_PartState_Normal;
m_pOwner->Repaint(&rtItem);
}
void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem,
const CFX_RectF& rtItem,
int32_t& iState) {
- if (iState == FWL_PARTSTATE_SCB_Hovered) {
+ if (iState == CFWL_PartState_Hovered) {
return;
}
- iState = FWL_PARTSTATE_SCB_Hovered;
+ iState = CFWL_PartState_Hovered;
m_pOwner->Repaint(&rtItem);
}