diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-09-08 14:31:14 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-08 20:35:43 +0000 |
commit | ee1e757902d0096cc482c74d4fc0e568e0b18541 (patch) | |
tree | 0adc60bb9c98854c48fd2f16b1a5485e9703a1ba /xfa | |
parent | e8b3e0cdcea319abf82639edb5e074ff94c4d66c (diff) | |
download | pdfium-ee1e757902d0096cc482c74d4fc0e568e0b18541.tar.xz |
Remove CFWL_SpinButton, which is unused.chromium/3211
Change-Id: I0be113b5515a95829566938c84e2f74c7c1c75a3
Reviewed-on: https://pdfium-review.googlesource.com/13552
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fwl/cfwl_datetimepicker.cpp | 1 | ||||
-rw-r--r-- | xfa/fwl/cfwl_spinbutton.cpp | 348 | ||||
-rw-r--r-- | xfa/fwl/cfwl_spinbutton.h | 73 |
3 files changed, 0 insertions, 422 deletions
diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp index 7383729ad4..c8d7c5dc19 100644 --- a/xfa/fwl/cfwl_datetimepicker.cpp +++ b/xfa/fwl/cfwl_datetimepicker.cpp @@ -16,7 +16,6 @@ #include "xfa/fwl/cfwl_messagemouse.h" #include "xfa/fwl/cfwl_messagesetfocus.h" #include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fwl/cfwl_spinbutton.h" #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_widgetmgr.h" #include "xfa/fwl/ifwl_themeprovider.h" diff --git a/xfa/fwl/cfwl_spinbutton.cpp b/xfa/fwl/cfwl_spinbutton.cpp deleted file mode 100644 index f4ca339089..0000000000 --- a/xfa/fwl/cfwl_spinbutton.cpp +++ /dev/null @@ -1,348 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fwl/cfwl_spinbutton.h" - -#include <memory> -#include <utility> - -#include "third_party/base/ptr_util.h" -#include "xfa/fwl/cfwl_event.h" -#include "xfa/fwl/cfwl_messagekey.h" -#include "xfa/fwl/cfwl_messagemouse.h" -#include "xfa/fwl/cfwl_notedriver.h" -#include "xfa/fwl/cfwl_themebackground.h" -#include "xfa/fwl/cfwl_timerinfo.h" -#include "xfa/fwl/cfwl_widgetproperties.h" -#include "xfa/fwl/ifwl_themeprovider.h" - -namespace { -const int kElapseTime = 200; - -} // namespace - -CFWL_SpinButton::CFWL_SpinButton( - const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties) - : CFWL_Widget(app, std::move(properties), nullptr), - m_dwUpState(CFWL_PartState_Normal), - m_dwDnState(CFWL_PartState_Normal), - m_iButtonIndex(0), - m_bLButtonDwn(false), - m_pTimerInfo(nullptr), - m_Timer(this) { - m_rtClient.Reset(); - m_rtUpButton.Reset(); - m_rtDnButton.Reset(); - m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; -} - -CFWL_SpinButton::~CFWL_SpinButton() {} - -FWL_Type CFWL_SpinButton::GetClassID() const { - return FWL_Type::SpinButton; -} - -void CFWL_SpinButton::Update() { - if (IsLocked()) - return; - - m_rtClient = GetClientRect(); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { - m_rtUpButton = CFX_RectF(m_rtClient.top, m_rtClient.left, m_rtClient.width, - m_rtClient.height / 2); - m_rtDnButton = - CFX_RectF(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, - m_rtClient.width, m_rtClient.height / 2); - } else { - m_rtUpButton = CFX_RectF(m_rtClient.TopLeft(), m_rtClient.width / 2, - m_rtClient.height); - m_rtDnButton = - CFX_RectF(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top, - m_rtClient.width / 2, m_rtClient.height); - } -} - -FWL_WidgetHit CFWL_SpinButton::HitTest(const CFX_PointF& point) { - if (m_rtClient.Contains(point)) - return FWL_WidgetHit::Client; - if (HasBorder() && (m_rtClient.Contains(point))) - return FWL_WidgetHit::Border; - if (m_rtUpButton.Contains(point)) - return FWL_WidgetHit::UpButton; - if (m_rtDnButton.Contains(point)) - return FWL_WidgetHit::DownButton; - return FWL_WidgetHit::Unknown; -} - -void CFWL_SpinButton::DrawWidget(CXFA_Graphics* pGraphics, - const CFX_Matrix& matrix) { - if (!pGraphics) - return; - - IFWL_ThemeProvider* pTheme = GetAvailableTheme(); - if (HasBorder()) - DrawBorder(pGraphics, CFWL_Part::Border, pTheme, matrix); - - DrawUpButton(pGraphics, pTheme, &matrix); - DrawDownButton(pGraphics, pTheme, &matrix); -} - -void CFWL_SpinButton::DisableButton() { - m_dwDnState = CFWL_PartState_Disabled; -} - -bool CFWL_SpinButton::IsUpButtonEnabled() { - return m_dwUpState != CFWL_PartState_Disabled; -} - -bool CFWL_SpinButton::IsDownButtonEnabled() { - return m_dwDnState != CFWL_PartState_Disabled; -} - -void CFWL_SpinButton::DrawUpButton(CXFA_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground params; - params.m_pWidget = this; - params.m_iPart = CFWL_Part::UpButton; - params.m_pGraphics = pGraphics; - params.m_dwStates = m_dwUpState + 1; - if (pMatrix) - params.m_matrix.Concat(*pMatrix); - - params.m_rtPart = m_rtUpButton; - pTheme->DrawBackground(¶ms); -} - -void CFWL_SpinButton::DrawDownButton(CXFA_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground params; - params.m_pWidget = this; - params.m_iPart = CFWL_Part::DownButton; - params.m_pGraphics = pGraphics; - params.m_dwStates = m_dwDnState + 1; - if (pMatrix) - params.m_matrix.Concat(*pMatrix); - - params.m_rtPart = m_rtDnButton; - pTheme->DrawBackground(¶ms); -} - -void CFWL_SpinButton::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return; - - switch (pMessage->GetType()) { - case CFWL_Message::Type::SetFocus: { - OnFocusChanged(pMessage, true); - break; - } - case CFWL_Message::Type::KillFocus: { - OnFocusChanged(pMessage, false); - break; - } - case CFWL_Message::Type::Mouse: { - CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); - switch (pMsg->m_dwCmd) { - case FWL_MouseCommand::LeftButtonDown: - OnLButtonDown(pMsg); - break; - case FWL_MouseCommand::LeftButtonUp: - OnLButtonUp(pMsg); - break; - case FWL_MouseCommand::Move: - OnMouseMove(pMsg); - break; - case FWL_MouseCommand::Leave: - OnMouseLeave(pMsg); - break; - default: - break; - } - break; - } - case CFWL_Message::Type::Key: { - CFWL_MessageKey* pKey = static_cast<CFWL_MessageKey*>(pMessage); - if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) - OnKeyDown(pKey); - break; - } - default: - break; - } - CFWL_Widget::OnProcessMessage(pMessage); -} - -void CFWL_SpinButton::OnDrawWidget(CXFA_Graphics* pGraphics, - const CFX_Matrix& matrix) { - DrawWidget(pGraphics, matrix); -} - -void CFWL_SpinButton::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { - if (bSet) - m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); - else - m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); - - RepaintRect(m_rtClient); -} - -void CFWL_SpinButton::OnLButtonDown(CFWL_MessageMouse* pMsg) { - m_bLButtonDwn = true; - SetGrab(true); - SetFocus(true); - - bool bUpPress = m_rtUpButton.Contains(pMsg->m_pos) && IsUpButtonEnabled(); - bool bDnPress = m_rtDnButton.Contains(pMsg->m_pos) && IsDownButtonEnabled(); - if (!bUpPress && !bDnPress) - return; - if (bUpPress) { - m_iButtonIndex = 0; - m_dwUpState = CFWL_PartState_Pressed; - } - if (bDnPress) { - m_iButtonIndex = 1; - m_dwDnState = CFWL_PartState_Pressed; - } - - CFWL_Event wmPosChanged(CFWL_Event::Type::Click, this); - DispatchEvent(&wmPosChanged); - - RepaintRect(bUpPress ? m_rtUpButton : m_rtDnButton); - m_pTimerInfo = m_Timer.StartTimer(kElapseTime, true); -} - -void CFWL_SpinButton::OnLButtonUp(CFWL_MessageMouse* pMsg) { - if (m_pProperties->m_dwStates & CFWL_PartState_Disabled) - return; - - m_bLButtonDwn = false; - SetGrab(false); - SetFocus(false); - if (m_pTimerInfo) { - m_pTimerInfo->StopTimer(); - m_pTimerInfo = nullptr; - } - bool bRepaint = false; - CFX_RectF rtInvalidate; - if (m_dwUpState == CFWL_PartState_Pressed && IsUpButtonEnabled()) { - m_dwUpState = CFWL_PartState_Normal; - bRepaint = true; - rtInvalidate = m_rtUpButton; - } else if (m_dwDnState == CFWL_PartState_Pressed && IsDownButtonEnabled()) { - m_dwDnState = CFWL_PartState_Normal; - bRepaint = true; - rtInvalidate = m_rtDnButton; - } - if (bRepaint) - RepaintRect(rtInvalidate); -} - -void CFWL_SpinButton::OnMouseMove(CFWL_MessageMouse* pMsg) { - if (m_bLButtonDwn) - return; - - bool bRepaint = false; - CFX_RectF rtInvlidate; - if (m_rtUpButton.Contains(pMsg->m_pos)) { - if (IsUpButtonEnabled()) { - if (m_dwUpState == CFWL_PartState_Hovered) { - m_dwUpState = CFWL_PartState_Hovered; - bRepaint = true; - rtInvlidate = m_rtUpButton; - } - if (m_dwDnState != CFWL_PartState_Normal && IsDownButtonEnabled()) { - m_dwDnState = CFWL_PartState_Normal; - if (bRepaint) - rtInvlidate.Union(m_rtDnButton); - else - rtInvlidate = m_rtDnButton; - - bRepaint = true; - } - } - if (!IsDownButtonEnabled()) - DisableButton(); - - } else if (m_rtDnButton.Contains(pMsg->m_pos)) { - if (IsDownButtonEnabled()) { - if (m_dwDnState != CFWL_PartState_Hovered) { - m_dwDnState = CFWL_PartState_Hovered; - bRepaint = true; - rtInvlidate = m_rtDnButton; - } - if (m_dwUpState != CFWL_PartState_Normal && IsUpButtonEnabled()) { - m_dwUpState = CFWL_PartState_Normal; - if (bRepaint) - rtInvlidate.Union(m_rtUpButton); - else - rtInvlidate = m_rtUpButton; - bRepaint = true; - } - } - } else if (m_dwUpState != CFWL_PartState_Normal || - m_dwDnState != CFWL_PartState_Normal) { - if (m_dwUpState != CFWL_PartState_Normal) { - m_dwUpState = CFWL_PartState_Normal; - bRepaint = true; - rtInvlidate = m_rtUpButton; - } - if (m_dwDnState != CFWL_PartState_Normal) { - m_dwDnState = CFWL_PartState_Normal; - if (bRepaint) - rtInvlidate.Union(m_rtDnButton); - else - rtInvlidate = m_rtDnButton; - - bRepaint = true; - } - } - if (bRepaint) - RepaintRect(rtInvlidate); -} - -void CFWL_SpinButton::OnMouseLeave(CFWL_MessageMouse* pMsg) { - if (!pMsg) - return; - if (m_dwUpState != CFWL_PartState_Normal && IsUpButtonEnabled()) - m_dwUpState = CFWL_PartState_Normal; - if (m_dwDnState != CFWL_PartState_Normal && IsDownButtonEnabled()) - m_dwDnState = CFWL_PartState_Normal; - - RepaintRect(m_rtClient); -} - -void CFWL_SpinButton::OnKeyDown(CFWL_MessageKey* pMsg) { - bool bUp = - pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left; - bool bDown = - pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right; - if (!bUp && !bDown) - return; - - bool bUpEnable = IsUpButtonEnabled(); - bool bDownEnable = IsDownButtonEnabled(); - if (!bUpEnable && !bDownEnable) - return; - - CFWL_Event wmPosChanged(CFWL_Event::Type::Click, this); - DispatchEvent(&wmPosChanged); - RepaintRect(bUpEnable ? m_rtUpButton : m_rtDnButton); -} - -CFWL_SpinButton::Timer::Timer(CFWL_SpinButton* pToolTip) - : CFWL_Timer(pToolTip) {} - -void CFWL_SpinButton::Timer::Run(CFWL_TimerInfo* pTimerInfo) { - CFWL_SpinButton* pButton = static_cast<CFWL_SpinButton*>(m_pWidget.Get()); - if (!pButton->m_pTimerInfo) - return; - - CFWL_Event wmPosChanged(CFWL_Event::Type::Click, pButton); - pButton->DispatchEvent(&wmPosChanged); -} diff --git a/xfa/fwl/cfwl_spinbutton.h b/xfa/fwl/cfwl_spinbutton.h deleted file mode 100644 index 2ebabb1799..0000000000 --- a/xfa/fwl/cfwl_spinbutton.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FWL_CFWL_SPINBUTTON_H_ -#define XFA_FWL_CFWL_SPINBUTTON_H_ - -#include <memory> - -#include "xfa/fwl/cfwl_timer.h" -#include "xfa/fwl/cfwl_widget.h" -#include "xfa/fxfa/cxfa_eventparam.h" - -#define FWL_STYLEEXE_SPB_Vert (1L << 0) - -class CFWL_MessageMouse; -class CFWL_WidgetProperties; - -class CFWL_SpinButton : public CFWL_Widget { - public: - CFWL_SpinButton(const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties); - ~CFWL_SpinButton() override; - - // CFWL_Widget - FWL_Type GetClassID() const override; - void Update() override; - FWL_WidgetHit HitTest(const CFX_PointF& point) override; - void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override; - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnDrawWidget(CXFA_Graphics* pGraphics, - const CFX_Matrix& matrix) override; - - private: - class Timer : public CFWL_Timer { - public: - explicit Timer(CFWL_SpinButton* pToolTip); - ~Timer() override {} - - void Run(CFWL_TimerInfo* pTimerInfo) override; - }; - friend class CFWL_SpinButton::Timer; - - void DisableButton(); - bool IsUpButtonEnabled(); - bool IsDownButtonEnabled(); - void DrawUpButton(CXFA_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawDownButton(CXFA_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void OnFocusChanged(CFWL_Message* pMsg, bool bSet); - void OnLButtonDown(CFWL_MessageMouse* pMsg); - void OnLButtonUp(CFWL_MessageMouse* pMsg); - void OnMouseMove(CFWL_MessageMouse* pMsg); - void OnMouseLeave(CFWL_MessageMouse* pMsg); - void OnKeyDown(CFWL_MessageKey* pMsg); - - CFX_RectF m_rtClient; - CFX_RectF m_rtUpButton; - CFX_RectF m_rtDnButton; - uint32_t m_dwUpState; - uint32_t m_dwDnState; - int32_t m_iButtonIndex; - bool m_bLButtonDwn; - CFWL_TimerInfo* m_pTimerInfo; - CFWL_SpinButton::Timer m_Timer; -}; - -#endif // XFA_FWL_CFWL_SPINBUTTON_H_ |