• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "core/fxge/render_defines.h"
10 #include "xfa/fwl/cfwl_edit.h"
11 #include "xfa/fwl/cfwl_themebackground.h"
12 #include "xfa/fwl/cfwl_widget.h"
13 #include "xfa/fxgraphics/cxfa_gecolor.h"
14 #include "xfa/fxgraphics/cxfa_gepath.h"
15 
16 CFWL_EditTP::CFWL_EditTP() = default;
17 
18 CFWL_EditTP::~CFWL_EditTP() = default;
19 
DrawBackground(const CFWL_ThemeBackground & pParams)20 void CFWL_EditTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
21   if (CFWL_Part::CombTextLine == pParams.m_iPart) {
22     CFWL_Widget::AdapterIface* pWidget =
23         pParams.m_pWidget->GetOutmost()->GetAdapterIface();
24     FX_ARGB cr = 0xFF000000;
25     float fWidth = 1.0f;
26     pWidget->GetBorderColorAndThickness(&cr, &fWidth);
27     pParams.m_pGraphics->SetStrokeColor(CXFA_GEColor(cr));
28     pParams.m_pGraphics->SetLineWidth(fWidth);
29     pParams.m_pGraphics->StrokePath(pParams.m_pPath.Get(), &pParams.m_matrix);
30     return;
31   }
32 
33   switch (pParams.m_iPart) {
34     case CFWL_Part::Border: {
35       DrawBorder(pParams.m_pGraphics.Get(), pParams.m_rtPart, pParams.m_matrix);
36       break;
37     }
38     case CFWL_Part::Background: {
39       if (pParams.m_pPath) {
40         CXFA_Graphics* pGraphics = pParams.m_pGraphics.Get();
41         pGraphics->SaveGraphState();
42         pGraphics->SetFillColor(CXFA_GEColor(FWLTHEME_COLOR_BKSelected));
43         pGraphics->FillPath(pParams.m_pPath.Get(), FXFILL_WINDING,
44                             &pParams.m_matrix);
45         pGraphics->RestoreGraphState();
46       } else {
47         CXFA_GEPath path;
48         path.AddRectangle(pParams.m_rtPart.left, pParams.m_rtPart.top,
49                           pParams.m_rtPart.width, pParams.m_rtPart.height);
50         CXFA_GEColor cr(FWLTHEME_COLOR_Background);
51         if (!pParams.m_bStaticBackground) {
52           if (pParams.m_dwStates & CFWL_PartState_Disabled)
53             cr = CXFA_GEColor(FWLTHEME_COLOR_EDGERB1);
54           else if (pParams.m_dwStates & CFWL_PartState_ReadOnly)
55             cr = CXFA_GEColor(ArgbEncode(255, 236, 233, 216));
56           else
57             cr = CXFA_GEColor(0xFFFFFFFF);
58         }
59         pParams.m_pGraphics->SaveGraphState();
60         pParams.m_pGraphics->SetFillColor(cr);
61         pParams.m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams.m_matrix);
62         pParams.m_pGraphics->RestoreGraphState();
63       }
64       break;
65     }
66     case CFWL_Part::CombTextLine: {
67       pParams.m_pGraphics->SetStrokeColor(CXFA_GEColor(0xFF000000));
68       pParams.m_pGraphics->SetLineWidth(1.0f);
69       pParams.m_pGraphics->StrokePath(pParams.m_pPath.Get(), &pParams.m_matrix);
70       break;
71     }
72     default:
73       break;
74   }
75 }
76