| 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_pushbuttonimp.h" | 7 #include "xfa/fwl/basewidget/fwl_pushbuttonimp.h" |
| 8 | 8 |
| 9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
| 10 #include "xfa/fwl/basewidget/ifwl_pushbutton.h" | 10 #include "xfa/fwl/basewidget/ifwl_pushbutton.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), | 37 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), |
| 38 m_iTTOAlign(FDE_TTOALIGNMENT_Center) { | 38 m_iTTOAlign(FDE_TTOALIGNMENT_Center) { |
| 39 m_rtClient.Set(0, 0, 0, 0); | 39 m_rtClient.Set(0, 0, 0, 0); |
| 40 m_rtCaption.Set(0, 0, 0, 0); | 40 m_rtCaption.Set(0, 0, 0, 0); |
| 41 } | 41 } |
| 42 CFWL_PushButtonImp::~CFWL_PushButtonImp() {} | 42 CFWL_PushButtonImp::~CFWL_PushButtonImp() {} |
| 43 FWL_ERR CFWL_PushButtonImp::GetClassName(CFX_WideString& wsClass) const { | 43 FWL_ERR CFWL_PushButtonImp::GetClassName(CFX_WideString& wsClass) const { |
| 44 wsClass = FWL_CLASS_PushButton; | 44 wsClass = FWL_CLASS_PushButton; |
| 45 return FWL_ERR_Succeeded; | 45 return FWL_ERR_Succeeded; |
| 46 } | 46 } |
| 47 FX_DWORD CFWL_PushButtonImp::GetClassID() const { | 47 uint32_t CFWL_PushButtonImp::GetClassID() const { |
| 48 return FWL_CLASSHASH_PushButton; | 48 return FWL_CLASSHASH_PushButton; |
| 49 } | 49 } |
| 50 FWL_ERR CFWL_PushButtonImp::Initialize() { | 50 FWL_ERR CFWL_PushButtonImp::Initialize() { |
| 51 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 51 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) |
| 52 return FWL_ERR_Indefinite; | 52 return FWL_ERR_Indefinite; |
| 53 m_pDelegate = new CFWL_PushButtonImpDelegate(this); | 53 m_pDelegate = new CFWL_PushButtonImpDelegate(this); |
| 54 return FWL_ERR_Succeeded; | 54 return FWL_ERR_Succeeded; |
| 55 } | 55 } |
| 56 FWL_ERR CFWL_PushButtonImp::Finalize() { | 56 FWL_ERR CFWL_PushButtonImp::Finalize() { |
| 57 delete m_pDelegate; | 57 delete m_pDelegate; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 77 } | 77 } |
| 78 FX_FLOAT* fcaption = | 78 FX_FLOAT* fcaption = |
| 79 static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin)); | 79 static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin)); |
| 80 rect.Inflate(*fcaption, *fcaption); | 80 rect.Inflate(*fcaption, *fcaption); |
| 81 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); | 81 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); |
| 82 } else { | 82 } else { |
| 83 rect = m_pProperties->m_rtWidget; | 83 rect = m_pProperties->m_rtWidget; |
| 84 } | 84 } |
| 85 return FWL_ERR_Succeeded; | 85 return FWL_ERR_Succeeded; |
| 86 } | 86 } |
| 87 FWL_ERR CFWL_PushButtonImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { | 87 FWL_ERR CFWL_PushButtonImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
| 88 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) { | 88 if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) { |
| 89 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled; | 89 m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled; |
| 90 return FWL_ERR_Succeeded; | 90 return FWL_ERR_Succeeded; |
| 91 } | 91 } |
| 92 return CFWL_WidgetImp::SetStates(dwStates, bSet); | 92 return CFWL_WidgetImp::SetStates(dwStates, bSet); |
| 93 } | 93 } |
| 94 FWL_ERR CFWL_PushButtonImp::Update() { | 94 FWL_ERR CFWL_PushButtonImp::Update() { |
| 95 if (IsLocked()) { | 95 if (IsLocked()) { |
| 96 return FWL_ERR_Indefinite; | 96 return FWL_ERR_Indefinite; |
| 97 } | 97 } |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 param.m_pGraphics = pGraphics; | 328 param.m_pGraphics = pGraphics; |
| 329 if (pMatrix) { | 329 if (pMatrix) { |
| 330 param.m_matrix.Concat(*pMatrix); | 330 param.m_matrix.Concat(*pMatrix); |
| 331 } | 331 } |
| 332 param.m_rtPart = m_rtCaption; | 332 param.m_rtPart = m_rtCaption; |
| 333 param.m_wsText = wsCaption; | 333 param.m_wsText = wsCaption; |
| 334 param.m_dwTTOStyles = m_dwTTOStyles; | 334 param.m_dwTTOStyles = m_dwTTOStyles; |
| 335 param.m_iTTOAlign = m_iTTOAlign; | 335 param.m_iTTOAlign = m_iTTOAlign; |
| 336 pTheme->DrawText(¶m); | 336 pTheme->DrawText(¶m); |
| 337 } | 337 } |
| 338 FX_DWORD CFWL_PushButtonImp::GetPartStates() { | 338 uint32_t CFWL_PushButtonImp::GetPartStates() { |
| 339 FX_DWORD dwStates = FWL_PARTSTATE_PSB_Normal; | 339 uint32_t dwStates = FWL_PARTSTATE_PSB_Normal; |
| 340 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { | 340 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { |
| 341 dwStates |= FWL_PARTSTATE_PSB_Focused; | 341 dwStates |= FWL_PARTSTATE_PSB_Focused; |
| 342 } | 342 } |
| 343 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { | 343 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { |
| 344 dwStates = FWL_PARTSTATE_PSB_Disabled; | 344 dwStates = FWL_PARTSTATE_PSB_Disabled; |
| 345 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) { | 345 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) { |
| 346 dwStates |= FWL_PARTSTATE_PSB_Pressed; | 346 dwStates |= FWL_PARTSTATE_PSB_Pressed; |
| 347 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { | 347 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { |
| 348 dwStates |= FWL_PARTSTATE_PSB_Hovered; | 348 dwStates |= FWL_PARTSTATE_PSB_Hovered; |
| 349 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) { | 349 } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate( | 401 CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate( |
| 402 CFWL_PushButtonImp* pOwner) | 402 CFWL_PushButtonImp* pOwner) |
| 403 : m_pOwner(pOwner) {} | 403 : m_pOwner(pOwner) {} |
| 404 int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 404 int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 405 if (!pMessage) | 405 if (!pMessage) |
| 406 return 0; | 406 return 0; |
| 407 if (!m_pOwner->IsEnabled()) { | 407 if (!m_pOwner->IsEnabled()) { |
| 408 return 1; | 408 return 1; |
| 409 } | 409 } |
| 410 int32_t iRet = 1; | 410 int32_t iRet = 1; |
| 411 FX_DWORD dwMsgCode = pMessage->GetClassID(); | 411 uint32_t dwMsgCode = pMessage->GetClassID(); |
| 412 switch (dwMsgCode) { | 412 switch (dwMsgCode) { |
| 413 case FWL_MSGHASH_SetFocus: | 413 case FWL_MSGHASH_SetFocus: |
| 414 case FWL_MSGHASH_KillFocus: { | 414 case FWL_MSGHASH_KillFocus: { |
| 415 OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); | 415 OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); |
| 416 break; | 416 break; |
| 417 } | 417 } |
| 418 case FWL_MSGHASH_Mouse: { | 418 case FWL_MSGHASH_Mouse: { |
| 419 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 419 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
| 420 FX_DWORD dwCmd = pMsg->m_dwCmd; | 420 uint32_t dwCmd = pMsg->m_dwCmd; |
| 421 switch (dwCmd) { | 421 switch (dwCmd) { |
| 422 case FWL_MSGMOUSECMD_LButtonDown: { | 422 case FWL_MSGMOUSECMD_LButtonDown: { |
| 423 OnLButtonDown(pMsg); | 423 OnLButtonDown(pMsg); |
| 424 break; | 424 break; |
| 425 } | 425 } |
| 426 case FWL_MSGMOUSECMD_LButtonUp: { | 426 case FWL_MSGMOUSECMD_LButtonUp: { |
| 427 OnLButtonUp(pMsg); | 427 OnLButtonUp(pMsg); |
| 428 break; | 428 break; |
| 429 } | 429 } |
| 430 case FWL_MSGMOUSECMD_MouseMove: { | 430 case FWL_MSGMOUSECMD_MouseMove: { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 CFWL_EvtClick wmClick; | 545 CFWL_EvtClick wmClick; |
| 546 wmClick.m_pSrcTarget = m_pOwner->m_pInterface; | 546 wmClick.m_pSrcTarget = m_pOwner->m_pInterface; |
| 547 m_pOwner->DispatchEvent(&wmClick); | 547 m_pOwner->DispatchEvent(&wmClick); |
| 548 return; | 548 return; |
| 549 } | 549 } |
| 550 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) { | 550 if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) { |
| 551 return; | 551 return; |
| 552 } | 552 } |
| 553 m_pOwner->DispatchKeyEvent(pMsg); | 553 m_pOwner->DispatchKeyEvent(pMsg); |
| 554 } | 554 } |
| OLD | NEW |