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