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_datetimepickertp.h"
8 
9 #include "xfa/fwl/cfwl_datetimepicker.h"
10 #include "xfa/fwl/cfwl_themebackground.h"
11 
12 CFWL_DateTimePickerTP::CFWL_DateTimePickerTP() = default;
13 
14 CFWL_DateTimePickerTP::~CFWL_DateTimePickerTP() = default;
15 
DrawBackground(const CFWL_ThemeBackground & pParams)16 void CFWL_DateTimePickerTP::DrawBackground(
17     const CFWL_ThemeBackground& pParams) {
18   switch (pParams.m_iPart) {
19     case CFWL_Part::Border:
20       DrawBorder(pParams.m_pGraphics.Get(), pParams.m_PartRect,
21                  pParams.m_matrix);
22       break;
23     case CFWL_Part::DropDownButton:
24       DrawDropDownButton(pParams, pParams.m_matrix);
25       break;
26     default:
27       break;
28   }
29 }
30 
DrawDropDownButton(const CFWL_ThemeBackground & pParams,const CFX_Matrix & matrix)31 void CFWL_DateTimePickerTP::DrawDropDownButton(
32     const CFWL_ThemeBackground& pParams,
33     const CFX_Matrix& matrix) {
34   uint32_t dwStates = pParams.m_dwStates;
35   dwStates &= 0x03;
36   FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
37   switch (eState & dwStates) {
38     case CFWL_PartState_Normal: {
39       eState = FWLTHEME_STATE_Normal;
40       break;
41     }
42     case CFWL_PartState_Hovered: {
43       eState = FWLTHEME_STATE_Hover;
44       break;
45     }
46     case CFWL_PartState_Pressed: {
47       eState = FWLTHEME_STATE_Pressed;
48       break;
49     }
50     case CFWL_PartState_Disabled: {
51       eState = FWLTHEME_STATE_Disable;
52       break;
53     }
54     default:
55       break;
56   }
57   DrawArrowBtn(pParams.m_pGraphics.Get(), pParams.m_PartRect,
58                FWLTHEME_DIRECTION_Down, eState, matrix);
59 }
60