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