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/cfwl_combobox.h" | 7 #include "xfa/fwl/core/cfwl_combobox.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
| 11 #include "third_party/base/ptr_util.h" |
11 #include "xfa/fwl/core/fwl_error.h" | 12 #include "xfa/fwl/core/fwl_error.h" |
12 #include "xfa/fwl/core/ifwl_widget.h" | 13 #include "xfa/fwl/core/ifwl_widget.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 IFWL_ComboBox* ToComboBox(IFWL_Widget* widget) { | 17 IFWL_ComboBox* ToComboBox(IFWL_Widget* widget) { |
17 return static_cast<IFWL_ComboBox*>(widget); | 18 return static_cast<IFWL_ComboBox*>(widget); |
18 } | 19 } |
19 | 20 |
20 const IFWL_ComboBox* ToComboBox(const IFWL_Widget* widget) { | 21 const IFWL_ComboBox* ToComboBox(const IFWL_Widget* widget) { |
21 return static_cast<const IFWL_ComboBox*>(widget); | 22 return static_cast<const IFWL_ComboBox*>(widget); |
22 } | 23 } |
23 | 24 |
24 } // namespace | 25 } // namespace |
25 | 26 |
26 CFWL_ComboBox::CFWL_ComboBox(const IFWL_App* app) : CFWL_Widget(app) {} | 27 CFWL_ComboBox::CFWL_ComboBox(const IFWL_App* app) : CFWL_Widget(app) {} |
27 | 28 |
28 CFWL_ComboBox::~CFWL_ComboBox() {} | 29 CFWL_ComboBox::~CFWL_ComboBox() {} |
29 | 30 |
30 void CFWL_ComboBox::Initialize() { | 31 void CFWL_ComboBox::Initialize() { |
31 ASSERT(!m_pIface); | 32 ASSERT(!m_pIface); |
32 | 33 |
33 std::unique_ptr<IFWL_ComboBox> pComboBox(new IFWL_ComboBox( | 34 m_pIface = pdfium::MakeUnique<IFWL_ComboBox>( |
34 m_pApp, m_pProperties->MakeWidgetImpProperties(&m_comboBoxData))); | 35 m_pApp, m_pProperties->MakeWidgetImpProperties(&m_comboBoxData)); |
35 pComboBox->Initialize(); | |
36 | 36 |
37 m_pIface = std::move(pComboBox); | |
38 CFWL_Widget::Initialize(); | 37 CFWL_Widget::Initialize(); |
39 } | 38 } |
40 | 39 |
41 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { | 40 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { |
42 std::unique_ptr<CFWL_ComboBoxItem> pItem(new CFWL_ComboBoxItem); | 41 std::unique_ptr<CFWL_ComboBoxItem> pItem(new CFWL_ComboBoxItem); |
43 pItem->m_wsText = wsText; | 42 pItem->m_wsText = wsText; |
44 pItem->m_dwStyles = 0; | 43 pItem->m_dwStyles = 0; |
45 m_comboBoxData.m_ItemArray.push_back(std::move(pItem)); | 44 m_comboBoxData.m_ItemArray.push_back(std::move(pItem)); |
46 return m_comboBoxData.m_ItemArray.size() - 1; | 45 return m_comboBoxData.m_ItemArray.size() - 1; |
47 } | 46 } |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 return FWL_Error::Succeeded; | 381 return FWL_Error::Succeeded; |
383 } | 382 } |
384 | 383 |
385 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { | 384 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { |
386 return m_fMaxListHeight; | 385 return m_fMaxListHeight; |
387 } | 386 } |
388 | 387 |
389 CFWL_ComboBoxItem::CFWL_ComboBoxItem() : m_pDIB(nullptr), m_pData(nullptr) {} | 388 CFWL_ComboBoxItem::CFWL_ComboBoxItem() : m_pDIB(nullptr), m_pData(nullptr) {} |
390 | 389 |
391 CFWL_ComboBoxItem::~CFWL_ComboBoxItem() {} | 390 CFWL_ComboBoxItem::~CFWL_ComboBoxItem() {} |
OLD | NEW |