| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fwl/basewidget/fwl_spinbuttonimp.h" | 7 #include "xfa/fwl/core/ifwl_spinbutton.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/basewidget/ifwl_spinbutton.h" | |
| 10 #include "xfa/fwl/core/cfwl_message.h" | 9 #include "xfa/fwl/core/cfwl_message.h" |
| 11 #include "xfa/fwl/core/cfwl_themebackground.h" | 10 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 12 #include "xfa/fwl/core/cfwl_widgetimpproperties.h" | 11 #include "xfa/fwl/core/cfwl_widgetimpproperties.h" |
| 13 #include "xfa/fwl/core/fwl_noteimp.h" | 12 #include "xfa/fwl/core/fwl_noteimp.h" |
| 14 #include "xfa/fwl/core/fwl_widgetimp.h" | 13 #include "xfa/fwl/core/ifwl_spinbutton.h" |
| 15 #include "xfa/fwl/core/ifwl_themeprovider.h" | 14 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 16 #include "xfa/fwl/core/ifwl_themeprovider.h" | 15 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 17 #include "xfa/fwl/core/ifwl_timer.h" | 16 #include "xfa/fwl/core/ifwl_timer.h" |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 const int kMinWidth = 18; | 20 const int kMinWidth = 18; |
| 22 const int kMinHeight = 32; | 21 const int kMinHeight = 32; |
| 23 const int kElapseTime = 200; | 22 const int kElapseTime = 200; |
| 24 | 23 |
| 25 } // namespace | 24 } // namespace |
| 26 | 25 |
| 27 // static | 26 // static |
| 28 IFWL_SpinButton* IFWL_SpinButton::Create( | 27 IFWL_SpinButton* IFWL_SpinButton::Create( |
| 29 const CFWL_WidgetImpProperties& properties, | 28 const CFWL_WidgetImpProperties& properties, |
| 30 IFWL_Widget* pOuter) { | 29 IFWL_Widget* pOuter) { |
| 31 IFWL_SpinButton* pSpinButton = new IFWL_SpinButton; | 30 return new IFWL_SpinButton(properties, nullptr); |
| 32 CFWL_SpinButtonImp* pSpinButtonImpl = | |
| 33 new CFWL_SpinButtonImp(properties, nullptr); | |
| 34 pSpinButton->SetImpl(pSpinButtonImpl); | |
| 35 pSpinButtonImpl->SetInterface(pSpinButton); | |
| 36 return pSpinButton; | |
| 37 } | |
| 38 IFWL_SpinButton::IFWL_SpinButton() {} | |
| 39 FWL_Error IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { | |
| 40 return static_cast<CFWL_SpinButtonImp*>(GetImpl()) | |
| 41 ->EnableButton(bEnable, bUp); | |
| 42 } | |
| 43 FX_BOOL IFWL_SpinButton::IsButtonEnable(FX_BOOL bUp) { | |
| 44 return static_cast<CFWL_SpinButtonImp*>(GetImpl())->IsButtonEnable(bUp); | |
| 45 } | 31 } |
| 46 | 32 |
| 47 CFWL_SpinButtonImp::CFWL_SpinButtonImp( | 33 IFWL_SpinButton::IFWL_SpinButton(const CFWL_WidgetImpProperties& properties, |
| 48 const CFWL_WidgetImpProperties& properties, | 34 IFWL_Widget* pOuter) |
| 49 IFWL_Widget* pOuter) | 35 : IFWL_Widget(properties, pOuter), |
| 50 : CFWL_WidgetImp(properties, pOuter), | |
| 51 m_dwUpState(CFWL_PartState_Normal), | 36 m_dwUpState(CFWL_PartState_Normal), |
| 52 m_dwDnState(CFWL_PartState_Normal), | 37 m_dwDnState(CFWL_PartState_Normal), |
| 53 m_iButtonIndex(0), | 38 m_iButtonIndex(0), |
| 54 m_bLButtonDwn(FALSE), | 39 m_bLButtonDwn(FALSE), |
| 55 m_pTimerInfo(nullptr) { | 40 m_pTimerInfo(nullptr) { |
| 56 m_rtClient.Reset(); | 41 m_rtClient.Reset(); |
| 57 m_rtUpButton.Reset(); | 42 m_rtUpButton.Reset(); |
| 58 m_rtDnButton.Reset(); | 43 m_rtDnButton.Reset(); |
| 59 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; | 44 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; |
| 60 } | 45 } |
| 61 | 46 |
| 62 CFWL_SpinButtonImp::~CFWL_SpinButtonImp() {} | 47 IFWL_SpinButton::~IFWL_SpinButton() {} |
| 63 | 48 |
| 64 FWL_Error CFWL_SpinButtonImp::GetClassName(CFX_WideString& wsClass) const { | 49 FWL_Error IFWL_SpinButton::GetClassName(CFX_WideString& wsClass) const { |
| 65 wsClass = FWL_CLASS_SpinButton; | 50 wsClass = FWL_CLASS_SpinButton; |
| 66 return FWL_Error::Succeeded; | 51 return FWL_Error::Succeeded; |
| 67 } | 52 } |
| 68 | 53 |
| 69 FWL_Type CFWL_SpinButtonImp::GetClassID() const { | 54 FWL_Type IFWL_SpinButton::GetClassID() const { |
| 70 return FWL_Type::SpinButton; | 55 return FWL_Type::SpinButton; |
| 71 } | 56 } |
| 72 | 57 |
| 73 FWL_Error CFWL_SpinButtonImp::Initialize() { | 58 FWL_Error IFWL_SpinButton::Initialize() { |
| 74 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) | 59 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) |
| 75 return FWL_Error::Indefinite; | 60 return FWL_Error::Indefinite; |
| 76 | 61 |
| 77 m_pDelegate = new CFWL_SpinButtonImpDelegate(this); | 62 m_pDelegate = new CFWL_SpinButtonImpDelegate(this); |
| 78 return FWL_Error::Succeeded; | 63 return FWL_Error::Succeeded; |
| 79 } | 64 } |
| 80 | 65 |
| 81 FWL_Error CFWL_SpinButtonImp::Finalize() { | 66 FWL_Error IFWL_SpinButton::Finalize() { |
| 82 delete m_pDelegate; | 67 delete m_pDelegate; |
| 83 m_pDelegate = nullptr; | 68 m_pDelegate = nullptr; |
| 84 return CFWL_WidgetImp::Finalize(); | 69 return IFWL_Widget::Finalize(); |
| 85 } | 70 } |
| 86 FWL_Error CFWL_SpinButtonImp::GetWidgetRect(CFX_RectF& rect, | 71 |
| 87 FX_BOOL bAutoSize) { | 72 FWL_Error IFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 88 if (bAutoSize) { | 73 if (bAutoSize) { |
| 89 rect.Set(0, 0, kMinWidth, kMinHeight); | 74 rect.Set(0, 0, kMinWidth, kMinHeight); |
| 90 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); | 75 IFWL_Widget::GetWidgetRect(rect, TRUE); |
| 91 } else { | 76 } else { |
| 92 rect = m_pProperties->m_rtWidget; | 77 rect = m_pProperties->m_rtWidget; |
| 93 } | 78 } |
| 94 return FWL_Error::Succeeded; | 79 return FWL_Error::Succeeded; |
| 95 } | 80 } |
| 96 FWL_Error CFWL_SpinButtonImp::Update() { | 81 |
| 82 FWL_Error IFWL_SpinButton::Update() { |
| 97 if (IsLocked()) { | 83 if (IsLocked()) { |
| 98 return FWL_Error::Indefinite; | 84 return FWL_Error::Indefinite; |
| 99 } | 85 } |
| 100 GetClientRect(m_rtClient); | 86 GetClientRect(m_rtClient); |
| 101 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { | 87 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { |
| 102 m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, | 88 m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, |
| 103 m_rtClient.height / 2); | 89 m_rtClient.height / 2); |
| 104 m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, | 90 m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, |
| 105 m_rtClient.width, m_rtClient.height / 2); | 91 m_rtClient.width, m_rtClient.height / 2); |
| 106 } else { | 92 } else { |
| 107 m_rtUpButton.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width / 2, | 93 m_rtUpButton.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width / 2, |
| 108 m_rtClient.height); | 94 m_rtClient.height); |
| 109 m_rtDnButton.Set(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top, | 95 m_rtDnButton.Set(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top, |
| 110 m_rtClient.width / 2, m_rtClient.height); | 96 m_rtClient.width / 2, m_rtClient.height); |
| 111 } | 97 } |
| 112 return FWL_Error::Succeeded; | 98 return FWL_Error::Succeeded; |
| 113 } | 99 } |
| 114 FWL_WidgetHit CFWL_SpinButtonImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 100 |
| 101 FWL_WidgetHit IFWL_SpinButton::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 115 if (m_rtClient.Contains(fx, fy)) | 102 if (m_rtClient.Contains(fx, fy)) |
| 116 return FWL_WidgetHit::Client; | 103 return FWL_WidgetHit::Client; |
| 117 if (HasBorder() && (m_rtClient.Contains(fx, fy))) | 104 if (HasBorder() && (m_rtClient.Contains(fx, fy))) |
| 118 return FWL_WidgetHit::Border; | 105 return FWL_WidgetHit::Border; |
| 119 if (HasEdge()) { | 106 if (HasEdge()) { |
| 120 CFX_RectF rtEdge; | 107 CFX_RectF rtEdge; |
| 121 GetEdgeRect(rtEdge); | 108 GetEdgeRect(rtEdge); |
| 122 if (rtEdge.Contains(fx, fy)) | 109 if (rtEdge.Contains(fx, fy)) |
| 123 return FWL_WidgetHit::Left; | 110 return FWL_WidgetHit::Left; |
| 124 } | 111 } |
| 125 if (m_rtUpButton.Contains(fx, fy)) | 112 if (m_rtUpButton.Contains(fx, fy)) |
| 126 return FWL_WidgetHit::UpButton; | 113 return FWL_WidgetHit::UpButton; |
| 127 if (m_rtDnButton.Contains(fx, fy)) | 114 if (m_rtDnButton.Contains(fx, fy)) |
| 128 return FWL_WidgetHit::DownButton; | 115 return FWL_WidgetHit::DownButton; |
| 129 return FWL_WidgetHit::Unknown; | 116 return FWL_WidgetHit::Unknown; |
| 130 } | 117 } |
| 131 FWL_Error CFWL_SpinButtonImp::DrawWidget(CFX_Graphics* pGraphics, | 118 |
| 132 const CFX_Matrix* pMatrix) { | 119 FWL_Error IFWL_SpinButton::DrawWidget(CFX_Graphics* pGraphics, |
| 120 const CFX_Matrix* pMatrix) { |
| 133 if (!pGraphics) | 121 if (!pGraphics) |
| 134 return FWL_Error::Indefinite; | 122 return FWL_Error::Indefinite; |
| 135 CFX_RectF rtClip(m_rtClient); | 123 CFX_RectF rtClip(m_rtClient); |
| 136 if (pMatrix) { | 124 if (pMatrix) { |
| 137 pMatrix->TransformRect(rtClip); | 125 pMatrix->TransformRect(rtClip); |
| 138 } | 126 } |
| 139 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); | 127 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); |
| 140 if (HasBorder()) { | 128 if (HasBorder()) { |
| 141 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 129 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 142 } | 130 } |
| 143 if (HasEdge()) { | 131 if (HasEdge()) { |
| 144 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 132 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 145 } | 133 } |
| 146 DrawUpButton(pGraphics, pTheme, pMatrix); | 134 DrawUpButton(pGraphics, pTheme, pMatrix); |
| 147 DrawDownButton(pGraphics, pTheme, pMatrix); | 135 DrawDownButton(pGraphics, pTheme, pMatrix); |
| 148 return FWL_Error::Succeeded; | 136 return FWL_Error::Succeeded; |
| 149 } | 137 } |
| 150 | 138 |
| 151 void CFWL_SpinButtonImp::Run(IFWL_TimerInfo* pTimerInfo) { | 139 void IFWL_SpinButton::Run(IFWL_TimerInfo* pTimerInfo) { |
| 152 if (!m_pTimerInfo) | 140 if (!m_pTimerInfo) |
| 153 return; | 141 return; |
| 154 | 142 |
| 155 CFWL_EvtSpbClick wmPosChanged; | 143 CFWL_EvtSpbClick wmPosChanged; |
| 156 wmPosChanged.m_pSrcTarget = m_pInterface; | 144 wmPosChanged.m_pSrcTarget = this; |
| 157 wmPosChanged.m_bUp = m_iButtonIndex == 0; | 145 wmPosChanged.m_bUp = m_iButtonIndex == 0; |
| 158 DispatchEvent(&wmPosChanged); | 146 DispatchEvent(&wmPosChanged); |
| 159 } | 147 } |
| 160 | 148 |
| 161 FWL_Error CFWL_SpinButtonImp::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { | 149 FWL_Error IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { |
| 162 if (bUp) { | 150 if (bUp) { |
| 163 if (bEnable) { | 151 if (bEnable) { |
| 164 m_dwUpState = CFWL_PartState_Normal; | 152 m_dwUpState = CFWL_PartState_Normal; |
| 165 } else { | 153 } else { |
| 166 m_dwUpState = CFWL_PartState_Disabled; | 154 m_dwUpState = CFWL_PartState_Disabled; |
| 167 } | 155 } |
| 168 } else { | 156 } else { |
| 169 if (bEnable) { | 157 if (bEnable) { |
| 170 m_dwDnState = CFWL_PartState_Normal; | 158 m_dwDnState = CFWL_PartState_Normal; |
| 171 } else { | 159 } else { |
| 172 m_dwDnState = CFWL_PartState_Disabled; | 160 m_dwDnState = CFWL_PartState_Disabled; |
| 173 } | 161 } |
| 174 } | 162 } |
| 175 return FWL_Error::Succeeded; | 163 return FWL_Error::Succeeded; |
| 176 } | 164 } |
| 177 FX_BOOL CFWL_SpinButtonImp::IsButtonEnable(FX_BOOL bUp) { | 165 |
| 166 FX_BOOL IFWL_SpinButton::IsButtonEnable(FX_BOOL bUp) { |
| 178 if (bUp) { | 167 if (bUp) { |
| 179 return (m_dwUpState != CFWL_PartState_Disabled); | 168 return (m_dwUpState != CFWL_PartState_Disabled); |
| 180 } | 169 } |
| 181 return (m_dwDnState != CFWL_PartState_Disabled); | 170 return (m_dwDnState != CFWL_PartState_Disabled); |
| 182 } | 171 } |
| 183 void CFWL_SpinButtonImp::DrawUpButton(CFX_Graphics* pGraphics, | 172 |
| 184 IFWL_ThemeProvider* pTheme, | 173 void IFWL_SpinButton::DrawUpButton(CFX_Graphics* pGraphics, |
| 185 const CFX_Matrix* pMatrix) { | 174 IFWL_ThemeProvider* pTheme, |
| 175 const CFX_Matrix* pMatrix) { |
| 186 CFWL_ThemeBackground params; | 176 CFWL_ThemeBackground params; |
| 187 params.m_pWidget = m_pInterface; | 177 params.m_pWidget = this; |
| 188 params.m_iPart = CFWL_Part::UpButton; | 178 params.m_iPart = CFWL_Part::UpButton; |
| 189 params.m_pGraphics = pGraphics; | 179 params.m_pGraphics = pGraphics; |
| 190 params.m_dwStates = m_dwUpState + 1; | 180 params.m_dwStates = m_dwUpState + 1; |
| 191 if (pMatrix) { | 181 if (pMatrix) { |
| 192 params.m_matrix.Concat(*pMatrix); | 182 params.m_matrix.Concat(*pMatrix); |
| 193 } | 183 } |
| 194 params.m_rtPart = m_rtUpButton; | 184 params.m_rtPart = m_rtUpButton; |
| 195 pTheme->DrawBackground(¶ms); | 185 pTheme->DrawBackground(¶ms); |
| 196 } | 186 } |
| 197 void CFWL_SpinButtonImp::DrawDownButton(CFX_Graphics* pGraphics, | 187 |
| 198 IFWL_ThemeProvider* pTheme, | 188 void IFWL_SpinButton::DrawDownButton(CFX_Graphics* pGraphics, |
| 199 const CFX_Matrix* pMatrix) { | 189 IFWL_ThemeProvider* pTheme, |
| 190 const CFX_Matrix* pMatrix) { |
| 200 CFWL_ThemeBackground params; | 191 CFWL_ThemeBackground params; |
| 201 params.m_pWidget = m_pInterface; | 192 params.m_pWidget = this; |
| 202 params.m_iPart = CFWL_Part::DownButton; | 193 params.m_iPart = CFWL_Part::DownButton; |
| 203 params.m_pGraphics = pGraphics; | 194 params.m_pGraphics = pGraphics; |
| 204 params.m_dwStates = m_dwDnState + 1; | 195 params.m_dwStates = m_dwDnState + 1; |
| 205 if (pMatrix) { | 196 if (pMatrix) { |
| 206 params.m_matrix.Concat(*pMatrix); | 197 params.m_matrix.Concat(*pMatrix); |
| 207 } | 198 } |
| 208 params.m_rtPart = m_rtDnButton; | 199 params.m_rtPart = m_rtDnButton; |
| 209 pTheme->DrawBackground(¶ms); | 200 pTheme->DrawBackground(¶ms); |
| 210 } | 201 } |
| 211 | 202 |
| 212 CFWL_SpinButtonImpDelegate::CFWL_SpinButtonImpDelegate( | 203 CFWL_SpinButtonImpDelegate::CFWL_SpinButtonImpDelegate(IFWL_SpinButton* pOwner) |
| 213 CFWL_SpinButtonImp* pOwner) | |
| 214 : m_pOwner(pOwner) {} | 204 : m_pOwner(pOwner) {} |
| 215 | 205 |
| 216 void CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 206 void CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 217 if (!pMessage) | 207 if (!pMessage) |
| 218 return; | 208 return; |
| 219 | 209 |
| 220 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 210 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
| 221 switch (dwMsgCode) { | 211 switch (dwMsgCode) { |
| 222 case CFWL_MessageType::SetFocus: { | 212 case CFWL_MessageType::SetFocus: { |
| 223 OnFocusChanged(pMessage, TRUE); | 213 OnFocusChanged(pMessage, TRUE); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 250 break; | 240 break; |
| 251 } | 241 } |
| 252 break; | 242 break; |
| 253 } | 243 } |
| 254 case CFWL_MessageType::Key: { | 244 case CFWL_MessageType::Key: { |
| 255 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); | 245 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); |
| 256 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) | 246 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) |
| 257 OnKeyDown(pKey); | 247 OnKeyDown(pKey); |
| 258 break; | 248 break; |
| 259 } | 249 } |
| 260 default: { | 250 default: { break; } |
| 261 break; | |
| 262 } | |
| 263 } | 251 } |
| 264 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 252 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
| 265 } | 253 } |
| 266 | 254 |
| 267 void CFWL_SpinButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} | 255 void CFWL_SpinButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} |
| 268 | 256 |
| 269 void CFWL_SpinButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 257 void CFWL_SpinButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 270 const CFX_Matrix* pMatrix) { | 258 const CFX_Matrix* pMatrix) { |
| 271 m_pOwner->DrawWidget(pGraphics, pMatrix); | 259 m_pOwner->DrawWidget(pGraphics, pMatrix); |
| 272 } | 260 } |
| 273 | 261 |
| 274 void CFWL_SpinButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg, | 262 void CFWL_SpinButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg, |
| 275 FX_BOOL bSet) { | 263 FX_BOOL bSet) { |
| 276 if (bSet) { | 264 if (bSet) { |
| 277 m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); | 265 m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); |
| 278 } else { | 266 } else { |
| 279 m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); | 267 m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); |
| 280 } | 268 } |
| 281 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 269 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 282 } | 270 } |
| 271 |
| 283 void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 272 void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
| 284 m_pOwner->m_bLButtonDwn = TRUE; | 273 m_pOwner->m_bLButtonDwn = TRUE; |
| 285 m_pOwner->SetGrab(TRUE); | 274 m_pOwner->SetGrab(TRUE); |
| 286 m_pOwner->SetFocus(TRUE); | 275 m_pOwner->SetFocus(TRUE); |
| 287 if (!m_pOwner->m_pProperties->m_pDataProvider) | 276 if (!m_pOwner->m_pProperties->m_pDataProvider) |
| 288 return; | 277 return; |
| 289 FX_BOOL bUpPress = (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && | 278 FX_BOOL bUpPress = (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && |
| 290 m_pOwner->IsButtonEnable(TRUE)); | 279 m_pOwner->IsButtonEnable(TRUE)); |
| 291 FX_BOOL bDnPress = (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && | 280 FX_BOOL bDnPress = (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && |
| 292 m_pOwner->IsButtonEnable(FALSE)); | 281 m_pOwner->IsButtonEnable(FALSE)); |
| 293 if (!bUpPress && !bDnPress) { | 282 if (!bUpPress && !bDnPress) { |
| 294 return; | 283 return; |
| 295 } | 284 } |
| 296 if (bUpPress) { | 285 if (bUpPress) { |
| 297 m_pOwner->m_iButtonIndex = 0; | 286 m_pOwner->m_iButtonIndex = 0; |
| 298 m_pOwner->m_dwUpState = CFWL_PartState_Pressed; | 287 m_pOwner->m_dwUpState = CFWL_PartState_Pressed; |
| 299 } | 288 } |
| 300 if (bDnPress) { | 289 if (bDnPress) { |
| 301 m_pOwner->m_iButtonIndex = 1; | 290 m_pOwner->m_iButtonIndex = 1; |
| 302 m_pOwner->m_dwDnState = CFWL_PartState_Pressed; | 291 m_pOwner->m_dwDnState = CFWL_PartState_Pressed; |
| 303 } | 292 } |
| 304 CFWL_EvtSpbClick wmPosChanged; | 293 CFWL_EvtSpbClick wmPosChanged; |
| 305 wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface; | 294 wmPosChanged.m_pSrcTarget = m_pOwner; |
| 306 wmPosChanged.m_bUp = bUpPress; | 295 wmPosChanged.m_bUp = bUpPress; |
| 307 m_pOwner->DispatchEvent(&wmPosChanged); | 296 m_pOwner->DispatchEvent(&wmPosChanged); |
| 308 m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton | 297 m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton |
| 309 : &m_pOwner->m_rtDnButton); | 298 : &m_pOwner->m_rtDnButton); |
| 310 m_pOwner->m_pTimerInfo = m_pOwner->StartTimer(kElapseTime, true); | 299 m_pOwner->m_pTimerInfo = m_pOwner->StartTimer(kElapseTime, true); |
| 311 } | 300 } |
| 312 | 301 |
| 313 void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 302 void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
| 314 if (m_pOwner->m_pProperties->m_dwStates & CFWL_PartState_Disabled) { | 303 if (m_pOwner->m_pProperties->m_dwStates & CFWL_PartState_Disabled) { |
| 315 return; | 304 return; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 331 } else if (m_pOwner->m_dwDnState == CFWL_PartState_Pressed && | 320 } else if (m_pOwner->m_dwDnState == CFWL_PartState_Pressed && |
| 332 m_pOwner->IsButtonEnable(FALSE)) { | 321 m_pOwner->IsButtonEnable(FALSE)) { |
| 333 m_pOwner->m_dwDnState = CFWL_PartState_Normal; | 322 m_pOwner->m_dwDnState = CFWL_PartState_Normal; |
| 334 bRepaint = TRUE; | 323 bRepaint = TRUE; |
| 335 rtInvalidate = m_pOwner->m_rtDnButton; | 324 rtInvalidate = m_pOwner->m_rtDnButton; |
| 336 } | 325 } |
| 337 if (bRepaint) { | 326 if (bRepaint) { |
| 338 m_pOwner->Repaint(&rtInvalidate); | 327 m_pOwner->Repaint(&rtInvalidate); |
| 339 } | 328 } |
| 340 } | 329 } |
| 330 |
| 341 void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { | 331 void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { |
| 342 if (!m_pOwner->m_pProperties->m_pDataProvider) | 332 if (!m_pOwner->m_pProperties->m_pDataProvider) |
| 343 return; | 333 return; |
| 344 if (m_pOwner->m_bLButtonDwn) { | 334 if (m_pOwner->m_bLButtonDwn) { |
| 345 return; | 335 return; |
| 346 } | 336 } |
| 347 FX_BOOL bRepaint = FALSE; | 337 FX_BOOL bRepaint = FALSE; |
| 348 CFX_RectF rtInvlidate; | 338 CFX_RectF rtInvlidate; |
| 349 rtInvlidate.Reset(); | 339 rtInvlidate.Reset(); |
| 350 if (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) { | 340 if (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } else { | 390 } else { |
| 401 rtInvlidate = m_pOwner->m_rtDnButton; | 391 rtInvlidate = m_pOwner->m_rtDnButton; |
| 402 } | 392 } |
| 403 bRepaint = TRUE; | 393 bRepaint = TRUE; |
| 404 } | 394 } |
| 405 } | 395 } |
| 406 if (bRepaint) { | 396 if (bRepaint) { |
| 407 m_pOwner->Repaint(&rtInvlidate); | 397 m_pOwner->Repaint(&rtInvlidate); |
| 408 } | 398 } |
| 409 } | 399 } |
| 400 |
| 410 void CFWL_SpinButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { | 401 void CFWL_SpinButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { |
| 411 if (!pMsg) | 402 if (!pMsg) |
| 412 return; | 403 return; |
| 413 if (m_pOwner->m_dwUpState != CFWL_PartState_Normal && | 404 if (m_pOwner->m_dwUpState != CFWL_PartState_Normal && |
| 414 m_pOwner->IsButtonEnable(TRUE)) { | 405 m_pOwner->IsButtonEnable(TRUE)) { |
| 415 m_pOwner->m_dwUpState = CFWL_PartState_Normal; | 406 m_pOwner->m_dwUpState = CFWL_PartState_Normal; |
| 416 } | 407 } |
| 417 if (m_pOwner->m_dwDnState != CFWL_PartState_Normal && | 408 if (m_pOwner->m_dwDnState != CFWL_PartState_Normal && |
| 418 m_pOwner->IsButtonEnable(FALSE)) { | 409 m_pOwner->IsButtonEnable(FALSE)) { |
| 419 m_pOwner->m_dwDnState = CFWL_PartState_Normal; | 410 m_pOwner->m_dwDnState = CFWL_PartState_Normal; |
| 420 } | 411 } |
| 421 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 412 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 422 } | 413 } |
| 414 |
| 423 void CFWL_SpinButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { | 415 void CFWL_SpinButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { |
| 424 if (!m_pOwner->m_pProperties->m_pDataProvider) | 416 if (!m_pOwner->m_pProperties->m_pDataProvider) |
| 425 return; | 417 return; |
| 426 FX_BOOL bUp = | 418 FX_BOOL bUp = |
| 427 pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left; | 419 pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left; |
| 428 FX_BOOL bDown = | 420 FX_BOOL bDown = |
| 429 pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right; | 421 pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right; |
| 430 if (!bUp && !bDown) { | 422 if (!bUp && !bDown) { |
| 431 return; | 423 return; |
| 432 } | 424 } |
| 433 FX_BOOL bUpEnable = m_pOwner->IsButtonEnable(TRUE); | 425 FX_BOOL bUpEnable = m_pOwner->IsButtonEnable(TRUE); |
| 434 FX_BOOL bDownEnable = m_pOwner->IsButtonEnable(FALSE); | 426 FX_BOOL bDownEnable = m_pOwner->IsButtonEnable(FALSE); |
| 435 if (!bUpEnable && !bDownEnable) { | 427 if (!bUpEnable && !bDownEnable) { |
| 436 return; | 428 return; |
| 437 } | 429 } |
| 438 CFWL_EvtSpbClick wmPosChanged; | 430 CFWL_EvtSpbClick wmPosChanged; |
| 439 wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface; | 431 wmPosChanged.m_pSrcTarget = m_pOwner; |
| 440 wmPosChanged.m_bUp = bUpEnable; | 432 wmPosChanged.m_bUp = bUpEnable; |
| 441 m_pOwner->DispatchEvent(&wmPosChanged); | 433 m_pOwner->DispatchEvent(&wmPosChanged); |
| 442 m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton | 434 m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton |
| 443 : &m_pOwner->m_rtDnButton); | 435 : &m_pOwner->m_rtDnButton); |
| 444 } | 436 } |
| OLD | NEW |