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

Side by Side Diff: xfa/src/fwl/src/basewidget/fwl_comboboximp.cpp

Issue 1458173002: Fix CFWL_WidgetImpDelegate hierarchy. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 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
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 "../../../foxitlib.h" 7 #include "../../../foxitlib.h"
8 #include "../../src/core/include/fwl_threadimp.h" 8 #include "../../src/core/include/fwl_threadimp.h"
9 #include "../../src/core/include/fwl_appimp.h" 9 #include "../../src/core/include/fwl_appimp.h"
10 #include "../core/include/fwl_targetimp.h" 10 #include "../core/include/fwl_targetimp.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 FXSYS_assert(pOuter != NULL); 199 FXSYS_assert(pOuter != NULL);
200 } 200 }
201 CFWL_ComboListImp::CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties, 201 CFWL_ComboListImp::CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties,
202 IFWL_Widget* pOuter) 202 IFWL_Widget* pOuter)
203 : CFWL_ListBoxImp(properties, pOuter), m_bNotifyOwner(TRUE) { 203 : CFWL_ListBoxImp(properties, pOuter), m_bNotifyOwner(TRUE) {
204 FXSYS_assert(pOuter != NULL); 204 FXSYS_assert(pOuter != NULL);
205 } 205 }
206 FWL_ERR CFWL_ComboListImp::Initialize() { 206 FWL_ERR CFWL_ComboListImp::Initialize() {
207 _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_ListBoxImp::Initialize(), 207 _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_ListBoxImp::Initialize(),
208 FWL_ERR_Indefinite); 208 FWL_ERR_Indefinite);
209 if (m_pDelegate) { 209 delete m_pDelegate;
210 delete (CFWL_ComboListImpDelegate*)m_pDelegate; 210 m_pDelegate = new CFWL_ComboListImpDelegate(this);
211 m_pDelegate = NULL;
212 }
213 m_pDelegate = (IFWL_WidgetDelegate*)new CFWL_ComboListImpDelegate(this);
214 return FWL_ERR_Succeeded; 211 return FWL_ERR_Succeeded;
215 } 212 }
216 FWL_ERR CFWL_ComboListImp::Finalize() { 213 FWL_ERR CFWL_ComboListImp::Finalize() {
217 if (m_pDelegate) { 214 delete m_pDelegate;
218 delete (CFWL_ComboListImpDelegate*)m_pDelegate; 215 m_pDelegate = nullptr;
219 m_pDelegate = NULL;
220 }
221 return CFWL_ListBoxImp::Finalize(); 216 return CFWL_ListBoxImp::Finalize();
222 } 217 }
223 int32_t CFWL_ComboListImp::MatchItem(const CFX_WideString& wsMatch) { 218 int32_t CFWL_ComboListImp::MatchItem(const CFX_WideString& wsMatch) {
224 if (wsMatch.IsEmpty()) { 219 if (wsMatch.IsEmpty()) {
225 return -1; 220 return -1;
226 } 221 }
227 _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, -1); 222 _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, -1);
228 IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider; 223 IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
229 int32_t iCount = pData->CountItems(m_pInterface); 224 int32_t iCount = pData->CountItems(m_pInterface);
230 for (int32_t i = 0; i < iCount; i++) { 225 for (int32_t i = 0; i < iCount; i++) {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } 507 }
513 FX_DWORD CFWL_ComboBoxImp::GetClassID() const { 508 FX_DWORD CFWL_ComboBoxImp::GetClassID() const {
514 return FWL_CLASSHASH_ComboBox; 509 return FWL_CLASSHASH_ComboBox;
515 } 510 }
516 FWL_ERR CFWL_ComboBoxImp::Initialize() { 511 FWL_ERR CFWL_ComboBoxImp::Initialize() {
517 if (m_pWidgetMgr->IsFormDisabled()) { 512 if (m_pWidgetMgr->IsFormDisabled()) {
518 return DisForm_Initialize(); 513 return DisForm_Initialize();
519 } 514 }
520 _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), 515 _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
521 FWL_WGTSTATE_Invisible); 516 FWL_WGTSTATE_Invisible);
522 m_pDelegate = (IFWL_WidgetDelegate*)new CFWL_ComboBoxImpDelegate(this); 517 m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
523 CFWL_WidgetImpProperties prop; 518 CFWL_WidgetImpProperties prop;
524 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 519 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
525 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; 520 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
526 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) { 521 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) {
527 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon; 522 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon;
528 } 523 }
529 prop.m_pDataProvider = m_pProperties->m_pDataProvider; 524 prop.m_pDataProvider = m_pProperties->m_pDataProvider;
530 CFWL_ComboListImp* pList = new CFWL_ComboListImp(prop, m_pInterface); 525 CFWL_ComboListImp* pList = new CFWL_ComboListImp(prop, m_pInterface);
531 m_pListBox = IFWL_ListBox::Create(); 526 m_pListBox = IFWL_ListBox::Create();
532 pList->SetInterface(m_pListBox); 527 pList->SetInterface(m_pListBox);
(...skipping 11 matching lines...) Expand all
544 m_pEdit->SetParent(m_pInterface); 539 m_pEdit->SetParent(m_pInterface);
545 } 540 }
546 SetStates(m_pProperties->m_dwStates); 541 SetStates(m_pProperties->m_dwStates);
547 return FWL_ERR_Succeeded; 542 return FWL_ERR_Succeeded;
548 } 543 }
549 FWL_ERR CFWL_ComboBoxImp::Finalize() { 544 FWL_ERR CFWL_ComboBoxImp::Finalize() {
550 if (m_pEdit) { 545 if (m_pEdit) {
551 m_pEdit->Finalize(); 546 m_pEdit->Finalize();
552 } 547 }
553 m_pListBox->Finalize(); 548 m_pListBox->Finalize();
554 if (m_pDelegate) { 549 delete m_pDelegate;
555 delete (CFWL_ComboBoxImpDelegate*)m_pDelegate; 550 m_pDelegate = nullptr;
556 m_pDelegate = NULL;
557 }
558 return CFWL_WidgetImp::Finalize(); 551 return CFWL_WidgetImp::Finalize();
559 } 552 }
560 FWL_ERR CFWL_ComboBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 553 FWL_ERR CFWL_ComboBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
561 if (bAutoSize) { 554 if (bAutoSize) {
562 rect.Reset(); 555 rect.Reset();
563 FX_BOOL bIsDropDown = IsDropDownStyle(); 556 FX_BOOL bIsDropDown = IsDropDownStyle();
564 if (bIsDropDown && m_pEdit) { 557 if (bIsDropDown && m_pEdit) {
565 m_pEdit->GetWidgetRect(rect, TRUE); 558 m_pEdit->GetWidgetRect(rect, TRUE);
566 } else { 559 } else {
567 rect.width = 100; 560 rect.width = 100;
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 propForm.m_pOwner = m_pInterface; 1137 propForm.m_pOwner = m_pInterface;
1145 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; 1138 propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
1146 propForm.m_dwStates = FWL_WGTSTATE_Invisible; 1139 propForm.m_dwStates = FWL_WGTSTATE_Invisible;
1147 m_pProxy = new CFWL_FormProxyImp(propForm, m_pListBox); 1140 m_pProxy = new CFWL_FormProxyImp(propForm, m_pListBox);
1148 m_pForm = IFWL_Form::Create(); 1141 m_pForm = IFWL_Form::Create();
1149 m_pProxy->SetInterface(m_pForm); 1142 m_pProxy->SetInterface(m_pForm);
1150 m_pForm->SetImpl(m_pProxy); 1143 m_pForm->SetImpl(m_pProxy);
1151 m_pProxy->Initialize(); 1144 m_pProxy->Initialize();
1152 m_pListBox->SetParent((IFWL_Widget*)m_pForm); 1145 m_pListBox->SetParent((IFWL_Widget*)m_pForm);
1153 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this); 1146 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this);
1154 m_pProxy->SetDelegate((IFWL_WidgetDelegate*)m_pListProxyDelegate); 1147 m_pProxy->SetDelegate(m_pListProxyDelegate);
1155 } 1148 }
1156 FWL_ERR CFWL_ComboBoxImp::DisForm_Initialize() { 1149 FWL_ERR CFWL_ComboBoxImp::DisForm_Initialize() {
1157 _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), 1150 _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
1158 FWL_WGTSTATE_Invisible); 1151 FWL_WGTSTATE_Invisible);
1159 m_pDelegate = (IFWL_WidgetDelegate*)new CFWL_ComboBoxImpDelegate(this); 1152 m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
1160 DisForm_InitComboList(); 1153 DisForm_InitComboList();
1161 DisForm_InitComboEdit(); 1154 DisForm_InitComboEdit();
1162 return FWL_ERR_Succeeded; 1155 return FWL_ERR_Succeeded;
1163 } 1156 }
1164 void CFWL_ComboBoxImp::DisForm_InitComboList() { 1157 void CFWL_ComboBoxImp::DisForm_InitComboList() {
1165 if (m_pListBox) { 1158 if (m_pListBox) {
1166 return; 1159 return;
1167 } 1160 }
1168 CFWL_WidgetImpProperties prop; 1161 CFWL_WidgetImpProperties prop;
1169 prop.m_pParent = (IFWL_Widget*)this->m_pInterface; 1162 prop.m_pParent = (IFWL_Widget*)this->m_pInterface;
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 m_pComboBox->ShowDropList(FALSE); 1857 m_pComboBox->ShowDropList(FALSE);
1865 } 1858 }
1866 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, 1859 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg,
1867 FX_BOOL bSet) { 1860 FX_BOOL bSet) {
1868 if (!bSet) { 1861 if (!bSet) {
1869 if (pMsg->m_pSetFocus == NULL) { 1862 if (pMsg->m_pSetFocus == NULL) {
1870 m_pComboBox->ShowDropList(FALSE); 1863 m_pComboBox->ShowDropList(FALSE);
1871 } 1864 }
1872 } 1865 }
1873 } 1866 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698