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 #ifndef XFA_FWL_CORE_IFWL_MONTHCALENDAR_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_MONTHCALENDAR_H_ |
8 #define XFA_FWL_CORE_IFWL_MONTHCALENDAR_H_ | 8 #define XFA_FWL_CORE_IFWL_MONTHCALENDAR_H_ |
9 | 9 |
10 #include "xfa/fgas/localization/fgas_datetime.h" | 10 #include "xfa/fgas/localization/fgas_datetime.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 FWL_EVENT_DEF(CFWL_EventMcdDateChanged, | 30 FWL_EVENT_DEF(CFWL_EventMcdDateChanged, |
31 CFWL_EventType::DateChanged, | 31 CFWL_EventType::DateChanged, |
32 int32_t m_iOldYear; | 32 int32_t m_iOldYear; |
33 int32_t m_iOldMonth; | 33 int32_t m_iOldMonth; |
34 int32_t m_iStartDay; | 34 int32_t m_iStartDay; |
35 int32_t m_iEndDay;) | 35 int32_t m_iEndDay;) |
36 | 36 |
37 class CFWL_MsgMouse; | 37 class CFWL_MsgMouse; |
38 class IFWL_Widget; | 38 class IFWL_Widget; |
39 | 39 |
40 struct FWL_DATEINFO; | |
41 | |
42 extern uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth); | |
43 | |
44 class IFWL_MonthCalendarDP : public IFWL_DataProvider { | 40 class IFWL_MonthCalendarDP : public IFWL_DataProvider { |
45 public: | 41 public: |
46 virtual int32_t GetCurDay(IFWL_Widget* pWidget) = 0; | 42 virtual int32_t GetCurDay(IFWL_Widget* pWidget) = 0; |
47 virtual int32_t GetCurMonth(IFWL_Widget* pWidget) = 0; | 43 virtual int32_t GetCurMonth(IFWL_Widget* pWidget) = 0; |
48 virtual int32_t GetCurYear(IFWL_Widget* pWidget) = 0; | 44 virtual int32_t GetCurYear(IFWL_Widget* pWidget) = 0; |
49 }; | 45 }; |
50 | 46 |
51 class IFWL_MonthCalendar : public IFWL_Widget { | 47 class IFWL_MonthCalendar : public IFWL_Widget { |
52 public: | 48 public: |
53 IFWL_MonthCalendar(const IFWL_App* app, | 49 IFWL_MonthCalendar(const IFWL_App* app, |
54 std::unique_ptr<CFWL_WidgetProperties> properties, | 50 std::unique_ptr<CFWL_WidgetProperties> properties, |
55 IFWL_Widget* pOuter); | 51 IFWL_Widget* pOuter); |
56 ~IFWL_MonthCalendar() override; | 52 ~IFWL_MonthCalendar() override; |
57 | 53 |
58 // FWL_WidgetImp | 54 // FWL_WidgetImp |
59 FWL_Type GetClassID() const override; | 55 FWL_Type GetClassID() const override; |
60 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; | 56 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; |
61 void Update() override; | 57 void Update() override; |
62 void DrawWidget(CFX_Graphics* pGraphics, | 58 void DrawWidget(CFX_Graphics* pGraphics, |
63 const CFX_Matrix* pMatrix = nullptr) override; | 59 const CFX_Matrix* pMatrix = nullptr) override; |
64 void OnProcessMessage(CFWL_Message* pMessage) override; | 60 void OnProcessMessage(CFWL_Message* pMessage) override; |
65 void OnDrawWidget(CFX_Graphics* pGraphics, | 61 void OnDrawWidget(CFX_Graphics* pGraphics, |
66 const CFX_Matrix* pMatrix) override; | 62 const CFX_Matrix* pMatrix) override; |
67 | 63 |
68 int32_t CountSelect(); | 64 void SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay); |
69 bool GetSelect(int32_t& iYear, | |
70 int32_t& iMonth, | |
71 int32_t& iDay, | |
72 int32_t nIndex = 0); | |
73 bool SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay); | |
74 | 65 |
75 protected: | 66 private: |
76 struct DATE { | 67 struct DATE { |
77 DATE() : iYear(0), iMonth(0), iDay(0) {} | 68 DATE() : iYear(0), iMonth(0), iDay(0) {} |
| 69 |
78 DATE(int32_t year, int32_t month, int32_t day) | 70 DATE(int32_t year, int32_t month, int32_t day) |
79 : iYear(year), iMonth(month), iDay(day) {} | 71 : iYear(year), iMonth(month), iDay(day) {} |
| 72 |
80 bool operator<(const DATE& right) { | 73 bool operator<(const DATE& right) { |
81 if (iYear < right.iYear) { | 74 if (iYear < right.iYear) |
82 return true; | 75 return true; |
83 } else if (iYear == right.iYear) { | 76 if (iYear == right.iYear) { |
84 if (iMonth < right.iMonth) { | 77 if (iMonth < right.iMonth) |
85 return true; | 78 return true; |
86 } else if (iMonth == right.iMonth) { | 79 if (iMonth == right.iMonth) |
87 return iDay < right.iDay; | 80 return iDay < right.iDay; |
88 } | |
89 } | 81 } |
90 return false; | 82 return false; |
91 } | 83 } |
| 84 |
92 bool operator>(const DATE& right) { | 85 bool operator>(const DATE& right) { |
93 if (iYear > right.iYear) { | 86 if (iYear > right.iYear) |
94 return true; | 87 return true; |
95 } else if (iYear == right.iYear) { | 88 if (iYear == right.iYear) { |
96 if (iMonth > right.iMonth) { | 89 if (iMonth > right.iMonth) |
97 return true; | 90 return true; |
98 } else if (iMonth == right.iMonth) { | 91 if (iMonth == right.iMonth) |
99 return iDay > right.iDay; | 92 return iDay > right.iDay; |
100 } | |
101 } | 93 } |
102 return false; | 94 return false; |
103 } | 95 } |
| 96 |
104 int32_t iYear; | 97 int32_t iYear; |
105 int32_t iMonth; | 98 int32_t iMonth; |
106 int32_t iDay; | 99 int32_t iDay; |
107 }; | 100 }; |
| 101 struct DATEINFO { |
| 102 DATEINFO(int32_t day, |
| 103 int32_t dayofweek, |
| 104 uint32_t dwSt, |
| 105 CFX_RectF rc, |
| 106 CFX_WideString& wsday); |
| 107 ~DATEINFO(); |
| 108 |
| 109 int32_t iDay; |
| 110 int32_t iDayOfWeek; |
| 111 uint32_t dwStates; |
| 112 CFX_RectF rect; |
| 113 CFX_WideString wsDay; |
| 114 }; |
108 | 115 |
109 void DrawBkground(CFX_Graphics* pGraphics, | 116 void DrawBkground(CFX_Graphics* pGraphics, |
110 IFWL_ThemeProvider* pTheme, | 117 IFWL_ThemeProvider* pTheme, |
111 const CFX_Matrix* pMatrix); | 118 const CFX_Matrix* pMatrix); |
112 void DrawHeadBK(CFX_Graphics* pGraphics, | 119 void DrawHeadBK(CFX_Graphics* pGraphics, |
113 IFWL_ThemeProvider* pTheme, | 120 IFWL_ThemeProvider* pTheme, |
114 const CFX_Matrix* pMatrix); | 121 const CFX_Matrix* pMatrix); |
115 void DrawLButton(CFX_Graphics* pGraphics, | 122 void DrawLButton(CFX_Graphics* pGraphics, |
116 IFWL_ThemeProvider* pTheme, | 123 IFWL_ThemeProvider* pTheme, |
117 const CFX_Matrix* pMatrix); | 124 const CFX_Matrix* pMatrix); |
(...skipping 23 matching lines...) Expand all Loading... |
141 const CFX_Matrix* pMatrix); | 148 const CFX_Matrix* pMatrix); |
142 void DrawDatesIn(CFX_Graphics* pGraphics, | 149 void DrawDatesIn(CFX_Graphics* pGraphics, |
143 IFWL_ThemeProvider* pTheme, | 150 IFWL_ThemeProvider* pTheme, |
144 const CFX_Matrix* pMatrix); | 151 const CFX_Matrix* pMatrix); |
145 void DrawDatesOut(CFX_Graphics* pGraphics, | 152 void DrawDatesOut(CFX_Graphics* pGraphics, |
146 IFWL_ThemeProvider* pTheme, | 153 IFWL_ThemeProvider* pTheme, |
147 const CFX_Matrix* pMatrix); | 154 const CFX_Matrix* pMatrix); |
148 void DrawDatesInCircle(CFX_Graphics* pGraphics, | 155 void DrawDatesInCircle(CFX_Graphics* pGraphics, |
149 IFWL_ThemeProvider* pTheme, | 156 IFWL_ThemeProvider* pTheme, |
150 const CFX_Matrix* pMatrix); | 157 const CFX_Matrix* pMatrix); |
151 void DrawTodayCircle(CFX_Graphics* pGraphics, | |
152 IFWL_ThemeProvider* pTheme, | |
153 const CFX_Matrix* pMatrix); | |
154 CFX_SizeF CalcSize(bool bAutoSize = false); | 158 CFX_SizeF CalcSize(bool bAutoSize = false); |
155 void LayOut(); | 159 void Layout(); |
156 void CalcHeadSize(); | 160 void CalcHeadSize(); |
157 void CalcTodaySize(); | 161 void CalcTodaySize(); |
158 void CalDateItem(); | 162 void CalDateItem(); |
159 void GetCapValue(); | 163 void GetCapValue(); |
160 int32_t CalWeekNumber(int32_t iYear, int32_t iMonth, int32_t iDay); | 164 void InitDate(); |
161 bool GetMinDate(int32_t& iYear, int32_t& iMonth, int32_t& iDay); | |
162 bool SetMinDate(int32_t iYear, int32_t iMonth, int32_t iDay); | |
163 bool GetMaxDate(int32_t& iYear, int32_t& iMonth, int32_t& iDay); | |
164 bool SetMaxDate(int32_t iYear, int32_t iMonth, int32_t iDay); | |
165 bool InitDate(); | |
166 void ClearDateItem(); | 165 void ClearDateItem(); |
167 void ReSetDateItem(); | 166 void ResetDateItem(); |
168 bool NextMonth(); | 167 void NextMonth(); |
169 bool PrevMonth(); | 168 void PrevMonth(); |
170 void ChangeToMonth(int32_t iYear, int32_t iMonth); | 169 void ChangeToMonth(int32_t iYear, int32_t iMonth); |
171 bool RemoveSelDay(int32_t iDay, bool bAll = false); | 170 void RemoveSelDay(int32_t iDay, bool bAll = false); |
172 bool AddSelDay(int32_t iDay); | 171 void AddSelDay(int32_t iDay); |
173 bool JumpToToday(); | 172 void JumpToToday(); |
174 void GetHeadText(int32_t iYear, int32_t iMonth, CFX_WideString& wsHead); | 173 void GetHeadText(int32_t iYear, int32_t iMonth, CFX_WideString& wsHead); |
175 void GetTodayText(int32_t iYear, | 174 void GetTodayText(int32_t iYear, |
176 int32_t iMonth, | 175 int32_t iMonth, |
177 int32_t iDay, | 176 int32_t iDay, |
178 CFX_WideString& wsToday); | 177 CFX_WideString& wsToday); |
179 int32_t GetDayAtPoint(FX_FLOAT x, FX_FLOAT y); | 178 int32_t GetDayAtPoint(FX_FLOAT x, FX_FLOAT y); |
180 bool GetDayRect(int32_t iDay, CFX_RectF& rtDay); | 179 void GetDayRect(int32_t iDay, CFX_RectF& rtDay); |
| 180 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
| 181 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
| 182 void DisForm_OnLButtonUp(CFWL_MsgMouse* pMsg); |
| 183 void OnMouseMove(CFWL_MsgMouse* pMsg); |
| 184 void OnMouseLeave(CFWL_MsgMouse* pMsg); |
181 | 185 |
182 bool m_bInit; | 186 bool m_bInitialized; |
183 CFX_RectF m_rtHead; | 187 CFX_RectF m_rtHead; |
184 CFX_RectF m_rtWeek; | 188 CFX_RectF m_rtWeek; |
185 CFX_RectF m_rtLBtn; | 189 CFX_RectF m_rtLBtn; |
186 CFX_RectF m_rtRBtn; | 190 CFX_RectF m_rtRBtn; |
187 CFX_RectF m_rtDates; | 191 CFX_RectF m_rtDates; |
188 CFX_RectF m_rtHSep; | 192 CFX_RectF m_rtHSep; |
189 CFX_RectF m_rtHeadText; | 193 CFX_RectF m_rtHeadText; |
190 CFX_RectF m_rtToday; | 194 CFX_RectF m_rtToday; |
191 CFX_RectF m_rtTodayFlag; | 195 CFX_RectF m_rtTodayFlag; |
192 CFX_RectF m_rtWeekNum; | 196 CFX_RectF m_rtWeekNum; |
193 CFX_RectF m_rtWeekNumSep; | 197 CFX_RectF m_rtWeekNumSep; |
194 CFX_RectF m_rtTemp; | |
195 CFX_WideString m_wsHead; | 198 CFX_WideString m_wsHead; |
196 CFX_WideString m_wsToday; | 199 CFX_WideString m_wsToday; |
197 std::unique_ptr<CFX_DateTime> m_pDateTime; | 200 std::unique_ptr<CFX_DateTime> m_pDateTime; |
198 CFX_ArrayTemplate<FWL_DATEINFO*> m_arrDates; | 201 CFX_ArrayTemplate<DATEINFO*> m_arrDates; |
199 int32_t m_iCurYear; | 202 int32_t m_iCurYear; |
200 int32_t m_iCurMonth; | 203 int32_t m_iCurMonth; |
201 int32_t m_iYear; | 204 int32_t m_iYear; |
202 int32_t m_iMonth; | 205 int32_t m_iMonth; |
203 int32_t m_iDay; | 206 int32_t m_iDay; |
204 int32_t m_iHovered; | 207 int32_t m_iHovered; |
205 int32_t m_iLBtnPartStates; | 208 int32_t m_iLBtnPartStates; |
206 int32_t m_iRBtnPartStates; | 209 int32_t m_iRBtnPartStates; |
207 DATE m_dtMin; | 210 DATE m_dtMin; |
208 DATE m_dtMax; | 211 DATE m_dtMax; |
209 CFX_SizeF m_szHead; | 212 CFX_SizeF m_szHead; |
210 CFX_SizeF m_szCell; | 213 CFX_SizeF m_szCell; |
211 CFX_SizeF m_szToday; | 214 CFX_SizeF m_szToday; |
212 CFX_ArrayTemplate<int32_t> m_arrSelDays; | 215 CFX_ArrayTemplate<int32_t> m_arrSelDays; |
213 int32_t m_iMaxSel; | |
214 CFX_RectF m_rtClient; | 216 CFX_RectF m_rtClient; |
215 FX_FLOAT m_fHeadWid; | 217 FX_FLOAT m_fHeadWid; |
216 FX_FLOAT m_fHeadHei; | 218 FX_FLOAT m_fHeadHei; |
217 FX_FLOAT m_fHeadBtnWid; | 219 FX_FLOAT m_fHeadBtnWid; |
218 FX_FLOAT m_fHeadBtnHei; | 220 FX_FLOAT m_fHeadBtnHei; |
219 FX_FLOAT m_fHeadBtnHMargin; | 221 FX_FLOAT m_fHeadBtnHMargin; |
220 FX_FLOAT m_fHeadBtnVMargin; | 222 FX_FLOAT m_fHeadBtnVMargin; |
221 FX_FLOAT m_fHeadTextWid; | 223 FX_FLOAT m_fHeadTextWid; |
222 FX_FLOAT m_fHeadTextHei; | 224 FX_FLOAT m_fHeadTextHei; |
223 FX_FLOAT m_fHeadTextHMargin; | 225 FX_FLOAT m_fHeadTextHMargin; |
224 FX_FLOAT m_fHeadTextVMargin; | 226 FX_FLOAT m_fHeadTextVMargin; |
225 FX_FLOAT m_fHSepWid; | 227 FX_FLOAT m_fHSepWid; |
226 FX_FLOAT m_fHSepHei; | 228 FX_FLOAT m_fHSepHei; |
227 FX_FLOAT m_fWeekNumWid; | 229 FX_FLOAT m_fWeekNumWid; |
228 FX_FLOAT m_fSepDOffset; | 230 FX_FLOAT m_fSepDOffset; |
229 FX_FLOAT m_fSepX; | 231 FX_FLOAT m_fSepX; |
230 FX_FLOAT m_fSepY; | 232 FX_FLOAT m_fSepY; |
231 FX_FLOAT m_fWeekNumHeigh; | 233 FX_FLOAT m_fWeekNumHeigh; |
232 FX_FLOAT m_fWeekWid; | 234 FX_FLOAT m_fWeekWid; |
233 FX_FLOAT m_fWeekHei; | 235 FX_FLOAT m_fWeekHei; |
234 FX_FLOAT m_fDateCellWid; | 236 FX_FLOAT m_fDateCellWid; |
235 FX_FLOAT m_fDateCellHei; | 237 FX_FLOAT m_fDateCellHei; |
236 FX_FLOAT m_fTodayWid; | 238 FX_FLOAT m_fTodayWid; |
237 FX_FLOAT m_fTodayHei; | 239 FX_FLOAT m_fTodayHei; |
238 FX_FLOAT m_fTodayFlagWid; | 240 FX_FLOAT m_fTodayFlagWid; |
239 FX_FLOAT m_fMCWid; | 241 FX_FLOAT m_fMCWid; |
240 FX_FLOAT m_fMCHei; | 242 FX_FLOAT m_fMCHei; |
241 bool m_bFlag; | 243 bool m_bFlag; |
242 | |
243 private: | |
244 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
245 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
246 void DisForm_OnLButtonUp(CFWL_MsgMouse* pMsg); | |
247 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
248 void OnMouseLeave(CFWL_MsgMouse* pMsg); | |
249 }; | |
250 | |
251 struct FWL_DATEINFO { | |
252 FWL_DATEINFO(int32_t day, | |
253 int32_t dayofweek, | |
254 uint32_t dwSt, | |
255 CFX_RectF rc, | |
256 CFX_WideString& wsday); | |
257 ~FWL_DATEINFO(); | |
258 | |
259 int32_t iDay; | |
260 int32_t iDayOfWeek; | |
261 uint32_t dwStates; | |
262 CFX_RectF rect; | |
263 CFX_WideString wsDay; | |
264 }; | 244 }; |
265 | 245 |
266 #endif // XFA_FWL_CORE_IFWL_MONTHCALENDAR_H_ | 246 #endif // XFA_FWL_CORE_IFWL_MONTHCALENDAR_H_ |
OLD | NEW |