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