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