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/fwl/theme/cfwl_edittp.h"
8
9 #include "xfa/fwl/cfwl_edit.h"
10 #include "xfa/fwl/cfwl_themebackground.h"
11 #include "xfa/fwl/cfwl_widget.h"
12 #include "xfa/fxfa/app/xfa_fwltheme.h"
13 #include "xfa/fxfa/xfa_ffwidget.h"
14 #include "xfa/fxgraphics/cfx_color.h"
15 #include "xfa/fxgraphics/cfx_path.h"
16
CFWL_EditTP()17 CFWL_EditTP::CFWL_EditTP() {}
18
~CFWL_EditTP()19 CFWL_EditTP::~CFWL_EditTP() {}
20
DrawBackground(CFWL_ThemeBackground * pParams)21 void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) {
22 if (CFWL_Part::CombTextLine == pParams->m_iPart) {
23 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget);
24 FX_ARGB cr = 0xFF000000;
25 FX_FLOAT fWidth = 1.0f;
26 if (CXFA_Border borderUI = pWidget->GetDataAcc()->GetUIBorder()) {
27 CXFA_Edge edge = borderUI.GetEdge(0);
28 if (edge) {
29 cr = edge.GetColor();
30 fWidth = edge.GetThickness();
31 }
32 }
33 CFX_Color crLine(cr);
34 pParams->m_pGraphics->SetStrokeColor(&crLine);
35 pParams->m_pGraphics->SetLineWidth(fWidth);
36 pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix);
37 return;
38 }
39
40 switch (pParams->m_iPart) {
41 case CFWL_Part::Border: {
42 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
43 break;
44 }
45 case CFWL_Part::Background: {
46 if (pParams->m_pPath) {
47 CFX_Graphics* pGraphics = pParams->m_pGraphics;
48 pGraphics->SaveGraphState();
49 CFX_Color crSelected(FWLTHEME_COLOR_BKSelected);
50 pGraphics->SetFillColor(&crSelected);
51 pGraphics->FillPath(pParams->m_pPath, FXFILL_WINDING,
52 &pParams->m_matrix);
53 pGraphics->RestoreGraphState();
54 } else {
55 CFX_Path path;
56 path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top,
57 pParams->m_rtPart.width, pParams->m_rtPart.height);
58 CFX_Color cr(FWLTHEME_COLOR_Background);
59 if (!pParams->m_bStaticBackground) {
60 if (pParams->m_dwStates & CFWL_PartState_Disabled)
61 cr.Set(FWLTHEME_COLOR_EDGERB1);
62 else if (pParams->m_dwStates & CFWL_PartState_ReadOnly)
63 cr.Set(ArgbEncode(255, 236, 233, 216));
64 else
65 cr.Set(0xFFFFFFFF);
66 }
67 pParams->m_pGraphics->SaveGraphState();
68 pParams->m_pGraphics->SetFillColor(&cr);
69 pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING,
70 &pParams->m_matrix);
71 pParams->m_pGraphics->RestoreGraphState();
72 }
73 break;
74 }
75 case CFWL_Part::CombTextLine: {
76 FX_ARGB cr = 0xFF000000;
77 FX_FLOAT fWidth = 1.0f;
78 CFX_Color crLine(cr);
79 pParams->m_pGraphics->SetStrokeColor(&crLine);
80 pParams->m_pGraphics->SetLineWidth(fWidth);
81 pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix);
82 break;
83 }
84 default:
85 break;
86 }
87 }
88