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/fxfa/app/xfa_ffcheckbutton.h" | 7 #include "xfa/fxfa/app/xfa_ffcheckbutton.h" |
8 | 8 |
9 #include "xfa/fwl/core/cfwl_message.h" | 9 #include "xfa/fwl/core/cfwl_message.h" |
10 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 10 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round); | 232 m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round); |
233 CFX_Matrix mt; | 233 CFX_Matrix mt; |
234 mt.Set(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); | 234 mt.Set(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); |
235 mt.Concat(mtRotate); | 235 mt.Concat(mtRotate); |
236 GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), | 236 GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), |
237 pGS, &mt); | 237 pGS, &mt); |
238 } | 238 } |
239 FX_BOOL CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags, | 239 FX_BOOL CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags, |
240 FX_FLOAT fx, | 240 FX_FLOAT fx, |
241 FX_FLOAT fy) { | 241 FX_FLOAT fy) { |
242 if (!m_pNormalWidget) { | 242 if (!m_pNormalWidget || !IsButtonDown()) |
243 return FALSE; | 243 return FALSE; |
244 } | 244 |
245 if (!IsButtonDown()) { | |
246 return FALSE; | |
247 } | |
248 SetButtonDown(FALSE); | 245 SetButtonDown(FALSE); |
249 CFWL_MsgMouse ms; | 246 CFWL_MsgMouse ms; |
250 ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; | 247 ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; |
251 ms.m_dwFlags = dwFlags; | 248 ms.m_dwFlags = dwFlags; |
252 ms.m_fx = fx; | 249 ms.m_fx = fx; |
253 ms.m_fy = fy; | 250 ms.m_fy = fy; |
254 FWLToClient(ms.m_fx, ms.m_fy); | 251 FWLToClient(ms.m_fx, ms.m_fy); |
255 ms.m_pDstTarget = m_pNormalWidget->m_pIface; | 252 ms.m_pDstTarget = m_pNormalWidget->m_pIface; |
256 TranslateFWLMessage(&ms); | 253 TranslateFWLMessage(&ms); |
257 return TRUE; | 254 return TRUE; |
258 } | 255 } |
| 256 |
259 XFA_CHECKSTATE CXFA_FFCheckButton::FWLState2XFAState() { | 257 XFA_CHECKSTATE CXFA_FFCheckButton::FWLState2XFAState() { |
260 XFA_CHECKSTATE eCheckState = XFA_CHECKSTATE_Off; | |
261 uint32_t dwState = m_pNormalWidget->GetStates(); | 258 uint32_t dwState = m_pNormalWidget->GetStates(); |
262 if (dwState & FWL_STATE_CKB_Checked) { | 259 if (dwState & FWL_STATE_CKB_Checked) |
263 eCheckState = XFA_CHECKSTATE_On; | 260 return XFA_CHECKSTATE_On; |
264 } else if (dwState & FWL_STATE_CKB_Neutral) { | 261 if (dwState & FWL_STATE_CKB_Neutral) |
265 eCheckState = XFA_CHECKSTATE_Neutral; | 262 return XFA_CHECKSTATE_Neutral; |
266 } | 263 return XFA_CHECKSTATE_Off; |
267 return eCheckState; | |
268 } | 264 } |
| 265 |
269 FX_BOOL CXFA_FFCheckButton::CommitData() { | 266 FX_BOOL CXFA_FFCheckButton::CommitData() { |
270 XFA_CHECKSTATE eCheckState = FWLState2XFAState(); | 267 XFA_CHECKSTATE eCheckState = FWLState2XFAState(); |
271 m_pDataAcc->SetCheckState(eCheckState, TRUE); | 268 m_pDataAcc->SetCheckState(eCheckState, true); |
272 return TRUE; | 269 return TRUE; |
273 } | 270 } |
| 271 |
274 FX_BOOL CXFA_FFCheckButton::IsDataChanged() { | 272 FX_BOOL CXFA_FFCheckButton::IsDataChanged() { |
275 XFA_CHECKSTATE eCheckState = FWLState2XFAState(); | 273 XFA_CHECKSTATE eCheckState = FWLState2XFAState(); |
276 return m_pDataAcc->GetCheckState() != eCheckState; | 274 return m_pDataAcc->GetCheckState() != eCheckState; |
277 } | 275 } |
278 void CXFA_FFCheckButton::SetFWLCheckState(XFA_CHECKSTATE eCheckState) { | 276 void CXFA_FFCheckButton::SetFWLCheckState(XFA_CHECKSTATE eCheckState) { |
279 if (eCheckState == XFA_CHECKSTATE_Neutral) { | 277 if (eCheckState == XFA_CHECKSTATE_Neutral) { |
280 m_pNormalWidget->SetStates(FWL_STATE_CKB_Neutral, TRUE); | 278 m_pNormalWidget->SetStates(FWL_STATE_CKB_Neutral, TRUE); |
281 } else { | 279 } else { |
282 m_pNormalWidget->SetStates(FWL_STATE_CKB_Checked, | 280 m_pNormalWidget->SetStates(FWL_STATE_CKB_Checked, |
283 eCheckState == XFA_CHECKSTATE_On); | 281 eCheckState == XFA_CHECKSTATE_On); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 default: | 326 default: |
329 break; | 327 break; |
330 } | 328 } |
331 m_pOldDelegate->OnProcessEvent(pEvent); | 329 m_pOldDelegate->OnProcessEvent(pEvent); |
332 } | 330 } |
333 | 331 |
334 void CXFA_FFCheckButton::OnDrawWidget(CFX_Graphics* pGraphics, | 332 void CXFA_FFCheckButton::OnDrawWidget(CFX_Graphics* pGraphics, |
335 const CFX_Matrix* pMatrix) { | 333 const CFX_Matrix* pMatrix) { |
336 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 334 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
337 } | 335 } |
OLD | NEW |