xref: /aosp_15_r20/external/pdfium/xfa/fwl/theme/cfwl_edittp.cpp (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1*3ac0a46fSAndroid Build Coastguard Worker // Copyright 2014 The PDFium Authors
2*3ac0a46fSAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*3ac0a46fSAndroid Build Coastguard Worker // found in the LICENSE file.
4*3ac0a46fSAndroid Build Coastguard Worker 
5*3ac0a46fSAndroid Build Coastguard Worker // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6*3ac0a46fSAndroid Build Coastguard Worker 
7*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fwl/theme/cfwl_edittp.h"
8*3ac0a46fSAndroid Build Coastguard Worker 
9*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fgas/graphics/cfgas_gecolor.h"
10*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fgas/graphics/cfgas_gegraphics.h"
11*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fgas/graphics/cfgas_gepath.h"
12*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fwl/cfwl_edit.h"
13*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fwl/cfwl_themebackground.h"
14*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fwl/cfwl_widget.h"
15*3ac0a46fSAndroid Build Coastguard Worker 
16*3ac0a46fSAndroid Build Coastguard Worker CFWL_EditTP::CFWL_EditTP() = default;
17*3ac0a46fSAndroid Build Coastguard Worker 
18*3ac0a46fSAndroid Build Coastguard Worker CFWL_EditTP::~CFWL_EditTP() = default;
19*3ac0a46fSAndroid Build Coastguard Worker 
DrawBackground(const CFWL_ThemeBackground & pParams)20*3ac0a46fSAndroid Build Coastguard Worker void CFWL_EditTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
21*3ac0a46fSAndroid Build Coastguard Worker   switch (pParams.GetPart()) {
22*3ac0a46fSAndroid Build Coastguard Worker     case CFWL_ThemePart::Part::kBorder: {
23*3ac0a46fSAndroid Build Coastguard Worker       DrawBorder(pParams.GetGraphics(), pParams.m_PartRect, pParams.m_matrix);
24*3ac0a46fSAndroid Build Coastguard Worker       break;
25*3ac0a46fSAndroid Build Coastguard Worker     }
26*3ac0a46fSAndroid Build Coastguard Worker     case CFWL_ThemePart::Part::kBackground: {
27*3ac0a46fSAndroid Build Coastguard Worker       CFGAS_GEGraphics* pGraphics = pParams.GetGraphics();
28*3ac0a46fSAndroid Build Coastguard Worker       CFGAS_GEGraphics::StateRestorer restorer(pGraphics);
29*3ac0a46fSAndroid Build Coastguard Worker       const CFGAS_GEPath* pParamsPath = pParams.GetPath();
30*3ac0a46fSAndroid Build Coastguard Worker       if (pParamsPath) {
31*3ac0a46fSAndroid Build Coastguard Worker         pGraphics->SetFillColor(CFGAS_GEColor(FWLTHEME_COLOR_BKSelected));
32*3ac0a46fSAndroid Build Coastguard Worker         pGraphics->FillPath(*pParamsPath,
33*3ac0a46fSAndroid Build Coastguard Worker                             CFX_FillRenderOptions::FillType::kWinding,
34*3ac0a46fSAndroid Build Coastguard Worker                             pParams.m_matrix);
35*3ac0a46fSAndroid Build Coastguard Worker       } else {
36*3ac0a46fSAndroid Build Coastguard Worker         CFGAS_GEPath path;
37*3ac0a46fSAndroid Build Coastguard Worker         path.AddRectangle(pParams.m_PartRect.left, pParams.m_PartRect.top,
38*3ac0a46fSAndroid Build Coastguard Worker                           pParams.m_PartRect.width, pParams.m_PartRect.height);
39*3ac0a46fSAndroid Build Coastguard Worker         CFGAS_GEColor cr(FWLTHEME_COLOR_Background);
40*3ac0a46fSAndroid Build Coastguard Worker         if (!pParams.m_bStaticBackground) {
41*3ac0a46fSAndroid Build Coastguard Worker           if (pParams.m_dwStates & CFWL_PartState::kDisabled)
42*3ac0a46fSAndroid Build Coastguard Worker             cr = CFGAS_GEColor(FWLTHEME_COLOR_EDGERB1);
43*3ac0a46fSAndroid Build Coastguard Worker           else if (pParams.m_dwStates & CFWL_PartState::kReadOnly)
44*3ac0a46fSAndroid Build Coastguard Worker             cr = CFGAS_GEColor(ArgbEncode(255, 236, 233, 216));
45*3ac0a46fSAndroid Build Coastguard Worker           else
46*3ac0a46fSAndroid Build Coastguard Worker             cr = CFGAS_GEColor(0xFFFFFFFF);
47*3ac0a46fSAndroid Build Coastguard Worker         }
48*3ac0a46fSAndroid Build Coastguard Worker         pGraphics->SetFillColor(cr);
49*3ac0a46fSAndroid Build Coastguard Worker         pGraphics->FillPath(path, CFX_FillRenderOptions::FillType::kWinding,
50*3ac0a46fSAndroid Build Coastguard Worker                             pParams.m_matrix);
51*3ac0a46fSAndroid Build Coastguard Worker       }
52*3ac0a46fSAndroid Build Coastguard Worker       break;
53*3ac0a46fSAndroid Build Coastguard Worker     }
54*3ac0a46fSAndroid Build Coastguard Worker     case CFWL_ThemePart::Part::kCombTextLine: {
55*3ac0a46fSAndroid Build Coastguard Worker       CFWL_Widget::AdapterIface* pWidget =
56*3ac0a46fSAndroid Build Coastguard Worker           pParams.GetWidget()->GetOutmost()->GetAdapterIface();
57*3ac0a46fSAndroid Build Coastguard Worker       FX_ARGB cr = 0xFF000000;
58*3ac0a46fSAndroid Build Coastguard Worker       float fWidth = 1.0f;
59*3ac0a46fSAndroid Build Coastguard Worker       pWidget->GetBorderColorAndThickness(&cr, &fWidth);
60*3ac0a46fSAndroid Build Coastguard Worker       pParams.GetGraphics()->SetStrokeColor(CFGAS_GEColor(cr));
61*3ac0a46fSAndroid Build Coastguard Worker       pParams.GetGraphics()->SetLineWidth(fWidth);
62*3ac0a46fSAndroid Build Coastguard Worker       const CFGAS_GEPath* pParamsPath = pParams.GetPath();
63*3ac0a46fSAndroid Build Coastguard Worker       if (pParamsPath)
64*3ac0a46fSAndroid Build Coastguard Worker         pParams.GetGraphics()->StrokePath(*pParamsPath, pParams.m_matrix);
65*3ac0a46fSAndroid Build Coastguard Worker       break;
66*3ac0a46fSAndroid Build Coastguard Worker     }
67*3ac0a46fSAndroid Build Coastguard Worker     default:
68*3ac0a46fSAndroid Build Coastguard Worker       break;
69*3ac0a46fSAndroid Build Coastguard Worker   }
70*3ac0a46fSAndroid Build Coastguard Worker }
71