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