diff options
author | dsinclair <dsinclair@chromium.org> | 2016-12-07 17:58:41 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-12-07 17:58:41 -0800 |
commit | 442997cbb3a9e970946dd294acd1498e9fa9bfc7 (patch) | |
tree | 99041d1d439501ee4616efa87ee2ab76b3d2fca0 /xfa/fwl/core/cfwl_spinbutton.cpp | |
parent | 31559c91c4983b42361415d30b0b2a518c7ef383 (diff) | |
download | pdfium-442997cbb3a9e970946dd294acd1498e9fa9bfc7.tar.xz |
Cleanup FWL default values part II.
This CL cleans up the remaining default values in the fwl/core directory. Some
methods are renamed to better represent what they do.
Review-Url: https://codereview.chromium.org/2557103002
Diffstat (limited to 'xfa/fwl/core/cfwl_spinbutton.cpp')
-rw-r--r-- | xfa/fwl/core/cfwl_spinbutton.cpp | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/xfa/fwl/core/cfwl_spinbutton.cpp b/xfa/fwl/core/cfwl_spinbutton.cpp index e66b92e701..8780fed1a9 100644 --- a/xfa/fwl/core/cfwl_spinbutton.cpp +++ b/xfa/fwl/core/cfwl_spinbutton.cpp @@ -114,17 +114,16 @@ void CFWL_SpinButton::DrawWidget(CFX_Graphics* pGraphics, DrawDownButton(pGraphics, pTheme, pMatrix); } -void CFWL_SpinButton::EnableButton(bool bEnable, bool bUp) { - if (bUp) - m_dwUpState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled; - else - m_dwDnState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled; +void CFWL_SpinButton::DisableButton() { + m_dwDnState = CFWL_PartState_Disabled; +} + +bool CFWL_SpinButton::IsUpButtonEnabled() { + return m_dwUpState != CFWL_PartState_Disabled; } -bool CFWL_SpinButton::IsButtonEnabled(bool bUp) { - if (bUp) - return (m_dwUpState != CFWL_PartState_Disabled); - return (m_dwDnState != CFWL_PartState_Disabled); +bool CFWL_SpinButton::IsDownButtonEnabled() { + return m_dwDnState != CFWL_PartState_Disabled; } void CFWL_SpinButton::DrawUpButton(CFX_Graphics* pGraphics, @@ -222,9 +221,9 @@ void CFWL_SpinButton::OnLButtonDown(CFWL_MsgMouse* pMsg) { SetFocus(true); bool bUpPress = - (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnabled(true)); + (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsUpButtonEnabled()); bool bDnPress = - (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnabled(false)); + (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsDownButtonEnabled()); if (!bUpPress && !bDnPress) return; if (bUpPress) { @@ -256,11 +255,11 @@ void CFWL_SpinButton::OnLButtonUp(CFWL_MsgMouse* pMsg) { } bool bRepaint = false; CFX_RectF rtInvalidate; - if (m_dwUpState == CFWL_PartState_Pressed && IsButtonEnabled(true)) { + if (m_dwUpState == CFWL_PartState_Pressed && IsUpButtonEnabled()) { m_dwUpState = CFWL_PartState_Normal; bRepaint = true; rtInvalidate = m_rtUpButton; - } else if (m_dwDnState == CFWL_PartState_Pressed && IsButtonEnabled(false)) { + } else if (m_dwDnState == CFWL_PartState_Pressed && IsDownButtonEnabled()) { m_dwDnState = CFWL_PartState_Normal; bRepaint = true; rtInvalidate = m_rtDnButton; @@ -277,13 +276,13 @@ void CFWL_SpinButton::OnMouseMove(CFWL_MsgMouse* pMsg) { CFX_RectF rtInvlidate; rtInvlidate.Reset(); if (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) { - if (IsButtonEnabled(true)) { + if (IsUpButtonEnabled()) { if (m_dwUpState == CFWL_PartState_Hovered) { m_dwUpState = CFWL_PartState_Hovered; bRepaint = true; rtInvlidate = m_rtUpButton; } - if (m_dwDnState != CFWL_PartState_Normal && IsButtonEnabled(false)) { + if (m_dwDnState != CFWL_PartState_Normal && IsDownButtonEnabled()) { m_dwDnState = CFWL_PartState_Normal; if (bRepaint) rtInvlidate.Union(m_rtDnButton); @@ -293,17 +292,17 @@ void CFWL_SpinButton::OnMouseMove(CFWL_MsgMouse* pMsg) { bRepaint = true; } } - if (!IsButtonEnabled(false)) - EnableButton(false, false); + if (!IsDownButtonEnabled()) + DisableButton(); } else if (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy)) { - if (IsButtonEnabled(false)) { + if (IsDownButtonEnabled()) { if (m_dwDnState != CFWL_PartState_Hovered) { m_dwDnState = CFWL_PartState_Hovered; bRepaint = true; rtInvlidate = m_rtDnButton; } - if (m_dwUpState != CFWL_PartState_Normal && IsButtonEnabled(true)) { + if (m_dwUpState != CFWL_PartState_Normal && IsUpButtonEnabled()) { m_dwUpState = CFWL_PartState_Normal; if (bRepaint) rtInvlidate.Union(m_rtUpButton); @@ -336,9 +335,9 @@ void CFWL_SpinButton::OnMouseMove(CFWL_MsgMouse* pMsg) { void CFWL_SpinButton::OnMouseLeave(CFWL_MsgMouse* pMsg) { if (!pMsg) return; - if (m_dwUpState != CFWL_PartState_Normal && IsButtonEnabled(true)) + if (m_dwUpState != CFWL_PartState_Normal && IsUpButtonEnabled()) m_dwUpState = CFWL_PartState_Normal; - if (m_dwDnState != CFWL_PartState_Normal && IsButtonEnabled(false)) + if (m_dwDnState != CFWL_PartState_Normal && IsDownButtonEnabled()) m_dwDnState = CFWL_PartState_Normal; Repaint(&m_rtClient); @@ -352,8 +351,8 @@ void CFWL_SpinButton::OnKeyDown(CFWL_MsgKey* pMsg) { if (!bUp && !bDown) return; - bool bUpEnable = IsButtonEnabled(true); - bool bDownEnable = IsButtonEnabled(false); + bool bUpEnable = IsUpButtonEnabled(); + bool bDownEnable = IsDownButtonEnabled(); if (!bUpEnable && !bDownEnable) return; |