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