| 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 "third_party/base/ptr_util.h" |
| 12 #include "xfa/fwl/core/fwl_error.h" | 12 #include "xfa/fwl/core/fwl_error.h" |
| 13 #include "xfa/fwl/core/ifwl_combobox.h" | 13 #include "xfa/fwl/core/ifwl_combobox.h" |
| 14 #include "xfa/fwl/core/ifwl_widget.h" | 14 #include "xfa/fwl/core/ifwl_widget.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 IFWL_ComboBox* ToComboBox(IFWL_Widget* widget) { | 18 IFWL_ComboBox* ToComboBox(IFWL_Widget* widget) { |
| 19 return static_cast<IFWL_ComboBox*>(widget); | 19 return static_cast<IFWL_ComboBox*>(widget); |
| 20 } | 20 } |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 CFWL_ComboBox::CFWL_ComboBox(const CFWL_App* app) | 24 CFWL_ComboBox::CFWL_ComboBox(const CFWL_App* app) : CFWL_Widget(app) {} |
| 25 : CFWL_Widget(app), m_fMaxListHeight(0) {} | |
| 26 | 25 |
| 27 CFWL_ComboBox::~CFWL_ComboBox() {} | 26 CFWL_ComboBox::~CFWL_ComboBox() {} |
| 28 | 27 |
| 29 void CFWL_ComboBox::Initialize() { | 28 void CFWL_ComboBox::Initialize() { |
| 30 ASSERT(!m_pIface); | 29 ASSERT(!m_pIface); |
| 31 | 30 |
| 32 m_pIface = pdfium::MakeUnique<IFWL_ComboBox>( | 31 m_pIface = pdfium::MakeUnique<IFWL_ComboBox>( |
| 33 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(this)); | 32 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(this)); |
| 34 | 33 |
| 35 CFWL_Widget::Initialize(); | 34 CFWL_Widget::Initialize(); |
| 36 } | 35 } |
| 37 | 36 |
| 38 void CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { | 37 void CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { |
| 39 if (GetWidget()) | 38 if (GetWidget()) |
| 40 ToComboBox(GetWidget())->AddString(wsText); | 39 ToComboBox(GetWidget())->AddString(wsText); |
| 41 } | 40 } |
| 42 | 41 |
| 43 bool CFWL_ComboBox::RemoveAt(int32_t iIndex) { | 42 bool CFWL_ComboBox::RemoveAt(int32_t iIndex) { |
| 44 return GetWidget() && ToComboBox(GetWidget())->RemoveAt(iIndex); | 43 return GetWidget() && ToComboBox(GetWidget())->RemoveAt(iIndex); |
| 45 } | 44 } |
| 46 | 45 |
| 47 void CFWL_ComboBox::RemoveAll() { | 46 void CFWL_ComboBox::RemoveAll() { |
| 48 if (GetWidget()) | 47 if (GetWidget()) |
| 49 ToComboBox(GetWidget())->RemoveAll(); | 48 ToComboBox(GetWidget())->RemoveAll(); |
| 50 } | 49 } |
| 51 | 50 |
| 52 FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) { | |
| 53 return m_fMaxListHeight; | |
| 54 } | |
| 55 | |
| 56 void CFWL_ComboBox::GetTextByIndex(int32_t iIndex, | 51 void CFWL_ComboBox::GetTextByIndex(int32_t iIndex, |
| 57 CFX_WideString& wsText) const { | 52 CFX_WideString& wsText) const { |
| 58 if (!GetWidget()) | 53 if (!GetWidget()) |
| 59 return; | 54 return; |
| 60 ToComboBox(GetWidget())->GetTextByIndex(iIndex, wsText); | 55 ToComboBox(GetWidget())->GetTextByIndex(iIndex, wsText); |
| 61 } | 56 } |
| 62 | 57 |
| 63 int32_t CFWL_ComboBox::GetCurSel() const { | 58 int32_t CFWL_ComboBox::GetCurSel() const { |
| 64 return GetWidget() ? ToComboBox(GetWidget())->GetCurSel() : -1; | 59 return GetWidget() ? ToComboBox(GetWidget())->GetCurSel() : -1; |
| 65 } | 60 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 ToComboBox(GetWidget())->GetBBox(rect); | 140 ToComboBox(GetWidget())->GetBBox(rect); |
| 146 } | 141 } |
| 147 | 142 |
| 148 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, | 143 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, |
| 149 uint32_t dwStylesExRemoved) { | 144 uint32_t dwStylesExRemoved) { |
| 150 if (GetWidget()) { | 145 if (GetWidget()) { |
| 151 ToComboBox(GetWidget()) | 146 ToComboBox(GetWidget()) |
| 152 ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 147 ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 153 } | 148 } |
| 154 } | 149 } |
| OLD | NEW |