| 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_barcode.h" | 7 #include "xfa/fwl/core/ifwl_barcode.h" |
| 8 | 8 |
| 9 #include "third_party/base/ptr_util.h" |
| 9 #include "xfa/fgas/font/fgas_gefont.h" | 10 #include "xfa/fgas/font/fgas_gefont.h" |
| 10 #include "xfa/fwl/core/cfwl_themepart.h" | 11 #include "xfa/fwl/core/cfwl_themepart.h" |
| 11 #include "xfa/fwl/core/cfx_barcode.h" | 12 #include "xfa/fwl/core/cfx_barcode.h" |
| 12 #include "xfa/fwl/core/fwl_noteimp.h" | 13 #include "xfa/fwl/core/fwl_noteimp.h" |
| 13 #include "xfa/fwl/core/ifwl_themeprovider.h" | 14 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 14 | 15 |
| 15 IFWL_Barcode::IFWL_Barcode(const IFWL_App* app, | 16 IFWL_Barcode::IFWL_Barcode(const IFWL_App* app, |
| 16 const CFWL_WidgetImpProperties& properties) | 17 const CFWL_WidgetImpProperties& properties) |
| 17 : IFWL_Edit(app, properties, nullptr), m_dwStatus(0), m_type(BC_UNKNOWN) {} | 18 : IFWL_Edit(app, properties, nullptr), m_dwStatus(0), m_type(BC_UNKNOWN) { |
| 19 SetDelegate(pdfium::MakeUnique<CFWL_BarcodeImpDelegate>(this)); |
| 20 } |
| 18 | 21 |
| 19 IFWL_Barcode::~IFWL_Barcode() {} | 22 IFWL_Barcode::~IFWL_Barcode() { |
| 23 m_pBarcodeEngine.reset(); |
| 24 } |
| 20 | 25 |
| 21 FWL_Type IFWL_Barcode::GetClassID() const { | 26 FWL_Type IFWL_Barcode::GetClassID() const { |
| 22 return FWL_Type::Barcode; | 27 return FWL_Type::Barcode; |
| 23 } | 28 } |
| 24 | 29 |
| 25 void IFWL_Barcode::Initialize() { | |
| 26 if (!m_pDelegate) | |
| 27 m_pDelegate = new CFWL_BarcodeImpDelegate(this); | |
| 28 | |
| 29 IFWL_Edit::Initialize(); | |
| 30 } | |
| 31 | |
| 32 void IFWL_Barcode::Finalize() { | |
| 33 delete m_pDelegate; | |
| 34 m_pDelegate = nullptr; | |
| 35 m_pBarcodeEngine.reset(); | |
| 36 IFWL_Edit::Finalize(); | |
| 37 } | |
| 38 | |
| 39 FWL_Error IFWL_Barcode::Update() { | 30 FWL_Error IFWL_Barcode::Update() { |
| 40 if (IsLocked()) { | 31 if (IsLocked()) { |
| 41 return FWL_Error::Indefinite; | 32 return FWL_Error::Indefinite; |
| 42 } | 33 } |
| 43 FWL_Error ret = IFWL_Edit::Update(); | 34 FWL_Error ret = IFWL_Edit::Update(); |
| 44 GenerateBarcodeImageCache(); | 35 GenerateBarcodeImageCache(); |
| 45 return ret; | 36 return ret; |
| 46 } | 37 } |
| 47 | 38 |
| 48 FWL_Error IFWL_Barcode::DrawWidget(CFX_Graphics* pGraphics, | 39 FWL_Error IFWL_Barcode::DrawWidget(CFX_Graphics* pGraphics, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 : CFWL_EditImpDelegate(pOwner) {} | 181 : CFWL_EditImpDelegate(pOwner) {} |
| 191 | 182 |
| 192 void CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 183 void CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
| 193 if (pEvent->GetClassID() == CFWL_EventType::TextChanged) { | 184 if (pEvent->GetClassID() == CFWL_EventType::TextChanged) { |
| 194 IFWL_Barcode* pOwner = static_cast<IFWL_Barcode*>(m_pOwner); | 185 IFWL_Barcode* pOwner = static_cast<IFWL_Barcode*>(m_pOwner); |
| 195 pOwner->m_pBarcodeEngine.reset(); | 186 pOwner->m_pBarcodeEngine.reset(); |
| 196 pOwner->m_dwStatus = XFA_BCS_NeedUpdate; | 187 pOwner->m_dwStatus = XFA_BCS_NeedUpdate; |
| 197 } | 188 } |
| 198 CFWL_EditImpDelegate::OnProcessEvent(pEvent); | 189 CFWL_EditImpDelegate::OnProcessEvent(pEvent); |
| 199 } | 190 } |
| OLD | NEW |