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

Side by Side Diff: xfa/fxfa/app/xfa_ffchoicelist.cpp

Issue 2524173002: Merge IFWL and CFWL classes. (Closed)
Patch Set: make chrome build happy Created 4 years 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/fxfa/app/xfa_ffchoicelist.h" 7 #include "xfa/fxfa/app/xfa_ffchoicelist.h"
8 8
9 #include "third_party/base/ptr_util.h"
9 #include "xfa/fwl/core/cfwl_app.h" 10 #include "xfa/fwl/core/cfwl_app.h"
10 #include "xfa/fwl/core/cfwl_combobox.h" 11 #include "xfa/fwl/core/cfwl_combobox.h"
12 #include "xfa/fwl/core/cfwl_edit.h"
11 #include "xfa/fwl/core/cfwl_evtselectchanged.h" 13 #include "xfa/fwl/core/cfwl_evtselectchanged.h"
12 #include "xfa/fwl/core/cfwl_listbox.h" 14 #include "xfa/fwl/core/cfwl_listbox.h"
13 #include "xfa/fwl/core/cfwl_notedriver.h" 15 #include "xfa/fwl/core/cfwl_notedriver.h"
14 #include "xfa/fwl/core/ifwl_combobox.h" 16 #include "xfa/fwl/core/cfwl_widgetproperties.h"
15 #include "xfa/fwl/core/ifwl_edit.h"
16 #include "xfa/fwl/core/ifwl_listbox.h"
17 #include "xfa/fxfa/app/xfa_fffield.h" 17 #include "xfa/fxfa/app/xfa_fffield.h"
18 #include "xfa/fxfa/app/xfa_fwladapter.h" 18 #include "xfa/fxfa/app/xfa_fwladapter.h"
19 #include "xfa/fxfa/cxfa_eventparam.h" 19 #include "xfa/fxfa/cxfa_eventparam.h"
20 #include "xfa/fxfa/xfa_ffdoc.h" 20 #include "xfa/fxfa/xfa_ffdoc.h"
21 #include "xfa/fxfa/xfa_ffdocview.h" 21 #include "xfa/fxfa/xfa_ffdocview.h"
22 #include "xfa/fxfa/xfa_ffpageview.h" 22 #include "xfa/fxfa/xfa_ffpageview.h"
23 #include "xfa/fxfa/xfa_ffwidget.h" 23 #include "xfa/fxfa/xfa_ffwidget.h"
24 24
25 CXFA_FFListBox::CXFA_FFListBox(CXFA_FFPageView* pPageView, 25 CXFA_FFListBox::CXFA_FFListBox(CXFA_FFPageView* pPageView,
26 CXFA_WidgetAcc* pDataAcc) 26 CXFA_WidgetAcc* pDataAcc)
27 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} 27 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {}
28 28
29 CXFA_FFListBox::~CXFA_FFListBox() { 29 CXFA_FFListBox::~CXFA_FFListBox() {
30 if (m_pNormalWidget) { 30 if (m_pNormalWidget) {
31 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); 31 CFWL_NoteDriver* pNoteDriver =
32 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); 32 m_pNormalWidget->GetOwnerApp()->GetNoteDriver();
33 pNoteDriver->UnregisterEventTarget(pWidget); 33 pNoteDriver->UnregisterEventTarget(m_pNormalWidget);
34 } 34 }
35 } 35 }
36 36
37 bool CXFA_FFListBox::LoadWidget() { 37 bool CXFA_FFListBox::LoadWidget() {
38 CFWL_ListBox* pListBox = new CFWL_ListBox(GetFWLApp()); 38 CFWL_ListBox* pListBox = new CFWL_ListBox(
39 pListBox->Initialize(); 39 GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr);
40 pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, 40 pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground,
41 0xFFFFFFFF); 41 0xFFFFFFFF);
42 m_pNormalWidget = (CFWL_Widget*)pListBox; 42 m_pNormalWidget = (CFWL_Widget*)pListBox;
43 m_pNormalWidget->SetLayoutItem(this); 43 m_pNormalWidget->SetLayoutItem(this);
44 44
45 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); 45 CFWL_NoteDriver* pNoteDriver =
46 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); 46 m_pNormalWidget->GetOwnerApp()->GetNoteDriver();
47 pNoteDriver->RegisterEventTarget(pWidget, pWidget); 47 pNoteDriver->RegisterEventTarget(m_pNormalWidget, m_pNormalWidget);
48 48
49 m_pOldDelegate = m_pNormalWidget->GetDelegate(); 49 m_pOldDelegate = m_pNormalWidget->GetDelegate();
50 m_pNormalWidget->SetDelegate(this); 50 m_pNormalWidget->SetDelegate(this);
51 m_pNormalWidget->LockUpdate(); 51 m_pNormalWidget->LockUpdate();
52 52
53 CFX_WideStringArray wsLabelArray; 53 CFX_WideStringArray wsLabelArray;
54 m_pDataAcc->GetChoiceListItems(wsLabelArray, false); 54 m_pDataAcc->GetChoiceListItems(wsLabelArray, false);
55 int32_t iItems = wsLabelArray.GetSize(); 55 int32_t iItems = wsLabelArray.GetSize();
56 for (int32_t i = 0; i < iItems; i++) { 56 for (int32_t i = 0; i < iItems; i++) {
57 pListBox->AddString(wsLabelArray[i].AsStringC()); 57 pListBox->AddString(wsLabelArray[i].AsStringC());
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 CFWL_ListItem* lpItemSel = pListBox->GetSelItem(iSelArray[j]); 144 CFWL_ListItem* lpItemSel = pListBox->GetSelItem(iSelArray[j]);
145 selItemArray.Add(lpItemSel); 145 selItemArray.Add(lpItemSel);
146 } 146 }
147 pListBox->SetSelItem(pListBox->GetSelItem(-1), false); 147 pListBox->SetSelItem(pListBox->GetSelItem(-1), false);
148 for (int32_t i = 0; i < iSelCount; i++) { 148 for (int32_t i = 0; i < iSelCount; i++) {
149 ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], true); 149 ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], true);
150 } 150 }
151 m_pNormalWidget->Update(); 151 m_pNormalWidget->Update();
152 return true; 152 return true;
153 } 153 }
154 void CXFA_FFListBox::OnSelectChanged(IFWL_Widget* pWidget, 154 void CXFA_FFListBox::OnSelectChanged(CFWL_Widget* pWidget,
155 const CFX_Int32Array& arrSels) { 155 const CFX_Int32Array& arrSels) {
156 CXFA_EventParam eParam; 156 CXFA_EventParam eParam;
157 eParam.m_eType = XFA_EVENT_Change; 157 eParam.m_eType = XFA_EVENT_Change;
158 eParam.m_pTarget = m_pDataAcc; 158 eParam.m_pTarget = m_pDataAcc;
159 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); 159 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw);
160 CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; 160 CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget;
161 int32_t iSels = pListBox->CountSelItems(); 161 int32_t iSels = pListBox->CountSelItems();
162 if (iSels > 0) { 162 if (iSels > 0) {
163 pListBox->GetItemText(nullptr, pListBox->GetSelItem(0), eParam.m_wsNewText); 163 pListBox->GetItemText(nullptr, pListBox->GetSelItem(0), eParam.m_wsNewText);
164 } 164 }
(...skipping 25 matching lines...) Expand all
190 190
191 void CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { 191 void CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) {
192 m_pOldDelegate->OnProcessMessage(pMessage); 192 m_pOldDelegate->OnProcessMessage(pMessage);
193 } 193 }
194 194
195 void CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { 195 void CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) {
196 CXFA_FFField::OnProcessEvent(pEvent); 196 CXFA_FFField::OnProcessEvent(pEvent);
197 switch (pEvent->GetClassID()) { 197 switch (pEvent->GetClassID()) {
198 case CFWL_EventType::SelectChanged: { 198 case CFWL_EventType::SelectChanged: {
199 CFX_Int32Array arrSels; 199 CFX_Int32Array arrSels;
200 OnSelectChanged(m_pNormalWidget->GetWidget(), arrSels); 200 OnSelectChanged(m_pNormalWidget, arrSels);
201 break; 201 break;
202 } 202 }
203 default: 203 default:
204 break; 204 break;
205 } 205 }
206 m_pOldDelegate->OnProcessEvent(pEvent); 206 m_pOldDelegate->OnProcessEvent(pEvent);
207 } 207 }
208 void CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, 208 void CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics,
209 const CFX_Matrix* pMatrix) { 209 const CFX_Matrix* pMatrix) {
210 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); 210 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
(...skipping 19 matching lines...) Expand all
230 } 230 }
231 CFX_RectF rtWidget; 231 CFX_RectF rtWidget;
232 ((CFWL_ComboBox*)m_pNormalWidget)->GetBBox(rtWidget); 232 ((CFWL_ComboBox*)m_pNormalWidget)->GetBBox(rtWidget);
233 if (rtWidget.Contains(fx, fy)) { 233 if (rtWidget.Contains(fx, fy)) {
234 return true; 234 return true;
235 } 235 }
236 return false; 236 return false;
237 } 237 }
238 bool CXFA_FFComboBox::LoadWidget() { 238 bool CXFA_FFComboBox::LoadWidget() {
239 CFWL_ComboBox* pComboBox = new CFWL_ComboBox(GetFWLApp()); 239 CFWL_ComboBox* pComboBox = new CFWL_ComboBox(GetFWLApp());
240 pComboBox->Initialize();
241 m_pNormalWidget = (CFWL_Widget*)pComboBox; 240 m_pNormalWidget = (CFWL_Widget*)pComboBox;
242 m_pNormalWidget->SetLayoutItem(this); 241 m_pNormalWidget->SetLayoutItem(this);
243 242
244 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); 243 CFWL_NoteDriver* pNoteDriver =
245 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); 244 m_pNormalWidget->GetOwnerApp()->GetNoteDriver();
246 pNoteDriver->RegisterEventTarget(pWidget, pWidget); 245 pNoteDriver->RegisterEventTarget(m_pNormalWidget, m_pNormalWidget);
247 246
248 m_pOldDelegate = m_pNormalWidget->GetDelegate(); 247 m_pOldDelegate = m_pNormalWidget->GetDelegate();
249 m_pNormalWidget->SetDelegate(this); 248 m_pNormalWidget->SetDelegate(this);
250 m_pNormalWidget->LockUpdate(); 249 m_pNormalWidget->LockUpdate();
251 250
252 CFX_WideStringArray wsLabelArray; 251 CFX_WideStringArray wsLabelArray;
253 m_pDataAcc->GetChoiceListItems(wsLabelArray, false); 252 m_pDataAcc->GetChoiceListItems(wsLabelArray, false);
254 int32_t iItems = wsLabelArray.GetSize(); 253 int32_t iItems = wsLabelArray.GetSize();
255 for (int32_t i = 0; i < iItems; i++) { 254 for (int32_t i = 0; i < iItems; i++) {
256 pComboBox->AddString(wsLabelArray[i].AsStringC()); 255 pComboBox->AddString(wsLabelArray[i].AsStringC());
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 467 }
469 void CXFA_FFComboBox::DeleteItem(int32_t nIndex) { 468 void CXFA_FFComboBox::DeleteItem(int32_t nIndex) {
470 if (nIndex < 0) { 469 if (nIndex < 0) {
471 ((CFWL_ComboBox*)m_pNormalWidget)->RemoveAll(); 470 ((CFWL_ComboBox*)m_pNormalWidget)->RemoveAll();
472 } else { 471 } else {
473 ((CFWL_ComboBox*)m_pNormalWidget)->RemoveAt(nIndex); 472 ((CFWL_ComboBox*)m_pNormalWidget)->RemoveAt(nIndex);
474 } 473 }
475 m_pNormalWidget->Update(); 474 m_pNormalWidget->Update();
476 AddInvalidateRect(); 475 AddInvalidateRect();
477 } 476 }
478 void CXFA_FFComboBox::OnTextChanged(IFWL_Widget* pWidget, 477 void CXFA_FFComboBox::OnTextChanged(CFWL_Widget* pWidget,
479 const CFX_WideString& wsChanged) { 478 const CFX_WideString& wsChanged) {
480 CXFA_EventParam eParam; 479 CXFA_EventParam eParam;
481 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); 480 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw);
482 eParam.m_wsChange = wsChanged; 481 eParam.m_wsChange = wsChanged;
483 FWLEventSelChange(&eParam); 482 FWLEventSelChange(&eParam);
484 } 483 }
485 void CXFA_FFComboBox::OnSelectChanged(IFWL_Widget* pWidget, 484 void CXFA_FFComboBox::OnSelectChanged(CFWL_Widget* pWidget, bool bLButtonUp) {
486 bool bLButtonUp) {
487 CXFA_EventParam eParam; 485 CXFA_EventParam eParam;
488 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); 486 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw);
489 FWLEventSelChange(&eParam); 487 FWLEventSelChange(&eParam);
490 if (m_pDataAcc->GetChoiceListCommitOn() == XFA_ATTRIBUTEENUM_Select && 488 if (m_pDataAcc->GetChoiceListCommitOn() == XFA_ATTRIBUTEENUM_Select &&
491 bLButtonUp) { 489 bLButtonUp) {
492 m_pDocView->SetFocusWidgetAcc(nullptr); 490 m_pDocView->SetFocusWidgetAcc(nullptr);
493 } 491 }
494 } 492 }
495 void CXFA_FFComboBox::OnPreOpen(IFWL_Widget* pWidget) { 493 void CXFA_FFComboBox::OnPreOpen(CFWL_Widget* pWidget) {
496 CXFA_EventParam eParam; 494 CXFA_EventParam eParam;
497 eParam.m_eType = XFA_EVENT_PreOpen; 495 eParam.m_eType = XFA_EVENT_PreOpen;
498 eParam.m_pTarget = m_pDataAcc; 496 eParam.m_pTarget = m_pDataAcc;
499 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PreOpen, &eParam); 497 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PreOpen, &eParam);
500 } 498 }
501 void CXFA_FFComboBox::OnPostOpen(IFWL_Widget* pWidget) { 499 void CXFA_FFComboBox::OnPostOpen(CFWL_Widget* pWidget) {
502 CXFA_EventParam eParam; 500 CXFA_EventParam eParam;
503 eParam.m_eType = XFA_EVENT_PostOpen; 501 eParam.m_eType = XFA_EVENT_PostOpen;
504 eParam.m_pTarget = m_pDataAcc; 502 eParam.m_pTarget = m_pDataAcc;
505 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PostOpen, &eParam); 503 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PostOpen, &eParam);
506 } 504 }
507 505
508 void CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) { 506 void CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) {
509 m_pOldDelegate->OnProcessMessage(pMessage); 507 m_pOldDelegate->OnProcessMessage(pMessage);
510 } 508 }
511 509
512 void CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) { 510 void CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) {
513 CXFA_FFField::OnProcessEvent(pEvent); 511 CXFA_FFField::OnProcessEvent(pEvent);
514 switch (pEvent->GetClassID()) { 512 switch (pEvent->GetClassID()) {
515 case CFWL_EventType::SelectChanged: { 513 case CFWL_EventType::SelectChanged: {
516 CFWL_EvtSelectChanged* postEvent = 514 CFWL_EvtSelectChanged* postEvent =
517 static_cast<CFWL_EvtSelectChanged*>(pEvent); 515 static_cast<CFWL_EvtSelectChanged*>(pEvent);
518 OnSelectChanged(m_pNormalWidget->GetWidget(), postEvent->bLButtonUp); 516 OnSelectChanged(m_pNormalWidget, postEvent->bLButtonUp);
519 break; 517 break;
520 } 518 }
521 case CFWL_EventType::EditChanged: { 519 case CFWL_EventType::EditChanged: {
522 CFX_WideString wsChanged; 520 CFX_WideString wsChanged;
523 OnTextChanged(m_pNormalWidget->GetWidget(), wsChanged); 521 OnTextChanged(m_pNormalWidget, wsChanged);
524 break; 522 break;
525 } 523 }
526 case CFWL_EventType::PreDropDown: { 524 case CFWL_EventType::PreDropDown: {
527 OnPreOpen(m_pNormalWidget->GetWidget()); 525 OnPreOpen(m_pNormalWidget);
528 break; 526 break;
529 } 527 }
530 case CFWL_EventType::PostDropDown: { 528 case CFWL_EventType::PostDropDown: {
531 OnPostOpen(m_pNormalWidget->GetWidget()); 529 OnPostOpen(m_pNormalWidget);
532 break; 530 break;
533 } 531 }
534 default: 532 default:
535 break; 533 break;
536 } 534 }
537 m_pOldDelegate->OnProcessEvent(pEvent); 535 m_pOldDelegate->OnProcessEvent(pEvent);
538 } 536 }
539 537
540 void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, 538 void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics,
541 const CFX_Matrix* pMatrix) { 539 const CFX_Matrix* pMatrix) {
542 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); 540 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
543 } 541 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698