| OLD | NEW |
| (Empty) |
| 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/include/fwl/theme/listboxtp.h" | |
| 8 | |
| 9 #include "xfa/fwl/basewidget/ifwl_listbox.h" | |
| 10 #include "xfa/fwl/core/cfwl_themebackground.h" | |
| 11 #include "xfa/fwl/core/ifwl_widget.h" | |
| 12 #include "xfa/fxgraphics/cfx_color.h" | |
| 13 #include "xfa/fxgraphics/cfx_path.h" | |
| 14 | |
| 15 CFWL_ListBoxTP::CFWL_ListBoxTP() {} | |
| 16 CFWL_ListBoxTP::~CFWL_ListBoxTP() {} | |
| 17 | |
| 18 FX_BOOL CFWL_ListBoxTP::IsValidWidget(IFWL_Widget* pWidget) { | |
| 19 if (!pWidget) | |
| 20 return FALSE; | |
| 21 return pWidget->GetClassID() == FWL_CLASSHASH_ListBox; | |
| 22 } | |
| 23 FX_BOOL CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { | |
| 24 if (!pParams) | |
| 25 return FALSE; | |
| 26 switch (pParams->m_iPart) { | |
| 27 case FWL_PART_LTB_Border: { | |
| 28 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); | |
| 29 break; | |
| 30 } | |
| 31 case FWL_PART_LTB_Edge: { | |
| 32 DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), | |
| 33 &pParams->m_rtPart, &pParams->m_matrix); | |
| 34 break; | |
| 35 } | |
| 36 case FWL_PART_LTB_Background: { | |
| 37 FillSoildRect(pParams->m_pGraphics, ArgbEncode(255, 255, 255, 255), | |
| 38 &pParams->m_rtPart, &pParams->m_matrix); | |
| 39 if (pParams->m_pData) { | |
| 40 FillSoildRect(pParams->m_pGraphics, FWLTHEME_COLOR_Background, | |
| 41 (CFX_RectF*)pParams->m_pData, &pParams->m_matrix); | |
| 42 } | |
| 43 break; | |
| 44 } | |
| 45 case FWL_PART_LTB_ListItem: { | |
| 46 DrawListBoxItem(pParams->m_pGraphics, pParams->m_dwStates, | |
| 47 &pParams->m_rtPart, pParams->m_pData, &pParams->m_matrix); | |
| 48 break; | |
| 49 } | |
| 50 case FWL_PART_LTB_Icon: { | |
| 51 pParams->m_pGraphics->StretchImage(pParams->m_pImage, pParams->m_rtPart, | |
| 52 &pParams->m_matrix); | |
| 53 break; | |
| 54 } | |
| 55 case FWL_PART_LTB_Check: { | |
| 56 uint32_t color = 0xFF000000; | |
| 57 if (pParams->m_dwStates == FWL_PARTSTATE_LTB_Checked) { | |
| 58 color = 0xFFFF0000; | |
| 59 } else if (pParams->m_dwStates == FWL_PARTSTATE_LTB_UnChecked) { | |
| 60 color = 0xFF0000FF; | |
| 61 } | |
| 62 FillSoildRect(pParams->m_pGraphics, color, &pParams->m_rtPart, | |
| 63 &pParams->m_matrix); | |
| 64 } | |
| 65 default: {} | |
| 66 } | |
| 67 return TRUE; | |
| 68 } | |
| 69 FWL_ERR CFWL_ListBoxTP::Initialize() { | |
| 70 InitTTO(); | |
| 71 return CFWL_WidgetTP::Initialize(); | |
| 72 } | |
| 73 FWL_ERR CFWL_ListBoxTP::Finalize() { | |
| 74 FinalizeTTO(); | |
| 75 return CFWL_WidgetTP::Finalize(); | |
| 76 } | |
| 77 void CFWL_ListBoxTP::DrawListBoxItem(CFX_Graphics* pGraphics, | |
| 78 uint32_t dwStates, | |
| 79 const CFX_RectF* prtItem, | |
| 80 void* pData, | |
| 81 CFX_Matrix* pMatrix) { | |
| 82 if (dwStates & FWL_PARTSTATE_LTB_Selected) { | |
| 83 pGraphics->SaveGraphState(); | |
| 84 CFX_Color crFill(FWL_GetThemeColor(m_dwThemeID) == 0 | |
| 85 ? FWLTHEME_COLOR_BKSelected | |
| 86 : FWLTHEME_COLOR_Green_BKSelected); | |
| 87 pGraphics->SetFillColor(&crFill); | |
| 88 CFX_RectF rt(*prtItem); | |
| 89 CFX_Path path; | |
| 90 path.Create(); | |
| 91 #if (_FX_OS_ == _FX_MACOSX_) | |
| 92 path.AddRectangle(rt.left, rt.top, rt.width - 1, rt.height - 1); | |
| 93 #else | |
| 94 path.AddRectangle(rt.left, rt.top, rt.width, rt.height); | |
| 95 #endif | |
| 96 pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); | |
| 97 pGraphics->RestoreGraphState(); | |
| 98 } | |
| 99 if (dwStates & FWL_PARTSTATE_LTB_Focused) { | |
| 100 if (pData) { | |
| 101 DrawFocus(pGraphics, (CFX_RectF*)pData, pMatrix); | |
| 102 } | |
| 103 } | |
| 104 } | |
| OLD | NEW |