Use fxcrt::Mask<> for theme part states.
CFWL_PartState can now become an enum class.
Change-Id: I15ea04a2569d94a0e1beb079376706c00a48f3eb
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84000
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fwl/cfwl_caret.cpp b/xfa/fwl/cfwl_caret.cpp
index 417901d..5535d87 100644
--- a/xfa/fwl/cfwl_caret.cpp
+++ b/xfa/fwl/cfwl_caret.cpp
@@ -64,7 +64,7 @@
CFWL_ThemeBackground param(this, pGraphics);
param.m_PartRect = CFX_RectF(0, 0, GetWidgetRect().Size());
param.m_iPart = CFWL_ThemePart::Part::kBackground;
- param.m_dwStates = CFWL_PartState_HightLight;
+ param.m_dwStates = CFWL_PartState::kHightLight;
param.m_matrix = mtMatrix;
GetThemeProvider()->DrawBackground(param);
}
diff --git a/xfa/fwl/cfwl_checkbox.cpp b/xfa/fwl/cfwl_checkbox.cpp
index cd912a9..bb6c5ea 100644
--- a/xfa/fwl/cfwl_checkbox.cpp
+++ b/xfa/fwl/cfwl_checkbox.cpp
@@ -58,7 +58,7 @@
if (HasBorder())
DrawBorder(pGraphics, CFWL_ThemePart::Part::kBorder, matrix);
- int32_t dwStates = GetPartStates();
+ Mask<CFWL_PartState> dwStates = GetPartStates();
CFWL_ThemeBackground param(this, pGraphics);
param.m_iPart = CFWL_ThemePart::Part::kBackground;
param.m_dwStates = dwStates;
@@ -121,25 +121,25 @@
m_FocusRect.Inflate(1, 1);
}
-uint32_t CFWL_CheckBox::GetPartStates() const {
- int32_t dwStates = CFWL_PartState_Normal;
+Mask<CFWL_PartState> CFWL_CheckBox::GetPartStates() const {
+ Mask<CFWL_PartState> dwStates = CFWL_PartState::kNormal;
if ((m_Properties.m_dwStates & FWL_STATE_CKB_CheckMask) ==
FWL_STATE_CKB_Neutral) {
- dwStates = CFWL_PartState_Neutral;
+ dwStates = CFWL_PartState::kNeutral;
} else if ((m_Properties.m_dwStates & FWL_STATE_CKB_CheckMask) ==
FWL_STATE_CKB_Checked) {
- dwStates = CFWL_PartState_Checked;
+ dwStates = CFWL_PartState::kChecked;
}
if (m_Properties.m_dwStates & FWL_STATE_WGT_Disabled)
- dwStates |= CFWL_PartState_Disabled;
+ dwStates |= CFWL_PartState::kDisabled;
else if (m_Properties.m_dwStates & FWL_STATE_CKB_Hovered)
- dwStates |= CFWL_PartState_Hovered;
+ dwStates |= CFWL_PartState::kHovered;
else if (m_Properties.m_dwStates & FWL_STATE_CKB_Pressed)
- dwStates |= CFWL_PartState_Pressed;
+ dwStates |= CFWL_PartState::kPressed;
else
- dwStates |= CFWL_PartState_Normal;
+ dwStates |= CFWL_PartState::kNormal;
if (m_Properties.m_dwStates & FWL_STATE_WGT_Focused)
- dwStates |= CFWL_PartState_Focused;
+ dwStates |= CFWL_PartState::kFocused;
return dwStates;
}
diff --git a/xfa/fwl/cfwl_checkbox.h b/xfa/fwl/cfwl_checkbox.h
index 65e4209..9e67622 100644
--- a/xfa/fwl/cfwl_checkbox.h
+++ b/xfa/fwl/cfwl_checkbox.h
@@ -51,7 +51,7 @@
void SetCheckState(int32_t iCheck);
void Layout();
- uint32_t GetPartStates() const;
+ Mask<CFWL_PartState> GetPartStates() const;
void UpdateTextOutStyles();
void NextStates();
void OnFocusGained();
diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp
index c602b17..c1081dc 100644
--- a/xfa/fwl/cfwl_combobox.cpp
+++ b/xfa/fwl/cfwl_combobox.cpp
@@ -450,9 +450,9 @@
void CFWL_ComboBox::OnLButtonUp(CFWL_MessageMouse* pMsg) {
if (m_BtnRect.Contains(pMsg->m_pos))
- m_iBtnState = CFWL_PartState_Hovered;
+ m_iBtnState = CFWL_PartState::kHovered;
else
- m_iBtnState = CFWL_PartState_Normal;
+ m_iBtnState = CFWL_PartState::kNormal;
RepaintRect(m_BtnRect);
}
diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h
index e115f75..029f3e9 100644
--- a/xfa/fwl/cfwl_combobox.h
+++ b/xfa/fwl/cfwl_combobox.h
@@ -119,7 +119,7 @@
cppgc::Member<CFWL_ComboEdit> const m_pEdit;
cppgc::Member<CFWL_ComboList> const m_pListBox;
int32_t m_iCurSel = -1;
- int32_t m_iBtnState = CFWL_PartState_Normal;
+ Mask<CFWL_PartState> m_iBtnState = CFWL_PartState::kNormal;
};
#endif // XFA_FWL_CFWL_COMBOBOX_H_
diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp
index 20aca78..3d19bf5 100644
--- a/xfa/fwl/cfwl_datetimepicker.cpp
+++ b/xfa/fwl/cfwl_datetimepicker.cpp
@@ -397,22 +397,22 @@
m_bLBtnDown = false;
if (m_BtnRect.Contains(pMsg->m_pos))
- m_iBtnState = CFWL_PartState_Hovered;
+ m_iBtnState = CFWL_PartState::kHovered;
else
- m_iBtnState = CFWL_PartState_Normal;
+ m_iBtnState = CFWL_PartState::kNormal;
RepaintRect(m_BtnRect);
}
void CFWL_DateTimePicker::OnMouseMove(CFWL_MessageMouse* pMsg) {
if (!m_BtnRect.Contains(pMsg->m_pos))
- m_iBtnState = CFWL_PartState_Normal;
+ m_iBtnState = CFWL_PartState::kNormal;
RepaintRect(m_BtnRect);
}
void CFWL_DateTimePicker::OnMouseLeave(CFWL_MessageMouse* pMsg) {
if (!pMsg)
return;
- m_iBtnState = CFWL_PartState_Normal;
+ m_iBtnState = CFWL_PartState::kNormal;
RepaintRect(m_BtnRect);
}
diff --git a/xfa/fwl/cfwl_datetimepicker.h b/xfa/fwl/cfwl_datetimepicker.h
index 3e45630..9c144a7 100644
--- a/xfa/fwl/cfwl_datetimepicker.h
+++ b/xfa/fwl/cfwl_datetimepicker.h
@@ -99,7 +99,7 @@
void RepaintInflatedMonthCalRect();
bool m_bLBtnDown = false;
- int32_t m_iBtnState = 1;
+ Mask<CFWL_PartState> m_iBtnState = CFWL_PartState::kChecked;
int32_t m_iYear = -1;
int32_t m_iMonth = -1;
int32_t m_iDay = -1;
diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp
index 10e59ad..bf6c8f6 100644
--- a/xfa/fwl/cfwl_listbox.cpp
+++ b/xfa/fwl/cfwl_listbox.cpp
@@ -324,7 +324,7 @@
if (IsShowHorzScrollBar() && IsShowVertScrollBar())
param.m_pRtData = &m_StaticRect;
if (!IsEnabled())
- param.m_dwStates = CFWL_PartState_Disabled;
+ param.m_dwStates = CFWL_PartState::kDisabled;
GetThemeProvider()->DrawBackground(param);
}
@@ -365,15 +365,15 @@
int32_t Index,
const CFX_RectF& rtItem,
const CFX_Matrix& mtMatrix) {
- CFWL_PartStateMask dwPartStates = CFWL_PartState_Normal;
+ Mask<CFWL_PartState> dwPartStates = CFWL_PartState::kNormal;
if (m_Properties.m_dwStates & FWL_STATE_WGT_Disabled)
- dwPartStates = CFWL_PartState_Disabled;
+ dwPartStates = CFWL_PartState::kDisabled;
else if (pItem && pItem->IsSelected())
- dwPartStates = CFWL_PartState_Selected;
+ dwPartStates = CFWL_PartState::kSelected;
if ((m_Properties.m_dwStates & FWL_STATE_WGT_Focused) && pItem &&
pItem->IsFocused()) {
- dwPartStates |= CFWL_PartState_Focused;
+ dwPartStates |= CFWL_PartState::kFocused;
}
CFX_RectF rtFocus(rtItem); // Must outlive |bg_param|.
@@ -385,7 +385,7 @@
bg_param.m_bMaximize = true;
bg_param.m_pRtData = &rtFocus;
if (m_pVertScrollBar && !m_pHorzScrollBar &&
- (dwPartStates & CFWL_PartState_Focused)) {
+ (dwPartStates & CFWL_PartState::kFocused)) {
bg_param.m_PartRect.left += 1;
bg_param.m_PartRect.width -= (m_fScorllBarWidth + 1);
rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1);
diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp
index ee5e37e..b04dac3 100644
--- a/xfa/fwl/cfwl_monthcalendar.cpp
+++ b/xfa/fwl/cfwl_monthcalendar.cpp
@@ -221,19 +221,19 @@
for (int32_t j = 0; j < iCount; j++) {
DATEINFO* pDataInfo = m_DateArray[j].get();
if (pDataInfo->bSelected) {
- params.m_dwStates |= CFWL_PartState_Selected;
+ params.m_dwStates |= CFWL_PartState::kSelected;
if (pDataInfo->bFlagged) {
- params.m_dwStates |= CFWL_PartState_Flagged;
+ params.m_dwStates |= CFWL_PartState::kFlagged;
}
} else if (j == m_iHovered - 1) {
- params.m_dwStates |= CFWL_PartState_Hovered;
+ params.m_dwStates |= CFWL_PartState::kHovered;
} else if (pDataInfo->bFlagged) {
- params.m_dwStates = CFWL_PartState_Flagged;
+ params.m_dwStates = CFWL_PartState::kFlagged;
pTheme->DrawBackground(params);
}
params.m_PartRect = pDataInfo->rect;
pTheme->DrawBackground(params);
- params.m_dwStates = 0;
+ params.m_dwStates = CFWL_PartState::kNormal;
}
}
@@ -287,7 +287,7 @@
params.m_PartRect = pDataInfo->rect;
params.m_dwStates = pDataInfo->AsPartStateMask();
if (j + 1 == m_iHovered)
- params.m_dwStates |= CFWL_PartState_Hovered;
+ params.m_dwStates |= CFWL_PartState::kHovered;
params.m_dwTTOStyles.single_line_ = true;
pTheme->DrawText(params);
@@ -640,11 +640,11 @@
void CFWL_MonthCalendar::OnLButtonDown(CFWL_MessageMouse* pMsg) {
if (m_LBtnRect.Contains(pMsg->m_pos)) {
- m_iLBtnPartStates = CFWL_PartState_Pressed;
+ m_iLBtnPartStates = CFWL_PartState::kPressed;
PrevMonth();
RepaintRect(m_ClientRect);
} else if (m_RBtnRect.Contains(pMsg->m_pos)) {
- m_iRBtnPartStates |= CFWL_PartState_Pressed;
+ m_iRBtnPartStates |= CFWL_PartState::kPressed;
NextMonth();
RepaintRect(m_ClientRect);
} else if (m_TodayRect.Contains(pMsg->m_pos)) {
@@ -655,12 +655,12 @@
void CFWL_MonthCalendar::OnLButtonUp(CFWL_MessageMouse* pMsg) {
if (m_LBtnRect.Contains(pMsg->m_pos)) {
- m_iLBtnPartStates = 0;
+ m_iLBtnPartStates = CFWL_PartState::kNormal;
RepaintRect(m_LBtnRect);
return;
}
if (m_RBtnRect.Contains(pMsg->m_pos)) {
- m_iRBtnPartStates = 0;
+ m_iRBtnPartStates = CFWL_PartState::kNormal;
RepaintRect(m_RBtnRect);
return;
}
@@ -739,11 +739,11 @@
CFWL_MonthCalendar::DATEINFO::~DATEINFO() = default;
-CFWL_PartStateMask CFWL_MonthCalendar::DATEINFO::AsPartStateMask() const {
- CFWL_PartStateMask dwStates = 0;
+Mask<CFWL_PartState> CFWL_MonthCalendar::DATEINFO::AsPartStateMask() const {
+ Mask<CFWL_PartState> dwStates = CFWL_PartState::kNormal;
if (bFlagged)
- dwStates |= CFWL_PartState_Flagged;
+ dwStates |= CFWL_PartState::kFlagged;
if (bSelected)
- dwStates |= CFWL_PartState_Selected;
+ dwStates |= CFWL_PartState::kSelected;
return dwStates;
}
diff --git a/xfa/fwl/cfwl_monthcalendar.h b/xfa/fwl/cfwl_monthcalendar.h
index 1e63e3d..0ce018c 100644
--- a/xfa/fwl/cfwl_monthcalendar.h
+++ b/xfa/fwl/cfwl_monthcalendar.h
@@ -77,7 +77,7 @@
const WideString& wsday);
~DATEINFO();
- CFWL_PartStateMask AsPartStateMask() const;
+ Mask<CFWL_PartState> AsPartStateMask() const;
const int32_t iDay;
const int32_t iDayOfWeek;
@@ -146,8 +146,8 @@
int32_t m_iMonth = 1;
int32_t m_iDay = 1;
int32_t m_iHovered = -1;
- int32_t m_iLBtnPartStates = CFWL_PartState_Normal;
- int32_t m_iRBtnPartStates = CFWL_PartState_Normal;
+ Mask<CFWL_PartState> m_iLBtnPartStates = CFWL_PartState::kNormal;
+ Mask<CFWL_PartState> m_iRBtnPartStates = CFWL_PartState::kNormal;
DATE m_dtMin;
DATE m_dtMax;
CFX_SizeF m_HeadSize;
diff --git a/xfa/fwl/cfwl_pushbutton.cpp b/xfa/fwl/cfwl_pushbutton.cpp
index cb9b9a3..9d17565 100644
--- a/xfa/fwl/cfwl_pushbutton.cpp
+++ b/xfa/fwl/cfwl_pushbutton.cpp
@@ -65,16 +65,16 @@
GetThemeProvider()->DrawBackground(param);
}
-uint32_t CFWL_PushButton::GetPartStates() {
- uint32_t dwStates = CFWL_PartState_Normal;
+Mask<CFWL_PartState> CFWL_PushButton::GetPartStates() {
+ Mask<CFWL_PartState> dwStates = CFWL_PartState::kNormal;
if (m_Properties.m_dwStates & FWL_STATE_WGT_Focused)
- dwStates |= CFWL_PartState_Focused;
+ dwStates |= CFWL_PartState::kFocused;
if (m_Properties.m_dwStates & FWL_STATE_WGT_Disabled)
- dwStates = CFWL_PartState_Disabled;
+ dwStates = CFWL_PartState::kDisabled;
else if (m_Properties.m_dwStates & FWL_STATE_PSB_Pressed)
- dwStates |= CFWL_PartState_Pressed;
+ dwStates |= CFWL_PartState::kPressed;
else if (m_Properties.m_dwStates & FWL_STATE_PSB_Hovered)
- dwStates |= CFWL_PartState_Hovered;
+ dwStates |= CFWL_PartState::kHovered;
return dwStates;
}
diff --git a/xfa/fwl/cfwl_pushbutton.h b/xfa/fwl/cfwl_pushbutton.h
index 341a4b4..4bd96de 100644
--- a/xfa/fwl/cfwl_pushbutton.h
+++ b/xfa/fwl/cfwl_pushbutton.h
@@ -35,7 +35,7 @@
explicit CFWL_PushButton(CFWL_App* pApp);
void DrawBkground(CFGAS_GEGraphics* pGraphics, const CFX_Matrix& mtMatrix);
- uint32_t GetPartStates();
+ Mask<CFWL_PartState> GetPartStates();
void UpdateTextOutStyles();
void OnFocusGained();
void OnFocusLost();
diff --git a/xfa/fwl/cfwl_scrollbar.cpp b/xfa/fwl/cfwl_scrollbar.cpp
index ddcbab5..277e24b 100644
--- a/xfa/fwl/cfwl_scrollbar.cpp
+++ b/xfa/fwl/cfwl_scrollbar.cpp
@@ -80,7 +80,7 @@
param.m_iPart = bLower ? CFWL_ThemePart::Part::kLowerTrack
: CFWL_ThemePart::Part::kUpperTrack;
param.m_dwStates = (m_Properties.m_dwStates & FWL_STATE_WGT_Disabled)
- ? CFWL_PartState_Disabled
+ ? CFWL_PartState::kDisabled
: (bLower ? m_iMinTrackState : m_iMaxTrackState);
param.m_matrix = mtMatrix;
param.m_PartRect = bLower ? m_MinTrackRect : m_MaxTrackRect;
@@ -94,7 +94,7 @@
param.m_iPart = bMinBtn ? CFWL_ThemePart::Part::kForeArrow
: CFWL_ThemePart::Part::kBackArrow;
param.m_dwStates = (m_Properties.m_dwStates & FWL_STATE_WGT_Disabled)
- ? CFWL_PartState_Disabled
+ ? CFWL_PartState::kDisabled
: (bMinBtn ? m_iMinButtonState : m_iMaxButtonState);
param.m_matrix = mtMatrix;
param.m_PartRect = bMinBtn ? m_MinBtnRect : m_MaxBtnRect;
@@ -107,7 +107,7 @@
CFWL_ThemeBackground param(this, pGraphics);
param.m_iPart = CFWL_ThemePart::Part::kThumb;
param.m_dwStates = (m_Properties.m_dwStates & FWL_STATE_WGT_Disabled)
- ? CFWL_PartState_Disabled
+ ? CFWL_PartState::kDisabled
: m_iThumbButtonState;
param.m_matrix = mtMatrix;
param.m_PartRect = m_ThumbRect;
@@ -255,19 +255,19 @@
}
bool CFWL_ScrollBar::SendEvent() {
- if (m_iMinButtonState == CFWL_PartState_Pressed) {
+ if (m_iMinButtonState == CFWL_PartState::kPressed) {
DoScroll(CFWL_EventScroll::Code::StepBackward, m_fTrackPos);
return false;
}
- if (m_iMaxButtonState == CFWL_PartState_Pressed) {
+ if (m_iMaxButtonState == CFWL_PartState::kPressed) {
DoScroll(CFWL_EventScroll::Code::StepForward, m_fTrackPos);
return false;
}
- if (m_iMinTrackState == CFWL_PartState_Pressed) {
+ if (m_iMinTrackState == CFWL_PartState::kPressed) {
DoScroll(CFWL_EventScroll::Code::PageBackward, m_fTrackPos);
return m_ThumbRect.Contains(m_cpTrackPoint);
}
- if (m_iMaxTrackState == CFWL_PartState_Pressed) {
+ if (m_iMaxTrackState == CFWL_PartState::kPressed) {
DoScroll(CFWL_EventScroll::Code::PageForward, m_fTrackPos);
return m_ThumbRect.Contains(m_cpTrackPoint);
}
@@ -382,10 +382,10 @@
const CFX_PointF& point) {
if (!rtItem.Contains(point))
return;
- if (*pState == CFWL_PartState_Pressed)
+ if (*pState == CFWL_PartState::kPressed)
return;
- *pState = CFWL_PartState_Pressed;
+ *pState = CFWL_PartState::kPressed;
RepaintRect(rtItem);
}
@@ -393,8 +393,8 @@
const CFX_RectF& rtItem,
CFWL_PartState* pState,
const CFX_PointF& point) {
- CFWL_PartState iNewState =
- rtItem.Contains(point) ? CFWL_PartState_Hovered : CFWL_PartState_Normal;
+ CFWL_PartState iNewState = rtItem.Contains(point) ? CFWL_PartState::kHovered
+ : CFWL_PartState::kNormal;
if (*pState == iNewState)
return;
@@ -408,14 +408,15 @@
CFWL_PartState* pState,
const CFX_PointF& point) {
if (!m_bMouseDown) {
- CFWL_PartState iNewState =
- rtItem.Contains(point) ? CFWL_PartState_Hovered : CFWL_PartState_Normal;
+ CFWL_PartState iNewState = rtItem.Contains(point) ? CFWL_PartState::kHovered
+ : CFWL_PartState::kNormal;
if (*pState == iNewState)
return;
*pState = iNewState;
RepaintRect(rtItem);
- } else if ((2 == iItem) && (m_iThumbButtonState == CFWL_PartState_Pressed)) {
+ } else if ((2 == iItem) &&
+ (m_iThumbButtonState == CFWL_PartState::kPressed)) {
m_fTrackPos = GetTrackPointPos(point);
OnScroll(CFWL_EventScroll::Code::TrackPos, m_fTrackPos);
}
@@ -424,20 +425,20 @@
void CFWL_ScrollBar::DoMouseLeave(int32_t iItem,
const CFX_RectF& rtItem,
CFWL_PartState* pState) {
- if (*pState == CFWL_PartState_Normal)
+ if (*pState == CFWL_PartState::kNormal)
return;
- *pState = CFWL_PartState_Normal;
+ *pState = CFWL_PartState::kNormal;
RepaintRect(rtItem);
}
void CFWL_ScrollBar::DoMouseHover(int32_t iItem,
const CFX_RectF& rtItem,
CFWL_PartState* pState) {
- if (*pState == CFWL_PartState_Hovered)
+ if (*pState == CFWL_PartState::kHovered)
return;
- *pState = CFWL_PartState_Hovered;
+ *pState = CFWL_PartState::kHovered;
RepaintRect(rtItem);
}
diff --git a/xfa/fwl/cfwl_scrollbar.h b/xfa/fwl/cfwl_scrollbar.h
index 1f9d04f..ab8645a 100644
--- a/xfa/fwl/cfwl_scrollbar.h
+++ b/xfa/fwl/cfwl_scrollbar.h
@@ -111,11 +111,11 @@
float m_fStepSize = 0.0f;
float m_fPos = 0.0f;
float m_fTrackPos = 0.0f;
- CFWL_PartState m_iMinButtonState = CFWL_PartState_Normal;
- CFWL_PartState m_iMaxButtonState = CFWL_PartState_Normal;
- CFWL_PartState m_iThumbButtonState = CFWL_PartState_Normal;
- CFWL_PartState m_iMinTrackState = CFWL_PartState_Normal;
- CFWL_PartState m_iMaxTrackState = CFWL_PartState_Normal;
+ CFWL_PartState m_iMinButtonState = CFWL_PartState::kNormal;
+ CFWL_PartState m_iMaxButtonState = CFWL_PartState::kNormal;
+ CFWL_PartState m_iThumbButtonState = CFWL_PartState::kNormal;
+ CFWL_PartState m_iMinTrackState = CFWL_PartState::kNormal;
+ CFWL_PartState m_iMaxTrackState = CFWL_PartState::kNormal;
float m_fLastTrackPos = 0.0f;
CFX_PointF m_cpTrackPoint;
int32_t m_iMouseWheel = 0;
diff --git a/xfa/fwl/cfwl_themepart.cpp b/xfa/fwl/cfwl_themepart.cpp
index 69bdb37..090712e 100644
--- a/xfa/fwl/cfwl_themepart.cpp
+++ b/xfa/fwl/cfwl_themepart.cpp
@@ -11,11 +11,11 @@
CFWL_ThemePart::~CFWL_ThemePart() = default;
FWLTHEME_STATE CFWL_ThemePart::GetThemeState() const {
- if (m_dwStates & CFWL_PartState_Disabled)
+ if (m_dwStates & CFWL_PartState::kDisabled)
return FWLTHEME_STATE::kDisable;
- if (m_dwStates & CFWL_PartState_Pressed)
+ if (m_dwStates & CFWL_PartState::kPressed)
return FWLTHEME_STATE::kPressed;
- if (m_dwStates & CFWL_PartState_Hovered)
+ if (m_dwStates & CFWL_PartState::kHovered)
return FWLTHEME_STATE::kHover;
return FWLTHEME_STATE::kNormal;
}
diff --git a/xfa/fwl/cfwl_themepart.h b/xfa/fwl/cfwl_themepart.h
index fc1d1a6..6346a3b 100644
--- a/xfa/fwl/cfwl_themepart.h
+++ b/xfa/fwl/cfwl_themepart.h
@@ -12,29 +12,28 @@
#include <type_traits>
#include "core/fxcrt/fx_coordinates.h"
+#include "core/fxcrt/mask.h"
#include "core/fxcrt/unowned_ptr.h"
#include "xfa/fwl/theme/cfwl_utils.h"
class CFWL_Widget;
-enum CFWL_PartState : uint32_t {
- CFWL_PartState_Normal = 0,
-
- CFWL_PartState_Checked = 1 << 1,
- CFWL_PartState_Default = 1 << 2,
- CFWL_PartState_Disabled = 1 << 3,
- CFWL_PartState_Flagged = 1 << 4,
- CFWL_PartState_Focused = 1 << 5,
- CFWL_PartState_HightLight = 1 << 6,
- CFWL_PartState_Hovered = 1 << 7,
- CFWL_PartState_Neutral = 1 << 9,
- CFWL_PartState_Pressed = 1 << 10,
- CFWL_PartState_ReadOnly = 1 << 11,
- CFWL_PartState_LSelected = 1 << 12,
- CFWL_PartState_RSelected = 1 << 13,
- CFWL_PartState_Selected = 1 << 14
+enum class CFWL_PartState : uint16_t {
+ kNormal = 0,
+ kChecked = 1 << 1,
+ kDefault = 1 << 2,
+ kDisabled = 1 << 3,
+ kFlagged = 1 << 4,
+ kFocused = 1 << 5,
+ kHightLight = 1 << 6,
+ kHovered = 1 << 7,
+ kNeutral = 1 << 9,
+ kPressed = 1 << 10,
+ kReadOnly = 1 << 11,
+ kLSelected = 1 << 12,
+ kRSelected = 1 << 13,
+ kSelected = 1 << 14
};
-using CFWL_PartStateMask = std::underlying_type<CFWL_PartState>::type;
class CFWL_ThemePart {
public:
@@ -93,7 +92,7 @@
CFX_Matrix m_matrix;
CFX_RectF m_PartRect;
UnownedPtr<const CFX_RectF> m_pRtData;
- CFWL_PartStateMask m_dwStates = CFWL_PartState_Normal;
+ Mask<CFWL_PartState> m_dwStates = CFWL_PartState::kNormal;
Part m_iPart = Part::kNone;
bool m_bMaximize = false;
bool m_bStaticBackground = false;
diff --git a/xfa/fwl/theme/cfwl_carettp.cpp b/xfa/fwl/theme/cfwl_carettp.cpp
index 8859e3e..b40b810 100644
--- a/xfa/fwl/theme/cfwl_carettp.cpp
+++ b/xfa/fwl/theme/cfwl_carettp.cpp
@@ -20,7 +20,7 @@
void CFWL_CaretTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
switch (pParams.m_iPart) {
case CFWL_ThemePart::Part::kBackground: {
- if (!(pParams.m_dwStates & CFWL_PartState_HightLight))
+ if (!(pParams.m_dwStates & CFWL_PartState::kHightLight))
return;
DrawCaretBK(pParams.GetGraphics(), pParams.m_dwStates, pParams.m_PartRect,
@@ -33,7 +33,7 @@
}
void CFWL_CaretTP::DrawCaretBK(CFGAS_GEGraphics* pGraphics,
- uint32_t dwStates,
+ Mask<CFWL_PartState> dwStates,
const CFX_RectF& rect,
const CFX_Matrix& matrix) {
CFGAS_GEPath path;
diff --git a/xfa/fwl/theme/cfwl_carettp.h b/xfa/fwl/theme/cfwl_carettp.h
index 071a0be..8470f0e 100644
--- a/xfa/fwl/theme/cfwl_carettp.h
+++ b/xfa/fwl/theme/cfwl_carettp.h
@@ -8,6 +8,7 @@
#define XFA_FWL_THEME_CFWL_CARETTP_H_
#include "fxjs/gc/heap.h"
+#include "xfa/fwl/cfwl_themepart.h"
#include "xfa/fwl/theme/cfwl_widgettp.h"
class CFWL_CaretTP final : public CFWL_WidgetTP {
@@ -22,7 +23,7 @@
CFWL_CaretTP();
void DrawCaretBK(CFGAS_GEGraphics* pGraphics,
- uint32_t dwStates,
+ Mask<CFWL_PartState> dwStates,
const CFX_RectF& rect,
const CFX_Matrix& matrix);
};
diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp
index 5007976..6cff533 100644
--- a/xfa/fwl/theme/cfwl_checkboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp
@@ -38,7 +38,7 @@
void CFWL_CheckBoxTP::DrawText(const CFWL_ThemeText& pParams) {
EnsureTTOInitialized();
- m_pTextOut->SetTextColor(pParams.m_dwStates & CFWL_PartState_Disabled
+ m_pTextOut->SetTextColor(pParams.m_dwStates & CFWL_PartState::kDisabled
? FWLTHEME_CAPACITY_TextDisColor
: FWLTHEME_CAPACITY_TextColor);
CFWL_WidgetTP::DrawText(pParams);
@@ -211,8 +211,8 @@
if (pParams.m_iPart != CFWL_ThemePart::Part::kCheckBox)
return;
- if ((pParams.m_dwStates & CFWL_PartState_Checked) ||
- (pParams.m_dwStates & CFWL_PartState_Neutral)) {
+ if ((pParams.m_dwStates & CFWL_PartState::kChecked) ||
+ (pParams.m_dwStates & CFWL_PartState::kNeutral)) {
DrawCheckSign(pParams.GetWidget(), pParams.GetGraphics(),
pParams.m_PartRect, pParams.m_dwStates, pParams.m_matrix);
}
@@ -221,11 +221,11 @@
void CFWL_CheckBoxTP::DrawCheckSign(CFWL_Widget* pWidget,
CFGAS_GEGraphics* pGraphics,
const CFX_RectF& pRtBox,
- int32_t iState,
+ Mask<CFWL_PartState> iState,
const CFX_Matrix& matrix) {
CFX_RectF rtSign(pRtBox);
- uint32_t dwColor = iState & CFWL_PartState_Neutral ? 0xFFA9A9A9 : 0xFF000000;
-
+ uint32_t dwColor =
+ iState & CFWL_PartState::kNeutral ? 0xFFA9A9A9 : 0xFF000000;
uint32_t dwStyle = pWidget->GetStyleExts();
rtSign.Deflate(rtSign.width / 4, rtSign.height / 4);
switch (dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) {
diff --git a/xfa/fwl/theme/cfwl_checkboxtp.h b/xfa/fwl/theme/cfwl_checkboxtp.h
index 997272a..a1c35f1 100644
--- a/xfa/fwl/theme/cfwl_checkboxtp.h
+++ b/xfa/fwl/theme/cfwl_checkboxtp.h
@@ -10,6 +10,7 @@
#include <memory>
#include "fxjs/gc/heap.h"
+#include "xfa/fwl/cfwl_themepart.h"
#include "xfa/fwl/theme/cfwl_widgettp.h"
class CFGAS_GEPath;
@@ -30,7 +31,7 @@
void DrawCheckSign(CFWL_Widget* pWidget,
CFGAS_GEGraphics* pGraphics,
const CFX_RectF& pRtBox,
- int32_t iState,
+ Mask<CFWL_PartState> iState,
const CFX_Matrix& matrix);
void DrawSignCheck(CFGAS_GEGraphics* pGraphics,
const CFX_RectF& rtSign,
diff --git a/xfa/fwl/theme/cfwl_comboboxtp.cpp b/xfa/fwl/theme/cfwl_comboboxtp.cpp
index 969ccc3..e04fb77 100644
--- a/xfa/fwl/theme/cfwl_comboboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_comboboxtp.cpp
@@ -28,16 +28,13 @@
const CFX_RectF& rect = pParams.m_PartRect;
path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
FX_ARGB argb_color;
- switch (pParams.m_dwStates) {
- case CFWL_PartState_Selected:
- argb_color = FWLTHEME_COLOR_BKSelected;
- break;
- case CFWL_PartState_Disabled:
- argb_color = FWLTHEME_COLOR_EDGERB1;
- break;
- default:
- argb_color = 0xFFFFFFFF;
- }
+ if (pParams.m_dwStates & CFWL_PartState::kSelected)
+ argb_color = FWLTHEME_COLOR_BKSelected;
+ else if (pParams.m_dwStates & CFWL_PartState::kDisabled)
+ argb_color = FWLTHEME_COLOR_EDGERB1;
+ else
+ argb_color = 0xFFFFFFFF;
+
pParams.GetGraphics()->SaveGraphState();
pParams.GetGraphics()->SetFillColor(CFGAS_GEColor(argb_color));
pParams.GetGraphics()->FillPath(
diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp
index 527cb5c..39c65f9 100644
--- a/xfa/fwl/theme/cfwl_edittp.cpp
+++ b/xfa/fwl/theme/cfwl_edittp.cpp
@@ -40,9 +40,9 @@
pParams.m_PartRect.width, pParams.m_PartRect.height);
CFGAS_GEColor cr(FWLTHEME_COLOR_Background);
if (!pParams.m_bStaticBackground) {
- if (pParams.m_dwStates & CFWL_PartState_Disabled)
+ if (pParams.m_dwStates & CFWL_PartState::kDisabled)
cr = CFGAS_GEColor(FWLTHEME_COLOR_EDGERB1);
- else if (pParams.m_dwStates & CFWL_PartState_ReadOnly)
+ else if (pParams.m_dwStates & CFWL_PartState::kReadOnly)
cr = CFGAS_GEColor(ArgbEncode(255, 236, 233, 216));
else
cr = CFGAS_GEColor(0xFFFFFFFF);
diff --git a/xfa/fwl/theme/cfwl_listboxtp.cpp b/xfa/fwl/theme/cfwl_listboxtp.cpp
index df2ae46..3292079 100644
--- a/xfa/fwl/theme/cfwl_listboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_listboxtp.cpp
@@ -40,9 +40,9 @@
}
case CFWL_ThemePart::Part::kCheck: {
uint32_t color = 0xFF000000;
- if (pParams.m_dwStates == CFWL_PartState_Checked) {
+ if (pParams.m_dwStates == CFWL_PartState::kChecked) {
color = 0xFFFF0000;
- } else if (pParams.m_dwStates == CFWL_PartState_Normal) {
+ } else if (pParams.m_dwStates == CFWL_PartState::kNormal) {
color = 0xFF0000FF;
}
FillSolidRect(pParams.GetGraphics(), color, pParams.m_PartRect,
@@ -55,11 +55,11 @@
}
void CFWL_ListBoxTP::DrawListBoxItem(CFGAS_GEGraphics* pGraphics,
- uint32_t dwStates,
+ Mask<CFWL_PartState> dwStates,
const CFX_RectF& rtItem,
const CFX_RectF* pData,
const CFX_Matrix& matrix) {
- if (dwStates & CFWL_PartState_Selected) {
+ if (dwStates & CFWL_PartState::kSelected) {
pGraphics->SaveGraphState();
pGraphics->SetFillColor(CFGAS_GEColor(FWLTHEME_COLOR_BKSelected));
CFGAS_GEPath path;
@@ -73,6 +73,6 @@
matrix);
pGraphics->RestoreGraphState();
}
- if ((dwStates & CFWL_PartState_Focused) && pData)
+ if ((dwStates & CFWL_PartState::kFocused) && pData)
DrawFocus(pGraphics, *pData, matrix);
}
diff --git a/xfa/fwl/theme/cfwl_listboxtp.h b/xfa/fwl/theme/cfwl_listboxtp.h
index 5f5a5bb..aec658f 100644
--- a/xfa/fwl/theme/cfwl_listboxtp.h
+++ b/xfa/fwl/theme/cfwl_listboxtp.h
@@ -8,6 +8,7 @@
#define XFA_FWL_THEME_CFWL_LISTBOXTP_H_
#include "fxjs/gc/heap.h"
+#include "xfa/fwl/cfwl_themepart.h"
#include "xfa/fwl/theme/cfwl_widgettp.h"
class CFWL_ListBoxTP final : public CFWL_WidgetTP {
@@ -22,7 +23,7 @@
CFWL_ListBoxTP();
void DrawListBoxItem(CFGAS_GEGraphics* pGraphics,
- uint32_t dwStates,
+ Mask<CFWL_PartState> dwStates,
const CFX_RectF& rtItem,
const CFX_RectF* pData,
const CFX_Matrix& matrix);
diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/xfa/fwl/theme/cfwl_monthcalendartp.cpp
index 2f28c67..8b85af6 100644
--- a/xfa/fwl/theme/cfwl_monthcalendartp.cpp
+++ b/xfa/fwl/theme/cfwl_monthcalendartp.cpp
@@ -86,9 +86,9 @@
void CFWL_MonthCalendarTP::DrawText(const CFWL_ThemeText& pParams) {
EnsureTTOInitialized();
if (pParams.m_iPart == CFWL_ThemePart::Part::kDatesIn &&
- !(pParams.m_dwStates & CFWL_PartState_Flagged) &&
- (pParams.m_dwStates &
- (CFWL_PartState_Hovered | CFWL_PartState_Selected))) {
+ !(pParams.m_dwStates & CFWL_PartState::kFlagged) &&
+ (pParams.m_dwStates & Mask<CFWL_PartState>{CFWL_PartState::kHovered,
+ CFWL_PartState::kSelected})) {
m_pTextOut->SetTextColor(0xFFFFFFFF);
} else if (pParams.m_iPart == CFWL_ThemePart::Part::kCaption) {
m_pTextOut->SetTextColor(kCaptionColor);
@@ -131,7 +131,7 @@
pParams.GetGraphics()->SetStrokeColor(
CFGAS_GEColor(ArgbEncode(0xff, 205, 219, 243)));
pParams.GetGraphics()->StrokePath(path, matrix);
- if (pParams.m_dwStates & CFWL_PartState_Pressed) {
+ if (pParams.m_dwStates & CFWL_PartState::kPressed) {
pParams.GetGraphics()->SetFillColor(
CFGAS_GEColor(ArgbEncode(0xff, 174, 198, 242)));
pParams.GetGraphics()->FillPath(
@@ -166,7 +166,7 @@
pParams.GetGraphics()->SetStrokeColor(
CFGAS_GEColor(ArgbEncode(0xff, 205, 219, 243)));
pParams.GetGraphics()->StrokePath(path, matrix);
- if (pParams.m_dwStates & CFWL_PartState_Pressed) {
+ if (pParams.m_dwStates & CFWL_PartState::kPressed) {
pParams.GetGraphics()->SetFillColor(
CFGAS_GEColor(ArgbEncode(0xff, 174, 198, 242)));
pParams.GetGraphics()->FillPath(
@@ -219,7 +219,7 @@
void CFWL_MonthCalendarTP::DrawDatesInBK(const CFWL_ThemeBackground& pParams,
const CFX_Matrix& matrix) {
pParams.GetGraphics()->SaveGraphState();
- if (pParams.m_dwStates & CFWL_PartState_Selected) {
+ if (pParams.m_dwStates & CFWL_PartState::kSelected) {
CFGAS_GEPath path;
CFX_RectF rtSelDay = pParams.m_PartRect;
path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width,
@@ -228,7 +228,7 @@
CFGAS_GEColor(kDatesSelectedBackgroundColor));
pParams.GetGraphics()->FillPath(
path, CFX_FillRenderOptions::FillType::kWinding, matrix);
- } else if (pParams.m_dwStates & CFWL_PartState_Hovered) {
+ } else if (pParams.m_dwStates & CFWL_PartState::kHovered) {
CFGAS_GEPath path;
CFX_RectF rtSelDay = pParams.m_PartRect;
path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width,
diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.cpp b/xfa/fwl/theme/cfwl_pushbuttontp.cpp
index 9dbf0f6..a0ccdea 100644
--- a/xfa/fwl/theme/cfwl_pushbuttontp.cpp
+++ b/xfa/fwl/theme/cfwl_pushbuttontp.cpp
@@ -77,7 +77,7 @@
pGraphics->SetFillColor(CFGAS_GEColor(m_pThemeData->clrFill[iColor]));
pGraphics->FillPath(fillPath, CFX_FillRenderOptions::FillType::kWinding,
pParams.m_matrix);
- if (pParams.m_dwStates & CFWL_PartState_Focused) {
+ if (pParams.m_dwStates & CFWL_PartState::kFocused) {
rtInner.Inflate(1, 1, 0, 0);
DrawFocus(pGraphics, rtInner, pParams.m_matrix);
}
@@ -112,16 +112,16 @@
m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
}
-int32_t CFWL_PushButtonTP::GetColorID(uint32_t dwStates) const {
+int32_t CFWL_PushButtonTP::GetColorID(Mask<CFWL_PartState> dwStates) const {
int32_t color = 0;
- if (dwStates & CFWL_PartState_Disabled)
+ if (dwStates & CFWL_PartState::kDisabled)
color += 4;
- if (dwStates & CFWL_PartState_Default) {
+ if (dwStates & CFWL_PartState::kDefault) {
color += 3;
} else {
- if (dwStates & CFWL_PartState_Hovered)
+ if (dwStates & CFWL_PartState::kHovered)
color += 2;
- if (dwStates & CFWL_PartState_Pressed)
+ if (dwStates & CFWL_PartState::kPressed)
color += 1;
}
return color;
diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.h b/xfa/fwl/theme/cfwl_pushbuttontp.h
index 0da17b9..acd62ea 100644
--- a/xfa/fwl/theme/cfwl_pushbuttontp.h
+++ b/xfa/fwl/theme/cfwl_pushbuttontp.h
@@ -10,6 +10,7 @@
#include <memory>
#include "fxjs/gc/heap.h"
+#include "xfa/fwl/cfwl_themepart.h"
#include "xfa/fwl/theme/cfwl_widgettp.h"
class CFWL_PushButtonTP final : public CFWL_WidgetTP {
@@ -30,7 +31,7 @@
CFWL_PushButtonTP();
- int32_t GetColorID(uint32_t dwStates) const;
+ int32_t GetColorID(Mask<CFWL_PartState> dwStates) const;
void SetThemeData();
std::unique_ptr<PBThemeData> m_pThemeData;
diff --git a/xfa/fxfa/cxfa_fwltheme.cpp b/xfa/fxfa/cxfa_fwltheme.cpp
index 1379f97..ca00815 100644
--- a/xfa/fxfa/cxfa_fwltheme.cpp
+++ b/xfa/fxfa/cxfa_fwltheme.cpp
@@ -101,9 +101,10 @@
m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize);
m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
if ((pParams.m_iPart == CFWL_ThemePart::Part::kDatesIn) &&
- !(pParams.m_dwStates & CFWL_PartState_Flagged) &&
+ !(pParams.m_dwStates & CFWL_PartState::kFlagged) &&
(pParams.m_dwStates &
- (CFWL_PartState_Hovered | CFWL_PartState_Selected))) {
+ Mask<CFWL_PartState>{CFWL_PartState::kHovered,
+ CFWL_PartState::kSelected})) {
m_pTextOut->SetTextColor(0xFF888888);
}
if (pParams.m_iPart == CFWL_ThemePart::Part::kCaption)