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

Side by Side Diff: xfa/src/fxfa/app/xfa_ffpath.cpp

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months 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/src/fxfa/app/xfa_ffpath.h ('k') | xfa/src/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
(Empty)
1 // Copyright 2014 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/src/fxfa/app/xfa_ffpath.h"
8
9 #include "xfa/include/fxgraphics/fx_graphics.h"
10 #include "xfa/src/fxfa/app/xfa_ffapp.h"
11 #include "xfa/src/fxfa/app/xfa_ffdoc.h"
12 #include "xfa/src/fxfa/app/xfa_ffdraw.h"
13 #include "xfa/src/fxfa/app/xfa_ffpageview.h"
14 #include "xfa/src/fxfa/app/xfa_ffwidget.h"
15
16 CXFA_FFLine::CXFA_FFLine(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc)
17 : CXFA_FFDraw(pPageView, pDataAcc) {}
18 CXFA_FFLine::~CXFA_FFLine() {}
19 void CXFA_FFLine::GetRectFromHand(CFX_RectF& rect,
20 int32_t iHand,
21 FX_FLOAT fLineWidth) {
22 FX_FLOAT fHalfWidth = fLineWidth / 2.0f;
23 if (rect.height < 1.0f) {
24 switch (iHand) {
25 case XFA_ATTRIBUTEENUM_Left:
26 rect.top -= fHalfWidth;
27 break;
28 case XFA_ATTRIBUTEENUM_Right:
29 rect.top += fHalfWidth;
30 }
31 } else if (rect.width < 1.0f) {
32 switch (iHand) {
33 case XFA_ATTRIBUTEENUM_Left:
34 rect.left += fHalfWidth;
35 break;
36 case XFA_ATTRIBUTEENUM_Right:
37 rect.left += fHalfWidth;
38 break;
39 }
40 } else {
41 switch (iHand) {
42 case XFA_ATTRIBUTEENUM_Left:
43 rect.Inflate(fHalfWidth, fHalfWidth);
44 break;
45 case XFA_ATTRIBUTEENUM_Right:
46 rect.Deflate(fHalfWidth, fHalfWidth);
47 break;
48 }
49 }
50 }
51 void CXFA_FFLine::RenderWidget(CFX_Graphics* pGS,
52 CFX_Matrix* pMatrix,
53 FX_DWORD dwStatus,
54 int32_t iRotate) {
55 if (!IsMatchVisibleStatus(dwStatus)) {
56 return;
57 }
58 CXFA_Value value = m_pDataAcc->GetFormValue();
59 if (!value) {
60 return;
61 }
62 CXFA_Line lineObj = value.GetLine();
63 FX_ARGB lineColor = 0xFF000000;
64 int32_t iStrokeType = 0;
65 FX_FLOAT fLineWidth = 1.0f;
66 FX_BOOL bSlope = lineObj.GetSlop();
67 int32_t iCap = 0;
68 CXFA_Edge edge = lineObj.GetEdge();
69 if (edge) {
70 if (edge.GetPresence() != XFA_ATTRIBUTEENUM_Visible) {
71 return;
72 }
73 lineColor = edge.GetColor();
74 iStrokeType = edge.GetStrokeType();
75 fLineWidth = edge.GetThickness();
76 iCap = edge.GetCapType();
77 }
78 CFX_Matrix mtRotate;
79 GetRotateMatrix(mtRotate);
80 if (pMatrix) {
81 mtRotate.Concat(*pMatrix);
82 }
83 CFX_RectF rtLine;
84 GetRectWithoutRotate(rtLine);
85 if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) {
86 XFA_RectWidthoutMargin(rtLine, mgWidget);
87 }
88 GetRectFromHand(rtLine, lineObj.GetHand(), fLineWidth);
89 CFX_Path linePath;
90 linePath.Create();
91 if (bSlope && rtLine.right() > 0.0f && rtLine.bottom() > 0.0f) {
92 linePath.AddLine(rtLine.right(), rtLine.top, rtLine.left, rtLine.bottom());
93 } else {
94 linePath.AddLine(rtLine.left, rtLine.top, rtLine.right(), rtLine.bottom());
95 }
96 CFX_Color color(lineColor);
97 pGS->SaveGraphState();
98 pGS->SetLineWidth(fLineWidth, TRUE);
99 XFA_StrokeTypeSetLineDash(pGS, iStrokeType, iCap);
100 pGS->SetStrokeColor(&color);
101 pGS->SetLineCap(XFA_LineCapToFXGE(iCap));
102 pGS->StrokePath(&linePath, &mtRotate);
103 pGS->RestoreGraphState();
104 }
105 CXFA_FFArc::CXFA_FFArc(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc)
106 : CXFA_FFDraw(pPageView, pDataAcc) {}
107 CXFA_FFArc::~CXFA_FFArc() {}
108 void CXFA_FFArc::RenderWidget(CFX_Graphics* pGS,
109 CFX_Matrix* pMatrix,
110 FX_DWORD dwStatus,
111 int32_t iRotate) {
112 if (!IsMatchVisibleStatus(dwStatus)) {
113 return;
114 }
115 CXFA_Value value = m_pDataAcc->GetFormValue();
116 if (!value) {
117 return;
118 }
119 CXFA_Arc arcObj = value.GetArc();
120 CFX_Matrix mtRotate;
121 GetRotateMatrix(mtRotate);
122 if (pMatrix) {
123 mtRotate.Concat(*pMatrix);
124 }
125 CFX_RectF rtArc;
126 GetRectWithoutRotate(rtArc);
127 if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) {
128 XFA_RectWidthoutMargin(rtArc, mgWidget);
129 }
130 DrawBorder(pGS, arcObj, rtArc, &mtRotate);
131 }
132 CXFA_FFRectangle::CXFA_FFRectangle(CXFA_FFPageView* pPageView,
133 CXFA_WidgetAcc* pDataAcc)
134 : CXFA_FFDraw(pPageView, pDataAcc) {}
135 CXFA_FFRectangle::~CXFA_FFRectangle() {}
136 void CXFA_FFRectangle::RenderWidget(CFX_Graphics* pGS,
137 CFX_Matrix* pMatrix,
138 FX_DWORD dwStatus,
139 int32_t iRotate) {
140 if (!IsMatchVisibleStatus(dwStatus)) {
141 return;
142 }
143 CXFA_Value value = m_pDataAcc->GetFormValue();
144 if (!value) {
145 return;
146 }
147 CXFA_Rectangle rtObj = value.GetRectangle();
148 CFX_RectF rect;
149 GetRectWithoutRotate(rect);
150 if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) {
151 XFA_RectWidthoutMargin(rect, mgWidget);
152 }
153 CFX_Matrix mtRotate;
154 GetRotateMatrix(mtRotate);
155 if (pMatrix) {
156 mtRotate.Concat(*pMatrix);
157 }
158 DrawBorder(pGS, rtObj, rect, &mtRotate);
159 }
OLDNEW
« no previous file with comments | « xfa/src/fxfa/app/xfa_ffpath.h ('k') | xfa/src/fxfa/app/xfa_ffpushbutton.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698