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_BASEWIDGET_FWL_DATETIMEPICKERIMP_H_ | |
8 #define XFA_FWL_BASEWIDGET_FWL_DATETIMEPICKERIMP_H_ | |
9 | |
10 #include <memory> | |
11 | |
12 #include "xfa/fwl/basewidget/fwl_editimp.h" | |
13 #include "xfa/fwl/basewidget/fwl_monthcalendarimp.h" | |
14 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" | |
15 #include "xfa/fwl/basewidget/ifwl_edit.h" | |
16 #include "xfa/fwl/basewidget/ifwl_monthcalendar.h" | |
17 #include "xfa/fwl/core/ifwl_form.h" | |
18 | |
19 class CFWL_WidgetImp; | |
20 class CFWL_WidgetImpProperties; | |
21 class CFWL_WidgetImpDelegate; | |
22 class CFWL_DateTimeEdit; | |
23 class CFWL_DateTimeEditImpDelegate; | |
24 class CFWL_DateTimeCalendar; | |
25 class CFWL_DateTimeCalendarImpDelegate; | |
26 class CFWL_DateTimePickerImp; | |
27 class CFWL_DateTimePickerImpDelegate; | |
28 | |
29 class IFWL_DateTimeForm : public IFWL_Form { | |
30 public: | |
31 static IFWL_DateTimeForm* Create(const CFWL_WidgetImpProperties& properties, | |
32 IFWL_Widget* pOuter); | |
33 | |
34 protected: | |
35 IFWL_DateTimeForm() {} | |
36 }; | |
37 | |
38 class IFWL_DateTimeCalender : public IFWL_MonthCalendar { | |
39 public: | |
40 static IFWL_DateTimeCalender* Create( | |
41 const CFWL_WidgetImpProperties& properties, | |
42 IFWL_Widget* pOuter); | |
43 | |
44 protected: | |
45 IFWL_DateTimeCalender() {} | |
46 }; | |
47 | |
48 class IFWL_DateTimeEdit : public IFWL_Edit { | |
49 public: | |
50 static IFWL_DateTimeEdit* Create(const CFWL_WidgetImpProperties& properties, | |
51 IFWL_Widget* pOuter); | |
52 | |
53 protected: | |
54 IFWL_DateTimeEdit() {} | |
55 }; | |
56 | |
57 class CFWL_DateTimeEdit : public CFWL_EditImp { | |
58 public: | |
59 CFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties, | |
60 IFWL_Widget* pOuter); | |
61 | |
62 // CFWL_EditImp | |
63 FWL_Error Initialize() override; | |
64 FWL_Error Finalize() override; | |
65 | |
66 protected: | |
67 friend class CFWL_DateTimeEditImpDelegate; | |
68 }; | |
69 | |
70 class CFWL_DateTimeEditImpDelegate : public CFWL_EditImpDelegate { | |
71 public: | |
72 CFWL_DateTimeEditImpDelegate(CFWL_DateTimeEdit* pOwner); | |
73 void OnProcessMessage(CFWL_Message* pMessage) override; | |
74 | |
75 protected: | |
76 CFWL_DateTimeEdit* m_pOwner; | |
77 | |
78 private: | |
79 void DisForm_OnProcessMessage(CFWL_Message* pMessage); | |
80 }; | |
81 | |
82 class CFWL_DateTimeCalendar : public CFWL_MonthCalendarImp { | |
83 public: | |
84 CFWL_DateTimeCalendar(const CFWL_WidgetImpProperties& properties, | |
85 IFWL_Widget* pOuter); | |
86 | |
87 // CFWL_MonthCalendarImp | |
88 FWL_Error Initialize() override; | |
89 FWL_Error Finalize() override; | |
90 | |
91 protected: | |
92 friend class CFWL_DateTimeCalendarImpDelegate; | |
93 }; | |
94 | |
95 class CFWL_DateTimeCalendarImpDelegate : public CFWL_MonthCalendarImpDelegate { | |
96 public: | |
97 CFWL_DateTimeCalendarImpDelegate(CFWL_DateTimeCalendar* pOwner); | |
98 void OnProcessMessage(CFWL_Message* pMessage) override; | |
99 | |
100 void OnLButtonDownEx(CFWL_MsgMouse* pMsg); | |
101 void OnLButtonUpEx(CFWL_MsgMouse* pMsg); | |
102 void OnMouseMoveEx(CFWL_MsgMouse* pMsg); | |
103 | |
104 protected: | |
105 CFWL_DateTimeCalendar* m_pOwner; | |
106 FX_BOOL m_bFlag; | |
107 | |
108 private: | |
109 void DisForm_OnProcessMessage(CFWL_Message* pMessage); | |
110 void DisForm_OnLButtonUpEx(CFWL_MsgMouse* pMsg); | |
111 }; | |
112 | |
113 class CFWL_DateTimePickerImp : public CFWL_WidgetImp { | |
114 public: | |
115 CFWL_DateTimePickerImp(const CFWL_WidgetImpProperties& properties, | |
116 IFWL_Widget* pOuter); | |
117 ~CFWL_DateTimePickerImp() override; | |
118 | |
119 // CFWL_WidgetImp | |
120 FWL_Error GetClassName(CFX_WideString& wsClass) const override; | |
121 FWL_Type GetClassID() const override; | |
122 FWL_Error Initialize() override; | |
123 FWL_Error Finalize() override; | |
124 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | |
125 FWL_Error Update() override; | |
126 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | |
127 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | |
128 const CFX_Matrix* pMatrix = nullptr) override; | |
129 FWL_Error SetThemeProvider(IFWL_ThemeProvider* pTP) override; | |
130 | |
131 FWL_Error GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay); | |
132 FWL_Error SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay); | |
133 FWL_Error SetEditText(const CFX_WideString& wsText); | |
134 FWL_Error GetEditText(CFX_WideString& wsText, | |
135 int32_t nStart = 0, | |
136 int32_t nCount = -1) const; | |
137 | |
138 FX_BOOL CanUndo(); | |
139 FX_BOOL CanRedo(); | |
140 FX_BOOL Undo(); | |
141 FX_BOOL Redo(); | |
142 FX_BOOL CanCopy(); | |
143 FX_BOOL CanCut(); | |
144 FX_BOOL CanSelectAll(); | |
145 FX_BOOL Copy(CFX_WideString& wsCopy); | |
146 FX_BOOL Cut(CFX_WideString& wsCut); | |
147 FX_BOOL Paste(const CFX_WideString& wsPaste); | |
148 FX_BOOL SelectAll(); | |
149 FX_BOOL Delete(); | |
150 FX_BOOL DeSelect(); | |
151 FWL_Error GetBBox(CFX_RectF& rect); | |
152 FWL_Error SetEditLimit(int32_t nLimit); | |
153 FWL_Error ModifyEditStylesEx(uint32_t dwStylesExAdded, | |
154 uint32_t dwStylesExRemoved); | |
155 IFWL_DateTimeEdit* GetDataTimeEdit(); | |
156 | |
157 protected: | |
158 friend class CFWL_DateTimeEditImpDelegate; | |
159 friend class CFWL_DateTimeCalendar; | |
160 friend class CFWL_DateTimeCalendarImpDelegate; | |
161 friend class CFWL_DateTimePickerImpDelegate; | |
162 | |
163 class CFWL_MonthCalendarImpDP : public IFWL_MonthCalendarDP { | |
164 public: | |
165 CFWL_MonthCalendarImpDP(); | |
166 | |
167 // IFWL_DataProvider | |
168 FWL_Error GetCaption(IFWL_Widget* pWidget, | |
169 CFX_WideString& wsCaption) override; | |
170 | |
171 // IFWL_MonthCalendarDP | |
172 int32_t GetCurDay(IFWL_Widget* pWidget) override; | |
173 int32_t GetCurMonth(IFWL_Widget* pWidget) override; | |
174 int32_t GetCurYear(IFWL_Widget* pWidget) override; | |
175 | |
176 int32_t m_iCurDay; | |
177 int32_t m_iCurYear; | |
178 int32_t m_iCurMonth; | |
179 }; | |
180 | |
181 void DrawDropDownButton(CFX_Graphics* pGraphics, | |
182 IFWL_ThemeProvider* pTheme, | |
183 const CFX_Matrix* pMatrix); | |
184 void FormatDateString(int32_t iYear, | |
185 int32_t iMonth, | |
186 int32_t iDay, | |
187 CFX_WideString& wsText); | |
188 void ShowMonthCalendar(FX_BOOL bActivate); | |
189 FX_BOOL IsMonthCalendarShowed(); | |
190 void ReSetEditAlignment(); | |
191 void InitProxyForm(); | |
192 void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay); | |
193 | |
194 CFX_RectF m_rtBtn; | |
195 CFX_RectF m_rtClient; | |
196 int32_t m_iBtnState; | |
197 int32_t m_iYear; | |
198 int32_t m_iMonth; | |
199 int32_t m_iDay; | |
200 FX_BOOL m_bLBtnDown; | |
201 std::unique_ptr<IFWL_DateTimeEdit> m_pEdit; | |
202 std::unique_ptr<IFWL_DateTimeCalender> m_pMonthCal; | |
203 std::unique_ptr<IFWL_DateTimeForm> m_pForm; | |
204 FX_FLOAT m_fBtn; | |
205 CFWL_MonthCalendarImpDP m_MonthCalendarDP; | |
206 | |
207 private: | |
208 FWL_Error DisForm_Initialize(); | |
209 void DisForm_InitDateTimeCalendar(); | |
210 void DisForm_InitDateTimeEdit(); | |
211 FX_BOOL DisForm_IsMonthCalendarShowed(); | |
212 void DisForm_ShowMonthCalendar(FX_BOOL bActivate); | |
213 FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy); | |
214 FX_BOOL DisForm_IsNeedShowButton(); | |
215 FWL_Error DisForm_Update(); | |
216 FWL_Error DisForm_GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); | |
217 FWL_Error DisForm_GetBBox(CFX_RectF& rect); | |
218 FWL_Error DisForm_DrawWidget(CFX_Graphics* pGraphics, | |
219 const CFX_Matrix* pMatrix = nullptr); | |
220 }; | |
221 | |
222 class CFWL_DateTimePickerImpDelegate : public CFWL_WidgetImpDelegate { | |
223 public: | |
224 CFWL_DateTimePickerImpDelegate(CFWL_DateTimePickerImp* pOwner); | |
225 | |
226 // CFWL_WidgetImpDelegate | |
227 void OnProcessMessage(CFWL_Message* pMessage) override; | |
228 void OnDrawWidget(CFX_Graphics* pGraphics, | |
229 const CFX_Matrix* pMatrix = nullptr) override; | |
230 | |
231 protected: | |
232 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | |
233 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
234 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
235 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
236 void OnMouseLeave(CFWL_MsgMouse* pMsg); | |
237 | |
238 CFWL_DateTimePickerImp* m_pOwner; | |
239 | |
240 private: | |
241 void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | |
242 }; | |
243 | |
244 #endif // XFA_FWL_BASEWIDGET_FWL_DATETIMEPICKERIMP_H_ | |
OLD | NEW |