| 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_CORE_IFWL_DATETIMEPICKER_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_DATETIMEPICKER_H_ |
| 8 #define XFA_FWL_CORE_IFWL_DATETIMEPICKER_H_ | 8 #define XFA_FWL_CORE_IFWL_DATETIMEPICKER_H_ |
| 9 | 9 |
| 10 #include "xfa/fwl/core/cfwl_event.h" | 10 #include "xfa/fwl/core/cfwl_event.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 int32_t hoverday;) | 46 int32_t hoverday;) |
| 47 | 47 |
| 48 FWL_EVENT_DEF(CFWL_Event_DtpSelectChanged, | 48 FWL_EVENT_DEF(CFWL_Event_DtpSelectChanged, |
| 49 CFWL_EventType::SelectChanged, | 49 CFWL_EventType::SelectChanged, |
| 50 int32_t iYear; | 50 int32_t iYear; |
| 51 int32_t iMonth; | 51 int32_t iMonth; |
| 52 int32_t iDay;) | 52 int32_t iDay;) |
| 53 | 53 |
| 54 class IFWL_DateTimePickerDP : public IFWL_DataProvider { | 54 class IFWL_DateTimePickerDP : public IFWL_DataProvider { |
| 55 public: | 55 public: |
| 56 virtual FWL_Error GetToday(IFWL_Widget* pWidget, | 56 virtual void GetToday(IFWL_Widget* pWidget, |
| 57 int32_t& iYear, | 57 int32_t& iYear, |
| 58 int32_t& iMonth, | 58 int32_t& iMonth, |
| 59 int32_t& iDay) = 0; | 59 int32_t& iDay) = 0; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 class IFWL_DateTimePicker : public IFWL_Widget, public IFWL_MonthCalendarDP { | 62 class IFWL_DateTimePicker : public IFWL_Widget, public IFWL_MonthCalendarDP { |
| 63 public: | 63 public: |
| 64 explicit IFWL_DateTimePicker( | 64 explicit IFWL_DateTimePicker( |
| 65 const IFWL_App* app, | 65 const IFWL_App* app, |
| 66 std::unique_ptr<CFWL_WidgetProperties> properties); | 66 std::unique_ptr<CFWL_WidgetProperties> properties); |
| 67 ~IFWL_DateTimePicker() override; | 67 ~IFWL_DateTimePicker() override; |
| 68 | 68 |
| 69 // IFWL_Widget | 69 // IFWL_Widget |
| 70 FWL_Type GetClassID() const override; | 70 FWL_Type GetClassID() const override; |
| 71 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; | 71 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; |
| 72 void Update() override; | 72 void Update() override; |
| 73 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | 73 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; |
| 74 void DrawWidget(CFX_Graphics* pGraphics, | 74 void DrawWidget(CFX_Graphics* pGraphics, |
| 75 const CFX_Matrix* pMatrix = nullptr) override; | 75 const CFX_Matrix* pMatrix = nullptr) override; |
| 76 void SetThemeProvider(IFWL_ThemeProvider* pTP) override; | 76 void SetThemeProvider(IFWL_ThemeProvider* pTP) override; |
| 77 void OnProcessMessage(CFWL_Message* pMessage) override; | 77 void OnProcessMessage(CFWL_Message* pMessage) override; |
| 78 void OnDrawWidget(CFX_Graphics* pGraphics, | 78 void OnDrawWidget(CFX_Graphics* pGraphics, |
| 79 const CFX_Matrix* pMatrix) override; | 79 const CFX_Matrix* pMatrix) override; |
| 80 | 80 |
| 81 FWL_Error GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay); | |
| 82 FWL_Error SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay); | |
| 83 FWL_Error SetEditText(const CFX_WideString& wsText); | |
| 84 FWL_Error GetEditText(CFX_WideString& wsText, | |
| 85 int32_t nStart = 0, | |
| 86 int32_t nCount = -1) const; | |
| 87 int32_t CountSelRanges(); | |
| 88 int32_t GetSelRange(int32_t nIndex, int32_t& nStart); | |
| 89 | |
| 90 bool CanUndo(); | |
| 91 bool CanRedo(); | |
| 92 bool Undo(); | |
| 93 bool Redo(); | |
| 94 bool CanCopy(); | |
| 95 bool CanCut(); | |
| 96 bool CanSelectAll(); | |
| 97 bool Copy(CFX_WideString& wsCopy); | |
| 98 bool Cut(CFX_WideString& wsCut); | |
| 99 bool Paste(const CFX_WideString& wsPaste); | |
| 100 bool SelectAll(); | |
| 101 bool Delete(); | |
| 102 bool DeSelect(); | |
| 103 FWL_Error GetBBox(CFX_RectF& rect); | |
| 104 FWL_Error SetEditLimit(int32_t nLimit); | |
| 105 void ModifyEditStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); | |
| 106 IFWL_DateTimeEdit* GetDataTimeEdit(); | |
| 107 | |
| 108 bool IsMonthCalendarShowed(); | |
| 109 void ShowMonthCalendar(bool bActivate); | |
| 110 void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay); | |
| 111 | |
| 112 IFWL_FormProxy* GetFormProxy() const { return m_pForm.get(); } | |
| 113 | |
| 114 // IFWL_DataProvider | 81 // IFWL_DataProvider |
| 115 FWL_Error GetCaption(IFWL_Widget* pWidget, | 82 void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; |
| 116 CFX_WideString& wsCaption) override; | |
| 117 | 83 |
| 118 // IFWL_MonthCalendarDP | 84 // IFWL_MonthCalendarDP |
| 119 int32_t GetCurDay(IFWL_Widget* pWidget) override; | 85 int32_t GetCurDay(IFWL_Widget* pWidget) override; |
| 120 int32_t GetCurMonth(IFWL_Widget* pWidget) override; | 86 int32_t GetCurMonth(IFWL_Widget* pWidget) override; |
| 121 int32_t GetCurYear(IFWL_Widget* pWidget) override; | 87 int32_t GetCurYear(IFWL_Widget* pWidget) override; |
| 122 | 88 |
| 123 protected: | 89 void GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay); |
| 90 void SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay); |
| 91 |
| 92 void SetEditText(const CFX_WideString& wsText); |
| 93 void GetEditText(CFX_WideString& wsText, |
| 94 int32_t nStart = 0, |
| 95 int32_t nCount = -1) const; |
| 96 |
| 97 int32_t CountSelRanges(); |
| 98 int32_t GetSelRange(int32_t nIndex, int32_t& nStart); |
| 99 |
| 100 void GetBBox(CFX_RectF& rect); |
| 101 void SetEditLimit(int32_t nLimit); |
| 102 void ModifyEditStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); |
| 103 |
| 104 bool IsMonthCalendarVisible(); |
| 105 void ShowMonthCalendar(bool bActivate); |
| 106 void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay); |
| 107 |
| 108 IFWL_FormProxy* GetFormProxy() const { return m_pForm.get(); } |
| 109 |
| 110 private: |
| 124 void DrawDropDownButton(CFX_Graphics* pGraphics, | 111 void DrawDropDownButton(CFX_Graphics* pGraphics, |
| 125 IFWL_ThemeProvider* pTheme, | 112 IFWL_ThemeProvider* pTheme, |
| 126 const CFX_Matrix* pMatrix); | 113 const CFX_Matrix* pMatrix); |
| 127 void FormatDateString(int32_t iYear, | 114 void FormatDateString(int32_t iYear, |
| 128 int32_t iMonth, | 115 int32_t iMonth, |
| 129 int32_t iDay, | 116 int32_t iDay, |
| 130 CFX_WideString& wsText); | 117 CFX_WideString& wsText); |
| 131 void ReSetEditAlignment(); | 118 void ResetEditAlignment(); |
| 132 void InitProxyForm(); | 119 void InitProxyForm(); |
| 133 | 120 |
| 121 bool DisForm_IsMonthCalendarVisible(); |
| 122 void DisForm_ShowMonthCalendar(bool bActivate); |
| 123 FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy); |
| 124 bool DisForm_IsNeedShowButton(); |
| 125 void DisForm_Update(); |
| 126 void DisForm_GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false); |
| 127 void DisForm_GetBBox(CFX_RectF& rect); |
| 128 void DisForm_DrawWidget(CFX_Graphics* pGraphics, |
| 129 const CFX_Matrix* pMatrix = nullptr); |
| 130 void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet); |
| 131 void OnFocusChanged(CFWL_Message* pMsg, bool bSet); |
| 132 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
| 133 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
| 134 void OnMouseMove(CFWL_MsgMouse* pMsg); |
| 135 void OnMouseLeave(CFWL_MsgMouse* pMsg); |
| 136 |
| 134 CFX_RectF m_rtBtn; | 137 CFX_RectF m_rtBtn; |
| 135 CFX_RectF m_rtClient; | 138 CFX_RectF m_rtClient; |
| 136 int32_t m_iBtnState; | 139 int32_t m_iBtnState; |
| 137 int32_t m_iYear; | 140 int32_t m_iYear; |
| 138 int32_t m_iMonth; | 141 int32_t m_iMonth; |
| 139 int32_t m_iDay; | 142 int32_t m_iDay; |
| 143 int32_t m_iCurYear; |
| 144 int32_t m_iCurMonth; |
| 145 int32_t m_iCurDay; |
| 140 bool m_bLBtnDown; | 146 bool m_bLBtnDown; |
| 141 std::unique_ptr<IFWL_DateTimeEdit> m_pEdit; | 147 std::unique_ptr<IFWL_DateTimeEdit> m_pEdit; |
| 142 std::unique_ptr<IFWL_MonthCalendar> m_pMonthCal; | 148 std::unique_ptr<IFWL_MonthCalendar> m_pMonthCal; |
| 143 std::unique_ptr<IFWL_FormProxy> m_pForm; | 149 std::unique_ptr<IFWL_FormProxy> m_pForm; |
| 144 FX_FLOAT m_fBtn; | 150 FX_FLOAT m_fBtn; |
| 145 | |
| 146 private: | |
| 147 FWL_Error DisForm_Initialize(); | |
| 148 void DisForm_InitMonthCalendar(); | |
| 149 void DisForm_InitDateTimeEdit(); | |
| 150 bool DisForm_IsMonthCalendarShowed(); | |
| 151 void DisForm_ShowMonthCalendar(bool bActivate); | |
| 152 FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy); | |
| 153 bool DisForm_IsNeedShowButton(); | |
| 154 void DisForm_Update(); | |
| 155 void DisForm_GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false); | |
| 156 FWL_Error DisForm_GetBBox(CFX_RectF& rect); | |
| 157 void DisForm_DrawWidget(CFX_Graphics* pGraphics, | |
| 158 const CFX_Matrix* pMatrix = nullptr); | |
| 159 | |
| 160 void OnFocusChanged(CFWL_Message* pMsg, bool bSet); | |
| 161 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
| 162 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
| 163 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
| 164 void OnMouseLeave(CFWL_MsgMouse* pMsg); | |
| 165 void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet); | |
| 166 | |
| 167 int32_t m_iCurYear; | |
| 168 int32_t m_iCurMonth; | |
| 169 int32_t m_iCurDay; | |
| 170 }; | 151 }; |
| 171 | 152 |
| 172 #endif // XFA_FWL_CORE_IFWL_DATETIMEPICKER_H_ | 153 #endif // XFA_FWL_CORE_IFWL_DATETIMEPICKER_H_ |
| OLD | NEW |