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

Side by Side Diff: xfa/fxfa/app/xfa_ffpushbutton.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_ffpushbutton.h ('k') | xfa/fxfa/app/xfa_fftextedit.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_ffpushbutton.h" 7 #include "xfa/fxfa/app/xfa_ffpushbutton.h"
8 8
9 #include "third_party/base/ptr_util.h"
9 #include "xfa/fwl/core/cfwl_pushbutton.h" 10 #include "xfa/fwl/core/cfwl_pushbutton.h"
10 #include "xfa/fwl/core/cfwl_widgetmgr.h" 11 #include "xfa/fwl/core/cfwl_widgetmgr.h"
11 #include "xfa/fwl/core/fwl_noteimp.h" 12 #include "xfa/fwl/core/fwl_noteimp.h"
13 #include "xfa/fxfa/app/cxfa_ffpushbuttondelegate.h"
12 #include "xfa/fxfa/app/xfa_fffield.h" 14 #include "xfa/fxfa/app/xfa_fffield.h"
13 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" 15 #include "xfa/fxfa/app/xfa_ffwidgetacc.h"
14 #include "xfa/fxfa/app/xfa_textlayout.h" 16 #include "xfa/fxfa/app/xfa_textlayout.h"
15 #include "xfa/fxfa/xfa_ffapp.h" 17 #include "xfa/fxfa/xfa_ffapp.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 #include "xfa/fxgraphics/cfx_color.h" 20 #include "xfa/fxgraphics/cfx_color.h"
19 #include "xfa/fxgraphics/cfx_path.h" 21 #include "xfa/fxgraphics/cfx_path.h"
20 22
21 CXFA_FFPushButton::CXFA_FFPushButton(CXFA_FFPageView* pPageView, 23 CXFA_FFPushButton::CXFA_FFPushButton(CXFA_FFPageView* pPageView,
22 CXFA_WidgetAcc* pDataAcc) 24 CXFA_WidgetAcc* pDataAcc)
23 : CXFA_FFField(pPageView, pDataAcc), 25 : CXFA_FFField(pPageView, pDataAcc),
24 m_pRolloverTextLayout(nullptr), 26 m_pRolloverTextLayout(nullptr),
25 m_pDownTextLayout(nullptr), 27 m_pDownTextLayout(nullptr),
26 m_pDownProvider(nullptr), 28 m_pDownProvider(nullptr),
27 m_pRollProvider(nullptr), 29 m_pRollProvider(nullptr) {}
28 m_pOldDelegate(nullptr) {} 30
29 CXFA_FFPushButton::~CXFA_FFPushButton() { 31 CXFA_FFPushButton::~CXFA_FFPushButton() {
30 CXFA_FFPushButton::UnloadWidget(); 32 CXFA_FFPushButton::UnloadWidget();
31 } 33 }
34
32 void CXFA_FFPushButton::RenderWidget(CFX_Graphics* pGS, 35 void CXFA_FFPushButton::RenderWidget(CFX_Graphics* pGS,
33 CFX_Matrix* pMatrix, 36 CFX_Matrix* pMatrix,
34 uint32_t dwStatus) { 37 uint32_t dwStatus) {
35 if (!IsMatchVisibleStatus(dwStatus)) { 38 if (!IsMatchVisibleStatus(dwStatus)) {
36 return; 39 return;
37 } 40 }
38 CFX_Matrix mtRotate; 41 CFX_Matrix mtRotate;
39 GetRotateMatrix(mtRotate); 42 GetRotateMatrix(mtRotate);
40 if (pMatrix) { 43 if (pMatrix) {
41 mtRotate.Concat(*pMatrix); 44 mtRotate.Concat(*pMatrix);
42 } 45 }
43 CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); 46 CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus);
44 RenderHighlightCaption(pGS, &mtRotate); 47 RenderHighlightCaption(pGS, &mtRotate);
45 CFX_RectF rtWidget; 48 CFX_RectF rtWidget;
46 GetRectWithoutRotate(rtWidget); 49 GetRectWithoutRotate(rtWidget);
47 CFX_Matrix mt; 50 CFX_Matrix mt;
48 mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); 51 mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top);
49 mt.Concat(mtRotate); 52 mt.Concat(mtRotate);
50 GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(), 53 GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget->GetWidget(),
51 pGS, &mt); 54 pGS, &mt);
52 } 55 }
53 FX_BOOL CXFA_FFPushButton::LoadWidget() { 56 FX_BOOL CXFA_FFPushButton::LoadWidget() {
54 ASSERT(!m_pNormalWidget); 57 ASSERT(!m_pNormalWidget);
55 CFWL_PushButton* pPushButton = new CFWL_PushButton(GetFWLApp()); 58 CFWL_PushButton* pPushButton = new CFWL_PushButton(GetFWLApp());
56 pPushButton->Initialize(); 59 pPushButton->Initialize();
57 60
58 m_pOldDelegate = pPushButton->GetCurrentDelegate(); 61 pPushButton->SetDelegate(pdfium::MakeUnique<CXFA_FFPushButtonDelegate>(
59 pPushButton->SetCurrentDelegate(this); 62 pPushButton->ReleaseDelegate(), this));
60 63
61 m_pNormalWidget = pPushButton; 64 m_pNormalWidget = pPushButton;
62 m_pNormalWidget->SetLayoutItem(this); 65 m_pNormalWidget->SetLayoutItem(this);
63 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); 66 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
64 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); 67 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
65 pNoteDriver->RegisterEventTarget(pWidget, pWidget); 68 pNoteDriver->RegisterEventTarget(pWidget, pWidget);
66 m_pNormalWidget->LockUpdate(); 69 m_pNormalWidget->LockUpdate();
67 UpdateWidgetProperty(); 70 UpdateWidgetProperty();
68 LoadHighlightCaption(); 71 LoadHighlightCaption();
69 m_pNormalWidget->UnlockUpdate(); 72 m_pNormalWidget->UnlockUpdate();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (m_pRolloverTextLayout->DrawString(pRenderDevice, mt, rtClip)) { 197 if (m_pRolloverTextLayout->DrawString(pRenderDevice, mt, rtClip)) {
195 return; 198 return;
196 } 199 }
197 } 200 }
198 } 201 }
199 if (pCapTextLayout) { 202 if (pCapTextLayout) {
200 pCapTextLayout->DrawString(pRenderDevice, mt, rtClip); 203 pCapTextLayout->DrawString(pRenderDevice, mt, rtClip);
201 } 204 }
202 } 205 }
203 } 206 }
204
205 void CXFA_FFPushButton::OnProcessMessage(CFWL_Message* pMessage) {
206 m_pOldDelegate->OnProcessMessage(pMessage);
207 }
208
209 void CXFA_FFPushButton::OnProcessEvent(CFWL_Event* pEvent) {
210 m_pOldDelegate->OnProcessEvent(pEvent);
211 CXFA_FFField::OnProcessEvent(pEvent);
212 }
213
214 void CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics,
215 const CFX_Matrix* pMatrix) {
216 if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) {
217 if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) &&
218 (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) {
219 CFX_RectF rtFill;
220 m_pNormalWidget->GetWidgetRect(rtFill);
221 rtFill.left = rtFill.top = 0;
222 FX_FLOAT fLineWith = GetLineWidth();
223 rtFill.Deflate(fLineWith, fLineWith);
224 CFX_Color cr(FXARGB_MAKE(128, 128, 255, 255));
225 pGraphics->SetFillColor(&cr);
226 CFX_Path path;
227 path.Create();
228 path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height);
229 pGraphics->FillPath(&path, FXFILL_WINDING, (CFX_Matrix*)pMatrix);
230 }
231 } else if (m_pNormalWidget->GetStylesEx() &
232 XFA_FWL_PSBSTYLEEXT_HiliteOutLine) {
233 if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) &&
234 (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) {
235 FX_FLOAT fLineWidth = GetLineWidth();
236 CFX_Color cr(FXARGB_MAKE(255, 128, 255, 255));
237 pGraphics->SetStrokeColor(&cr);
238 pGraphics->SetLineWidth(fLineWidth);
239 CFX_Path path;
240 path.Create();
241 CFX_RectF rect;
242 m_pNormalWidget->GetWidgetRect(rect);
243 path.AddRectangle(0, 0, rect.width, rect.height);
244 pGraphics->StrokePath(&path, (CFX_Matrix*)pMatrix);
245 }
246 }
247 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffpushbutton.h ('k') | xfa/fxfa/app/xfa_fftextedit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698