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