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

Side by Side Diff: xfa/fxfa/app/cxfa_ffpushbuttondelegate.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/cxfa_ffpushbuttondelegate.h ('k') | xfa/fxfa/app/cxfa_fftexteditdelegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "xfa/fxfa/app/cxfa_ffpushbuttondelegate.h"
8
9 #include "xfa/fwl/core/cfwl_widget.h"
10 #include "xfa/fwl/core/ifwl_pushbutton.h"
11 #include "xfa/fxfa/app/xfa_fffield.h"
12 #include "xfa/fxfa/app/xfa_ffpushbutton.h"
13 #include "xfa/fxgraphics/cfx_color.h"
14 #include "xfa/fxgraphics/cfx_path.h"
15
16 CXFA_FFPushButtonDelegate::CXFA_FFPushButtonDelegate(
17 std::unique_ptr<IFWL_WidgetDelegate> pDelegate,
18 CXFA_FFPushButton* const pWidget)
19 : CXFA_FFFieldDelegate(std::move(pDelegate), pWidget) {}
20
21 CXFA_FFPushButtonDelegate::~CXFA_FFPushButtonDelegate() {}
22
23 void CXFA_FFPushButtonDelegate::OnProcessMessage(CFWL_Message* pMessage) {
24 m_pDelegate->OnProcessMessage(pMessage);
25 }
26
27 void CXFA_FFPushButtonDelegate::OnProcessEvent(CFWL_Event* pEvent) {
28 m_pDelegate->OnProcessEvent(pEvent);
29 CXFA_FFFieldDelegate::OnProcessEvent(pEvent);
30 }
31
32 void CXFA_FFPushButtonDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
33 const CFX_Matrix* pMatrix) {
34 CFWL_Widget* pNormalWidget =
35 static_cast<CXFA_FFField*>(m_pWidget)->GetNormalWidget();
36 CXFA_FFPushButton* widget = static_cast<CXFA_FFPushButton*>(m_pWidget);
37
38 if (pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) {
39 if ((pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) &&
40 (pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) {
41 CFX_RectF rtFill;
42 pNormalWidget->GetWidgetRect(rtFill);
43 rtFill.left = rtFill.top = 0;
44 FX_FLOAT fLineWith = widget->GetLineWidth();
45 rtFill.Deflate(fLineWith, fLineWith);
46 CFX_Color cr(FXARGB_MAKE(128, 128, 255, 255));
47 pGraphics->SetFillColor(&cr);
48 CFX_Path path;
49 path.Create();
50 path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height);
51 pGraphics->FillPath(&path, FXFILL_WINDING, (CFX_Matrix*)pMatrix);
52 }
53 } else if (pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteOutLine) {
54 if ((pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) &&
55 (pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) {
56 FX_FLOAT fLineWidth = widget->GetLineWidth();
57 CFX_Color cr(FXARGB_MAKE(255, 128, 255, 255));
58 pGraphics->SetStrokeColor(&cr);
59 pGraphics->SetLineWidth(fLineWidth);
60 CFX_Path path;
61 path.Create();
62 CFX_RectF rect;
63 pNormalWidget->GetWidgetRect(rect);
64 path.AddRectangle(0, 0, rect.width, rect.height);
65 pGraphics->StrokePath(&path, (CFX_Matrix*)pMatrix);
66 }
67 }
68 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/cxfa_ffpushbuttondelegate.h ('k') | xfa/fxfa/app/cxfa_fftexteditdelegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698