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

Side by Side Diff: xfa/fxfa/app/xfa_ffimageedit.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_ffimageedit.h ('k') | xfa/fxfa/app/xfa_ffpushbutton.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_ffimageedit.h" 7 #include "xfa/fxfa/app/xfa_ffimageedit.h"
8 8
9 #include "third_party/base/ptr_util.h"
9 #include "xfa/fwl/core/cfwl_message.h" 10 #include "xfa/fwl/core/cfwl_message.h"
10 #include "xfa/fwl/core/cfwl_picturebox.h" 11 #include "xfa/fwl/core/cfwl_picturebox.h"
11 #include "xfa/fwl/core/fwl_noteimp.h" 12 #include "xfa/fwl/core/fwl_noteimp.h"
12 #include "xfa/fwl/core/ifwl_app.h" 13 #include "xfa/fwl/core/ifwl_app.h"
14 #include "xfa/fxfa/app/cxfa_ffimageeditdelegate.h"
13 #include "xfa/fxfa/app/xfa_fffield.h" 15 #include "xfa/fxfa/app/xfa_fffield.h"
14 #include "xfa/fxfa/xfa_ffdoc.h" 16 #include "xfa/fxfa/xfa_ffdoc.h"
15 #include "xfa/fxfa/xfa_ffdocview.h" 17 #include "xfa/fxfa/xfa_ffdocview.h"
16 #include "xfa/fxfa/xfa_ffpageview.h" 18 #include "xfa/fxfa/xfa_ffpageview.h"
17 #include "xfa/fxfa/xfa_ffwidget.h" 19 #include "xfa/fxfa/xfa_ffwidget.h"
18 20
19 CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_FFPageView* pPageView, 21 CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_FFPageView* pPageView,
20 CXFA_WidgetAcc* pDataAcc) 22 CXFA_WidgetAcc* pDataAcc)
21 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} 23 : CXFA_FFField(pPageView, pDataAcc) {}
24
22 CXFA_FFImageEdit::~CXFA_FFImageEdit() { 25 CXFA_FFImageEdit::~CXFA_FFImageEdit() {
23 CXFA_FFImageEdit::UnloadWidget(); 26 CXFA_FFImageEdit::UnloadWidget();
24 } 27 }
25 FX_BOOL CXFA_FFImageEdit::LoadWidget() { 28 FX_BOOL CXFA_FFImageEdit::LoadWidget() {
26 CFWL_PictureBox* pPictureBox = new CFWL_PictureBox(GetFWLApp()); 29 CFWL_PictureBox* pPictureBox = new CFWL_PictureBox(GetFWLApp());
27 pPictureBox->Initialize(); 30 pPictureBox->Initialize();
28 m_pNormalWidget = pPictureBox; 31 m_pNormalWidget = pPictureBox;
29 m_pNormalWidget->SetLayoutItem(this); 32 m_pNormalWidget->SetLayoutItem(this);
30 33
31 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); 34 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
32 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); 35 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
33 pNoteDriver->RegisterEventTarget(pWidget, pWidget); 36 pNoteDriver->RegisterEventTarget(pWidget, pWidget);
34 37
35 m_pOldDelegate = pPictureBox->GetCurrentDelegate(); 38 pPictureBox->SetDelegate(pdfium::MakeUnique<CXFA_FFImageEditDelegate>(
36 pPictureBox->SetCurrentDelegate(this); 39 pPictureBox->ReleaseDelegate(), this));
37 40
38 CXFA_FFField::LoadWidget(); 41 CXFA_FFField::LoadWidget();
39 if (m_pDataAcc->GetImageEditImage()) { 42 if (m_pDataAcc->GetImageEditImage()) {
40 return TRUE; 43 return TRUE;
41 } 44 }
42 UpdateFWLData(); 45 UpdateFWLData();
43 return TRUE; 46 return TRUE;
44 } 47 }
45 void CXFA_FFImageEdit::UnloadWidget() { 48 void CXFA_FFImageEdit::UnloadWidget() {
46 m_pDataAcc->SetImageEditImage(nullptr); 49 m_pDataAcc->SetImageEditImage(nullptr);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 121 }
119 FX_BOOL CXFA_FFImageEdit::CommitData() { 122 FX_BOOL CXFA_FFImageEdit::CommitData() {
120 return TRUE; 123 return TRUE;
121 } 124 }
122 FX_BOOL CXFA_FFImageEdit::UpdateFWLData() { 125 FX_BOOL CXFA_FFImageEdit::UpdateFWLData() {
123 m_pDataAcc->SetImageEditImage(nullptr); 126 m_pDataAcc->SetImageEditImage(nullptr);
124 m_pDataAcc->LoadImageEditImage(); 127 m_pDataAcc->LoadImageEditImage();
125 return TRUE; 128 return TRUE;
126 } 129 }
127 130
128 void CXFA_FFImageEdit::OnProcessMessage(CFWL_Message* pMessage) {
129 m_pOldDelegate->OnProcessMessage(pMessage);
130 }
131
132 void CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) {
133 CXFA_FFField::OnProcessEvent(pEvent);
134 m_pOldDelegate->OnProcessEvent(pEvent);
135 }
136
137 void CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics,
138 const CFX_Matrix* pMatrix) {
139 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
140 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffimageedit.h ('k') | xfa/fxfa/app/xfa_ffpushbutton.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698