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

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

Issue 2469893004: Unify CFWL_WidgetProperties and CFWL_WidgetImpProperties. (Closed)
Patch Set: review cleanup 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_comboboxproxy.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 "third_party/base/ptr_util.h"
10 #include "xfa/fde/cfde_txtedtengine.h" 10 #include "xfa/fde/cfde_txtedtengine.h"
11 #include "xfa/fde/tto/fde_textout.h" 11 #include "xfa/fde/tto/fde_textout.h"
12 #include "xfa/fwl/core/cfwl_message.h" 12 #include "xfa/fwl/core/cfwl_message.h"
13 #include "xfa/fwl/core/cfwl_themebackground.h" 13 #include "xfa/fwl/core/cfwl_themebackground.h"
14 #include "xfa/fwl/core/cfwl_themepart.h" 14 #include "xfa/fwl/core/cfwl_themepart.h"
15 #include "xfa/fwl/core/cfwl_themetext.h" 15 #include "xfa/fwl/core/cfwl_themetext.h"
16 #include "xfa/fwl/core/cfwl_widgetmgr.h" 16 #include "xfa/fwl/core/cfwl_widgetmgr.h"
17 #include "xfa/fwl/core/fwl_noteimp.h" 17 #include "xfa/fwl/core/fwl_noteimp.h"
18 #include "xfa/fwl/core/ifwl_app.h" 18 #include "xfa/fwl/core/ifwl_app.h"
19 #include "xfa/fwl/core/ifwl_comboboxproxy.h" 19 #include "xfa/fwl/core/ifwl_comboboxproxy.h"
20 #include "xfa/fwl/core/ifwl_comboedit.h" 20 #include "xfa/fwl/core/ifwl_comboedit.h"
21 #include "xfa/fwl/core/ifwl_combolist.h" 21 #include "xfa/fwl/core/ifwl_combolist.h"
22 #include "xfa/fwl/core/ifwl_formproxy.h" 22 #include "xfa/fwl/core/ifwl_formproxy.h"
23 #include "xfa/fwl/core/ifwl_themeprovider.h" 23 #include "xfa/fwl/core/ifwl_themeprovider.h"
24 24
25 IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app, 25 IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app,
26 const CFWL_WidgetImpProperties& properties) 26 std::unique_ptr<CFWL_WidgetProperties> properties)
27 : IFWL_Widget(app, properties, nullptr), 27 : IFWL_Widget(app, std::move(properties), nullptr),
28 m_pComboBoxProxy(nullptr), 28 m_pComboBoxProxy(nullptr),
29 m_bLButtonDown(false), 29 m_bLButtonDown(false),
30 m_iCurSel(-1), 30 m_iCurSel(-1),
31 m_iBtnState(CFWL_PartState_Normal), 31 m_iBtnState(CFWL_PartState_Normal),
32 m_fComboFormHandler(0), 32 m_fComboFormHandler(0),
33 m_bNeedShowList(false) { 33 m_bNeedShowList(false) {
34 m_rtClient.Reset(); 34 m_rtClient.Reset();
35 m_rtBtn.Reset(); 35 m_rtBtn.Reset();
36 m_rtHandler.Reset(); 36 m_rtHandler.Reset();
37 37
38 if (m_pWidgetMgr->IsFormDisabled()) { 38 if (m_pWidgetMgr->IsFormDisabled()) {
39 DisForm_InitComboList(); 39 DisForm_InitComboList();
40 DisForm_InitComboEdit(); 40 DisForm_InitComboEdit();
41 return; 41 return;
42 } 42 }
43 43
44 CFWL_WidgetImpProperties prop; 44 auto prop =
45 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 45 pdfium::MakeUnique<CFWL_WidgetProperties>(m_pProperties->m_pDataProvider);
46 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; 46 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
47 prop->m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
47 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) 48 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText)
48 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon; 49 prop->m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon;
49 50
50 prop.m_pDataProvider = m_pProperties->m_pDataProvider; 51 m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, std::move(prop), this));
51 m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, prop, this));
52 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) { 52 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) {
53 CFWL_WidgetImpProperties prop2; 53 m_pEdit.reset(new IFWL_ComboEdit(
54 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop2, this)); 54 m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), this));
55 m_pEdit->SetOuter(this); 55 m_pEdit->SetOuter(this);
56 } 56 }
57 if (m_pEdit) 57 if (m_pEdit)
58 m_pEdit->SetParent(this); 58 m_pEdit->SetParent(this);
59 59
60 SetStates(m_pProperties->m_dwStates); 60 SetStates(m_pProperties->m_dwStates);
61 } 61 }
62 62
63 IFWL_ComboBox::~IFWL_ComboBox() {} 63 IFWL_ComboBox::~IFWL_ComboBox() {}
64 64
(...skipping 27 matching lines...) Expand all
92 } 92 }
93 93
94 FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded, 94 FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded,
95 uint32_t dwStylesExRemoved) { 95 uint32_t dwStylesExRemoved) {
96 if (m_pWidgetMgr->IsFormDisabled()) { 96 if (m_pWidgetMgr->IsFormDisabled()) {
97 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 97 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
98 } 98 }
99 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); 99 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
100 bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); 100 bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
101 if (bAddDropDown && !m_pEdit) { 101 if (bAddDropDown && !m_pEdit) {
102 CFWL_WidgetImpProperties prop; 102 m_pEdit.reset(new IFWL_ComboEdit(
103 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, nullptr)); 103 m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr));
104 m_pEdit->SetOuter(this); 104 m_pEdit->SetOuter(this);
105 m_pEdit->SetParent(this); 105 m_pEdit->SetParent(this);
106 } else if (bRemoveDropDown && m_pEdit) { 106 } else if (bRemoveDropDown && m_pEdit) {
107 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, true); 107 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, true);
108 } 108 }
109 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 109 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
110 } 110 }
111 111
112 FWL_Error IFWL_ComboBox::Update() { 112 FWL_Error IFWL_ComboBox::Update() {
113 if (m_pWidgetMgr->IsFormDisabled()) { 113 if (m_pWidgetMgr->IsFormDisabled()) {
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 Repaint(&m_rtClient); 686 Repaint(&m_rtClient);
687 } 687 }
688 } 688 }
689 689
690 void IFWL_ComboBox::InitProxyForm() { 690 void IFWL_ComboBox::InitProxyForm() {
691 if (m_pComboBoxProxy) 691 if (m_pComboBoxProxy)
692 return; 692 return;
693 if (!m_pListBox) 693 if (!m_pListBox)
694 return; 694 return;
695 695
696 CFWL_WidgetImpProperties propForm; 696 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
697 propForm.m_pOwner = this; 697 prop->m_pOwner = this;
698 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; 698 prop->m_dwStyles = FWL_WGTSTYLE_Popup;
699 propForm.m_dwStates = FWL_WGTSTATE_Invisible; 699 prop->m_dwStates = FWL_WGTSTATE_Invisible;
700 700
701 m_pComboBoxProxy = 701 m_pComboBoxProxy = new IFWL_ComboBoxProxy(this, m_pOwnerApp, std::move(prop),
702 new IFWL_ComboBoxProxy(this, m_pOwnerApp, propForm, m_pListBox.get()); 702 m_pListBox.get());
703 m_pListBox->SetParent(m_pComboBoxProxy); 703 m_pListBox->SetParent(m_pComboBoxProxy);
704 } 704 }
705 705
706 void IFWL_ComboBox::DisForm_InitComboList() { 706 void IFWL_ComboBox::DisForm_InitComboList() {
707 if (m_pListBox) 707 if (m_pListBox)
708 return; 708 return;
709 709
710 CFWL_WidgetImpProperties prop; 710 auto prop =
711 prop.m_pParent = this; 711 pdfium::MakeUnique<CFWL_WidgetProperties>(m_pProperties->m_pDataProvider);
712 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; 712 prop->m_pParent = this;
713 prop.m_dwStates = FWL_WGTSTATE_Invisible; 713 prop->m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
714 prop.m_pDataProvider = m_pProperties->m_pDataProvider; 714 prop->m_dwStates = FWL_WGTSTATE_Invisible;
715 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 715 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
716 m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, prop, this)); 716 m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, std::move(prop), this));
717 } 717 }
718 718
719 void IFWL_ComboBox::DisForm_InitComboEdit() { 719 void IFWL_ComboBox::DisForm_InitComboEdit() {
720 if (m_pEdit) 720 if (m_pEdit)
721 return; 721 return;
722 722
723 CFWL_WidgetImpProperties prop; 723 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
724 prop.m_pParent = this; 724 prop->m_pParent = this;
725 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 725 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
726 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, this)); 726 m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, std::move(prop), this));
727 m_pEdit->SetOuter(this); 727 m_pEdit->SetOuter(this);
728 } 728 }
729 729
730 void IFWL_ComboBox::DisForm_ShowDropList(bool bActivate) { 730 void IFWL_ComboBox::DisForm_ShowDropList(bool bActivate) {
731 bool bDropList = DisForm_IsDropListShowed(); 731 bool bDropList = DisForm_IsDropListShowed();
732 if (bDropList == bActivate) { 732 if (bDropList == bActivate) {
733 return; 733 return;
734 } 734 }
735 if (bActivate) { 735 if (bActivate) {
736 CFWL_EvtCmbPreDropDown preEvent; 736 CFWL_EvtCmbPreDropDown preEvent;
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 else 1255 else
1256 iCurSel++; 1256 iCurSel++;
1257 } 1257 }
1258 m_iCurSel = iCurSel; 1258 m_iCurSel = iCurSel;
1259 SynchrEditText(m_iCurSel); 1259 SynchrEditText(m_iCurSel);
1260 return; 1260 return;
1261 } 1261 }
1262 if (m_pEdit) 1262 if (m_pEdit)
1263 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); 1263 m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
1264 } 1264 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_combobox.h ('k') | xfa/fwl/core/ifwl_comboboxproxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698