| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fwl/theme/cfwl_listboxtp.h" | 7 #include "xfa/fwl/theme/cfwl_listboxtp.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/core/cfwl_themebackground.h" | 9 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 10 #include "xfa/fwl/core/ifwl_listbox.h" | 10 #include "xfa/fwl/core/ifwl_listbox.h" |
| 11 #include "xfa/fwl/core/ifwl_widget.h" | 11 #include "xfa/fwl/core/ifwl_widget.h" |
| 12 #include "xfa/fxgraphics/cfx_color.h" | 12 #include "xfa/fxgraphics/cfx_color.h" |
| 13 #include "xfa/fxgraphics/cfx_path.h" | 13 #include "xfa/fxgraphics/cfx_path.h" |
| 14 | 14 |
| 15 CFWL_ListBoxTP::CFWL_ListBoxTP() {} | 15 CFWL_ListBoxTP::CFWL_ListBoxTP() {} |
| 16 | 16 |
| 17 CFWL_ListBoxTP::~CFWL_ListBoxTP() {} | 17 CFWL_ListBoxTP::~CFWL_ListBoxTP() {} |
| 18 | 18 |
| 19 bool CFWL_ListBoxTP::IsValidWidget(IFWL_Widget* pWidget) { | 19 bool CFWL_ListBoxTP::IsValidWidget(IFWL_Widget* pWidget) { |
| 20 return pWidget && pWidget->GetClassID() == FWL_Type::ListBox; | 20 return pWidget && pWidget->GetClassID() == FWL_Type::ListBox; |
| 21 } | 21 } |
| 22 | 22 |
| 23 FX_BOOL CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { | 23 void CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { |
| 24 if (!pParams) | 24 if (!pParams) |
| 25 return FALSE; | 25 return; |
| 26 |
| 26 switch (pParams->m_iPart) { | 27 switch (pParams->m_iPart) { |
| 27 case CFWL_Part::Border: { | 28 case CFWL_Part::Border: { |
| 28 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); | 29 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); |
| 29 break; | 30 break; |
| 30 } | 31 } |
| 31 case CFWL_Part::Edge: { | 32 case CFWL_Part::Edge: { |
| 32 DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), | 33 DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), |
| 33 &pParams->m_rtPart, &pParams->m_matrix); | 34 &pParams->m_rtPart, &pParams->m_matrix); |
| 34 break; | 35 break; |
| 35 } | 36 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 55 case CFWL_Part::Check: { | 56 case CFWL_Part::Check: { |
| 56 uint32_t color = 0xFF000000; | 57 uint32_t color = 0xFF000000; |
| 57 if (pParams->m_dwStates == CFWL_PartState_Checked) { | 58 if (pParams->m_dwStates == CFWL_PartState_Checked) { |
| 58 color = 0xFFFF0000; | 59 color = 0xFFFF0000; |
| 59 } else if (pParams->m_dwStates == CFWL_PartState_Normal) { | 60 } else if (pParams->m_dwStates == CFWL_PartState_Normal) { |
| 60 color = 0xFF0000FF; | 61 color = 0xFF0000FF; |
| 61 } | 62 } |
| 62 FillSoildRect(pParams->m_pGraphics, color, &pParams->m_rtPart, | 63 FillSoildRect(pParams->m_pGraphics, color, &pParams->m_rtPart, |
| 63 &pParams->m_matrix); | 64 &pParams->m_matrix); |
| 64 } | 65 } |
| 65 default: {} | 66 default: |
| 67 break; |
| 66 } | 68 } |
| 67 return TRUE; | |
| 68 } | 69 } |
| 69 FWL_Error CFWL_ListBoxTP::Initialize() { | 70 |
| 71 void CFWL_ListBoxTP::Initialize() { |
| 70 InitTTO(); | 72 InitTTO(); |
| 71 return CFWL_WidgetTP::Initialize(); | 73 CFWL_WidgetTP::Initialize(); |
| 72 } | 74 } |
| 73 FWL_Error CFWL_ListBoxTP::Finalize() { | 75 |
| 76 void CFWL_ListBoxTP::Finalize() { |
| 74 FinalizeTTO(); | 77 FinalizeTTO(); |
| 75 return CFWL_WidgetTP::Finalize(); | 78 CFWL_WidgetTP::Finalize(); |
| 76 } | 79 } |
| 80 |
| 77 void CFWL_ListBoxTP::DrawListBoxItem(CFX_Graphics* pGraphics, | 81 void CFWL_ListBoxTP::DrawListBoxItem(CFX_Graphics* pGraphics, |
| 78 uint32_t dwStates, | 82 uint32_t dwStates, |
| 79 const CFX_RectF* prtItem, | 83 const CFX_RectF* prtItem, |
| 80 void* pData, | 84 void* pData, |
| 81 CFX_Matrix* pMatrix) { | 85 CFX_Matrix* pMatrix) { |
| 82 if (dwStates & CFWL_PartState_Selected) { | 86 if (dwStates & CFWL_PartState_Selected) { |
| 83 pGraphics->SaveGraphState(); | 87 pGraphics->SaveGraphState(); |
| 84 CFX_Color crFill(FWL_GetThemeColor(m_dwThemeID) == 0 | 88 CFX_Color crFill(FWL_GetThemeColor(m_dwThemeID) == 0 |
| 85 ? FWLTHEME_COLOR_BKSelected | 89 ? FWLTHEME_COLOR_BKSelected |
| 86 : FWLTHEME_COLOR_Green_BKSelected); | 90 : FWLTHEME_COLOR_Green_BKSelected); |
| 87 pGraphics->SetFillColor(&crFill); | 91 pGraphics->SetFillColor(&crFill); |
| 88 CFX_RectF rt(*prtItem); | 92 CFX_RectF rt(*prtItem); |
| 89 CFX_Path path; | 93 CFX_Path path; |
| 90 path.Create(); | 94 path.Create(); |
| 91 #if (_FX_OS_ == _FX_MACOSX_) | 95 #if (_FX_OS_ == _FX_MACOSX_) |
| 92 path.AddRectangle(rt.left, rt.top, rt.width - 1, rt.height - 1); | 96 path.AddRectangle(rt.left, rt.top, rt.width - 1, rt.height - 1); |
| 93 #else | 97 #else |
| 94 path.AddRectangle(rt.left, rt.top, rt.width, rt.height); | 98 path.AddRectangle(rt.left, rt.top, rt.width, rt.height); |
| 95 #endif | 99 #endif |
| 96 pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); | 100 pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); |
| 97 pGraphics->RestoreGraphState(); | 101 pGraphics->RestoreGraphState(); |
| 98 } | 102 } |
| 99 if (dwStates & CFWL_PartState_Focused) { | 103 if (dwStates & CFWL_PartState_Focused && pData) |
| 100 if (pData) { | 104 DrawFocus(pGraphics, (CFX_RectF*)pData, pMatrix); |
| 101 DrawFocus(pGraphics, (CFX_RectF*)pData, pMatrix); | |
| 102 } | |
| 103 } | |
| 104 } | 105 } |
| OLD | NEW |