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_scrollbartp.h" | 7 #include "xfa/fwl/theme/cfwl_scrollbartp.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_scrollbar.h" | 10 #include "xfa/fwl/core/ifwl_scrollbar.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 CFWL_ScrollBarTP::CFWL_ScrollBarTP() : m_pThemeData(new SBThemeData) { | 22 CFWL_ScrollBarTP::CFWL_ScrollBarTP() : m_pThemeData(new SBThemeData) { |
23 SetThemeData(0); | 23 SetThemeData(0); |
24 } | 24 } |
25 | 25 |
26 CFWL_ScrollBarTP::~CFWL_ScrollBarTP() {} | 26 CFWL_ScrollBarTP::~CFWL_ScrollBarTP() {} |
27 | 27 |
28 bool CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget* pWidget) { | 28 bool CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget* pWidget) { |
29 return pWidget && pWidget->GetClassID() == FWL_Type::ScrollBar; | 29 return pWidget && pWidget->GetClassID() == FWL_Type::ScrollBar; |
30 } | 30 } |
| 31 |
31 void* CFWL_ScrollBarTP::GetCapacity(CFWL_ThemePart* pThemePart, | 32 void* CFWL_ScrollBarTP::GetCapacity(CFWL_ThemePart* pThemePart, |
32 CFWL_WidgetCapacity dwCapacity) { | 33 CFWL_WidgetCapacity dwCapacity) { |
33 if (dwCapacity == CFWL_WidgetCapacity::Size) { | 34 if (dwCapacity == CFWL_WidgetCapacity::Size) { |
34 m_fValue = 5; | 35 m_fValue = 5; |
35 return &m_fValue; | 36 return &m_fValue; |
36 } | 37 } |
37 return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); | 38 return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); |
38 } | 39 } |
| 40 |
39 uint32_t CFWL_ScrollBarTP::SetThemeID(IFWL_Widget* pWidget, | 41 uint32_t CFWL_ScrollBarTP::SetThemeID(IFWL_Widget* pWidget, |
40 uint32_t dwThemeID) { | 42 uint32_t dwThemeID) { |
41 if (m_pThemeData) | 43 if (m_pThemeData) |
42 SetThemeData(FWL_GetThemeColor(dwThemeID)); | 44 SetThemeData(FWL_GetThemeColor(dwThemeID)); |
43 return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID); | 45 return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID); |
44 } | 46 } |
45 FX_BOOL CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground* pParams) { | 47 |
| 48 void CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground* pParams) { |
46 if (!pParams) | 49 if (!pParams) |
47 return FALSE; | 50 return; |
| 51 |
48 IFWL_Widget* pWidget = pParams->m_pWidget; | 52 IFWL_Widget* pWidget = pParams->m_pWidget; |
49 FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; | 53 FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; |
50 if (pParams->m_dwStates & CFWL_PartState_Hovered) | 54 if (pParams->m_dwStates & CFWL_PartState_Hovered) |
51 eState = FWLTHEME_STATE_Hover; | 55 eState = FWLTHEME_STATE_Hover; |
52 else if (pParams->m_dwStates & CFWL_PartState_Pressed) | 56 else if (pParams->m_dwStates & CFWL_PartState_Pressed) |
53 eState = FWLTHEME_STATE_Pressed; | 57 eState = FWLTHEME_STATE_Pressed; |
54 else if (pParams->m_dwStates & CFWL_PartState_Disabled) | 58 else if (pParams->m_dwStates & CFWL_PartState_Disabled) |
55 eState = FWLTHEME_STATE_Disabale; | 59 eState = FWLTHEME_STATE_Disable; |
| 60 |
56 CFX_Graphics* pGraphics = pParams->m_pGraphics; | 61 CFX_Graphics* pGraphics = pParams->m_pGraphics; |
57 CFX_RectF* pRect = &pParams->m_rtPart; | 62 CFX_RectF* pRect = &pParams->m_rtPart; |
58 FX_BOOL bVert = pWidget->GetStylesEx(); | 63 FX_BOOL bVert = pWidget->GetStylesEx(); |
59 switch (pParams->m_iPart) { | 64 switch (pParams->m_iPart) { |
60 case CFWL_Part::ForeArrow: { | 65 case CFWL_Part::ForeArrow: { |
61 DrawMaxMinBtn(pGraphics, pRect, | 66 DrawMaxMinBtn(pGraphics, pRect, |
62 bVert ? FWLTHEME_DIRECTION_Up : FWLTHEME_DIRECTION_Left, | 67 bVert ? FWLTHEME_DIRECTION_Up : FWLTHEME_DIRECTION_Left, |
63 eState, &pParams->m_matrix); | 68 eState, &pParams->m_matrix); |
64 break; | 69 break; |
65 } | 70 } |
66 case CFWL_Part::BackArrow: { | 71 case CFWL_Part::BackArrow: { |
67 DrawMaxMinBtn(pGraphics, pRect, | 72 DrawMaxMinBtn(pGraphics, pRect, |
68 bVert ? FWLTHEME_DIRECTION_Down : FWLTHEME_DIRECTION_Right, | 73 bVert ? FWLTHEME_DIRECTION_Down : FWLTHEME_DIRECTION_Right, |
69 eState, &pParams->m_matrix); | 74 eState, &pParams->m_matrix); |
70 break; | 75 break; |
71 } | 76 } |
72 case CFWL_Part::Thumb: { | 77 case CFWL_Part::Thumb: { |
73 DrawThumbBtn(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix); | 78 DrawThumbBtn(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix); |
74 break; | 79 break; |
75 } | 80 } |
76 case CFWL_Part::LowerTrack: { | 81 case CFWL_Part::LowerTrack: { |
77 DrawTrack(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix); | 82 DrawTrack(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix); |
78 break; | 83 break; |
79 } | 84 } |
80 case CFWL_Part::UpperTrack: { | 85 case CFWL_Part::UpperTrack: { |
81 DrawTrack(pGraphics, pRect, bVert, eState, FALSE, &pParams->m_matrix); | 86 DrawTrack(pGraphics, pRect, bVert, eState, FALSE, &pParams->m_matrix); |
82 break; | 87 break; |
83 } | 88 } |
84 default: {} | 89 default: |
| 90 break; |
85 } | 91 } |
86 return TRUE; | |
87 } | 92 } |
88 | 93 |
89 void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics, | 94 void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics, |
90 const CFX_RectF* pRect, | 95 const CFX_RectF* pRect, |
91 FX_BOOL bVert, | 96 FX_BOOL bVert, |
92 FWLTHEME_STATE eState, | 97 FWLTHEME_STATE eState, |
93 FX_BOOL bPawButton, | 98 FX_BOOL bPawButton, |
94 CFX_Matrix* pMatrix) { | 99 CFX_Matrix* pMatrix) { |
95 if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) { | 100 if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disable) |
96 return; | 101 return; |
97 } | 102 |
98 CFX_Path path; | 103 CFX_Path path; |
99 path.Create(); | 104 path.Create(); |
100 CFX_RectF rect(*pRect); | 105 CFX_RectF rect(*pRect); |
101 if (bVert) { | 106 if (bVert) { |
102 rect.Deflate(1, 0); | 107 rect.Deflate(1, 0); |
103 if (rect.IsEmpty(0.1f)) { | 108 if (rect.IsEmpty(0.1f)) |
104 return; | 109 return; |
105 } | 110 |
106 path.AddRectangle(rect.left, rect.top, rect.width, rect.height); | 111 path.AddRectangle(rect.left, rect.top, rect.width, rect.height); |
107 DrawAxialShading(pGraphics, rect.left, rect.top, rect.right(), rect.top, | 112 DrawAxialShading(pGraphics, rect.left, rect.top, rect.right(), rect.top, |
108 m_pThemeData->clrBtnBK[eState - 1][0], | 113 m_pThemeData->clrBtnBK[eState - 1][0], |
109 m_pThemeData->clrBtnBK[eState - 1][1], &path, | 114 m_pThemeData->clrBtnBK[eState - 1][1], &path, |
110 FXFILL_WINDING, pMatrix); | 115 FXFILL_WINDING, pMatrix); |
111 CFX_Color rcStroke; | 116 CFX_Color rcStroke; |
112 rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]); | 117 rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]); |
113 pGraphics->SaveGraphState(); | 118 pGraphics->SaveGraphState(); |
114 pGraphics->SetStrokeColor(&rcStroke); | 119 pGraphics->SetStrokeColor(&rcStroke); |
115 pGraphics->StrokePath(&path, pMatrix); | 120 pGraphics->StrokePath(&path, pMatrix); |
116 pGraphics->RestoreGraphState(); | 121 pGraphics->RestoreGraphState(); |
117 } else { | 122 } else { |
118 rect.Deflate(0, 1); | 123 rect.Deflate(0, 1); |
119 if (rect.IsEmpty(0.1f)) { | 124 if (rect.IsEmpty(0.1f)) |
120 return; | 125 return; |
121 } | 126 |
122 path.AddRectangle(rect.left, rect.top, rect.width, rect.height); | 127 path.AddRectangle(rect.left, rect.top, rect.width, rect.height); |
123 DrawAxialShading(pGraphics, rect.left, rect.top, rect.left, rect.bottom(), | 128 DrawAxialShading(pGraphics, rect.left, rect.top, rect.left, rect.bottom(), |
124 m_pThemeData->clrBtnBK[eState - 1][0], | 129 m_pThemeData->clrBtnBK[eState - 1][0], |
125 m_pThemeData->clrBtnBK[eState - 1][1], &path, | 130 m_pThemeData->clrBtnBK[eState - 1][1], &path, |
126 FXFILL_WINDING, pMatrix); | 131 FXFILL_WINDING, pMatrix); |
127 CFX_Color rcStroke; | 132 CFX_Color rcStroke; |
128 rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]); | 133 rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]); |
129 pGraphics->SaveGraphState(); | 134 pGraphics->SaveGraphState(); |
130 pGraphics->SetStrokeColor(&rcStroke); | 135 pGraphics->SetStrokeColor(&rcStroke); |
131 pGraphics->StrokePath(&path, pMatrix); | 136 pGraphics->StrokePath(&path, pMatrix); |
132 pGraphics->RestoreGraphState(); | 137 pGraphics->RestoreGraphState(); |
133 } | 138 } |
134 } | 139 } |
| 140 |
135 void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, | 141 void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, |
136 const CFX_RectF* pRect, | 142 const CFX_RectF* pRect, |
137 FX_BOOL bVert, | 143 FX_BOOL bVert, |
138 FWLTHEME_STATE eState, | 144 FWLTHEME_STATE eState, |
139 CFX_Matrix* pMatrix) { | 145 CFX_Matrix* pMatrix) { |
140 CFX_Path path; | 146 CFX_Path path; |
141 path.Create(); | 147 path.Create(); |
142 if (bVert) { | 148 if (bVert) { |
143 FX_FLOAT fPawLen = kPawLength; | 149 FX_FLOAT fPawLen = kPawLength; |
144 if (pRect->width / 2 <= fPawLen) { | 150 if (pRect->width / 2 <= fPawLen) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 path.MoveTo(fX + 1, fY); | 206 path.MoveTo(fX + 1, fY); |
201 path.LineTo(fX + 1, fY + fPawLen); | 207 path.LineTo(fX + 1, fY + fPawLen); |
202 path.MoveTo(fX + 3, fY); | 208 path.MoveTo(fX + 3, fY); |
203 path.LineTo(fX + 3, fY + fPawLen); | 209 path.LineTo(fX + 3, fY + fPawLen); |
204 CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); | 210 CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); |
205 pGraphics->SetLineWidth(1); | 211 pGraphics->SetLineWidth(1); |
206 pGraphics->SetStrokeColor(&clrDark); | 212 pGraphics->SetStrokeColor(&clrDark); |
207 pGraphics->StrokePath(&path, pMatrix); | 213 pGraphics->StrokePath(&path, pMatrix); |
208 } | 214 } |
209 } | 215 } |
| 216 |
210 void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics, | 217 void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics, |
211 const CFX_RectF* pRect, | 218 const CFX_RectF* pRect, |
212 FX_BOOL bVert, | 219 FX_BOOL bVert, |
213 FWLTHEME_STATE eState, | 220 FWLTHEME_STATE eState, |
214 FX_BOOL bLowerTrack, | 221 FX_BOOL bLowerTrack, |
215 CFX_Matrix* pMatrix) { | 222 CFX_Matrix* pMatrix) { |
216 if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) { | 223 if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disable) |
217 return; | 224 return; |
218 } | 225 |
219 pGraphics->SaveGraphState(); | 226 pGraphics->SaveGraphState(); |
220 CFX_Color colorLine(ArgbEncode(255, 238, 237, 229)); | 227 CFX_Color colorLine(ArgbEncode(255, 238, 237, 229)); |
221 CFX_Path path; | 228 CFX_Path path; |
222 path.Create(); | 229 path.Create(); |
223 FX_FLOAT fRight = pRect->right(); | 230 FX_FLOAT fRight = pRect->right(); |
224 FX_FLOAT fBottom = pRect->bottom(); | 231 FX_FLOAT fBottom = pRect->bottom(); |
225 if (bVert) { | 232 if (bVert) { |
226 path.AddRectangle(pRect->left, pRect->top, 1, pRect->height); | 233 path.AddRectangle(pRect->left, pRect->top, 1, pRect->height); |
227 path.AddRectangle(fRight - 1, pRect->top, 1, pRect->height); | 234 path.AddRectangle(fRight - 1, pRect->top, 1, pRect->height); |
228 } else { | 235 } else { |
229 path.AddRectangle(pRect->left, pRect->top, pRect->width, 1); | 236 path.AddRectangle(pRect->left, pRect->top, pRect->width, 1); |
230 path.AddRectangle(pRect->left, fBottom - 1, pRect->width, 1); | 237 path.AddRectangle(pRect->left, fBottom - 1, pRect->width, 1); |
231 } | 238 } |
232 pGraphics->SetFillColor(&colorLine); | 239 pGraphics->SetFillColor(&colorLine); |
233 pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); | 240 pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); |
234 path.Clear(); | 241 path.Clear(); |
235 path.AddRectangle(pRect->left + 1, pRect->top, pRect->width - 2, | 242 path.AddRectangle(pRect->left + 1, pRect->top, pRect->width - 2, |
236 pRect->height); | 243 pRect->height); |
237 FX_FLOAT x1 = bVert ? pRect->left + 1 : pRect->left; | 244 FX_FLOAT x1 = bVert ? pRect->left + 1 : pRect->left; |
238 FX_FLOAT y1 = bVert ? pRect->top : pRect->top + 1; | 245 FX_FLOAT y1 = bVert ? pRect->top : pRect->top + 1; |
239 FX_FLOAT x2 = bVert ? fRight - 1 : pRect->left; | 246 FX_FLOAT x2 = bVert ? fRight - 1 : pRect->left; |
240 FX_FLOAT y2 = bVert ? pRect->top : fBottom - 1; | 247 FX_FLOAT y2 = bVert ? pRect->top : fBottom - 1; |
241 pGraphics->RestoreGraphState(); | 248 pGraphics->RestoreGraphState(); |
242 DrawAxialShading(pGraphics, x1, y1, x2, y2, m_pThemeData->clrTrackBKStart, | 249 DrawAxialShading(pGraphics, x1, y1, x2, y2, m_pThemeData->clrTrackBKStart, |
243 m_pThemeData->clrTrackBKEnd, &path, FXFILL_WINDING, pMatrix); | 250 m_pThemeData->clrTrackBKEnd, &path, FXFILL_WINDING, pMatrix); |
244 } | 251 } |
| 252 |
245 void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics* pGraphics, | 253 void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics* pGraphics, |
246 const CFX_RectF* pRect, | 254 const CFX_RectF* pRect, |
247 FWLTHEME_DIRECTION eDict, | 255 FWLTHEME_DIRECTION eDict, |
248 FWLTHEME_STATE eState, | 256 FWLTHEME_STATE eState, |
249 CFX_Matrix* pMatrix) { | 257 CFX_Matrix* pMatrix) { |
250 DrawTrack(pGraphics, pRect, | 258 DrawTrack(pGraphics, pRect, |
251 eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down, | 259 eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down, |
252 eState, TRUE, pMatrix); | 260 eState, TRUE, pMatrix); |
253 CFX_RectF rtArrowBtn(*pRect); | 261 CFX_RectF rtArrowBtn(*pRect); |
254 rtArrowBtn.Deflate(1, 1, 1, 1); | 262 rtArrowBtn.Deflate(1, 1, 1, 1); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 218, 230, 254); | 300 m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 218, 230, 254); |
293 m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 207, 221, 253); | 301 m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 207, 221, 253); |
294 m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 131, 158, 216); | 302 m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 131, 158, 216); |
295 m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 167, 190, 245); | 303 m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 167, 190, 245); |
296 m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 146, 179, 249); | 304 m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 146, 179, 249); |
297 m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 124, 159, 211); | 305 m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 124, 159, 211); |
298 m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236); | 306 m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236); |
299 m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251); | 307 m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251); |
300 } | 308 } |
301 } | 309 } |
OLD | NEW |