| 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/lightwidget/cfwl_checkbox.h" | 7 #include "xfa/fwl/lightwidget/cfwl_checkbox.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "xfa/fwl/core/fwl_error.h" | 11 #include "xfa/fwl/core/fwl_error.h" |
| 12 | 12 |
| 13 IFWL_CheckBox* CFWL_CheckBox::GetWidget() { |
| 14 return static_cast<IFWL_CheckBox*>(m_pIface.get()); |
| 15 } |
| 16 |
| 17 const IFWL_CheckBox* CFWL_CheckBox::GetWidget() const { |
| 18 return static_cast<IFWL_CheckBox*>(m_pIface.get()); |
| 19 } |
| 20 |
| 13 CFWL_CheckBox* CFWL_CheckBox::Create() { | 21 CFWL_CheckBox* CFWL_CheckBox::Create() { |
| 14 return new CFWL_CheckBox; | 22 return new CFWL_CheckBox; |
| 15 } | 23 } |
| 16 | 24 |
| 17 FWL_Error CFWL_CheckBox::Initialize(const CFWL_WidgetProperties* pProperties) { | 25 FWL_Error CFWL_CheckBox::Initialize(const CFWL_WidgetProperties* pProperties) { |
| 18 if (m_pIface) | 26 if (m_pIface) |
| 19 return FWL_Error::Indefinite; | 27 return FWL_Error::Indefinite; |
| 20 if (pProperties) { | 28 if (pProperties) { |
| 21 *m_pProperties = *pProperties; | 29 *m_pProperties = *pProperties; |
| 22 } | 30 } |
| 23 std::unique_ptr<IFWL_CheckBox> pCheckBox(IFWL_CheckBox::Create( | 31 std::unique_ptr<IFWL_CheckBox> pCheckBox(IFWL_CheckBox::Create( |
| 24 m_pProperties->MakeWidgetImpProperties(&m_checkboxData), nullptr)); | 32 m_pProperties->MakeWidgetImpProperties(&m_checkboxData), nullptr)); |
| 25 FWL_Error ret = pCheckBox->Initialize(); | 33 FWL_Error ret = pCheckBox->Initialize(); |
| 26 if (ret != FWL_Error::Succeeded) { | 34 if (ret != FWL_Error::Succeeded) { |
| 27 return ret; | 35 return ret; |
| 28 } | 36 } |
| 29 m_pIface = pCheckBox.release(); | 37 m_pIface = std::move(pCheckBox); |
| 30 CFWL_Widget::Initialize(); | 38 CFWL_Widget::Initialize(); |
| 31 return FWL_Error::Succeeded; | 39 return FWL_Error::Succeeded; |
| 32 } | 40 } |
| 33 | 41 |
| 34 FWL_Error CFWL_CheckBox::SetCaption(const CFX_WideStringC& wsCaption) { | 42 FWL_Error CFWL_CheckBox::SetCaption(const CFX_WideStringC& wsCaption) { |
| 35 m_checkboxData.m_wsCaption = wsCaption; | 43 m_checkboxData.m_wsCaption = wsCaption; |
| 36 return FWL_Error::Succeeded; | 44 return FWL_Error::Succeeded; |
| 37 } | 45 } |
| 38 | 46 |
| 39 FWL_Error CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) { | 47 FWL_Error CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) { |
| 40 m_checkboxData.m_fBoxHeight = fHeight; | 48 m_checkboxData.m_fBoxHeight = fHeight; |
| 41 return FWL_Error::Succeeded; | 49 return FWL_Error::Succeeded; |
| 42 } | 50 } |
| 43 | 51 |
| 44 int32_t CFWL_CheckBox::GetCheckState() { | 52 int32_t CFWL_CheckBox::GetCheckState() { |
| 45 return static_cast<IFWL_CheckBox*>(m_pIface)->GetCheckState(); | 53 return GetWidget()->GetCheckState(); |
| 46 } | 54 } |
| 47 | 55 |
| 48 FWL_Error CFWL_CheckBox::SetCheckState(int32_t iCheck) { | 56 FWL_Error CFWL_CheckBox::SetCheckState(int32_t iCheck) { |
| 49 return static_cast<IFWL_CheckBox*>(m_pIface)->SetCheckState(iCheck); | 57 return GetWidget()->SetCheckState(iCheck); |
| 50 } | 58 } |
| 51 | 59 |
| 52 CFWL_CheckBox::CFWL_CheckBox() {} | 60 CFWL_CheckBox::CFWL_CheckBox() {} |
| 53 | 61 |
| 54 CFWL_CheckBox::~CFWL_CheckBox() {} | 62 CFWL_CheckBox::~CFWL_CheckBox() {} |
| 55 | 63 |
| 56 CFWL_CheckBox::CFWL_CheckBoxDP::CFWL_CheckBoxDP() | 64 CFWL_CheckBox::CFWL_CheckBoxDP::CFWL_CheckBoxDP() |
| 57 : m_fBoxHeight(16.0f), m_wsCaption(L"Check box") {} | 65 : m_fBoxHeight(16.0f), m_wsCaption(L"Check box") {} |
| 58 | 66 |
| 59 FWL_Error CFWL_CheckBox::CFWL_CheckBoxDP::GetCaption( | 67 FWL_Error CFWL_CheckBox::CFWL_CheckBoxDP::GetCaption( |
| 60 IFWL_Widget* pWidget, | 68 IFWL_Widget* pWidget, |
| 61 CFX_WideString& wsCaption) { | 69 CFX_WideString& wsCaption) { |
| 62 wsCaption = m_wsCaption; | 70 wsCaption = m_wsCaption; |
| 63 return FWL_Error::Succeeded; | 71 return FWL_Error::Succeeded; |
| 64 } | 72 } |
| 65 | 73 |
| 66 FX_FLOAT CFWL_CheckBox::CFWL_CheckBoxDP::GetBoxSize(IFWL_Widget* pWidget) { | 74 FX_FLOAT CFWL_CheckBox::CFWL_CheckBoxDP::GetBoxSize(IFWL_Widget* pWidget) { |
| 67 return m_fBoxHeight; | 75 return m_fBoxHeight; |
| 68 } | 76 } |
| OLD | NEW |