| 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/core/ifwl_checkbox.h" | 7 #include "xfa/fwl/core/ifwl_checkbox.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "third_party/base/ptr_util.h" |
| 11 #include "xfa/fde/tto/fde_textout.h" | 12 #include "xfa/fde/tto/fde_textout.h" |
| 12 #include "xfa/fwl/core/cfwl_message.h" | 13 #include "xfa/fwl/core/cfwl_message.h" |
| 13 #include "xfa/fwl/core/cfwl_themebackground.h" | 14 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 14 #include "xfa/fwl/core/cfwl_themetext.h" | 15 #include "xfa/fwl/core/cfwl_themetext.h" |
| 15 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 16 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
| 16 #include "xfa/fwl/core/ifwl_app.h" | 17 #include "xfa/fwl/core/ifwl_app.h" |
| 17 #include "xfa/fwl/core/fwl_noteimp.h" | 18 #include "xfa/fwl/core/fwl_noteimp.h" |
| 18 #include "xfa/fwl/core/ifwl_checkbox.h" | 19 #include "xfa/fwl/core/ifwl_checkbox.h" |
| 19 #include "xfa/fwl/core/ifwl_themeprovider.h" | 20 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const int kCaptionMargin = 5; | 24 const int kCaptionMargin = 5; |
| 24 | 25 |
| 25 } // namespace | 26 } // namespace |
| 26 | 27 |
| 27 IFWL_CheckBox::IFWL_CheckBox(const IFWL_App* app, | 28 IFWL_CheckBox::IFWL_CheckBox(const IFWL_App* app, |
| 28 const CFWL_WidgetImpProperties& properties) | 29 const CFWL_WidgetImpProperties& properties) |
| 29 : IFWL_Widget(app, properties, nullptr), | 30 : IFWL_Widget(app, properties, nullptr), |
| 30 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), | 31 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), |
| 31 m_iTTOAlign(FDE_TTOALIGNMENT_Center), | 32 m_iTTOAlign(FDE_TTOALIGNMENT_Center), |
| 32 m_bBtnDown(FALSE) { | 33 m_bBtnDown(FALSE) { |
| 33 m_rtClient.Reset(); | 34 m_rtClient.Reset(); |
| 34 m_rtBox.Reset(); | 35 m_rtBox.Reset(); |
| 35 m_rtCaption.Reset(); | 36 m_rtCaption.Reset(); |
| 36 m_rtFocus.Reset(); | 37 m_rtFocus.Reset(); |
| 38 |
| 39 SetDelegate(pdfium::MakeUnique<CFWL_CheckBoxImpDelegate>(this)); |
| 37 } | 40 } |
| 38 | 41 |
| 39 IFWL_CheckBox::~IFWL_CheckBox() {} | 42 IFWL_CheckBox::~IFWL_CheckBox() {} |
| 40 | 43 |
| 41 void IFWL_CheckBox::Initialize() { | |
| 42 IFWL_Widget::Initialize(); | |
| 43 m_pDelegate = new CFWL_CheckBoxImpDelegate(this); | |
| 44 } | |
| 45 | |
| 46 void IFWL_CheckBox::Finalize() { | |
| 47 delete m_pDelegate; | |
| 48 m_pDelegate = nullptr; | |
| 49 IFWL_Widget::Finalize(); | |
| 50 } | |
| 51 | |
| 52 FWL_Type IFWL_CheckBox::GetClassID() const { | 44 FWL_Type IFWL_CheckBox::GetClassID() const { |
| 53 return FWL_Type::CheckBox; | 45 return FWL_Type::CheckBox; |
| 54 } | 46 } |
| 55 | 47 |
| 56 FWL_Error IFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 48 FWL_Error IFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 57 if (bAutoSize) { | 49 if (bAutoSize) { |
| 58 rect.Set(0, 0, 0, 0); | 50 rect.Set(0, 0, 0, 0); |
| 59 if (!m_pProperties->m_pThemeProvider) | 51 if (!m_pProperties->m_pThemeProvider) |
| 60 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 52 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 61 if (!m_pProperties->m_pThemeProvider) | 53 if (!m_pProperties->m_pThemeProvider) |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { | 544 void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { |
| 553 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { | 545 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { |
| 554 m_pOwner->DispatchKeyEvent(pMsg); | 546 m_pOwner->DispatchKeyEvent(pMsg); |
| 555 return; | 547 return; |
| 556 } | 548 } |
| 557 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || | 549 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || |
| 558 pMsg->m_dwKeyCode == FWL_VKEY_Space) { | 550 pMsg->m_dwKeyCode == FWL_VKEY_Space) { |
| 559 m_pOwner->NextStates(); | 551 m_pOwner->NextStates(); |
| 560 } | 552 } |
| 561 } | 553 } |
| OLD | NEW |