xref: /aosp_15_r20/external/pdfium/xfa/fwl/theme/cfwl_comboboxtp.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_comboboxtp.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_gepath.h"
11*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fwl/cfwl_combobox.h"
12*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fwl/cfwl_themebackground.h"
13*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fwl/cfwl_widget.h"
14*3ac0a46fSAndroid Build Coastguard Worker #include "xfa/fwl/ifwl_themeprovider.h"
15*3ac0a46fSAndroid Build Coastguard Worker 
16*3ac0a46fSAndroid Build Coastguard Worker CFWL_ComboBoxTP::CFWL_ComboBoxTP() = default;
17*3ac0a46fSAndroid Build Coastguard Worker 
18*3ac0a46fSAndroid Build Coastguard Worker CFWL_ComboBoxTP::~CFWL_ComboBoxTP() = default;
19*3ac0a46fSAndroid Build Coastguard Worker 
DrawBackground(const CFWL_ThemeBackground & pParams)20*3ac0a46fSAndroid Build Coastguard Worker void CFWL_ComboBoxTP::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_GEPath path;
28*3ac0a46fSAndroid Build Coastguard Worker       const CFX_RectF& rect = pParams.m_PartRect;
29*3ac0a46fSAndroid Build Coastguard Worker       path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
30*3ac0a46fSAndroid Build Coastguard Worker       FX_ARGB argb_color;
31*3ac0a46fSAndroid Build Coastguard Worker       if (pParams.m_dwStates & CFWL_PartState::kSelected)
32*3ac0a46fSAndroid Build Coastguard Worker         argb_color = FWLTHEME_COLOR_BKSelected;
33*3ac0a46fSAndroid Build Coastguard Worker       else if (pParams.m_dwStates & CFWL_PartState::kDisabled)
34*3ac0a46fSAndroid Build Coastguard Worker         argb_color = FWLTHEME_COLOR_EDGERB1;
35*3ac0a46fSAndroid Build Coastguard Worker       else
36*3ac0a46fSAndroid Build Coastguard Worker         argb_color = 0xFFFFFFFF;
37*3ac0a46fSAndroid Build Coastguard Worker 
38*3ac0a46fSAndroid Build Coastguard Worker       CFGAS_GEGraphics::StateRestorer restorer(pParams.GetGraphics());
39*3ac0a46fSAndroid Build Coastguard Worker       pParams.GetGraphics()->SetFillColor(CFGAS_GEColor(argb_color));
40*3ac0a46fSAndroid Build Coastguard Worker       pParams.GetGraphics()->FillPath(
41*3ac0a46fSAndroid Build Coastguard Worker           path, CFX_FillRenderOptions::FillType::kWinding, pParams.m_matrix);
42*3ac0a46fSAndroid Build Coastguard Worker       break;
43*3ac0a46fSAndroid Build Coastguard Worker     }
44*3ac0a46fSAndroid Build Coastguard Worker     case CFWL_ThemePart::Part::kDropDownButton: {
45*3ac0a46fSAndroid Build Coastguard Worker       DrawArrowBtn(pParams.GetGraphics(), pParams.m_PartRect,
46*3ac0a46fSAndroid Build Coastguard Worker                    FWLTHEME_DIRECTION::kDown, pParams.GetThemeState(),
47*3ac0a46fSAndroid Build Coastguard Worker                    pParams.m_matrix);
48*3ac0a46fSAndroid Build Coastguard Worker       break;
49*3ac0a46fSAndroid Build Coastguard Worker     }
50*3ac0a46fSAndroid Build Coastguard Worker     default:
51*3ac0a46fSAndroid Build Coastguard Worker       break;
52*3ac0a46fSAndroid Build Coastguard Worker   }
53*3ac0a46fSAndroid Build Coastguard Worker }
54