| 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 |
| 11 #include "xfa/fde/tto/fde_textout.h" | 11 #include "xfa/fde/tto/fde_textout.h" |
| 12 #include "xfa/fwl/basewidget/ifwl_checkbox.h" | 12 #include "xfa/fwl/basewidget/ifwl_checkbox.h" |
| 13 #include "xfa/fwl/core/cfwl_message.h" | 13 #include "xfa/fwl/core/cfwl_message.h" |
| 14 #include "xfa/fwl/core/cfwl_themebackground.h" | 14 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 15 #include "xfa/fwl/core/cfwl_themetext.h" | 15 #include "xfa/fwl/core/cfwl_themetext.h" |
| 16 #include "xfa/fwl/core/fwl_noteimp.h" | 16 #include "xfa/fwl/core/fwl_noteimp.h" |
| 17 #include "xfa/fwl/core/fwl_widgetimp.h" | 17 #include "xfa/fwl/core/fwl_widgetimp.h" |
| 18 #include "xfa/fwl/core/fwl_widgetmgrimp.h" | 18 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
| 19 #include "xfa/fwl/core/ifwl_themeprovider.h" | 19 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 20 | 20 |
| 21 #define FWL_CKB_CaptionMargin 5 | 21 namespace { |
| 22 |
| 23 const int kCaptionMargin = 5; |
| 24 |
| 25 } // namespace |
| 22 | 26 |
| 23 // static | 27 // static |
| 24 IFWL_CheckBox* IFWL_CheckBox::Create(const CFWL_WidgetImpProperties& properties, | 28 IFWL_CheckBox* IFWL_CheckBox::Create(const CFWL_WidgetImpProperties& properties, |
| 25 IFWL_Widget* pOuter) { | 29 IFWL_Widget* pOuter) { |
| 26 IFWL_CheckBox* pCheckBox = new IFWL_CheckBox; | 30 IFWL_CheckBox* pCheckBox = new IFWL_CheckBox; |
| 27 CFWL_CheckBoxImp* pCheckBoxImpl = new CFWL_CheckBoxImp(properties, pOuter); | 31 CFWL_CheckBoxImp* pCheckBoxImpl = new CFWL_CheckBoxImp(properties, pOuter); |
| 28 pCheckBox->SetImpl(pCheckBoxImpl); | 32 pCheckBox->SetImpl(pCheckBoxImpl); |
| 29 pCheckBoxImpl->SetInterface(pCheckBox); | 33 pCheckBoxImpl->SetInterface(pCheckBox); |
| 30 return pCheckBox; | 34 return pCheckBox; |
| 31 } | 35 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 if (!m_pProperties->m_pDataProvider) | 81 if (!m_pProperties->m_pDataProvider) |
| 78 return FWL_ERR_Indefinite; | 82 return FWL_ERR_Indefinite; |
| 79 CFX_WideString wsCaption; | 83 CFX_WideString wsCaption; |
| 80 m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); | 84 m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); |
| 81 if (wsCaption.GetLength() > 0) { | 85 if (wsCaption.GetLength() > 0) { |
| 82 CFX_SizeF sz = CalcTextSize( | 86 CFX_SizeF sz = CalcTextSize( |
| 83 wsCaption, m_pProperties->m_pThemeProvider, | 87 wsCaption, m_pProperties->m_pThemeProvider, |
| 84 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine); | 88 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine); |
| 85 rect.Set(0, 0, sz.x, sz.y); | 89 rect.Set(0, 0, sz.x, sz.y); |
| 86 } | 90 } |
| 87 rect.Inflate(FWL_CKB_CaptionMargin, FWL_CKB_CaptionMargin); | 91 rect.Inflate(kCaptionMargin, kCaptionMargin); |
| 88 IFWL_CheckBoxDP* pData = | 92 IFWL_CheckBoxDP* pData = |
| 89 static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider); | 93 static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider); |
| 90 FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface); | 94 FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface); |
| 91 rect.width += fCheckBox; | 95 rect.width += fCheckBox; |
| 92 if (rect.height < fCheckBox) { | 96 if (rect.height < fCheckBox) { |
| 93 rect.height = fCheckBox; | 97 rect.height = fCheckBox; |
| 94 } | 98 } |
| 95 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); | 99 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); |
| 96 } else { | 100 } else { |
| 97 rect = m_pProperties->m_rtWidget; | 101 rect = m_pProperties->m_rtWidget; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 fBoxLeft = fClientRight - fCheckBox; | 238 fBoxLeft = fClientRight - fCheckBox; |
| 235 fTextLeft = m_rtClient.left; | 239 fTextLeft = m_rtClient.left; |
| 236 fTextRight = fBoxLeft; | 240 fTextRight = fBoxLeft; |
| 237 } else { | 241 } else { |
| 238 fTextLeft = fBoxLeft + fCheckBox; | 242 fTextLeft = fBoxLeft + fCheckBox; |
| 239 fTextRight = fClientRight; | 243 fTextRight = fClientRight; |
| 240 } | 244 } |
| 241 m_rtBox.Set(fBoxLeft, fBoxTop, fCheckBox, fCheckBox); | 245 m_rtBox.Set(fBoxLeft, fBoxTop, fCheckBox, fCheckBox); |
| 242 m_rtCaption.Set(fTextLeft, m_rtClient.top, fTextRight - fTextLeft, | 246 m_rtCaption.Set(fTextLeft, m_rtClient.top, fTextRight - fTextLeft, |
| 243 m_rtClient.height); | 247 m_rtClient.height); |
| 244 m_rtCaption.Inflate(-FWL_CKB_CaptionMargin, -FWL_CKB_CaptionMargin); | 248 m_rtCaption.Inflate(-kCaptionMargin, -kCaptionMargin); |
| 245 CFX_RectF rtFocus; | 249 CFX_RectF rtFocus; |
| 246 rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width, | 250 rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width, |
| 247 m_rtCaption.height); | 251 m_rtCaption.height); |
| 248 CFX_WideString wsCaption; | 252 CFX_WideString wsCaption; |
| 249 m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); | 253 m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); |
| 250 if (wsCaption.IsEmpty()) { | 254 if (wsCaption.IsEmpty()) { |
| 251 m_rtFocus.Set(0, 0, 0, 0); | 255 m_rtFocus.Set(0, 0, 0, 0); |
| 252 } else { | 256 } else { |
| 253 CalcTextRect(wsCaption, m_pProperties->m_pThemeProvider, m_dwTTOStyles, | 257 CalcTextRect(wsCaption, m_pProperties->m_pThemeProvider, m_dwTTOStyles, |
| 254 m_iTTOAlign, rtFocus); | 258 m_iTTOAlign, rtFocus); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 case CFWL_MessageType::SetFocus: { | 426 case CFWL_MessageType::SetFocus: { |
| 423 OnFocusChanged(pMessage, TRUE); | 427 OnFocusChanged(pMessage, TRUE); |
| 424 break; | 428 break; |
| 425 } | 429 } |
| 426 case CFWL_MessageType::KillFocus: { | 430 case CFWL_MessageType::KillFocus: { |
| 427 OnFocusChanged(pMessage, FALSE); | 431 OnFocusChanged(pMessage, FALSE); |
| 428 break; | 432 break; |
| 429 } | 433 } |
| 430 case CFWL_MessageType::Mouse: { | 434 case CFWL_MessageType::Mouse: { |
| 431 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 435 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
| 432 uint32_t dwCmd = pMsg->m_dwCmd; | 436 switch (pMsg->m_dwCmd) { |
| 433 switch (dwCmd) { | 437 case FWL_MouseCommand::LeftButtonDown: { |
| 434 case FWL_MSGMOUSECMD_LButtonDown: { | |
| 435 OnLButtonDown(pMsg); | 438 OnLButtonDown(pMsg); |
| 436 break; | 439 break; |
| 437 } | 440 } |
| 438 case FWL_MSGMOUSECMD_LButtonUp: { | 441 case FWL_MouseCommand::LeftButtonUp: { |
| 439 OnLButtonUp(pMsg); | 442 OnLButtonUp(pMsg); |
| 440 break; | 443 break; |
| 441 } | 444 } |
| 442 case FWL_MSGMOUSECMD_MouseMove: { | 445 case FWL_MouseCommand::Move: { |
| 443 OnMouseMove(pMsg); | 446 OnMouseMove(pMsg); |
| 444 break; | 447 break; |
| 445 } | 448 } |
| 446 case FWL_MSGMOUSECMD_MouseLeave: { | 449 case FWL_MouseCommand::Leave: { |
| 447 OnMouseLeave(pMsg); | 450 OnMouseLeave(pMsg); |
| 448 break; | 451 break; |
| 449 } | 452 } |
| 450 default: | 453 default: |
| 451 break; | 454 break; |
| 452 } | 455 } |
| 453 break; | 456 break; |
| 454 } | 457 } |
| 455 case CFWL_MessageType::Key: { | 458 case CFWL_MessageType::Key: { |
| 456 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); | 459 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); |
| 457 if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) | 460 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) |
| 458 OnKeyDown(pKey); | 461 OnKeyDown(pKey); |
| 459 break; | 462 break; |
| 460 } | 463 } |
| 461 default: { | 464 default: { |
| 462 iRet = 0; | 465 iRet = 0; |
| 463 break; | 466 break; |
| 464 } | 467 } |
| 465 } | 468 } |
| 466 | 469 |
| 467 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 470 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { | 559 void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { |
| 557 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { | 560 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { |
| 558 m_pOwner->DispatchKeyEvent(pMsg); | 561 m_pOwner->DispatchKeyEvent(pMsg); |
| 559 return; | 562 return; |
| 560 } | 563 } |
| 561 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || | 564 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || |
| 562 pMsg->m_dwKeyCode == FWL_VKEY_Space) { | 565 pMsg->m_dwKeyCode == FWL_VKEY_Space) { |
| 563 m_pOwner->NextStates(); | 566 m_pOwner->NextStates(); |
| 564 } | 567 } |
| 565 } | 568 } |
| OLD | NEW |