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

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

Issue 2433133002: Remove IFWL_*::Create methods, use new (Closed)
Patch Set: Created 4 years, 2 months 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
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/ifwl_combobox.h" 7 #include "xfa/fwl/core/ifwl_combobox.h"
8 8
9 #include "third_party/base/ptr_util.h"
9 #include "xfa/fde/cfde_txtedtengine.h" 10 #include "xfa/fde/cfde_txtedtengine.h"
10 #include "xfa/fde/tto/fde_textout.h" 11 #include "xfa/fde/tto/fde_textout.h"
11 #include "xfa/fwl/core/cfwl_message.h" 12 #include "xfa/fwl/core/cfwl_message.h"
12 #include "xfa/fwl/core/cfwl_themebackground.h" 13 #include "xfa/fwl/core/cfwl_themebackground.h"
13 #include "xfa/fwl/core/cfwl_themepart.h" 14 #include "xfa/fwl/core/cfwl_themepart.h"
14 #include "xfa/fwl/core/cfwl_themetext.h" 15 #include "xfa/fwl/core/cfwl_themetext.h"
15 #include "xfa/fwl/core/cfwl_widgetmgr.h" 16 #include "xfa/fwl/core/cfwl_widgetmgr.h"
16 #include "xfa/fwl/core/fwl_noteimp.h" 17 #include "xfa/fwl/core/fwl_noteimp.h"
17 #include "xfa/fwl/core/ifwl_app.h" 18 #include "xfa/fwl/core/ifwl_app.h"
18 #include "xfa/fwl/core/ifwl_comboedit.h" 19 #include "xfa/fwl/core/ifwl_comboedit.h"
19 #include "xfa/fwl/core/ifwl_combolist.h" 20 #include "xfa/fwl/core/ifwl_combolist.h"
20 #include "xfa/fwl/core/ifwl_formproxy.h" 21 #include "xfa/fwl/core/ifwl_formproxy.h"
21 #include "xfa/fwl/core/ifwl_themeprovider.h" 22 #include "xfa/fwl/core/ifwl_themeprovider.h"
22 23
23 // static 24 IFWL_ComboBox::IFWL_ComboBox(const CFWL_WidgetImpProperties& properties)
24 IFWL_ComboBox* IFWL_ComboBox::Create( 25 : IFWL_Widget(properties, nullptr),
25 const CFWL_WidgetImpProperties& properties) {
26 return new IFWL_ComboBox(properties, nullptr);
27 }
28
29 IFWL_ComboBox::IFWL_ComboBox(const CFWL_WidgetImpProperties& properties,
30 IFWL_Widget* pOuter)
31 : IFWL_Widget(properties, pOuter),
32 m_pForm(nullptr), 26 m_pForm(nullptr),
33 m_bLButtonDown(FALSE), 27 m_bLButtonDown(FALSE),
34 m_iCurSel(-1), 28 m_iCurSel(-1),
35 m_iBtnState(CFWL_PartState_Normal), 29 m_iBtnState(CFWL_PartState_Normal),
36 m_fComboFormHandler(0), 30 m_fComboFormHandler(0),
37 m_bNeedShowList(FALSE) { 31 m_bNeedShowList(FALSE) {
38 m_rtClient.Reset(); 32 m_rtClient.Reset();
39 m_rtBtn.Reset(); 33 m_rtBtn.Reset();
40 m_rtHandler.Reset(); 34 m_rtHandler.Reset();
41 } 35 }
(...skipping 17 matching lines...) Expand all
59 return FWL_Error::Indefinite; 53 return FWL_Error::Indefinite;
60 54
61 m_pDelegate = new CFWL_ComboBoxImpDelegate(this); 55 m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
62 CFWL_WidgetImpProperties prop; 56 CFWL_WidgetImpProperties prop;
63 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 57 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
64 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; 58 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
65 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) 59 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText)
66 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon; 60 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon;
67 61
68 prop.m_pDataProvider = m_pProperties->m_pDataProvider; 62 prop.m_pDataProvider = m_pProperties->m_pDataProvider;
69 m_pListBox.reset(IFWL_ComboList::Create(prop, this)); 63 m_pListBox = pdfium::MakeUnique<IFWL_ComboList>(prop, this);
70 m_pListBox->Initialize(); 64 m_pListBox->Initialize();
71 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) { 65 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) {
72 CFWL_WidgetImpProperties prop2; 66 CFWL_WidgetImpProperties prop2;
73 m_pEdit.reset(IFWL_ComboEdit::Create(prop2, this)); 67 m_pEdit = pdfium::MakeUnique<IFWL_ComboEdit>(prop2, this);
74 m_pEdit->Initialize(); 68 m_pEdit->Initialize();
75 m_pEdit->SetOuter(this); 69 m_pEdit->SetOuter(this);
76 } 70 }
77 if (m_pEdit) 71 if (m_pEdit)
78 m_pEdit->SetParent(this); 72 m_pEdit->SetParent(this);
79 73
80 SetStates(m_pProperties->m_dwStates); 74 SetStates(m_pProperties->m_dwStates);
81 return FWL_Error::Succeeded; 75 return FWL_Error::Succeeded;
82 } 76 }
83 77
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 112
119 FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded, 113 FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded,
120 uint32_t dwStylesExRemoved) { 114 uint32_t dwStylesExRemoved) {
121 if (m_pWidgetMgr->IsFormDisabled()) { 115 if (m_pWidgetMgr->IsFormDisabled()) {
122 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 116 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
123 } 117 }
124 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); 118 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
125 bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); 119 bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
126 if (bAddDropDown && !m_pEdit) { 120 if (bAddDropDown && !m_pEdit) {
127 CFWL_WidgetImpProperties prop; 121 CFWL_WidgetImpProperties prop;
128 m_pEdit.reset(IFWL_ComboEdit::Create(prop, nullptr)); 122 m_pEdit = pdfium::MakeUnique<IFWL_ComboEdit>(prop, nullptr);
129 m_pEdit->Initialize(); 123 m_pEdit->Initialize();
130 m_pEdit->SetOuter(this); 124 m_pEdit->SetOuter(this);
131 m_pEdit->SetParent(this); 125 m_pEdit->SetParent(this);
132 } else if (bRemoveDropDown && m_pEdit) { 126 } else if (bRemoveDropDown && m_pEdit) {
133 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE); 127 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE);
134 } 128 }
135 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 129 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
136 } 130 }
137 131
138 FWL_Error IFWL_ComboBox::Update() { 132 FWL_Error IFWL_ComboBox::Update() {
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 void IFWL_ComboBox::InitProxyForm() { 710 void IFWL_ComboBox::InitProxyForm() {
717 if (m_pForm) 711 if (m_pForm)
718 return; 712 return;
719 if (!m_pListBox) 713 if (!m_pListBox)
720 return; 714 return;
721 715
722 CFWL_WidgetImpProperties propForm; 716 CFWL_WidgetImpProperties propForm;
723 propForm.m_pOwner = this; 717 propForm.m_pOwner = this;
724 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; 718 propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
725 propForm.m_dwStates = FWL_WGTSTATE_Invisible; 719 propForm.m_dwStates = FWL_WGTSTATE_Invisible;
726 m_pForm = IFWL_FormProxy::Create(propForm, m_pListBox.get()); 720
721 m_pForm = new IFWL_FormProxy(propForm, m_pListBox.get());
727 m_pForm->Initialize(); 722 m_pForm->Initialize();
728 m_pListBox->SetParent(m_pForm); 723 m_pListBox->SetParent(m_pForm);
729 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this); 724 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this);
730 m_pForm->SetDelegate(m_pListProxyDelegate); 725 m_pForm->SetDelegate(m_pListProxyDelegate);
731 } 726 }
732 727
733 FWL_Error IFWL_ComboBox::DisForm_Initialize() { 728 FWL_Error IFWL_ComboBox::DisForm_Initialize() {
734 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) 729 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
735 return FWL_Error::Indefinite; 730 return FWL_Error::Indefinite;
736 731
737 m_pDelegate = new CFWL_ComboBoxImpDelegate(this); 732 m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
738 DisForm_InitComboList(); 733 DisForm_InitComboList();
739 DisForm_InitComboEdit(); 734 DisForm_InitComboEdit();
740 return FWL_Error::Succeeded; 735 return FWL_Error::Succeeded;
741 } 736 }
742 737
743 void IFWL_ComboBox::DisForm_InitComboList() { 738 void IFWL_ComboBox::DisForm_InitComboList() {
744 if (m_pListBox) 739 if (m_pListBox)
745 return; 740 return;
746 741
747 CFWL_WidgetImpProperties prop; 742 CFWL_WidgetImpProperties prop;
748 prop.m_pParent = this; 743 prop.m_pParent = this;
749 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; 744 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
750 prop.m_dwStates = FWL_WGTSTATE_Invisible; 745 prop.m_dwStates = FWL_WGTSTATE_Invisible;
751 prop.m_pDataProvider = m_pProperties->m_pDataProvider; 746 prop.m_pDataProvider = m_pProperties->m_pDataProvider;
752 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 747 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
753 m_pListBox.reset(IFWL_ComboList::Create(prop, this)); 748 m_pListBox = pdfium::MakeUnique<IFWL_ComboList>(prop, this);
754 m_pListBox->Initialize(); 749 m_pListBox->Initialize();
755 } 750 }
756 751
757 void IFWL_ComboBox::DisForm_InitComboEdit() { 752 void IFWL_ComboBox::DisForm_InitComboEdit() {
758 if (m_pEdit) { 753 if (m_pEdit) {
759 return; 754 return;
760 } 755 }
761 CFWL_WidgetImpProperties prop; 756 CFWL_WidgetImpProperties prop;
762 prop.m_pParent = this; 757 prop.m_pParent = this;
763 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 758 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
764 m_pEdit.reset(IFWL_ComboEdit::Create(prop, this)); 759 m_pEdit = pdfium::MakeUnique<IFWL_ComboEdit>(prop, this);
765 m_pEdit->Initialize(); 760 m_pEdit->Initialize();
766 m_pEdit->SetOuter(this); 761 m_pEdit->SetOuter(this);
767 } 762 }
768 763
769 void IFWL_ComboBox::DisForm_ShowDropList(FX_BOOL bActivate) { 764 void IFWL_ComboBox::DisForm_ShowDropList(FX_BOOL bActivate) {
770 FX_BOOL bDropList = DisForm_IsDropListShowed(); 765 FX_BOOL bDropList = DisForm_IsDropListShowed();
771 if (bDropList == bActivate) { 766 if (bDropList == bActivate) {
772 return; 767 return;
773 } 768 }
774 if (bActivate) { 769 if (bActivate) {
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 } 1430 }
1436 1431
1437 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, 1432 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg,
1438 FX_BOOL bSet) { 1433 FX_BOOL bSet) {
1439 if (!bSet) { 1434 if (!bSet) {
1440 if (!pMsg->m_pSetFocus) { 1435 if (!pMsg->m_pSetFocus) {
1441 m_pComboBox->ShowDropList(FALSE); 1436 m_pComboBox->ShowDropList(FALSE);
1442 } 1437 }
1443 } 1438 }
1444 } 1439 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698