Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fwl / src / theme / checkboxtp.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../../foxitlib.h"\r
8 #define CHECKBOX_SIZE_SIGNMARGIN                3\r
9 #define CHECKBOX_SIZE_SIGNBORDER                2\r
10 #define CHECKBOX_SIZE_SIGNPATH                  100\r
11 #define CHECKBOX_COLOR_BOXLT1           (ArgbEncode(255, 172, 168, 153))\r
12 #define CHECKBOX_COLOR_BOXLT2           (ArgbEncode(255, 113, 111, 100))\r
13 #define CHECKBOX_COLOR_BOXRB1           (ArgbEncode(255, 241, 239, 226))\r
14 #define CHECKBOX_COLOR_BOXRB2           (ArgbEncode(255, 255, 255, 255))\r
15 #define CHECKBOX_FXGE_CoordinatesAdjust\r
16 CFWL_CheckBoxTP::CFWL_CheckBoxTP()\r
17     : m_pCheckPath(NULL)\r
18 {\r
19     m_pThemeData = FX_NEW CKBThemeData;\r
20     SetThemeData(0);\r
21 }\r
22 CFWL_CheckBoxTP::~CFWL_CheckBoxTP()\r
23 {\r
24     if (m_pThemeData) {\r
25         delete m_pThemeData;\r
26         m_pThemeData = NULL;\r
27     }\r
28     if (m_pCheckPath) {\r
29         m_pCheckPath->Clear();\r
30         delete m_pCheckPath;\r
31         m_pCheckPath = NULL;\r
32     }\r
33 }\r
34 FX_BOOL CFWL_CheckBoxTP::IsValidWidget(IFWL_Widget *pWidget)\r
35 {\r
36     _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);\r
37     FX_DWORD dwHash = pWidget->GetClassID();\r
38     return dwHash == FWL_CLASSHASH_CheckBox || dwHash == FWL_CLASSHASH_RadioButton;\r
39 }\r
40 FX_DWORD CFWL_CheckBoxTP::SetThemeID(IFWL_Widget *pWidget, FX_DWORD dwThemeID, FX_BOOL bChildren )\r
41 {\r
42     if (m_pThemeData) {\r
43         SetThemeData(FWL_GetThemeColor(dwThemeID));\r
44     }\r
45     return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);\r
46 }\r
47 FX_BOOL CFWL_CheckBoxTP::DrawText(CFWL_ThemeText *pParams)\r
48 {\r
49     _FWL_RETURN_VALUE_IF_FAIL(m_pTextOut, FALSE);\r
50     FX_BOOL bDisable = (pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled;\r
51     FX_ARGB argText = bDisable ? FWLTHEME_CAPACITY_TextDisColor : FWLTHEME_CAPACITY_TextColor;\r
52     m_pTextOut->SetTextColor(argText);\r
53     return CFWL_WidgetTP::DrawText(pParams);\r
54 }\r
55 FX_BOOL CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground *pParams)\r
56 {\r
57     _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);\r
58     switch(pParams->m_iPart) {\r
59         case FWL_PART_CKB_Border: {\r
60                 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);\r
61                 break;\r
62             }\r
63         case FWL_PART_CKB_Edge: {\r
64                 DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);\r
65                 break;\r
66             }\r
67         case FWL_PART_CKB_Background: {\r
68                 FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);\r
69                 if (pParams->m_dwStates & FWL_PARTSTATE_CKB_Focused) {\r
70                     pParams->m_rtPart = *(CFX_RectF*)pParams->m_pData;\r
71                     DrawFocus(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);\r
72                 }\r
73                 break;\r
74             }\r
75         case FWL_PART_CKB_CheckBox: {\r
76                 DrawBoxBk(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, pParams->m_dwStates, &pParams->m_matrix);\r
77                 if (((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) |\r
78                         ((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Neutral)) {\r
79                     DrawSign(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, pParams->m_dwStates, &pParams->m_matrix);\r
80                 }\r
81                 FX_BOOL bDisable = (pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled;\r
82                 DrawSignBorder(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, bDisable, &pParams->m_matrix);\r
83                 break;\r
84             }\r
85         default: {\r
86                 return FALSE;\r
87             }\r
88     }\r
89     return TRUE;\r
90 }\r
91 FWL_ERR CFWL_CheckBoxTP::Initialize()\r
92 {\r
93     InitTTO();\r
94     return CFWL_WidgetTP::Initialize();\r
95 }\r
96 FWL_ERR CFWL_CheckBoxTP::Finalize()\r
97 {\r
98     FinalizeTTO();\r
99     return CFWL_WidgetTP::Finalize();\r
100 }\r
101 void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_RectF *pRect, FX_DWORD dwStates, CFX_Matrix *pMatrix )\r
102 {\r
103     dwStates &= 0x03;\r
104     FX_INT32 fillMode = FXFILL_WINDING;\r
105     FX_DWORD dwStyleEx = pWidget->GetStylesEx();\r
106     dwStyleEx &= FWL_STYLEEXT_CKB_ShapeMask;\r
107     CFX_Path path;\r
108     path.Create();\r
109     FX_FLOAT fRight = pRect->right();\r
110     FX_FLOAT fBottom = pRect->bottom();\r
111     FX_BOOL bClipSign = (dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered;\r
112     if ((dwStyleEx == FWL_STYLEEXT_CKB_ShapeSolidSquare) || (dwStyleEx == FWL_STYLEEXT_CKB_ShapeSunkenSquare)) {\r
113         path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);\r
114         if (bClipSign) {\r
115             fillMode = FXFILL_ALTERNATE;\r
116             path.AddRectangle(pRect->left + CHECKBOX_SIZE_SIGNMARGIN,\r
117                               pRect->top + CHECKBOX_SIZE_SIGNMARGIN,\r
118                               pRect->width - CHECKBOX_SIZE_SIGNMARGIN * 2,\r
119                               pRect->height - CHECKBOX_SIZE_SIGNMARGIN * 2);\r
120         }\r
121     } else {\r
122 #ifdef CHECKBOX_FXGE_CoordinatesAdjust\r
123         CFX_RectF rect(*pRect);\r
124         rect.Deflate(0, 0, 1, 1);\r
125         path.AddEllipse(rect);\r
126 #else\r
127         path.AddEllipse(*pRect);\r
128 #endif\r
129         if (bClipSign) {\r
130             fillMode = FXFILL_ALTERNATE;\r
131 #ifdef CHECKBOX_FXGE_CoordinatesAdjust\r
132             CFX_RectF rtClip(rect);\r
133 #else\r
134             CFX_RectF rtClip(*pRect);\r
135 #endif\r
136             rtClip.Deflate(CHECKBOX_SIZE_SIGNMARGIN - 1, CHECKBOX_SIZE_SIGNMARGIN - 1);\r
137             path.AddEllipse(rtClip);\r
138         }\r
139     }\r
140     FX_INT32 iTheme = 1;\r
141     if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered) {\r
142         iTheme = 2;\r
143     } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Pressed) {\r
144         iTheme = 3;\r
145     } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled) {\r
146         iTheme = 4;\r
147     }\r
148     if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) {\r
149         iTheme += 4;\r
150     } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Neutral) {\r
151         iTheme += 8;\r
152     }\r
153     DrawAxialShading(pGraphics, pRect->left - 1, pRect->top - 1, fRight,\r
154                      fBottom, m_pThemeData->clrBoxBk[iTheme][0],\r
155                      m_pThemeData->clrBoxBk[iTheme][1], &path, fillMode, pMatrix);\r
156 }\r
157 void CFWL_CheckBoxTP::DrawSign(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_RectF *pRtBox, FX_DWORD dwStates, CFX_Matrix *pMatrix )\r
158 {\r
159     CFX_RectF rtSign(*pRtBox);\r
160     rtSign.Deflate(CHECKBOX_SIZE_SIGNMARGIN, CHECKBOX_SIZE_SIGNMARGIN);\r
161     FX_DWORD dwColor = m_pThemeData->clrSignCheck;\r
162     FX_BOOL bCheck = TRUE;\r
163     if (((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled) &&\r
164             ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked)) {\r
165         dwColor = m_pThemeData->clrSignBorderDisable;\r
166     } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Neutral) {\r
167         switch (dwStates & FWL_PARTSTATE_CKB_Mask1) {\r
168             case FWL_PARTSTATE_CKB_Normal: {\r
169                     bCheck = FALSE;\r
170                     dwColor = m_pThemeData->clrSignNeutralNormal;\r
171                     break;\r
172                 }\r
173             case FWL_PARTSTATE_CKB_Hovered: {\r
174                     bCheck = FALSE;\r
175                     dwColor = m_pThemeData->clrSignNeutralHover;\r
176                     break;\r
177                 }\r
178             case FWL_PARTSTATE_CKB_Pressed: {\r
179                     bCheck = FALSE,     dwColor = m_pThemeData->clrSignNeutralPressed;\r
180                     break;\r
181                 }\r
182             case FWL_PARTSTATE_CKB_Disabled: {\r
183                     bCheck = FALSE, dwColor = m_pThemeData->clrSignBorderDisable;\r
184                     break;\r
185                 }\r
186         }\r
187     }\r
188     if (bCheck) {\r
189         FX_DWORD dwStyle = pWidget->GetStylesEx();\r
190         switch(dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) {\r
191             case FWL_STYLEEXT_CKB_SignShapeCheck: {\r
192                     DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix);\r
193                     break;\r
194                 }\r
195             case FWL_STYLEEXT_CKB_SignShapeCircle: {\r
196                     rtSign.Deflate(1, 1);\r
197                     DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix);\r
198                     break;\r
199                 }\r
200             case FWL_STYLEEXT_CKB_SignShapeCross: {\r
201                     DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix);\r
202                     break;\r
203                 }\r
204             case FWL_STYLEEXT_CKB_SignShapeDiamond: {\r
205                     DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix);\r
206                     break;\r
207                 }\r
208             case FWL_STYLEEXT_CKB_SignShapeSquare: {\r
209                     DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix);\r
210                     break;\r
211                 }\r
212             case FWL_STYLEEXT_CKB_SignShapeStar: {\r
213                     DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix);\r
214                     break;\r
215                 }\r
216         }\r
217     } else {\r
218         FillSoildRect(pGraphics, ArgbEncode(255, 33, 161, 33), &rtSign, pMatrix);\r
219     }\r
220 }\r
221 void CFWL_CheckBoxTP::DrawSignNeutral(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, CFX_Matrix *pMatrix )\r
222 {\r
223     ((CFX_RectF*)pRtSign)->Inflate(-3, -3);\r
224     FillSoildRect(pGraphics, m_pThemeData->clrSignNeutral, pRtSign, pMatrix);\r
225 }\r
226 void CFWL_CheckBoxTP::DrawSignCheck(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )\r
227 {\r
228     if (!m_pCheckPath) {\r
229         initCheckPath(pRtSign->width);\r
230     }\r
231     CFX_Matrix mt;\r
232     mt.Reset();\r
233     mt.Translate(pRtSign->left, pRtSign->top);\r
234     mt.Concat(*pMatrix);\r
235     CFX_Color crFill(argbFill);\r
236     pGraphics->SaveGraphState();\r
237     pGraphics->SetFillColor(&crFill);\r
238     pGraphics->FillPath(m_pCheckPath, FXFILL_WINDING, &mt);\r
239     pGraphics->RestoreGraphState();\r
240 }\r
241 void CFWL_CheckBoxTP::DrawSignCircle(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )\r
242 {\r
243     CFX_Path path;\r
244     path.Create();\r
245     path.AddEllipse(*pRtSign);\r
246     CFX_Color crFill(argbFill);\r
247     pGraphics->SaveGraphState();\r
248     pGraphics->SetFillColor(&crFill);\r
249     pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
250     pGraphics->RestoreGraphState();\r
251 }\r
252 void CFWL_CheckBoxTP::DrawSignCross(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )\r
253 {\r
254     CFX_Path path;\r
255     path.Create();\r
256     FX_FLOAT fRight = pRtSign->right();\r
257     FX_FLOAT fBottom = pRtSign->bottom();\r
258     path.AddLine(pRtSign->left, pRtSign->top, fRight, fBottom);\r
259     path.AddLine(pRtSign->left, fBottom, fRight, pRtSign->top);\r
260     CFX_Color crFill(argbFill);\r
261     pGraphics->SaveGraphState();\r
262     pGraphics->SetStrokeColor(&crFill);\r
263     pGraphics->SetLineWidth(1.0f);\r
264     pGraphics->StrokePath(&path, pMatrix);\r
265     pGraphics->RestoreGraphState();\r
266 }\r
267 void CFWL_CheckBoxTP::DrawSignDiamond(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )\r
268 {\r
269     CFX_Path path;\r
270     path.Create();\r
271     FX_FLOAT fWidth = pRtSign->width;\r
272     FX_FLOAT fHeight = pRtSign->height;\r
273     FX_FLOAT fBottom = pRtSign->bottom();\r
274     path.MoveTo(pRtSign->left + fWidth / 2, pRtSign->top);\r
275     path.LineTo(pRtSign->left, pRtSign->top + fHeight / 2);\r
276     path.LineTo(pRtSign->left + fWidth / 2, fBottom);\r
277     path.LineTo(pRtSign->right(), pRtSign->top + fHeight / 2);\r
278     path.LineTo(pRtSign->left + fWidth / 2, pRtSign->top);\r
279     CFX_Color crFill(argbFill);\r
280     pGraphics->SaveGraphState();\r
281     pGraphics->SetFillColor(&crFill);\r
282     pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
283     pGraphics->RestoreGraphState();\r
284 }\r
285 void CFWL_CheckBoxTP::DrawSignSquare(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )\r
286 {\r
287     CFX_Path path;\r
288     path.Create();\r
289     path.AddRectangle(pRtSign->left, pRtSign->top, pRtSign->width, pRtSign->height);\r
290     CFX_Color crFill(argbFill);\r
291     pGraphics->SaveGraphState();\r
292     pGraphics->SetFillColor(&crFill);\r
293     pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
294     pGraphics->RestoreGraphState();\r
295 }\r
296 void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )\r
297 {\r
298     CFX_Path path;\r
299     path.Create();\r
300     FX_FLOAT fBottom = pRtSign->bottom();\r
301     FX_FLOAT fRadius = (pRtSign->top - fBottom) / ( 1 + (FX_FLOAT)cos(FX_PI / 5.0f));\r
302     CFX_PointF ptCenter;\r
303     ptCenter.Set((pRtSign->left + pRtSign->right()) / 2.0f, (pRtSign->top + fBottom) / 2.0f);\r
304     FX_FLOAT px[5], py[5];\r
305     FX_FLOAT fAngel = FX_PI / 10.0f;\r
306     for (FX_INT32 i = 0; i < 5; i++) {\r
307         px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);\r
308         py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);\r
309         fAngel += FX_PI * 2 / 5.0f;\r
310     }\r
311     path.MoveTo(px[0], py[0]);\r
312     FX_INT32 nNext = 0;\r
313     for (FX_INT32 j = 0; j < 5; j++) {\r
314         nNext += 2;\r
315         if (nNext >= 5) {\r
316             nNext -= 5;\r
317         }\r
318         path.LineTo(px[nNext], py[nNext]);\r
319     }\r
320     CFX_Color crFill(argbFill);\r
321     pGraphics->SaveGraphState();\r
322     pGraphics->SetFillColor(&crFill);\r
323     pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
324     pGraphics->RestoreGraphState();\r
325 }\r
326 void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_RectF *pRtBox, FX_BOOL bDisable , CFX_Matrix *pMatrix )\r
327 {\r
328     switch(pWidget->GetStylesEx() & FWL_STYLEEXT_CKB_ShapeMask) {\r
329         case FWL_STYLEEXT_CKB_ShapeSolidSquare: {\r
330                 DrawAnnulusRect(pGraphics,\r
331                                 bDisable ? m_pThemeData->clrSignBorderDisable : m_pThemeData->clrSignBorderNormal,\r
332                                 pRtBox,\r
333                                 1,\r
334                                 pMatrix);\r
335                 break;\r
336             }\r
337         case FWL_STYLEEXT_CKB_ShapeSunkenSquare: {\r
338                 Draw3DRect(pGraphics,\r
339                            FWLTHEME_EDGE_Sunken,\r
340                            CHECKBOX_SIZE_SIGNBORDER,\r
341                            pRtBox,\r
342                            CHECKBOX_COLOR_BOXLT1,\r
343                            CHECKBOX_COLOR_BOXLT2,\r
344                            CHECKBOX_COLOR_BOXRB1,\r
345                            CHECKBOX_COLOR_BOXRB2,\r
346                            pMatrix);\r
347                 break;\r
348             }\r
349         case FWL_STYLEEXT_CKB_ShapeSolidCircle: {\r
350                 DrawAnnulusCircle(pGraphics,\r
351                                   bDisable ? m_pThemeData->clrSignBorderDisable : m_pThemeData->clrSignBorderNormal,\r
352                                   pRtBox,\r
353                                   1,\r
354                                   pMatrix);\r
355                 break;\r
356             }\r
357         case FWL_STYLEEXT_CKB_ShapeSunkenCircle: {\r
358                 Draw3DCircle(pGraphics,\r
359                              FWLTHEME_EDGE_Sunken,\r
360                              CHECKBOX_SIZE_SIGNBORDER,\r
361                              pRtBox,\r
362                              CHECKBOX_COLOR_BOXLT1,\r
363                              CHECKBOX_COLOR_BOXLT2,\r
364                              CHECKBOX_COLOR_BOXRB1,\r
365                              CHECKBOX_COLOR_BOXRB2,\r
366                              pMatrix);\r
367                 break;\r
368             }\r
369     }\r
370 }\r
371 void CFWL_CheckBoxTP::SetThemeData(FX_DWORD dwID)\r
372 {\r
373     FX_DWORD *pData = (FX_DWORD*)&m_pThemeData->clrBoxBk;\r
374     if (dwID) {\r
375         *pData++ = 0, *pData++ = 0, \\r
376                                  *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \\r
377                                             *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \\r
378                                                     *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \\r
379                                                             *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255), \\r
380                                                                     *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \\r
381                                                                             *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \\r
382                                                                                     *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \\r
383                                                                                             *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255), \\r
384                                                                                                     *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \\r
385                                                                                                             *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \\r
386                                                                                                                     *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \\r
387                                                                                                                             *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255);\r
388         m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 154, 167, 114);\r
389         m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187);\r
390         m_pThemeData->clrSignCheck = ArgbEncode(255, 164, 180, 138);\r
391         m_pThemeData->clrSignNeutral = ArgbEncode(2255, 28, 134, 26);\r
392         m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113);\r
393         m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33);\r
394         m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26);\r
395     } else {\r
396         *pData++ = 0, *pData++ = 0, \\r
397                                  *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \\r
398                                             *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \\r
399                                                     *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \\r
400                                                             *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255), \\r
401                                                                     *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \\r
402                                                                             *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \\r
403                                                                                     *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \\r
404                                                                                             *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255), \\r
405                                                                                                     *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \\r
406                                                                                                             *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \\r
407                                                                                                                     *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \\r
408                                                                                                                             *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255);\r
409         m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 28, 81, 128);\r
410         m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187);\r
411         m_pThemeData->clrSignCheck = ArgbEncode(255, 28, 81, 128);\r
412         m_pThemeData->clrSignNeutral = ArgbEncode(255, 28, 134, 26);\r
413         m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113);\r
414         m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33);\r
415         m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26);\r
416     }\r
417 }\r
418 void CFWL_CheckBoxTP::initCheckPath(FX_FLOAT fCheckLen)\r
419 {\r
420     if (!m_pCheckPath) {\r
421         m_pCheckPath = FX_NEW CFX_Path;\r
422         m_pCheckPath->Create();\r
423         FX_FLOAT fWidth = CHECKBOX_SIZE_SIGNPATH;\r
424         FX_FLOAT fHeight = -CHECKBOX_SIZE_SIGNPATH;\r
425         FX_FLOAT fBottom = CHECKBOX_SIZE_SIGNPATH;\r
426         FX_FLOAT px1, py1, px2, py2;\r
427         CFX_PointF pt1;\r
428         pt1.Set(fWidth / 15.0f, fBottom + fHeight * 2 / 5.0f);\r
429         CFX_PointF pt2;\r
430         pt2.Set(fWidth / 4.5f, fBottom + fHeight / 16.0f);\r
431         CFX_PointF pt3;\r
432         pt3.Set(fWidth / 3.0f, fBottom);\r
433         CFX_PointF pt4;\r
434         pt4.Set(fWidth * 14 / 15.0f, fBottom + fHeight * 15 / 16.0f);\r
435         CFX_PointF pt5;\r
436         pt5.Set(fWidth / 3.6f, fBottom + fHeight / 3.5f);\r
437         CFX_PointF pt12;\r
438         pt12.Set(fWidth / 7.0f, fBottom + fHeight * 2 / 7.0f);\r
439         CFX_PointF pt21;\r
440         pt21.Set(fWidth / 5.0f, fBottom + fHeight / 5.0f);\r
441         CFX_PointF pt23;\r
442         pt23.Set(fWidth / 4.4f, fBottom + fHeight * 0 / 16.0f);\r
443         CFX_PointF pt32;\r
444         pt32.Set(fWidth / 4.0f, fBottom);\r
445         CFX_PointF pt34;\r
446         pt34.Set(fWidth * (1 / 7.0f + 7 / 15.0f), fBottom + fHeight * 4 / 5.0f);\r
447         CFX_PointF pt43;\r
448         pt43.Set(fWidth * (1 / 7.0f + 7 / 15.0f), fBottom + fHeight * 4 / 5.0f);\r
449         CFX_PointF pt45;\r
450         pt45.Set(fWidth * 7 / 15.0f, fBottom + fHeight * 8 / 7.0f);\r
451         CFX_PointF pt54;\r
452         pt54.Set(fWidth / 3.4f, fBottom + fHeight / 3.5f);\r
453         CFX_PointF pt51;\r
454         pt51.Set(fWidth / 3.6f, fBottom + fHeight / 4.0f);\r
455         CFX_PointF pt15;\r
456         pt15.Set(fWidth / 3.5f, fBottom + fHeight * 3.5f / 5.0f);\r
457         m_pCheckPath->MoveTo(pt1.x, pt1.y);\r
458         px1 = pt12.x - pt1.x;\r
459         py1 = pt12.y - pt1.y;\r
460         px2 = pt21.x - pt2.x;\r
461         py2 = pt21.y - pt2.y;\r
462         m_pCheckPath->BezierTo(pt1.x + px1 * FWLTHEME_BEZIER, pt1.y + py1 * FWLTHEME_BEZIER,\r
463                                pt2.x + px2 * FWLTHEME_BEZIER, pt2.y + py2 * FWLTHEME_BEZIER,\r
464                                pt2.x, pt2.y);\r
465         px1 = pt23.x - pt2.x;\r
466         py1 = pt23.y - pt2.y;\r
467         px2 = pt32.x - pt3.x;\r
468         py2 = pt32.y - pt3.y;\r
469         m_pCheckPath->BezierTo(pt2.x + px1 * FWLTHEME_BEZIER, pt2.y + py1 * FWLTHEME_BEZIER,\r
470                                pt3.x + px2 * FWLTHEME_BEZIER, pt3.y + py2 * FWLTHEME_BEZIER,\r
471                                pt3.x, pt3.y);\r
472         px1 = pt34.x - pt3.x;\r
473         py1 = pt34.y - pt3.y;\r
474         px2 = pt43.x - pt4.x;\r
475         py2 = pt43.y - pt4.y;\r
476         m_pCheckPath->BezierTo(pt3.x + px1 * FWLTHEME_BEZIER, pt3.y + py1 * FWLTHEME_BEZIER,\r
477                                pt4.x + px2 * FWLTHEME_BEZIER, pt4.y + py2 * FWLTHEME_BEZIER,\r
478                                pt4.x, pt4.y);\r
479         px1 = pt45.x - pt4.x;\r
480         py1 = pt45.y - pt4.y;\r
481         px2 = pt54.x - pt5.x;\r
482         py2 = pt54.y - pt5.y;\r
483         m_pCheckPath->BezierTo(pt4.x + px1 * FWLTHEME_BEZIER, pt4.y + py1 * FWLTHEME_BEZIER,\r
484                                pt5.x + px2 * FWLTHEME_BEZIER, pt5.y + py2 * FWLTHEME_BEZIER,\r
485                                pt5.x, pt5.y);\r
486         px1 = pt51.x - pt5.x;\r
487         py1 = pt51.y - pt5.y;\r
488         px2 = pt15.x - pt1.x;\r
489         py2 = pt15.y - pt1.y;\r
490         m_pCheckPath->BezierTo(pt5.x + px1 * FWLTHEME_BEZIER, pt5.y + py1 * FWLTHEME_BEZIER,\r
491                                pt1.x + px2 * FWLTHEME_BEZIER, pt1.y + py2 * FWLTHEME_BEZIER,\r
492                                pt1.x, pt1.y);\r
493         FX_FLOAT fScale = fCheckLen / CHECKBOX_SIZE_SIGNPATH;\r
494         CFX_AffineMatrix mt;\r
495         mt.Set(1, 0, 0, 1, 0, 0);\r
496         mt.Scale(fScale, fScale);\r
497         CFX_PathData *pData = m_pCheckPath->GetPathData();\r
498         pData->Transform(&mt);\r
499     }\r
500 }\r