Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(711)

Side by Side Diff: xfa/fwl/core/cfwl_combobox.cpp

Issue 2436103002: Remove FWL globals. (Closed)
Patch Set: Review feedback Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/core/cfwl_combobox.h ('k') | xfa/fwl/core/cfwl_datetimepicker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "xfa/fwl/core/fwl_error.h" 11 #include "xfa/fwl/core/fwl_error.h"
12 #include "xfa/fwl/core/ifwl_widget.h" 12 #include "xfa/fwl/core/ifwl_widget.h"
13 13
14 CFWL_ComboBox::CFWL_ComboBox(const IFWL_App* app) : CFWL_Widget(app) {}
15
16 CFWL_ComboBox::~CFWL_ComboBox() {}
17
18 void CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) {
19 ASSERT(!m_pIface);
20
21 if (pProperties)
22 *m_pProperties = *pProperties;
23
24 std::unique_ptr<IFWL_ComboBox> pComboBox(new IFWL_ComboBox(
25 m_pApp, m_pProperties->MakeWidgetImpProperties(&m_comboBoxData)));
26 pComboBox->Initialize();
27
28 m_pIface = std::move(pComboBox);
29 CFWL_Widget::Initialize(pProperties);
30 }
31
14 IFWL_ComboBox* CFWL_ComboBox::GetWidget() { 32 IFWL_ComboBox* CFWL_ComboBox::GetWidget() {
15 return static_cast<IFWL_ComboBox*>(m_pIface.get()); 33 return static_cast<IFWL_ComboBox*>(m_pIface.get());
16 } 34 }
17 35
18 const IFWL_ComboBox* CFWL_ComboBox::GetWidget() const { 36 const IFWL_ComboBox* CFWL_ComboBox::GetWidget() const {
19 return static_cast<IFWL_ComboBox*>(m_pIface.get()); 37 return static_cast<IFWL_ComboBox*>(m_pIface.get());
20 } 38 }
21 39
22 FWL_Error CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) {
23 if (m_pIface)
24 return FWL_Error::Indefinite;
25 if (pProperties) {
26 *m_pProperties = *pProperties;
27 }
28 std::unique_ptr<IFWL_ComboBox> pComboBox(new IFWL_ComboBox(
29 m_pProperties->MakeWidgetImpProperties(&m_comboBoxData)));
30 FWL_Error ret = pComboBox->Initialize();
31 if (ret != FWL_Error::Succeeded) {
32 return ret;
33 }
34 m_pIface = std::move(pComboBox);
35 CFWL_Widget::Initialize();
36 return FWL_Error::Succeeded;
37 }
38
39 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { 40 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) {
40 std::unique_ptr<CFWL_ComboBoxItem> pItem(new CFWL_ComboBoxItem); 41 std::unique_ptr<CFWL_ComboBoxItem> pItem(new CFWL_ComboBoxItem);
41 pItem->m_wsText = wsText; 42 pItem->m_wsText = wsText;
42 pItem->m_dwStyles = 0; 43 pItem->m_dwStyles = 0;
43 m_comboBoxData.m_ItemArray.push_back(std::move(pItem)); 44 m_comboBoxData.m_ItemArray.push_back(std::move(pItem));
44 return m_comboBoxData.m_ItemArray.size() - 1; 45 return m_comboBoxData.m_ItemArray.size() - 1;
45 } 46 }
46 47
47 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText, 48 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText,
48 CFX_DIBitmap* pIcon) { 49 CFX_DIBitmap* pIcon) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 225 }
225 226
226 FWL_Error CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, 227 FWL_Error CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
227 uint32_t dwStylesExRemoved) { 228 uint32_t dwStylesExRemoved) {
228 return GetWidget() 229 return GetWidget()
229 ? GetWidget()->EditModifyStylesEx(dwStylesExAdded, 230 ? GetWidget()->EditModifyStylesEx(dwStylesExAdded,
230 dwStylesExRemoved) 231 dwStylesExRemoved)
231 : FWL_Error::Indefinite; 232 : FWL_Error::Indefinite;
232 } 233 }
233 234
234 CFWL_ComboBox::CFWL_ComboBox() {}
235
236 CFWL_ComboBox::~CFWL_ComboBox() {}
237
238 CFWL_ComboBox::CFWL_ComboBoxDP::CFWL_ComboBoxDP() { 235 CFWL_ComboBox::CFWL_ComboBoxDP::CFWL_ComboBoxDP() {
239 m_fItemHeight = 0; 236 m_fItemHeight = 0;
240 m_fMaxListHeight = 0; 237 m_fMaxListHeight = 0;
241 } 238 }
242 239
243 CFWL_ComboBox::CFWL_ComboBoxDP::~CFWL_ComboBoxDP() {} 240 CFWL_ComboBox::CFWL_ComboBoxDP::~CFWL_ComboBoxDP() {}
244 241
245 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetCaption( 242 FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetCaption(
246 IFWL_Widget* pWidget, 243 IFWL_Widget* pWidget,
247 CFX_WideString& wsCaption) { 244 CFX_WideString& wsCaption) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 return FWL_Error::Succeeded; 376 return FWL_Error::Succeeded;
380 } 377 }
381 378
382 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { 379 FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) {
383 return m_fMaxListHeight; 380 return m_fMaxListHeight;
384 } 381 }
385 382
386 CFWL_ComboBoxItem::CFWL_ComboBoxItem() : m_pDIB(nullptr), m_pData(nullptr) {} 383 CFWL_ComboBoxItem::CFWL_ComboBoxItem() : m_pDIB(nullptr), m_pData(nullptr) {}
387 384
388 CFWL_ComboBoxItem::~CFWL_ComboBoxItem() {} 385 CFWL_ComboBoxItem::~CFWL_ComboBoxItem() {}
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_combobox.h ('k') | xfa/fwl/core/cfwl_datetimepicker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698