| 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_checkboximp.h" | 7 #include "xfa/fwl/basewidget/fwl_checkboximp.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 m_rtClient.Reset(); | 47 m_rtClient.Reset(); |
| 48 m_rtBox.Reset(); | 48 m_rtBox.Reset(); |
| 49 m_rtCaption.Reset(); | 49 m_rtCaption.Reset(); |
| 50 m_rtFocus.Reset(); | 50 m_rtFocus.Reset(); |
| 51 } | 51 } |
| 52 CFWL_CheckBoxImp::~CFWL_CheckBoxImp() {} | 52 CFWL_CheckBoxImp::~CFWL_CheckBoxImp() {} |
| 53 FWL_ERR CFWL_CheckBoxImp::GetClassName(CFX_WideString& wsClass) const { | 53 FWL_ERR CFWL_CheckBoxImp::GetClassName(CFX_WideString& wsClass) const { |
| 54 wsClass = FWL_CLASS_CheckBox; | 54 wsClass = FWL_CLASS_CheckBox; |
| 55 return FWL_ERR_Succeeded; | 55 return FWL_ERR_Succeeded; |
| 56 } | 56 } |
| 57 FX_DWORD CFWL_CheckBoxImp::GetClassID() const { | 57 uint32_t CFWL_CheckBoxImp::GetClassID() const { |
| 58 return FWL_CLASSHASH_CheckBox; | 58 return FWL_CLASSHASH_CheckBox; |
| 59 } | 59 } |
| 60 FWL_ERR CFWL_CheckBoxImp::Initialize() { | 60 FWL_ERR CFWL_CheckBoxImp::Initialize() { |
| 61 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 61 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) |
| 62 return FWL_ERR_Indefinite; | 62 return FWL_ERR_Indefinite; |
| 63 m_pDelegate = new CFWL_CheckBoxImpDelegate(this); | 63 m_pDelegate = new CFWL_CheckBoxImpDelegate(this); |
| 64 return FWL_ERR_Succeeded; | 64 return FWL_ERR_Succeeded; |
| 65 } | 65 } |
| 66 FWL_ERR CFWL_CheckBoxImp::Finalize() { | 66 FWL_ERR CFWL_CheckBoxImp::Finalize() { |
| 67 delete m_pDelegate; | 67 delete m_pDelegate; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 FWL_STYLEEXT_CKB_VLayoutMask) == FWL_STYLEEXT_CKB_Bottom) { | 272 FWL_STYLEEXT_CKB_VLayoutMask) == FWL_STYLEEXT_CKB_Bottom) { |
| 273 fTop = m_rtCaption.bottom() - fHeight; | 273 fTop = m_rtCaption.bottom() - fHeight; |
| 274 } | 274 } |
| 275 m_rtFocus.Set(fLeft, fTop, fWidth, fHeight); | 275 m_rtFocus.Set(fLeft, fTop, fWidth, fHeight); |
| 276 } else { | 276 } else { |
| 277 m_rtFocus.Set(rtFocus.left, rtFocus.top, rtFocus.width, rtFocus.height); | 277 m_rtFocus.Set(rtFocus.left, rtFocus.top, rtFocus.width, rtFocus.height); |
| 278 } | 278 } |
| 279 m_rtFocus.Inflate(1, 1); | 279 m_rtFocus.Inflate(1, 1); |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 FX_DWORD CFWL_CheckBoxImp::GetPartStates() { | 282 uint32_t CFWL_CheckBoxImp::GetPartStates() { |
| 283 int32_t dwStates = FWL_PARTSTATE_CKB_UnChecked; | 283 int32_t dwStates = FWL_PARTSTATE_CKB_UnChecked; |
| 284 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == | 284 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == |
| 285 FWL_STATE_CKB_Neutral) { | 285 FWL_STATE_CKB_Neutral) { |
| 286 dwStates = FWL_PARTSTATE_CKB_Neutral; | 286 dwStates = FWL_PARTSTATE_CKB_Neutral; |
| 287 } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == | 287 } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == |
| 288 FWL_STATE_CKB_Checked) { | 288 FWL_STATE_CKB_Checked) { |
| 289 dwStates = FWL_PARTSTATE_CKB_Checked; | 289 dwStates = FWL_PARTSTATE_CKB_Checked; |
| 290 } | 290 } |
| 291 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { | 291 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { |
| 292 dwStates |= FWL_PARTSTATE_CKB_Disabled; | 292 dwStates |= FWL_PARTSTATE_CKB_Disabled; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { | 348 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { |
| 349 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; | 349 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; |
| 350 } | 350 } |
| 351 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) { | 351 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) { |
| 352 m_dwTTOStyles |= FDE_TTOSTYLE_LineWrap; | 352 m_dwTTOStyles |= FDE_TTOSTYLE_LineWrap; |
| 353 } else { | 353 } else { |
| 354 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; | 354 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 void CFWL_CheckBoxImp::NextStates() { | 357 void CFWL_CheckBoxImp::NextStates() { |
| 358 FX_DWORD dwFirststate = m_pProperties->m_dwStates; | 358 uint32_t dwFirststate = m_pProperties->m_dwStates; |
| 359 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { | 359 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { |
| 360 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == | 360 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == |
| 361 FWL_STATE_CKB_Unchecked) { | 361 FWL_STATE_CKB_Unchecked) { |
| 362 CFWL_WidgetMgr* pWidgetMgr = | 362 CFWL_WidgetMgr* pWidgetMgr = |
| 363 static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 363 static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 364 if (!pWidgetMgr->IsFormDisabled()) { | 364 if (!pWidgetMgr->IsFormDisabled()) { |
| 365 CFX_PtrArray radioarr; | 365 CFX_PtrArray radioarr; |
| 366 pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr); | 366 pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr); |
| 367 IFWL_CheckBox* pCheckBox = NULL; | 367 IFWL_CheckBox* pCheckBox = NULL; |
| 368 int32_t iCount = radioarr.GetSize(); | 368 int32_t iCount = radioarr.GetSize(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 393 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; | 393 m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask; |
| 394 } else { | 394 } else { |
| 395 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { | 395 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) { |
| 396 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; | 396 m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral; |
| 397 } else { | 397 } else { |
| 398 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; | 398 m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked; |
| 399 } | 399 } |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 Repaint(&m_rtClient); | 402 Repaint(&m_rtClient); |
| 403 FX_DWORD dwLaststate = m_pProperties->m_dwStates; | 403 uint32_t dwLaststate = m_pProperties->m_dwStates; |
| 404 if (dwFirststate != dwLaststate) { | 404 if (dwFirststate != dwLaststate) { |
| 405 CFWL_EvtCkbCheckStateChanged wmCheckBoxState; | 405 CFWL_EvtCkbCheckStateChanged wmCheckBoxState; |
| 406 wmCheckBoxState.m_pSrcTarget = m_pInterface; | 406 wmCheckBoxState.m_pSrcTarget = m_pInterface; |
| 407 DispatchEvent(&wmCheckBoxState); | 407 DispatchEvent(&wmCheckBoxState); |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner) | 410 CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner) |
| 411 : m_pOwner(pOwner) {} | 411 : m_pOwner(pOwner) {} |
| 412 int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 412 int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 413 if (!pMessage) | 413 if (!pMessage) |
| 414 return 0; | 414 return 0; |
| 415 FX_DWORD dwMsgCode = pMessage->GetClassID(); | 415 uint32_t dwMsgCode = pMessage->GetClassID(); |
| 416 int32_t iRet = 1; | 416 int32_t iRet = 1; |
| 417 switch (dwMsgCode) { | 417 switch (dwMsgCode) { |
| 418 case FWL_MSGHASH_Activate: { | 418 case FWL_MSGHASH_Activate: { |
| 419 OnActivate(pMessage); | 419 OnActivate(pMessage); |
| 420 break; | 420 break; |
| 421 } | 421 } |
| 422 case FWL_MSGHASH_SetFocus: | 422 case FWL_MSGHASH_SetFocus: |
| 423 case FWL_MSGHASH_KillFocus: { | 423 case FWL_MSGHASH_KillFocus: { |
| 424 OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); | 424 OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); |
| 425 break; | 425 break; |
| 426 } | 426 } |
| 427 case FWL_MSGHASH_Mouse: { | 427 case FWL_MSGHASH_Mouse: { |
| 428 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 428 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
| 429 FX_DWORD dwCmd = pMsg->m_dwCmd; | 429 uint32_t dwCmd = pMsg->m_dwCmd; |
| 430 switch (dwCmd) { | 430 switch (dwCmd) { |
| 431 case FWL_MSGMOUSECMD_LButtonDown: { | 431 case FWL_MSGMOUSECMD_LButtonDown: { |
| 432 OnLButtonDown(pMsg); | 432 OnLButtonDown(pMsg); |
| 433 break; | 433 break; |
| 434 } | 434 } |
| 435 case FWL_MSGMOUSECMD_LButtonUp: { | 435 case FWL_MSGMOUSECMD_LButtonUp: { |
| 436 OnLButtonUp(pMsg); | 436 OnLButtonUp(pMsg); |
| 437 break; | 437 break; |
| 438 } | 438 } |
| 439 case FWL_MSGMOUSECMD_MouseMove: { | 439 case FWL_MSGMOUSECMD_MouseMove: { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { | 549 void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { |
| 550 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { | 550 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { |
| 551 m_pOwner->DispatchKeyEvent(pMsg); | 551 m_pOwner->DispatchKeyEvent(pMsg); |
| 552 return; | 552 return; |
| 553 } | 553 } |
| 554 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || | 554 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || |
| 555 pMsg->m_dwKeyCode == FWL_VKEY_Space) { | 555 pMsg->m_dwKeyCode == FWL_VKEY_Space) { |
| 556 m_pOwner->NextStates(); | 556 m_pOwner->NextStates(); |
| 557 } | 557 } |
| 558 } | 558 } |
| OLD | NEW |