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/basewidget/ifwl_scrollbar.h" | 9 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" |
10 #include "xfa/fwl/core/cfwl_themebackground.h" | 10 #include "xfa/fwl/core/cfwl_themebackground.h" |
11 #include "xfa/fwl/core/ifwl_themeprovider.h" | 11 #include "xfa/fwl/core/ifwl_themeprovider.h" |
12 #include "xfa/fwl/core/ifwl_widget.h" | 12 #include "xfa/fwl/core/ifwl_widget.h" |
13 #include "xfa/fxgraphics/cfx_color.h" | 13 #include "xfa/fxgraphics/cfx_color.h" |
14 #include "xfa/fxgraphics/cfx_path.h" | 14 #include "xfa/fxgraphics/cfx_path.h" |
15 | 15 |
16 #define FWL_SCROLL_PawLen 12.5f | 16 namespace { |
| 17 |
| 18 const float kPawLength = 12.5f; |
| 19 |
| 20 } // namespace |
17 | 21 |
18 CFWL_ScrollBarTP::CFWL_ScrollBarTP() : m_pThemeData(new SBThemeData) { | 22 CFWL_ScrollBarTP::CFWL_ScrollBarTP() : m_pThemeData(new SBThemeData) { |
19 SetThemeData(0); | 23 SetThemeData(0); |
20 } | 24 } |
21 | 25 |
22 CFWL_ScrollBarTP::~CFWL_ScrollBarTP() { | 26 CFWL_ScrollBarTP::~CFWL_ScrollBarTP() { |
23 delete m_pThemeData; | 27 delete m_pThemeData; |
24 } | 28 } |
25 | 29 |
26 FX_BOOL CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget* pWidget) { | 30 FX_BOOL CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget* pWidget) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 147 } |
144 } | 148 } |
145 void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, | 149 void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, |
146 const CFX_RectF* pRect, | 150 const CFX_RectF* pRect, |
147 FX_BOOL bVert, | 151 FX_BOOL bVert, |
148 FWLTHEME_STATE eState, | 152 FWLTHEME_STATE eState, |
149 CFX_Matrix* pMatrix) { | 153 CFX_Matrix* pMatrix) { |
150 CFX_Path path; | 154 CFX_Path path; |
151 path.Create(); | 155 path.Create(); |
152 if (bVert) { | 156 if (bVert) { |
153 FX_FLOAT fPawLen = FWL_SCROLL_PawLen; | 157 FX_FLOAT fPawLen = kPawLength; |
154 if (pRect->width / 2 <= fPawLen) { | 158 if (pRect->width / 2 <= fPawLen) { |
155 fPawLen = (pRect->width - 6) / 2; | 159 fPawLen = (pRect->width - 6) / 2; |
156 } | 160 } |
157 FX_FLOAT fX = pRect->left + pRect->width / 4; | 161 FX_FLOAT fX = pRect->left + pRect->width / 4; |
158 FX_FLOAT fY = pRect->top + pRect->height / 2; | 162 FX_FLOAT fY = pRect->top + pRect->height / 2; |
159 path.MoveTo(fX, fY - 4); | 163 path.MoveTo(fX, fY - 4); |
160 path.LineTo(fX + fPawLen, fY - 4); | 164 path.LineTo(fX + fPawLen, fY - 4); |
161 path.MoveTo(fX, fY - 2); | 165 path.MoveTo(fX, fY - 2); |
162 path.LineTo(fX + fPawLen, fY - 2); | 166 path.LineTo(fX + fPawLen, fY - 2); |
163 path.MoveTo(fX, fY); | 167 path.MoveTo(fX, fY); |
(...skipping 12 matching lines...) Expand all Loading... |
176 path.LineTo(fX + fPawLen, fY - 1); | 180 path.LineTo(fX + fPawLen, fY - 1); |
177 path.MoveTo(fX, fY + 1); | 181 path.MoveTo(fX, fY + 1); |
178 path.LineTo(fX + fPawLen, fY + 1); | 182 path.LineTo(fX + fPawLen, fY + 1); |
179 path.MoveTo(fX, fY + 3); | 183 path.MoveTo(fX, fY + 3); |
180 path.LineTo(fX + fPawLen, fY + 3); | 184 path.LineTo(fX + fPawLen, fY + 3); |
181 CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); | 185 CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); |
182 pGraphics->SetLineWidth(1); | 186 pGraphics->SetLineWidth(1); |
183 pGraphics->SetStrokeColor(&clrDark); | 187 pGraphics->SetStrokeColor(&clrDark); |
184 pGraphics->StrokePath(&path, pMatrix); | 188 pGraphics->StrokePath(&path, pMatrix); |
185 } else { | 189 } else { |
186 FX_FLOAT fPawLen = FWL_SCROLL_PawLen; | 190 FX_FLOAT fPawLen = kPawLength; |
187 if (pRect->height / 2 <= fPawLen) { | 191 if (pRect->height / 2 <= fPawLen) { |
188 fPawLen = (pRect->height - 6) / 2; | 192 fPawLen = (pRect->height - 6) / 2; |
189 } | 193 } |
190 FX_FLOAT fX = pRect->left + pRect->width / 2; | 194 FX_FLOAT fX = pRect->left + pRect->width / 2; |
191 FX_FLOAT fY = pRect->top + pRect->height / 4; | 195 FX_FLOAT fY = pRect->top + pRect->height / 4; |
192 path.MoveTo(fX - 4, fY); | 196 path.MoveTo(fX - 4, fY); |
193 path.LineTo(fX - 4, fY + fPawLen); | 197 path.LineTo(fX - 4, fY + fPawLen); |
194 path.MoveTo(fX - 2, fY); | 198 path.MoveTo(fX - 2, fY); |
195 path.LineTo(fX - 2, fY + fPawLen); | 199 path.LineTo(fX - 2, fY + fPawLen); |
196 path.MoveTo(fX, fY); | 200 path.MoveTo(fX, fY); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 218, 230, 254); | 306 m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 218, 230, 254); |
303 m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 207, 221, 253); | 307 m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 207, 221, 253); |
304 m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 131, 158, 216); | 308 m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 131, 158, 216); |
305 m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 167, 190, 245); | 309 m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 167, 190, 245); |
306 m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 146, 179, 249); | 310 m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 146, 179, 249); |
307 m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 124, 159, 211); | 311 m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 124, 159, 211); |
308 m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236); | 312 m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236); |
309 m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251); | 313 m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251); |
310 } | 314 } |
311 } | 315 } |
OLD | NEW |