• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The PDFium Authors
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/fgas/graphics/cfgas_gecolor.h"
10 #include "xfa/fgas/graphics/cfgas_gegraphics.h"
11 #include "xfa/fgas/graphics/cfgas_gepath.h"
12 #include "xfa/fwl/cfwl_edit.h"
13 #include "xfa/fwl/cfwl_themebackground.h"
14 #include "xfa/fwl/cfwl_widget.h"
15 
16 namespace pdfium {
17 
18 CFWL_EditTP::CFWL_EditTP() = default;
19 
20 CFWL_EditTP::~CFWL_EditTP() = default;
21 
DrawBackground(const CFWL_ThemeBackground & pParams)22 void CFWL_EditTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
23   switch (pParams.GetPart()) {
24     case CFWL_ThemePart::Part::kBorder: {
25       DrawBorder(pParams.GetGraphics(), pParams.m_PartRect, pParams.m_matrix);
26       break;
27     }
28     case CFWL_ThemePart::Part::kBackground: {
29       CFGAS_GEGraphics* pGraphics = pParams.GetGraphics();
30       CFGAS_GEGraphics::StateRestorer restorer(pGraphics);
31       const CFGAS_GEPath* pParamsPath = pParams.GetPath();
32       if (pParamsPath) {
33         pGraphics->SetFillColor(CFGAS_GEColor(FWLTHEME_COLOR_BKSelected));
34         pGraphics->FillPath(*pParamsPath,
35                             CFX_FillRenderOptions::FillType::kWinding,
36                             pParams.m_matrix);
37       } else {
38         CFGAS_GEPath path;
39         path.AddRectangle(pParams.m_PartRect.left, pParams.m_PartRect.top,
40                           pParams.m_PartRect.width, pParams.m_PartRect.height);
41         CFGAS_GEColor cr(FWLTHEME_COLOR_Background);
42         if (!pParams.m_bStaticBackground) {
43           if (pParams.m_dwStates & CFWL_PartState::kDisabled)
44             cr = CFGAS_GEColor(FWLTHEME_COLOR_EDGERB1);
45           else if (pParams.m_dwStates & CFWL_PartState::kReadOnly)
46             cr = CFGAS_GEColor(ArgbEncode(255, 236, 233, 216));
47           else
48             cr = CFGAS_GEColor(0xFFFFFFFF);
49         }
50         pGraphics->SetFillColor(cr);
51         pGraphics->FillPath(path, CFX_FillRenderOptions::FillType::kWinding,
52                             pParams.m_matrix);
53       }
54       break;
55     }
56     case CFWL_ThemePart::Part::kCombTextLine: {
57       CFWL_Widget::AdapterIface* pWidget =
58           pParams.GetWidget()->GetOutmost()->GetAdapterIface();
59       FX_ARGB cr = 0xFF000000;
60       float fWidth = 1.0f;
61       pWidget->GetBorderColorAndThickness(&cr, &fWidth);
62       pParams.GetGraphics()->SetStrokeColor(CFGAS_GEColor(cr));
63       pParams.GetGraphics()->SetLineWidth(fWidth);
64       const CFGAS_GEPath* pParamsPath = pParams.GetPath();
65       if (pParamsPath)
66         pParams.GetGraphics()->StrokePath(*pParamsPath, pParams.m_matrix);
67       break;
68     }
69     default:
70       break;
71   }
72 }
73 
74 }  // namespace pdfium
75