Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fwl / src / theme / monthcalendartp.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 FWL_THEMECAPACITY_MC_HEADER_WIDTH                       200\r
9 #define FWL_THEMECAPACITY_MC_HEADER_HEIGHT                      30\r
10 #define FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH           18\r
11 #define FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT          16\r
12 #define FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN         5\r
13 #define FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN         (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT)/2\r
14 #define FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT           100\r
15 #define FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT          20\r
16 #define FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN        (FWL_THEMECAPACITY_MC_HEADER_WIDTH - FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT)/2\r
17 #define FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN        (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT)/2\r
18 #define FWL_THEMECAPACITY_MC_HSEP_WIDTH                         (FWL_THEMECAPACITY_MC_WEEK_WIDTH - 10)\r
19 #define FWL_THEMECAPACITY_MC_HSEP_HEIGHT                        1\r
20 #define FWL_THEMECAPACITY_MC_VSEP_WIDTH                         1\r
21 #define FWL_THEMECAPACITY_MC_VSEP_HEIGHT                        FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT\r
22 #define FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH                      26\r
23 #define FWL_THEMECAPACITY_MC_SEP_DOFFSET                                -4\r
24 #define FWL_THEMECAPACITY_MC_SEP_X                                      3\r
25 #define FWL_THEMECAPACITY_MC_SEP_Y                                      (FWL_THEMECAPACITY_MC_HEADER_HEIGHT + FWL_THEMECAPACITY_MC_WEEK_HEIGHT + FWL_THEMECAPACITY_MC_SEP_DOFFSET)\r
26 #define FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT                     (6*FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT)\r
27 #define FWL_THEMECAPACITY_MC_WEEK_WIDTH                         (FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH*7)\r
28 #define FWL_THEMECAPACITY_MC_WEEK_HEIGHT                        FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT\r
29 #define FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH           (FWL_THEMECAPACITY_MC_HEADER_WIDTH/7)\r
30 #define FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT                          16\r
31 #define FWL_THEMECAPACITY_MC_TODAY_WIDHT                        FWL_THEMECAPACITY_MC_HEADER_WIDTH\r
32 #define FWL_THEMECAPACITY_MC_TODAY_HEIGHT                       FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT\r
33 #define FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT           FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH\r
34 #define FWL_MC_WIDTH                                    200\r
35 #define FWL_MC_HEIGHT                               160\r
36 CFWL_MonthCalendarTP::CFWL_MonthCalendarTP()\r
37 {\r
38     m_pThemeData = FX_NEW MCThemeData;\r
39     SetThemeData(0);\r
40 }\r
41 CFWL_MonthCalendarTP::~CFWL_MonthCalendarTP()\r
42 {\r
43     delete m_pThemeData;\r
44 }\r
45 FX_BOOL CFWL_MonthCalendarTP::IsValidWidget(IFWL_Widget *pWidget)\r
46 {\r
47     _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);\r
48     return pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar;\r
49 }\r
50 FX_DWORD CFWL_MonthCalendarTP::SetThemeID(IFWL_Widget *pWidget, FX_DWORD dwThemeID, FX_BOOL bChildren )\r
51 {\r
52     if (m_pThemeData) {\r
53         SetThemeData(FWL_GetThemeColor(dwThemeID));\r
54     }\r
55     return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);\r
56 }\r
57 FX_BOOL CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground *pParams)\r
58 {\r
59     _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);\r
60     switch(pParams->m_iPart) {\r
61         case FWL_PART_MCD_Border: {\r
62                 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);\r
63                 break;\r
64             }\r
65         case FWL_PART_MCD_Edge: {\r
66                 DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);\r
67                 break;\r
68             }\r
69         case FWL_PART_MCD_Background: {\r
70                 DrawTotalBK(pParams, &pParams->m_matrix);\r
71                 break;\r
72             }\r
73         case FWL_PART_MCD_Header: {\r
74                 DrawHeadBk(pParams, &pParams->m_matrix);\r
75                 break;\r
76             }\r
77         case FWL_PART_MCD_LBtn: {\r
78 #ifdef THEME_XPSimilar\r
79                 FWLTHEME_STATE eState = GetState(pParams->m_dwStates);\r
80                 DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Left, eState, &pParams->m_matrix);\r
81 #else\r
82                 DrawLButton(pParams, &pParams->m_matrix);\r
83 #endif\r
84                 break;\r
85             }\r
86         case FWL_PART_MCD_RBtn: {\r
87 #ifdef THEME_XPSimilar\r
88                 FWLTHEME_STATE eState = GetState(pParams->m_dwStates);\r
89                 DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Right, eState, &pParams->m_matrix);\r
90 #else\r
91                 DrawRButton(pParams, &pParams->m_matrix);\r
92 #endif\r
93                 break;\r
94             }\r
95         case FWL_PART_MCD_HSeparator: {\r
96                 DrawHSeperator(pParams, &pParams->m_matrix);\r
97                 break;\r
98             }\r
99         case FWL_PART_MCD_DatesIn: {\r
100                 DrawDatesInBK(pParams, &pParams->m_matrix);\r
101                 break;\r
102             }\r
103         case FWL_PART_MCD_TodayCircle: {\r
104                 DrawTodayCircle(pParams, &pParams->m_matrix);\r
105                 break;\r
106             }\r
107         case FWL_PART_MCD_DateInCircle: {\r
108                 DrawDatesInCircle(pParams, &pParams->m_matrix);\r
109                 break;\r
110             }\r
111         case FWL_PART_MCD_WeekNumSep: {\r
112                 DrawWeekNumSep(pParams, &pParams->m_matrix);\r
113                 break;\r
114             }\r
115         default: {\r
116             }\r
117     }\r
118     return TRUE;\r
119 }\r
120 FX_BOOL CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText *pParams)\r
121 {\r
122     _FWL_RETURN_VALUE_IF_FAIL(m_pTextOut, FALSE);\r
123     if ((pParams->m_iPart == FWL_PART_MCD_DatesIn) && !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) &&\r
124             (pParams->m_dwStates & (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) {\r
125         m_pTextOut->SetTextColor(0xFFFFFFFF);\r
126     } else if (pParams->m_iPart == FWL_PART_MCD_Caption) {\r
127         m_pTextOut->SetTextColor(m_pThemeData->clrCaption);\r
128     } else {\r
129         m_pTextOut->SetTextColor(0xFF000000);\r
130     }\r
131     return CFWL_WidgetTP::DrawText(pParams);\r
132 }\r
133 FX_LPVOID CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart *pThemePart, FX_DWORD dwCapacity)\r
134 {\r
135     FX_BOOL bDefPro = FALSE;\r
136     FX_BOOL bDwordVal = FALSE;\r
137     switch(dwCapacity) {\r
138         case FWL_WGTCAPACITY_MC_HEADER_WIDTH: {\r
139                 m_fValue = FWL_THEMECAPACITY_MC_HEADER_WIDTH;\r
140                 break;\r
141             }\r
142         case FWL_WGTCAPACITY_MC_HEADER_Height: {\r
143                 m_fValue = FWL_THEMECAPACITY_MC_HEADER_HEIGHT;\r
144                 break;\r
145             }\r
146         case FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH: {\r
147                 m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH;\r
148                 break;\r
149             }\r
150         case FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT: {\r
151                 m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT;\r
152                 break;\r
153             }\r
154         case FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN: {\r
155                 bDwordVal = TRUE;\r
156                 m_dwValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN;\r
157                 break;\r
158             }\r
159         case FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN: {\r
160                 m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN;\r
161                 break;\r
162             }\r
163         case FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT: {\r
164                 m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT;\r
165                 break;\r
166             }\r
167         case FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT: {\r
168                 m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT;\r
169                 break;\r
170             }\r
171         case FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN: {\r
172                 m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN;\r
173                 break;\r
174             }\r
175         case FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN: {\r
176                 m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN;\r
177                 break;\r
178             }\r
179         case FWL_WGTCAPACITY_MC_HSEP_WIDTH: {\r
180                 m_fValue = FWL_THEMECAPACITY_MC_HSEP_WIDTH;\r
181                 break;\r
182             }\r
183         case FWL_WGTCAPACITY_MC_HSEP_HEIGHT: {\r
184                 m_fValue = FWL_THEMECAPACITY_MC_HSEP_HEIGHT;\r
185                 break;\r
186             }\r
187         case FWL_WGTCAPACITY_MC_VSEP_WIDTH: {\r
188                 m_fValue = FWL_THEMECAPACITY_MC_VSEP_WIDTH;\r
189                 break;\r
190             }\r
191         case FWL_WGTCAPACITY_MC_VSEP_HEIGHT: {\r
192                 m_fValue = FWL_THEMECAPACITY_MC_VSEP_HEIGHT;\r
193                 break;\r
194             }\r
195         case FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH: {\r
196                 m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH;\r
197                 break;\r
198             }\r
199         case FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT: {\r
200                 m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT;\r
201                 break;\r
202             }\r
203         case FWL_WGTCAPACITY_MC_WEEK_WIDTH: {\r
204                 m_fValue = FWL_THEMECAPACITY_MC_WEEK_WIDTH;\r
205                 break;\r
206             }\r
207         case FWL_WGTCAPACITY_MC_WEEK_HEIGHT: {\r
208                 m_fValue =      FWL_THEMECAPACITY_MC_WEEK_HEIGHT;\r
209                 break;\r
210             }\r
211         case FWL_WGTCAPACITY_MC_SEP_DOFFSET: {\r
212                 m_fValue = FWL_THEMECAPACITY_MC_SEP_DOFFSET;\r
213                 break;\r
214             }\r
215         case FWL_WGTCAPACITY_MC_SEP_X: {\r
216                 m_fValue = FWL_THEMECAPACITY_MC_SEP_X;\r
217                 break;\r
218             }\r
219         case FWL_WGTCAPACITY_MC_SEP_Y: {\r
220                 m_fValue = FWL_THEMECAPACITY_MC_SEP_Y;\r
221                 break;\r
222             }\r
223         case FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH: {\r
224                 m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH;\r
225                 break;\r
226             }\r
227         case FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT: {\r
228                 m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT;\r
229                 break;\r
230             }\r
231         case FWL_WGTCAPACITY_MC_TODAY_WIDHT: {\r
232                 m_fValue = FWL_THEMECAPACITY_MC_TODAY_WIDHT;\r
233                 break;\r
234             }\r
235         case FWL_WGTCAPACITY_MC_TODAY_HEIGHT: {\r
236                 m_fValue = FWL_THEMECAPACITY_MC_TODAY_HEIGHT;\r
237                 break;\r
238             }\r
239         case FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT: {\r
240                 m_fValue = FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT;\r
241                 break;\r
242             }\r
243         case FWL_WGTCAPACITY_MC_WIDTH: {\r
244                 m_fValue = FWL_MC_WIDTH;\r
245                 break;\r
246             }\r
247         case FWL_WGTCAPACITY_MC_HEIGHT: {\r
248                 m_fValue = FWL_MC_HEIGHT;\r
249                 break;\r
250             }\r
251         case FWL_MCCAPACITY_Sun: {\r
252                 wsResource = L"Sun";\r
253                 return &wsResource;\r
254             }\r
255         case FWL_MCCAPACITY_Mon: {\r
256                 wsResource = L"Mon";\r
257                 return &wsResource;\r
258             }\r
259         case FWL_MCCAPACITY_Tue: {\r
260                 wsResource = L"Tue";\r
261                 return &wsResource;\r
262             }\r
263         case FWL_MCCAPACITY_Wed: {\r
264                 wsResource = L"Wed";\r
265                 return &wsResource;\r
266             }\r
267         case FWL_MCCAPACITY_Thu: {\r
268                 wsResource = L"Thu";\r
269                 return &wsResource;\r
270             }\r
271         case FWL_MCCAPACITY_Fri: {\r
272                 wsResource = L"Fri";\r
273                 return &wsResource;\r
274             }\r
275         case FWL_MCCAPACITY_Sat: {\r
276                 wsResource = L"Sat";\r
277                 return &wsResource;\r
278             }\r
279         case FWL_MCCAPACITY_January: {\r
280                 wsResource = L"January";\r
281                 return &wsResource;\r
282             }\r
283         case FWL_MCCAPACITY_February: {\r
284                 wsResource = L"February";\r
285                 return &wsResource;\r
286             }\r
287         case FWL_MCCAPACITY_March: {\r
288                 wsResource = L"March";\r
289                 return &wsResource;\r
290             }\r
291         case FWL_MCCAPACITY_April: {\r
292                 wsResource = L"April";\r
293                 return &wsResource;\r
294             }\r
295         case FWL_MCCAPACITY_May: {\r
296                 wsResource = L"May";\r
297                 return &wsResource;\r
298             }\r
299         case FWL_MCCAPACITY_June: {\r
300                 wsResource = L"June";\r
301                 return &wsResource;\r
302             }\r
303         case FWL_MCCAPACITY_July: {\r
304                 wsResource = L"July";\r
305                 return &wsResource;\r
306             }\r
307         case FWL_MCCAPACITY_August: {\r
308                 wsResource = L"August";\r
309                 return &wsResource;\r
310             }\r
311         case FWL_MCCAPACITY_September: {\r
312                 wsResource = L"September";\r
313                 return &wsResource;\r
314             }\r
315         case FWL_MCCAPACITY_October: {\r
316                 wsResource = L"October";\r
317                 return &wsResource;\r
318             }\r
319         case FWL_MCCAPACITY_November: {\r
320                 wsResource = L"November";\r
321                 return &wsResource;\r
322             }\r
323         case FWL_MCCAPACITY_December: {\r
324                 wsResource =  L"December";\r
325                 return &wsResource;\r
326             }\r
327         case FWL_MCCAPACITY_Today: {\r
328                 wsResource = L"Today";\r
329                 return &wsResource;\r
330             }\r
331         default: {\r
332                 bDefPro = TRUE;\r
333             }\r
334     }\r
335     if (!bDefPro) {\r
336         if (bDwordVal) {\r
337             return &m_dwValue;\r
338         }\r
339         return &m_fValue;\r
340     }\r
341     return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);\r
342 }\r
343 FWL_ERR CFWL_MonthCalendarTP::Initialize()\r
344 {\r
345     InitTTO();\r
346     return CFWL_WidgetTP::Initialize();\r
347 }\r
348 FWL_ERR CFWL_MonthCalendarTP::Finalize()\r
349 {\r
350     FinalizeTTO();\r
351     return CFWL_WidgetTP::Finalize();\r
352 }\r
353 FX_BOOL CFWL_MonthCalendarTP::DrawTotalBK(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)\r
354 {\r
355     CFX_Path path;\r
356     path.Create();\r
357     CFX_RectF rtTotal(pParams->m_rtPart);\r
358     path.AddRectangle(rtTotal.left, rtTotal.top, rtTotal.width, rtTotal.height);\r
359     pParams->m_pGraphics->SaveGraphState();\r
360     CFX_Color clrBK(m_pThemeData->clrBK);\r
361     pParams->m_pGraphics->SetFillColor(&clrBK);\r
362     pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
363     pParams->m_pGraphics->RestoreGraphState();\r
364     return TRUE;\r
365 }\r
366 FX_BOOL CFWL_MonthCalendarTP::DrawHeadBk(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)\r
367 {\r
368     CFX_Path path;\r
369     path.Create();\r
370     CFX_RectF rtHead = pParams->m_rtPart;\r
371     path.AddRectangle(rtHead.left, rtHead.top, rtHead.width, rtHead.height);\r
372     pParams->m_pGraphics->SaveGraphState();\r
373     CFX_Color clrHeadBK(m_pThemeData->clrBK);\r
374     pParams->m_pGraphics->SetFillColor(&clrHeadBK);\r
375     pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
376     pParams->m_pGraphics->RestoreGraphState();\r
377     return TRUE;\r
378 }\r
379 FX_BOOL CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)\r
380 {\r
381     CFX_Path path;\r
382     path.Create();\r
383     CFX_RectF rtLBtn;\r
384     rtLBtn = pParams->m_rtPart;\r
385     path.AddRectangle(rtLBtn.left, rtLBtn.top, rtLBtn.width, rtLBtn.height);\r
386     pParams->m_pGraphics->SaveGraphState();\r
387     CFX_Color clrLBtnEdge(ArgbEncode(0xff, 205, 219, 243));\r
388     pParams->m_pGraphics->SetStrokeColor(&clrLBtnEdge);\r
389     pParams->m_pGraphics->StrokePath(&path, pMatrix);\r
390     if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) == FWL_PARTSTATE_MCD_Pressed) {\r
391         CFX_Color clrLBtnFill(ArgbEncode(0xff, 174, 198, 242));\r
392         pParams->m_pGraphics->SetFillColor(&clrLBtnFill);\r
393         pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
394     } else {\r
395         CFX_Color clrLBtnFill(ArgbEncode(0xff, 227, 235, 249));\r
396         pParams->m_pGraphics->SetFillColor(&clrLBtnFill);\r
397         pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
398     }\r
399     path.Clear();\r
400     path.MoveTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, rtLBtn.top + rtLBtn.height / 4);\r
401     path.LineTo(rtLBtn.left + rtLBtn.Width() / 3, rtLBtn.top + rtLBtn.height / 2);\r
402     path.LineTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, rtLBtn.bottom() - rtLBtn.height / 4);\r
403     CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205));\r
404     pParams->m_pGraphics->SetStrokeColor(&clrFlag);\r
405     pParams->m_pGraphics->StrokePath(&path, pMatrix);\r
406     pParams->m_pGraphics->RestoreGraphState();\r
407     return TRUE;\r
408 }\r
409 FX_BOOL CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)\r
410 {\r
411     CFX_Path path;\r
412     path.Create();\r
413     CFX_RectF rtRBtn;\r
414     rtRBtn = pParams->m_rtPart;\r
415     path.AddRectangle(rtRBtn.left, rtRBtn.top, rtRBtn.width, rtRBtn.height);\r
416     pParams->m_pGraphics->SaveGraphState();\r
417     CFX_Color clrRBtnEdge(ArgbEncode(0xff, 205, 219, 243));\r
418     pParams->m_pGraphics->SetStrokeColor(&clrRBtnEdge);\r
419     pParams->m_pGraphics->StrokePath(&path, pMatrix);\r
420     if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) == FWL_PARTSTATE_MCD_Pressed) {\r
421         CFX_Color clrRBtnFill(ArgbEncode(0xff, 174, 198, 242));\r
422         pParams->m_pGraphics->SetFillColor(&clrRBtnFill);\r
423         pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
424     } else {\r
425         CFX_Color clrRBtnFill(ArgbEncode(0xff, 227, 235, 249));\r
426         pParams->m_pGraphics->SetFillColor(&clrRBtnFill);\r
427         pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
428     }\r
429     path.Clear();\r
430     path.MoveTo(rtRBtn.left + rtRBtn.Width() / 3, rtRBtn.top + rtRBtn.height / 4);\r
431     path.LineTo(rtRBtn.left + rtRBtn.Width() / 3 * 2, rtRBtn.top + rtRBtn.height / 2);\r
432     path.LineTo(rtRBtn.left + rtRBtn.Width() / 3, rtRBtn.bottom() - rtRBtn.height / 4);\r
433     CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205));\r
434     pParams->m_pGraphics->SetStrokeColor(&clrFlag);\r
435     pParams->m_pGraphics->StrokePath(&path, pMatrix);\r
436     pParams->m_pGraphics->RestoreGraphState();\r
437     return TRUE;\r
438 }\r
439 FX_BOOL CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)\r
440 {\r
441     CFX_Path path;\r
442     path.Create();\r
443     CFX_RectF rtHSep;\r
444     rtHSep = pParams->m_rtPart;\r
445     path.MoveTo(rtHSep.left, rtHSep.top + rtHSep.height / 2);\r
446     path.LineTo(rtHSep.right(), rtHSep.top + rtHSep.height / 2);\r
447     pParams->m_pGraphics->SaveGraphState();\r
448     CFX_Color clrHSep(m_pThemeData->clrSeperator);\r
449     pParams->m_pGraphics->SetStrokeColor(&clrHSep);\r
450     pParams->m_pGraphics->StrokePath(&path, pMatrix);\r
451     pParams->m_pGraphics->RestoreGraphState();\r
452     return TRUE;\r
453 }\r
454 FX_BOOL CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)\r
455 {\r
456     CFX_Path path;\r
457     path.Create();\r
458     CFX_RectF rtWeekSep;\r
459     rtWeekSep = pParams->m_rtPart;\r
460     path.MoveTo(rtWeekSep.left, rtWeekSep.top);\r
461     path.LineTo(rtWeekSep.left, rtWeekSep.bottom());\r
462     pParams->m_pGraphics->SaveGraphState();\r
463     CFX_Color clrHSep(m_pThemeData->clrSeperator);\r
464     pParams->m_pGraphics->SetStrokeColor(&clrHSep);\r
465     pParams->m_pGraphics->StrokePath(&path, pMatrix);\r
466     pParams->m_pGraphics->RestoreGraphState();\r
467     return TRUE;\r
468 }\r
469 FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)\r
470 {\r
471     pParams->m_pGraphics->SaveGraphState();\r
472     if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Selected) {\r
473         CFX_Path path;\r
474         path.Create();\r
475         CFX_RectF rtSelDay;\r
476         rtSelDay = pParams->m_rtPart;\r
477         path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height);\r
478         CFX_Color clrSelDayBK;\r
479         clrSelDayBK = m_pThemeData->clrDatesSelectedBK;\r
480         pParams->m_pGraphics->SetFillColor(&clrSelDayBK);\r
481         pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
482     } else if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Hovered) {\r
483         CFX_Path path;\r
484         path.Create();\r
485         CFX_RectF rtSelDay;\r
486         rtSelDay = pParams->m_rtPart;\r
487         path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height);\r
488         CFX_Color clrSelDayBK;\r
489         clrSelDayBK = m_pThemeData->clrDatesHoverBK;\r
490         pParams->m_pGraphics->SetFillColor(&clrSelDayBK);\r
491         pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);\r
492     }\r
493     pParams->m_pGraphics->RestoreGraphState();\r
494     return FALSE;\r
495 }\r
496 FX_BOOL CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)\r
497 {\r
498     CFX_Path path;\r
499     path.Create();\r
500     CFX_RectF rtSelDay;\r
501     rtSelDay = pParams->m_rtPart;\r
502     path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height);\r
503     pParams->m_pGraphics->SaveGraphState();\r
504     CFX_Color clrSelDayBK;\r
505     clrSelDayBK = m_pThemeData->clrDatesCircle;\r
506     pParams->m_pGraphics->SetStrokeColor(&clrSelDayBK);\r
507     pParams->m_pGraphics->StrokePath(&path, pMatrix);\r
508     pParams->m_pGraphics->RestoreGraphState();\r
509     return TRUE;\r
510 }\r
511 FX_BOOL CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)\r
512 {\r
513     CFX_Path path;\r
514     path.Create();\r
515     CFX_RectF rtTodayCircle;\r
516     rtTodayCircle = pParams->m_rtPart;\r
517     path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width, rtTodayCircle.height);\r
518     pParams->m_pGraphics->SaveGraphState();\r
519     CFX_Color clrTodayCircle;\r
520     clrTodayCircle = m_pThemeData->clrDatesCircle;\r
521     pParams->m_pGraphics->SetStrokeColor(&clrTodayCircle);\r
522     pParams->m_pGraphics->StrokePath(&path, pMatrix);\r
523     pParams->m_pGraphics->RestoreGraphState();\r
524     return TRUE;\r
525 }\r
526 FWLTHEME_STATE CFWL_MonthCalendarTP::GetState(FX_DWORD dwFWLStates)\r
527 {\r
528     if (dwFWLStates & FWL_PARTSTATE_MCD_Hovered) {\r
529         return FWLTHEME_STATE_Hover;\r
530     } else if (dwFWLStates & FWL_PARTSTATE_MCD_Pressed) {\r
531         return FWLTHEME_STATE_Pressed;\r
532     }\r
533     return FWLTHEME_STATE_Normal;\r
534 }\r
535 void CFWL_MonthCalendarTP::SetThemeData(FX_DWORD dwThemeID)\r
536 {\r
537     if (dwThemeID == 0) {\r
538         m_pThemeData->clrCaption = ArgbEncode(0xff, 0, 153, 255);\r
539         m_pThemeData->clrSeperator = ArgbEncode(0xff, 141, 161, 239);\r
540         m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 193, 211, 251);\r
541         m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 173, 188, 239);\r
542         m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 103, 144, 209);\r
543         m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0);\r
544         m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255);\r
545     } else {\r
546         m_pThemeData->clrCaption = ArgbEncode(0xff, 128, 128, 0);\r
547         m_pThemeData->clrSeperator = ArgbEncode(0xff, 128, 128, 64);\r
548         m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff,  217, 220, 191);\r
549         m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 204, 208, 183);\r
550         m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 128, 128, 0);\r
551         m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0);\r
552         m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255);\r
553     }\r
554 }\r