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_listbox.h" | 7 #include "xfa/fwl/core/cfwl_listbox.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "third_party/base/stl_util.h" | 11 #include "third_party/base/stl_util.h" |
12 | 12 |
| 13 CFWL_ListBox::CFWL_ListBox(const IFWL_App* app) : CFWL_Widget(app) {} |
| 14 |
| 15 CFWL_ListBox::~CFWL_ListBox() {} |
| 16 |
| 17 void CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) { |
| 18 ASSERT(!m_pIface); |
| 19 |
| 20 if (pProperties) |
| 21 *m_pProperties = *pProperties; |
| 22 |
| 23 std::unique_ptr<IFWL_ListBox> pListBox(new IFWL_ListBox( |
| 24 m_pApp, m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP), nullptr)); |
| 25 pListBox->Initialize(); |
| 26 |
| 27 m_pIface = std::move(pListBox); |
| 28 CFWL_Widget::Initialize(pProperties); |
| 29 } |
| 30 |
13 IFWL_ListBox* CFWL_ListBox::GetWidget() { | 31 IFWL_ListBox* CFWL_ListBox::GetWidget() { |
14 return static_cast<IFWL_ListBox*>(m_pIface.get()); | 32 return static_cast<IFWL_ListBox*>(m_pIface.get()); |
15 } | 33 } |
16 | 34 |
17 const IFWL_ListBox* CFWL_ListBox::GetWidget() const { | 35 const IFWL_ListBox* CFWL_ListBox::GetWidget() const { |
18 return static_cast<IFWL_ListBox*>(m_pIface.get()); | 36 return static_cast<IFWL_ListBox*>(m_pIface.get()); |
19 } | 37 } |
20 | 38 |
21 FWL_Error CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) { | |
22 if (m_pIface) | |
23 return FWL_Error::Indefinite; | |
24 if (pProperties) { | |
25 *m_pProperties = *pProperties; | |
26 } | |
27 std::unique_ptr<IFWL_ListBox> pListBox(new IFWL_ListBox( | |
28 m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP), nullptr)); | |
29 FWL_Error ret = pListBox->Initialize(); | |
30 if (ret != FWL_Error::Succeeded) { | |
31 return ret; | |
32 } | |
33 m_pIface = std::move(pListBox); | |
34 CFWL_Widget::Initialize(); | |
35 return FWL_Error::Succeeded; | |
36 } | |
37 | |
38 FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem) { | 39 FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem) { |
39 static_cast<CFWL_ListItem*>(pItem)->m_pDIB = pDIB; | 40 static_cast<CFWL_ListItem*>(pItem)->m_pDIB = pDIB; |
40 return FWL_Error::Succeeded; | 41 return FWL_Error::Succeeded; |
41 } | 42 } |
42 | 43 |
43 IFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, | 44 IFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, |
44 FX_BOOL bSelect) { | 45 FX_BOOL bSelect) { |
45 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); | 46 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); |
46 pItem->m_dwStates = 0; | 47 pItem->m_dwStates = 0; |
47 pItem->m_wsText = wsAdd; | 48 pItem->m_wsText = wsAdd; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 return nullptr; | 197 return nullptr; |
197 } | 198 } |
198 | 199 |
199 uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* pItem) { | 200 uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* pItem) { |
200 if (!pItem) | 201 if (!pItem) |
201 return 0; | 202 return 0; |
202 CFWL_ListItem* pListItem = static_cast<CFWL_ListItem*>(pItem); | 203 CFWL_ListItem* pListItem = static_cast<CFWL_ListItem*>(pItem); |
203 return pListItem->m_dwStates | pListItem->m_dwCheckState; | 204 return pListItem->m_dwStates | pListItem->m_dwCheckState; |
204 } | 205 } |
205 | 206 |
206 CFWL_ListBox::CFWL_ListBox() {} | |
207 | |
208 CFWL_ListBox::~CFWL_ListBox() {} | |
209 | |
210 CFWL_ListBox::CFWL_ListBoxDP::CFWL_ListBoxDP() {} | 207 CFWL_ListBox::CFWL_ListBoxDP::CFWL_ListBoxDP() {} |
211 | 208 |
212 CFWL_ListBox::CFWL_ListBoxDP::~CFWL_ListBoxDP() {} | 209 CFWL_ListBox::CFWL_ListBoxDP::~CFWL_ListBoxDP() {} |
213 | 210 |
214 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetCaption(IFWL_Widget* pWidget, | 211 FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetCaption(IFWL_Widget* pWidget, |
215 CFX_WideString& wsCaption) { | 212 CFX_WideString& wsCaption) { |
216 wsCaption = m_wsData; | 213 wsCaption = m_wsData; |
217 return FWL_Error::Succeeded; | 214 return FWL_Error::Succeeded; |
218 } | 215 } |
219 | 216 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 m_rtItem.Reset(); | 343 m_rtItem.Reset(); |
347 m_dwStates = 0; | 344 m_dwStates = 0; |
348 m_wsText = L""; | 345 m_wsText = L""; |
349 m_pDIB = nullptr; | 346 m_pDIB = nullptr; |
350 m_pData = nullptr; | 347 m_pData = nullptr; |
351 m_dwCheckState = 0; | 348 m_dwCheckState = 0; |
352 m_rtCheckBox.Reset(); | 349 m_rtCheckBox.Reset(); |
353 } | 350 } |
354 | 351 |
355 CFWL_ListItem::~CFWL_ListItem() {} | 352 CFWL_ListItem::~CFWL_ListItem() {} |
OLD | NEW |