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_comboboxtp.h"
8
9 #include "xfa/fgas/graphics/cfgas_gecolor.h"
10 #include "xfa/fgas/graphics/cfgas_gepath.h"
11 #include "xfa/fwl/cfwl_combobox.h"
12 #include "xfa/fwl/cfwl_themebackground.h"
13 #include "xfa/fwl/cfwl_widget.h"
14 #include "xfa/fwl/ifwl_themeprovider.h"
15
16 CFWL_ComboBoxTP::CFWL_ComboBoxTP() = default;
17
18 CFWL_ComboBoxTP::~CFWL_ComboBoxTP() = default;
19
DrawBackground(const CFWL_ThemeBackground & pParams)20 void CFWL_ComboBoxTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
21 switch (pParams.GetPart()) {
22 case CFWL_ThemePart::Part::kBorder: {
23 DrawBorder(pParams.GetGraphics(), pParams.m_PartRect, pParams.m_matrix);
24 break;
25 }
26 case CFWL_ThemePart::Part::kBackground: {
27 CFGAS_GEPath path;
28 const CFX_RectF& rect = pParams.m_PartRect;
29 path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
30 FX_ARGB argb_color;
31 if (pParams.m_dwStates & CFWL_PartState::kSelected)
32 argb_color = FWLTHEME_COLOR_BKSelected;
33 else if (pParams.m_dwStates & CFWL_PartState::kDisabled)
34 argb_color = FWLTHEME_COLOR_EDGERB1;
35 else
36 argb_color = 0xFFFFFFFF;
37
38 CFGAS_GEGraphics::StateRestorer restorer(pParams.GetGraphics());
39 pParams.GetGraphics()->SetFillColor(CFGAS_GEColor(argb_color));
40 pParams.GetGraphics()->FillPath(
41 path, CFX_FillRenderOptions::FillType::kWinding, pParams.m_matrix);
42 break;
43 }
44 case CFWL_ThemePart::Part::kDropDownButton: {
45 DrawArrowBtn(pParams.GetGraphics(), pParams.m_PartRect,
46 FWLTHEME_DIRECTION::kDown, pParams.GetThemeState(),
47 pParams.m_matrix);
48 break;
49 }
50 default:
51 break;
52 }
53 }
54