diff options
author | dsinclair <dsinclair@chromium.org> | 2016-10-31 07:29:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-31 07:29:34 -0700 |
commit | 20855384b8149a631c3c1d229551523c12eb767b (patch) | |
tree | e3cef278e322742bea6c4b48f40ed580754ebd80 /xfa/fwl/core/ifwl_spinbutton.cpp | |
parent | 747dcf775c5cb661e96a639f73322cc489d8590f (diff) | |
download | pdfium-20855384b8149a631c3c1d229551523c12eb767b.tar.xz |
Remove FWL globals.
This CL removes the FWL_GetApp, FWL_SetApp and FWL_GetWidgetAdapter methods.
In the process it changes the various Initialize methods to return void.
Review-Url: https://codereview.chromium.org/2436103002
Diffstat (limited to 'xfa/fwl/core/ifwl_spinbutton.cpp')
-rw-r--r-- | xfa/fwl/core/ifwl_spinbutton.cpp | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/xfa/fwl/core/ifwl_spinbutton.cpp b/xfa/fwl/core/ifwl_spinbutton.cpp index d94a240e59..992ea7358c 100644 --- a/xfa/fwl/core/ifwl_spinbutton.cpp +++ b/xfa/fwl/core/ifwl_spinbutton.cpp @@ -23,13 +23,15 @@ const int kElapseTime = 200; } // namespace -IFWL_SpinButton::IFWL_SpinButton(const CFWL_WidgetImpProperties& properties) - : IFWL_Widget(properties, nullptr), +IFWL_SpinButton::IFWL_SpinButton(const IFWL_App* app, + const CFWL_WidgetImpProperties& properties) + : IFWL_Widget(app, properties, nullptr), m_dwUpState(CFWL_PartState_Normal), m_dwDnState(CFWL_PartState_Normal), m_iButtonIndex(0), m_bLButtonDwn(FALSE), - m_pTimerInfo(nullptr) { + m_pTimerInfo(nullptr), + m_Timer(this) { m_rtClient.Reset(); m_rtUpButton.Reset(); m_rtDnButton.Reset(); @@ -38,16 +40,9 @@ IFWL_SpinButton::IFWL_SpinButton(const CFWL_WidgetImpProperties& properties) IFWL_SpinButton::~IFWL_SpinButton() {} -FWL_Type IFWL_SpinButton::GetClassID() const { - return FWL_Type::SpinButton; -} - -FWL_Error IFWL_SpinButton::Initialize() { - if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) - return FWL_Error::Indefinite; - +void IFWL_SpinButton::Initialize() { + IFWL_Widget::Initialize(); m_pDelegate = new CFWL_SpinButtonImpDelegate(this); - return FWL_Error::Succeeded; } void IFWL_SpinButton::Finalize() { @@ -56,6 +51,10 @@ void IFWL_SpinButton::Finalize() { IFWL_Widget::Finalize(); } +FWL_Type IFWL_SpinButton::GetClassID() const { + return FWL_Type::SpinButton; +} + FWL_Error IFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { if (bAutoSize) { rect.Set(0, 0, kMinWidth, kMinHeight); @@ -123,16 +122,6 @@ FWL_Error IFWL_SpinButton::DrawWidget(CFX_Graphics* pGraphics, return FWL_Error::Succeeded; } -void IFWL_SpinButton::Run(IFWL_TimerInfo* pTimerInfo) { - if (!m_pTimerInfo) - return; - - CFWL_EvtSpbClick wmPosChanged; - wmPosChanged.m_pSrcTarget = this; - wmPosChanged.m_bUp = m_iButtonIndex == 0; - DispatchEvent(&wmPosChanged); -} - FWL_Error IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { if (bUp) { if (bEnable) { @@ -283,7 +272,7 @@ void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { m_pOwner->DispatchEvent(&wmPosChanged); m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton : &m_pOwner->m_rtDnButton); - m_pOwner->m_pTimerInfo = m_pOwner->StartTimer(kElapseTime, true); + m_pOwner->m_pTimerInfo = m_pOwner->m_Timer.StartTimer(kElapseTime, true); } void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { @@ -421,3 +410,18 @@ void CFWL_SpinButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton : &m_pOwner->m_rtDnButton); } + +IFWL_SpinButton::Timer::Timer(IFWL_SpinButton* pToolTip) + : IFWL_Timer(pToolTip) {} + +void IFWL_SpinButton::Timer::Run(IFWL_TimerInfo* pTimerInfo) { + IFWL_SpinButton* pButton = static_cast<IFWL_SpinButton*>(m_pWidget); + + if (!pButton->m_pTimerInfo) + return; + + CFWL_EvtSpbClick wmPosChanged; + wmPosChanged.m_pSrcTarget = pButton; + wmPosChanged.m_bUp = pButton->m_iButtonIndex == 0; + pButton->DispatchEvent(&wmPosChanged); +} |