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_comboboxtp.h"
8
9 #include "core/fxge/render_defines.h"
10 #include "xfa/fwl/cfwl_combobox.h"
11 #include "xfa/fwl/cfwl_themebackground.h"
12 #include "xfa/fwl/cfwl_widget.h"
13 #include "xfa/fwl/ifwl_themeprovider.h"
14 #include "xfa/fxgraphics/cxfa_gecolor.h"
15 #include "xfa/fxgraphics/cxfa_gepath.h"
16
17 CFWL_ComboBoxTP::CFWL_ComboBoxTP() = default;
18
19 CFWL_ComboBoxTP::~CFWL_ComboBoxTP() = default;
20
DrawBackground(const CFWL_ThemeBackground & pParams)21 void CFWL_ComboBoxTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
22 switch (pParams.m_iPart) {
23 case CFWL_Part::Border: {
24 DrawBorder(pParams.m_pGraphics.Get(), pParams.m_rtPart, pParams.m_matrix);
25 break;
26 }
27 case CFWL_Part::Background: {
28 CXFA_GEPath path;
29 const CFX_RectF& rect = pParams.m_rtPart;
30 path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
31 FX_ARGB argb_color;
32 switch (pParams.m_dwStates) {
33 case CFWL_PartState_Selected:
34 argb_color = FWLTHEME_COLOR_BKSelected;
35 break;
36 case CFWL_PartState_Disabled:
37 argb_color = FWLTHEME_COLOR_EDGERB1;
38 break;
39 default:
40 argb_color = 0xFFFFFFFF;
41 }
42 pParams.m_pGraphics->SaveGraphState();
43 pParams.m_pGraphics->SetFillColor(CXFA_GEColor(argb_color));
44 pParams.m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams.m_matrix);
45 pParams.m_pGraphics->RestoreGraphState();
46 break;
47 }
48 case CFWL_Part::DropDownButton: {
49 DrawDropDownButton(pParams, pParams.m_dwStates, pParams.m_matrix);
50 break;
51 }
52 default:
53 break;
54 }
55 }
56
DrawDropDownButton(const CFWL_ThemeBackground & pParams,uint32_t dwStates,const CFX_Matrix & matrix)57 void CFWL_ComboBoxTP::DrawDropDownButton(const CFWL_ThemeBackground& pParams,
58 uint32_t dwStates,
59 const CFX_Matrix& matrix) {
60 FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
61 switch (dwStates) {
62 case CFWL_PartState_Normal: {
63 eState = FWLTHEME_STATE_Normal;
64 break;
65 }
66 case CFWL_PartState_Hovered: {
67 eState = FWLTHEME_STATE_Hover;
68 break;
69 }
70 case CFWL_PartState_Pressed: {
71 eState = FWLTHEME_STATE_Pressed;
72 break;
73 }
74 case CFWL_PartState_Disabled: {
75 eState = FWLTHEME_STATE_Disable;
76 break;
77 }
78 default:
79 break;
80 }
81 DrawArrowBtn(pParams.m_pGraphics.Get(), pParams.m_rtPart,
82 FWLTHEME_DIRECTION_Down, eState, pParams.m_matrix);
83 }
84