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 #ifndef XFA_FWL_CORE_CFWL_MONTHCALENDAR_H_ | |
8 #define XFA_FWL_CORE_CFWL_MONTHCALENDAR_H_ | |
9 | |
10 #include <memory> | |
11 | |
12 #include "xfa/fgas/localization/fgas_datetime.h" | |
13 #include "xfa/fwl/core/cfwl_event.h" | |
14 #include "xfa/fwl/core/cfwl_widget.h" | |
15 #include "xfa/fwl/core/cfwl_widgetproperties.h" | |
16 | |
17 #define FWL_STYLEEXT_MCD_MultiSelect (1L << 0) | |
18 #define FWL_STYLEEXT_MCD_NoToday (1L << 1) | |
19 #define FWL_STYLEEXT_MCD_NoTodayCircle (1L << 2) | |
20 #define FWL_STYLEEXT_MCD_WeekNumbers (1L << 3) | |
21 #define FWL_ITEMSTATE_MCD_Nomal (0L << 0) | |
22 #define FWL_ITEMSTATE_MCD_Flag (1L << 0) | |
23 #define FWL_ITEMSTATE_MCD_Selected (1L << 1) | |
24 #define FWL_ITEMSTATE_MCD_Focused (1L << 2) | |
25 | |
26 class CFWL_MsgMouse; | |
27 class CFWL_Widget; | |
28 | |
29 class CFWL_MonthCalendar : public CFWL_Widget { | |
30 public: | |
31 CFWL_MonthCalendar(const CFWL_App* app, | |
32 std::unique_ptr<CFWL_WidgetProperties> properties, | |
33 CFWL_Widget* pOuter); | |
34 ~CFWL_MonthCalendar() override; | |
35 | |
36 // FWL_WidgetImp | |
37 FWL_Type GetClassID() const override; | |
38 CFX_RectF GetAutosizedWidgetRect() override; | |
39 void Update() override; | |
40 void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; | |
41 void OnProcessMessage(CFWL_Message* pMessage) override; | |
42 void OnDrawWidget(CFX_Graphics* pGraphics, | |
43 const CFX_Matrix* pMatrix) override; | |
44 | |
45 void SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay); | |
46 | |
47 private: | |
48 struct DATE { | |
49 DATE() : iYear(0), iMonth(0), iDay(0) {} | |
50 | |
51 DATE(int32_t year, int32_t month, int32_t day) | |
52 : iYear(year), iMonth(month), iDay(day) {} | |
53 | |
54 bool operator<(const DATE& right) { | |
55 if (iYear < right.iYear) | |
56 return true; | |
57 if (iYear == right.iYear) { | |
58 if (iMonth < right.iMonth) | |
59 return true; | |
60 if (iMonth == right.iMonth) | |
61 return iDay < right.iDay; | |
62 } | |
63 return false; | |
64 } | |
65 | |
66 bool operator>(const DATE& right) { | |
67 if (iYear > right.iYear) | |
68 return true; | |
69 if (iYear == right.iYear) { | |
70 if (iMonth > right.iMonth) | |
71 return true; | |
72 if (iMonth == right.iMonth) | |
73 return iDay > right.iDay; | |
74 } | |
75 return false; | |
76 } | |
77 | |
78 int32_t iYear; | |
79 int32_t iMonth; | |
80 int32_t iDay; | |
81 }; | |
82 struct DATEINFO { | |
83 DATEINFO(int32_t day, | |
84 int32_t dayofweek, | |
85 uint32_t dwSt, | |
86 CFX_RectF rc, | |
87 CFX_WideString& wsday); | |
88 ~DATEINFO(); | |
89 | |
90 int32_t iDay; | |
91 int32_t iDayOfWeek; | |
92 uint32_t dwStates; | |
93 CFX_RectF rect; | |
94 CFX_WideString wsDay; | |
95 }; | |
96 | |
97 void DrawBackground(CFX_Graphics* pGraphics, | |
98 IFWL_ThemeProvider* pTheme, | |
99 const CFX_Matrix* pMatrix); | |
100 void DrawHeadBK(CFX_Graphics* pGraphics, | |
101 IFWL_ThemeProvider* pTheme, | |
102 const CFX_Matrix* pMatrix); | |
103 void DrawLButton(CFX_Graphics* pGraphics, | |
104 IFWL_ThemeProvider* pTheme, | |
105 const CFX_Matrix* pMatrix); | |
106 void DrawRButton(CFX_Graphics* pGraphics, | |
107 IFWL_ThemeProvider* pTheme, | |
108 const CFX_Matrix* pMatrix); | |
109 void DrawCaption(CFX_Graphics* pGraphics, | |
110 IFWL_ThemeProvider* pTheme, | |
111 const CFX_Matrix* pMatrix); | |
112 void DrawSeperator(CFX_Graphics* pGraphics, | |
113 IFWL_ThemeProvider* pTheme, | |
114 const CFX_Matrix* pMatrix); | |
115 void DrawDatesInBK(CFX_Graphics* pGraphics, | |
116 IFWL_ThemeProvider* pTheme, | |
117 const CFX_Matrix* pMatrix); | |
118 void DrawWeek(CFX_Graphics* pGraphics, | |
119 IFWL_ThemeProvider* pTheme, | |
120 const CFX_Matrix* pMatrix); | |
121 void DrawWeekNumber(CFX_Graphics* pGraphics, | |
122 IFWL_ThemeProvider* pTheme, | |
123 const CFX_Matrix* pMatrix); | |
124 void DrawWeekNumberSep(CFX_Graphics* pGraphics, | |
125 IFWL_ThemeProvider* pTheme, | |
126 const CFX_Matrix* pMatrix); | |
127 void DrawToday(CFX_Graphics* pGraphics, | |
128 IFWL_ThemeProvider* pTheme, | |
129 const CFX_Matrix* pMatrix); | |
130 void DrawDatesIn(CFX_Graphics* pGraphics, | |
131 IFWL_ThemeProvider* pTheme, | |
132 const CFX_Matrix* pMatrix); | |
133 void DrawDatesOut(CFX_Graphics* pGraphics, | |
134 IFWL_ThemeProvider* pTheme, | |
135 const CFX_Matrix* pMatrix); | |
136 void DrawDatesInCircle(CFX_Graphics* pGraphics, | |
137 IFWL_ThemeProvider* pTheme, | |
138 const CFX_Matrix* pMatrix); | |
139 CFX_SizeF CalcSize(); | |
140 void Layout(); | |
141 void CalcHeadSize(); | |
142 void CalcTodaySize(); | |
143 void CalDateItem(); | |
144 void GetCapValue(); | |
145 void InitDate(); | |
146 void ClearDateItem(); | |
147 void ResetDateItem(); | |
148 void NextMonth(); | |
149 void PrevMonth(); | |
150 void ChangeToMonth(int32_t iYear, int32_t iMonth); | |
151 void RemoveSelDay(); | |
152 void AddSelDay(int32_t iDay); | |
153 void JumpToToday(); | |
154 void GetHeadText(int32_t iYear, int32_t iMonth, CFX_WideString& wsHead); | |
155 void GetTodayText(int32_t iYear, | |
156 int32_t iMonth, | |
157 int32_t iDay, | |
158 CFX_WideString& wsToday); | |
159 int32_t GetDayAtPoint(FX_FLOAT x, FX_FLOAT y); | |
160 void GetDayRect(int32_t iDay, CFX_RectF& rtDay); | |
161 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
162 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
163 void DisForm_OnLButtonUp(CFWL_MsgMouse* pMsg); | |
164 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
165 void OnMouseLeave(CFWL_MsgMouse* pMsg); | |
166 | |
167 bool m_bInitialized; | |
168 CFX_RectF m_rtHead; | |
169 CFX_RectF m_rtWeek; | |
170 CFX_RectF m_rtLBtn; | |
171 CFX_RectF m_rtRBtn; | |
172 CFX_RectF m_rtDates; | |
173 CFX_RectF m_rtHSep; | |
174 CFX_RectF m_rtHeadText; | |
175 CFX_RectF m_rtToday; | |
176 CFX_RectF m_rtTodayFlag; | |
177 CFX_RectF m_rtWeekNum; | |
178 CFX_RectF m_rtWeekNumSep; | |
179 CFX_WideString m_wsHead; | |
180 CFX_WideString m_wsToday; | |
181 std::unique_ptr<CFX_DateTime> m_pDateTime; | |
182 CFX_ArrayTemplate<DATEINFO*> m_arrDates; | |
183 int32_t m_iCurYear; | |
184 int32_t m_iCurMonth; | |
185 int32_t m_iYear; | |
186 int32_t m_iMonth; | |
187 int32_t m_iDay; | |
188 int32_t m_iHovered; | |
189 int32_t m_iLBtnPartStates; | |
190 int32_t m_iRBtnPartStates; | |
191 DATE m_dtMin; | |
192 DATE m_dtMax; | |
193 CFX_SizeF m_szHead; | |
194 CFX_SizeF m_szCell; | |
195 CFX_SizeF m_szToday; | |
196 CFX_ArrayTemplate<int32_t> m_arrSelDays; | |
197 CFX_RectF m_rtClient; | |
198 FX_FLOAT m_fHeadWid; | |
199 FX_FLOAT m_fHeadHei; | |
200 FX_FLOAT m_fHeadBtnWid; | |
201 FX_FLOAT m_fHeadBtnHei; | |
202 FX_FLOAT m_fHeadBtnHMargin; | |
203 FX_FLOAT m_fHeadBtnVMargin; | |
204 FX_FLOAT m_fHeadTextWid; | |
205 FX_FLOAT m_fHeadTextHei; | |
206 FX_FLOAT m_fHeadTextHMargin; | |
207 FX_FLOAT m_fHeadTextVMargin; | |
208 FX_FLOAT m_fHSepWid; | |
209 FX_FLOAT m_fHSepHei; | |
210 FX_FLOAT m_fWeekNumWid; | |
211 FX_FLOAT m_fSepDOffset; | |
212 FX_FLOAT m_fSepX; | |
213 FX_FLOAT m_fSepY; | |
214 FX_FLOAT m_fWeekNumHeigh; | |
215 FX_FLOAT m_fWeekWid; | |
216 FX_FLOAT m_fWeekHei; | |
217 FX_FLOAT m_fDateCellWid; | |
218 FX_FLOAT m_fDateCellHei; | |
219 FX_FLOAT m_fTodayWid; | |
220 FX_FLOAT m_fTodayHei; | |
221 FX_FLOAT m_fTodayFlagWid; | |
222 FX_FLOAT m_fMCWid; | |
223 FX_FLOAT m_fMCHei; | |
224 bool m_bFlag; | |
225 }; | |
226 | |
227 #endif // XFA_FWL_CORE_CFWL_MONTHCALENDAR_H_ | |
OLD | NEW |