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 "xfa/fde/tto/fde_textout.h" | 11 #include "xfa/fde/tto/fde_textout.h" |
12 #include "xfa/fwl/core/cfwl_message.h" | 12 #include "xfa/fwl/core/cfwl_message.h" |
13 #include "xfa/fwl/core/cfwl_themebackground.h" | 13 #include "xfa/fwl/core/cfwl_themebackground.h" |
14 #include "xfa/fwl/core/cfwl_themetext.h" | 14 #include "xfa/fwl/core/cfwl_themetext.h" |
15 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 15 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
| 16 #include "xfa/fwl/core/ifwl_app.h" |
16 #include "xfa/fwl/core/fwl_noteimp.h" | 17 #include "xfa/fwl/core/fwl_noteimp.h" |
17 #include "xfa/fwl/core/ifwl_checkbox.h" | 18 #include "xfa/fwl/core/ifwl_checkbox.h" |
18 #include "xfa/fwl/core/ifwl_themeprovider.h" | 19 #include "xfa/fwl/core/ifwl_themeprovider.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 const int kCaptionMargin = 5; | 23 const int kCaptionMargin = 5; |
23 | 24 |
24 } // namespace | 25 } // namespace |
25 | 26 |
26 IFWL_CheckBox::IFWL_CheckBox(const CFWL_WidgetImpProperties& properties) | 27 IFWL_CheckBox::IFWL_CheckBox(const IFWL_App* app, |
27 : IFWL_Widget(properties, nullptr), | 28 const CFWL_WidgetImpProperties& properties) |
| 29 : IFWL_Widget(app, properties, nullptr), |
28 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), | 30 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), |
29 m_iTTOAlign(FDE_TTOALIGNMENT_Center), | 31 m_iTTOAlign(FDE_TTOALIGNMENT_Center), |
30 m_bBtnDown(FALSE) { | 32 m_bBtnDown(FALSE) { |
31 m_rtClient.Reset(); | 33 m_rtClient.Reset(); |
32 m_rtBox.Reset(); | 34 m_rtBox.Reset(); |
33 m_rtCaption.Reset(); | 35 m_rtCaption.Reset(); |
34 m_rtFocus.Reset(); | 36 m_rtFocus.Reset(); |
35 } | 37 } |
36 | 38 |
37 IFWL_CheckBox::~IFWL_CheckBox() {} | 39 IFWL_CheckBox::~IFWL_CheckBox() {} |
38 | 40 |
39 FWL_Type IFWL_CheckBox::GetClassID() const { | 41 void IFWL_CheckBox::Initialize() { |
40 return FWL_Type::CheckBox; | 42 IFWL_Widget::Initialize(); |
41 } | |
42 | |
43 FWL_Error IFWL_CheckBox::Initialize() { | |
44 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) | |
45 return FWL_Error::Indefinite; | |
46 | |
47 m_pDelegate = new CFWL_CheckBoxImpDelegate(this); | 43 m_pDelegate = new CFWL_CheckBoxImpDelegate(this); |
48 return FWL_Error::Succeeded; | |
49 } | 44 } |
50 | 45 |
51 void IFWL_CheckBox::Finalize() { | 46 void IFWL_CheckBox::Finalize() { |
52 delete m_pDelegate; | 47 delete m_pDelegate; |
53 m_pDelegate = nullptr; | 48 m_pDelegate = nullptr; |
54 IFWL_Widget::Finalize(); | 49 IFWL_Widget::Finalize(); |
55 } | 50 } |
56 | 51 |
| 52 FWL_Type IFWL_CheckBox::GetClassID() const { |
| 53 return FWL_Type::CheckBox; |
| 54 } |
| 55 |
57 FWL_Error IFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 56 FWL_Error IFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
58 if (bAutoSize) { | 57 if (bAutoSize) { |
59 rect.Set(0, 0, 0, 0); | 58 rect.Set(0, 0, 0, 0); |
60 if (!m_pProperties->m_pThemeProvider) | 59 if (!m_pProperties->m_pThemeProvider) |
61 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 60 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
62 if (!m_pProperties->m_pThemeProvider) | 61 if (!m_pProperties->m_pThemeProvider) |
63 return FWL_Error::Indefinite; | 62 return FWL_Error::Indefinite; |
64 if (!m_pProperties->m_pDataProvider) | 63 if (!m_pProperties->m_pDataProvider) |
65 return FWL_Error::Indefinite; | 64 return FWL_Error::Indefinite; |
66 CFX_WideString wsCaption; | 65 CFX_WideString wsCaption; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } else { | 345 } else { |
347 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; | 346 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; |
348 } | 347 } |
349 } | 348 } |
350 | 349 |
351 void IFWL_CheckBox::NextStates() { | 350 void IFWL_CheckBox::NextStates() { |
352 uint32_t dwFirststate = m_pProperties->m_dwStates; | 351 uint32_t dwFirststate = m_pProperties->m_dwStates; |
353 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { | 352 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) { |
354 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == | 353 if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == |
355 FWL_STATE_CKB_Unchecked) { | 354 FWL_STATE_CKB_Unchecked) { |
356 CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance(); | 355 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
357 if (!pWidgetMgr->IsFormDisabled()) { | 356 if (!pWidgetMgr->IsFormDisabled()) { |
358 CFX_ArrayTemplate<IFWL_Widget*> radioarr; | 357 CFX_ArrayTemplate<IFWL_Widget*> radioarr; |
359 pWidgetMgr->GetSameGroupRadioButton(this, radioarr); | 358 pWidgetMgr->GetSameGroupRadioButton(this, radioarr); |
360 IFWL_CheckBox* pCheckBox = nullptr; | 359 IFWL_CheckBox* pCheckBox = nullptr; |
361 int32_t iCount = radioarr.GetSize(); | 360 int32_t iCount = radioarr.GetSize(); |
362 for (int32_t i = 0; i < iCount; i++) { | 361 for (int32_t i = 0; i < iCount; i++) { |
363 pCheckBox = static_cast<IFWL_CheckBox*>(radioarr[i]); | 362 pCheckBox = static_cast<IFWL_CheckBox*>(radioarr[i]); |
364 if (pCheckBox != this && | 363 if (pCheckBox != this && |
365 pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { | 364 pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { |
366 pCheckBox->SetCheckState(0); | 365 pCheckBox->SetCheckState(0); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { | 552 void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { |
554 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { | 553 if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) { |
555 m_pOwner->DispatchKeyEvent(pMsg); | 554 m_pOwner->DispatchKeyEvent(pMsg); |
556 return; | 555 return; |
557 } | 556 } |
558 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || | 557 if (pMsg->m_dwKeyCode == FWL_VKEY_Return || |
559 pMsg->m_dwKeyCode == FWL_VKEY_Space) { | 558 pMsg->m_dwKeyCode == FWL_VKEY_Space) { |
560 m_pOwner->NextStates(); | 559 m_pOwner->NextStates(); |
561 } | 560 } |
562 } | 561 } |
OLD | NEW |