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

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

Issue 2466273003: Change IFWL_Widget to store a single delegate. (Closed)
Patch Set: Fix Mac 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/fxfa/app/xfa_ffcheckbutton.h ('k') | xfa/fxfa/app/xfa_ffchoicelist.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/fxfa/app/xfa_ffcheckbutton.h" 7 #include "xfa/fxfa/app/xfa_ffcheckbutton.h"
8 8
9 #include "third_party/base/ptr_util.h"
9 #include "xfa/fwl/core/cfwl_checkbox.h" 10 #include "xfa/fwl/core/cfwl_checkbox.h"
10 #include "xfa/fwl/core/cfwl_message.h" 11 #include "xfa/fwl/core/cfwl_message.h"
11 #include "xfa/fwl/core/cfwl_widgetmgr.h" 12 #include "xfa/fwl/core/cfwl_widgetmgr.h"
12 #include "xfa/fwl/core/fwl_noteimp.h" 13 #include "xfa/fwl/core/fwl_noteimp.h"
14 #include "xfa/fxfa/app/cxfa_ffcheckbuttondelegate.h"
13 #include "xfa/fxfa/app/xfa_ffexclgroup.h" 15 #include "xfa/fxfa/app/xfa_ffexclgroup.h"
14 #include "xfa/fxfa/app/xfa_fffield.h" 16 #include "xfa/fxfa/app/xfa_fffield.h"
15 #include "xfa/fxfa/xfa_ffapp.h" 17 #include "xfa/fxfa/xfa_ffapp.h"
16 #include "xfa/fxfa/xfa_ffdoc.h" 18 #include "xfa/fxfa/xfa_ffdoc.h"
17 #include "xfa/fxfa/xfa_ffdocview.h" 19 #include "xfa/fxfa/xfa_ffdocview.h"
18 #include "xfa/fxfa/xfa_ffpageview.h" 20 #include "xfa/fxfa/xfa_ffpageview.h"
19 #include "xfa/fxfa/xfa_ffwidget.h" 21 #include "xfa/fxfa/xfa_ffwidget.h"
20 22
21 CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_FFPageView* pPageView, 23 CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_FFPageView* pPageView,
22 CXFA_WidgetAcc* pDataAcc) 24 CXFA_WidgetAcc* pDataAcc)
23 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) { 25 : CXFA_FFField(pPageView, pDataAcc) {
24 m_rtCheckBox.Set(0, 0, 0, 0); 26 m_rtCheckBox.Set(0, 0, 0, 0);
25 } 27 }
26 28
27 CXFA_FFCheckButton::~CXFA_FFCheckButton() {} 29 CXFA_FFCheckButton::~CXFA_FFCheckButton() {}
28 30
29 FX_BOOL CXFA_FFCheckButton::LoadWidget() { 31 FX_BOOL CXFA_FFCheckButton::LoadWidget() {
30 CFWL_CheckBox* pCheckBox = new CFWL_CheckBox(GetFWLApp()); 32 CFWL_CheckBox* pCheckBox = new CFWL_CheckBox(GetFWLApp());
31 pCheckBox->Initialize(); 33 pCheckBox->Initialize();
32 m_pNormalWidget = pCheckBox; 34 m_pNormalWidget = pCheckBox;
33 m_pNormalWidget->SetLayoutItem(this); 35 m_pNormalWidget->SetLayoutItem(this);
34 36
35 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); 37 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
36 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); 38 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
37 pNoteDriver->RegisterEventTarget(pWidget, pWidget); 39 pNoteDriver->RegisterEventTarget(pWidget, pWidget);
38 40
39 m_pOldDelegate = m_pNormalWidget->GetCurrentDelegate(); 41 m_pNormalWidget->SetDelegate(pdfium::MakeUnique<CXFA_FFCheckButtonDelegate>(
40 m_pNormalWidget->SetCurrentDelegate(this); 42 m_pNormalWidget->ReleaseDelegate(), this));
41 43
42 if (m_pDataAcc->IsRadioButton()) 44 if (m_pDataAcc->IsRadioButton())
43 pCheckBox->ModifyStylesEx(FWL_STYLEEXT_CKB_RadioButton, 0xFFFFFFFF); 45 pCheckBox->ModifyStylesEx(FWL_STYLEEXT_CKB_RadioButton, 0xFFFFFFFF);
44 46
45 m_pNormalWidget->LockUpdate(); 47 m_pNormalWidget->LockUpdate();
46 UpdateWidgetProperty(); 48 UpdateWidgetProperty();
47 SetFWLCheckState(m_pDataAcc->GetCheckState()); 49 SetFWLCheckState(m_pDataAcc->GetCheckState());
48 m_pNormalWidget->UnlockUpdate(); 50 m_pNormalWidget->UnlockUpdate();
49 return CXFA_FFField::LoadWidget(); 51 return CXFA_FFField::LoadWidget();
50 } 52 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 290 }
289 FX_BOOL CXFA_FFCheckButton::UpdateFWLData() { 291 FX_BOOL CXFA_FFCheckButton::UpdateFWLData() {
290 if (!m_pNormalWidget) { 292 if (!m_pNormalWidget) {
291 return FALSE; 293 return FALSE;
292 } 294 }
293 XFA_CHECKSTATE eState = m_pDataAcc->GetCheckState(); 295 XFA_CHECKSTATE eState = m_pDataAcc->GetCheckState();
294 SetFWLCheckState(eState); 296 SetFWLCheckState(eState);
295 m_pNormalWidget->Update(); 297 m_pNormalWidget->Update();
296 return TRUE; 298 return TRUE;
297 } 299 }
298
299 void CXFA_FFCheckButton::OnProcessMessage(CFWL_Message* pMessage) {
300 m_pOldDelegate->OnProcessMessage(pMessage);
301 }
302
303 void CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) {
304 CXFA_FFField::OnProcessEvent(pEvent);
305 switch (pEvent->GetClassID()) {
306 case CFWL_EventType::CheckStateChanged: {
307 CXFA_EventParam eParam;
308 eParam.m_eType = XFA_EVENT_Change;
309 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw);
310 CXFA_WidgetAcc* pFFExclGroup = m_pDataAcc->GetExclGroup();
311 if (ProcessCommittedData()) {
312 eParam.m_pTarget = pFFExclGroup;
313 if (pFFExclGroup) {
314 m_pDocView->AddValidateWidget(pFFExclGroup);
315 m_pDocView->AddCalculateWidgetAcc(pFFExclGroup);
316 pFFExclGroup->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam);
317 }
318 eParam.m_pTarget = m_pDataAcc;
319 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam);
320 } else {
321 SetFWLCheckState(m_pDataAcc->GetCheckState());
322 }
323 if (pFFExclGroup) {
324 eParam.m_pTarget = pFFExclGroup;
325 pFFExclGroup->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam);
326 }
327 eParam.m_pTarget = m_pDataAcc;
328 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam);
329 break;
330 }
331 default:
332 break;
333 }
334 m_pOldDelegate->OnProcessEvent(pEvent);
335 }
336
337 void CXFA_FFCheckButton::OnDrawWidget(CFX_Graphics* pGraphics,
338 const CFX_Matrix* pMatrix) {
339 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
340 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffcheckbutton.h ('k') | xfa/fxfa/app/xfa_ffchoicelist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698