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

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

Issue 2464703006: Fold IFWL*::{Initialize|Finalize} into constructor/destructor (Closed)
Patch Set: Rebase to master 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/ifwl_combobox.h ('k') | xfa/fwl/core/ifwl_combolist.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/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 IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app, 24 IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app,
24 const CFWL_WidgetImpProperties& properties) 25 const CFWL_WidgetImpProperties& properties)
25 : IFWL_Widget(app, properties, nullptr), 26 : IFWL_Widget(app, properties, nullptr),
26 m_pForm(nullptr), 27 m_pForm(nullptr),
27 m_bLButtonDown(FALSE), 28 m_bLButtonDown(FALSE),
28 m_iCurSel(-1), 29 m_iCurSel(-1),
29 m_iBtnState(CFWL_PartState_Normal), 30 m_iBtnState(CFWL_PartState_Normal),
30 m_fComboFormHandler(0), 31 m_fComboFormHandler(0),
31 m_bNeedShowList(FALSE) { 32 m_bNeedShowList(FALSE) {
32 m_rtClient.Reset(); 33 m_rtClient.Reset();
33 m_rtBtn.Reset(); 34 m_rtBtn.Reset();
34 m_rtHandler.Reset(); 35 m_rtHandler.Reset();
35 }
36 36
37 IFWL_ComboBox::~IFWL_ComboBox() {} 37 SetDelegate(pdfium::MakeUnique<CFWL_ComboBoxImpDelegate>(this));
38
39 void IFWL_ComboBox::Initialize() {
40 IFWL_Widget::Initialize();
41 m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
42 38
43 if (m_pWidgetMgr->IsFormDisabled()) { 39 if (m_pWidgetMgr->IsFormDisabled()) {
44 DisForm_InitComboList(); 40 DisForm_InitComboList();
45 DisForm_InitComboEdit(); 41 DisForm_InitComboEdit();
46 return; 42 return;
47 } 43 }
48 44
49 CFWL_WidgetImpProperties prop; 45 CFWL_WidgetImpProperties prop;
50 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 46 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
51 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; 47 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
52 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) 48 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText)
53 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon; 49 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon;
54 50
55 prop.m_pDataProvider = m_pProperties->m_pDataProvider; 51 prop.m_pDataProvider = m_pProperties->m_pDataProvider;
56 m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, prop, this)); 52 m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, prop, this));
57 m_pListBox->Initialize();
58 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) { 53 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) {
59 CFWL_WidgetImpProperties prop2; 54 CFWL_WidgetImpProperties prop2;
60 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop2, this)); 55 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop2, this));
61 m_pEdit->Initialize();
62 m_pEdit->SetOuter(this); 56 m_pEdit->SetOuter(this);
63 } 57 }
64 if (m_pEdit) 58 if (m_pEdit)
65 m_pEdit->SetParent(this); 59 m_pEdit->SetParent(this);
66 60
67 SetStates(m_pProperties->m_dwStates); 61 SetStates(m_pProperties->m_dwStates);
68 } 62 }
69 63
70 void IFWL_ComboBox::Finalize() { 64 IFWL_ComboBox::~IFWL_ComboBox() {}
71 if (m_pEdit)
72 m_pEdit->Finalize();
73
74 m_pListBox->Finalize();
75 delete m_pDelegate;
76 m_pDelegate = nullptr;
77 IFWL_Widget::Finalize();
78 }
79 65
80 FWL_Type IFWL_ComboBox::GetClassID() const { 66 FWL_Type IFWL_ComboBox::GetClassID() const {
81 return FWL_Type::ComboBox; 67 return FWL_Type::ComboBox;
82 } 68 }
83 69
84 FWL_Error IFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 70 FWL_Error IFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
85 if (bAutoSize) { 71 if (bAutoSize) {
86 rect.Reset(); 72 rect.Reset();
87 FX_BOOL bIsDropDown = IsDropDownStyle(); 73 FX_BOOL bIsDropDown = IsDropDownStyle();
88 if (bIsDropDown && m_pEdit) { 74 if (bIsDropDown && m_pEdit) {
(...skipping 20 matching lines...) Expand all
109 FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded, 95 FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded,
110 uint32_t dwStylesExRemoved) { 96 uint32_t dwStylesExRemoved) {
111 if (m_pWidgetMgr->IsFormDisabled()) { 97 if (m_pWidgetMgr->IsFormDisabled()) {
112 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 98 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
113 } 99 }
114 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); 100 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
115 bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); 101 bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
116 if (bAddDropDown && !m_pEdit) { 102 if (bAddDropDown && !m_pEdit) {
117 CFWL_WidgetImpProperties prop; 103 CFWL_WidgetImpProperties prop;
118 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, nullptr)); 104 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, nullptr));
119 m_pEdit->Initialize();
120 m_pEdit->SetOuter(this); 105 m_pEdit->SetOuter(this);
121 m_pEdit->SetParent(this); 106 m_pEdit->SetParent(this);
122 } else if (bRemoveDropDown && m_pEdit) { 107 } else if (bRemoveDropDown && m_pEdit) {
123 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE); 108 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE);
124 } 109 }
125 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 110 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
126 } 111 }
127 112
128 FWL_Error IFWL_ComboBox::Update() { 113 FWL_Error IFWL_ComboBox::Update() {
129 if (m_pWidgetMgr->IsFormDisabled()) { 114 if (m_pWidgetMgr->IsFormDisabled()) {
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 return; 693 return;
709 if (!m_pListBox) 694 if (!m_pListBox)
710 return; 695 return;
711 696
712 CFWL_WidgetImpProperties propForm; 697 CFWL_WidgetImpProperties propForm;
713 propForm.m_pOwner = this; 698 propForm.m_pOwner = this;
714 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; 699 propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
715 propForm.m_dwStates = FWL_WGTSTATE_Invisible; 700 propForm.m_dwStates = FWL_WGTSTATE_Invisible;
716 701
717 m_pForm = new IFWL_FormProxy(m_pOwnerApp, propForm, m_pListBox.get()); 702 m_pForm = new IFWL_FormProxy(m_pOwnerApp, propForm, m_pListBox.get());
718 m_pForm->Initialize();
719 m_pListBox->SetParent(m_pForm); 703 m_pListBox->SetParent(m_pForm);
720 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this); 704 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this);
721 m_pForm->SetCurrentDelegate(m_pListProxyDelegate); 705 m_pForm->SetCurrentDelegate(m_pListProxyDelegate);
722 } 706 }
723 707
724 void IFWL_ComboBox::DisForm_InitComboList() { 708 void IFWL_ComboBox::DisForm_InitComboList() {
725 if (m_pListBox) 709 if (m_pListBox)
726 return; 710 return;
727 711
728 CFWL_WidgetImpProperties prop; 712 CFWL_WidgetImpProperties prop;
729 prop.m_pParent = this; 713 prop.m_pParent = this;
730 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; 714 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
731 prop.m_dwStates = FWL_WGTSTATE_Invisible; 715 prop.m_dwStates = FWL_WGTSTATE_Invisible;
732 prop.m_pDataProvider = m_pProperties->m_pDataProvider; 716 prop.m_pDataProvider = m_pProperties->m_pDataProvider;
733 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 717 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
734 m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, prop, this)); 718 m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, prop, this));
735 m_pListBox->Initialize();
736 } 719 }
737 720
738 void IFWL_ComboBox::DisForm_InitComboEdit() { 721 void IFWL_ComboBox::DisForm_InitComboEdit() {
739 if (m_pEdit) 722 if (m_pEdit)
740 return; 723 return;
741 724
742 CFWL_WidgetImpProperties prop; 725 CFWL_WidgetImpProperties prop;
743 prop.m_pParent = this; 726 prop.m_pParent = this;
744 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 727 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
745 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, this)); 728 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, this));
746 m_pEdit->Initialize();
747 m_pEdit->SetOuter(this); 729 m_pEdit->SetOuter(this);
748 } 730 }
749 731
750 void IFWL_ComboBox::DisForm_ShowDropList(FX_BOOL bActivate) { 732 void IFWL_ComboBox::DisForm_ShowDropList(FX_BOOL bActivate) {
751 FX_BOOL bDropList = DisForm_IsDropListShowed(); 733 FX_BOOL bDropList = DisForm_IsDropListShowed();
752 if (bDropList == bActivate) { 734 if (bDropList == bActivate) {
753 return; 735 return;
754 } 736 }
755 if (bActivate) { 737 if (bActivate) {
756 CFWL_EvtCmbPreDropDown preEvent; 738 CFWL_EvtCmbPreDropDown preEvent;
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 } 1391 }
1410 1392
1411 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, 1393 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg,
1412 FX_BOOL bSet) { 1394 FX_BOOL bSet) {
1413 if (!bSet) { 1395 if (!bSet) {
1414 if (!pMsg->m_pSetFocus) { 1396 if (!pMsg->m_pSetFocus) {
1415 m_pComboBox->ShowDropList(FALSE); 1397 m_pComboBox->ShowDropList(FALSE);
1416 } 1398 }
1417 } 1399 }
1418 } 1400 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_combobox.h ('k') | xfa/fwl/core/ifwl_combolist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698