| 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_CORE_CFWL_DATETIMEPICKER_H_ | |
| 8 #define XFA_FWL_CORE_CFWL_DATETIMEPICKER_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "xfa/fwl/core/cfwl_datetimeedit.h" | |
| 13 #include "xfa/fwl/core/cfwl_event.h" | |
| 14 #include "xfa/fwl/core/cfwl_monthcalendar.h" | |
| 15 #include "xfa/fwl/core/cfwl_widget.h" | |
| 16 #include "xfa/fwl/core/cfwl_widgetproperties.h" | |
| 17 | |
| 18 #define FWL_STYLEEXT_DTP_AllowEdit (1L << 0) | |
| 19 #define FWL_STYLEEXT_DTP_LongDateFormat (0L << 1) | |
| 20 #define FWL_STYLEEXT_DTP_ShortDateFormat (1L << 1) | |
| 21 #define FWL_STYLEEXT_DTP_TimeFormat (2L << 1) | |
| 22 #define FWL_STYLEEXT_DTP_Spin (1L << 3) | |
| 23 #define FWL_STYLEEXT_DTP_EditHNear (0L << 4) | |
| 24 #define FWL_STYLEEXT_DTP_EditHCenter (1L << 4) | |
| 25 #define FWL_STYLEEXT_DTP_EditHFar (2L << 4) | |
| 26 #define FWL_STYLEEXT_DTP_EditVNear (0L << 6) | |
| 27 #define FWL_STYLEEXT_DTP_EditVCenter (1L << 6) | |
| 28 #define FWL_STYLEEXT_DTP_EditVFar (2L << 6) | |
| 29 #define FWL_STYLEEXT_DTP_EditJustified (1L << 8) | |
| 30 #define FWL_STYLEEXT_DTP_EditDistributed (2L << 8) | |
| 31 #define FWL_STYLEEXT_DTP_EditHAlignMask (3L << 4) | |
| 32 #define FWL_STYLEEXT_DTP_EditVAlignMask (3L << 6) | |
| 33 #define FWL_STYLEEXT_DTP_EditHAlignModeMask (3L << 8) | |
| 34 | |
| 35 class CFWL_DateTimeEdit; | |
| 36 class CFWL_FormProxy; | |
| 37 | |
| 38 class CFWL_DateTimePicker : public CFWL_Widget { | |
| 39 public: | |
| 40 explicit CFWL_DateTimePicker(const CFWL_App* pApp); | |
| 41 ~CFWL_DateTimePicker() override; | |
| 42 | |
| 43 // CFWL_Widget | |
| 44 FWL_Type GetClassID() const override; | |
| 45 void Update() override; | |
| 46 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | |
| 47 void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; | |
| 48 void SetThemeProvider(IFWL_ThemeProvider* pTP) override; | |
| 49 void OnProcessMessage(CFWL_Message* pMessage) override; | |
| 50 void OnDrawWidget(CFX_Graphics* pGraphics, | |
| 51 const CFX_Matrix* pMatrix) override; | |
| 52 | |
| 53 void GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay); | |
| 54 void SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay); | |
| 55 | |
| 56 void SetEditText(const CFX_WideString& wsText); | |
| 57 CFX_WideString GetEditText() const; | |
| 58 | |
| 59 int32_t CountSelRanges() const { return m_pEdit->CountSelRanges(); } | |
| 60 int32_t GetSelRange(int32_t nIndex, int32_t* nStart) const { | |
| 61 return m_pEdit->GetSelRange(nIndex, nStart); | |
| 62 } | |
| 63 | |
| 64 void GetBBox(CFX_RectF& rect) const; | |
| 65 void SetEditLimit(int32_t nLimit) { m_pEdit->SetLimit(nLimit); } | |
| 66 void ModifyEditStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); | |
| 67 | |
| 68 bool IsMonthCalendarVisible() const; | |
| 69 void ShowMonthCalendar(bool bActivate); | |
| 70 void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay); | |
| 71 | |
| 72 CFWL_FormProxy* GetFormProxy() const { return m_pForm.get(); } | |
| 73 | |
| 74 private: | |
| 75 void DrawDropDownButton(CFX_Graphics* pGraphics, | |
| 76 IFWL_ThemeProvider* pTheme, | |
| 77 const CFX_Matrix* pMatrix); | |
| 78 void FormatDateString(int32_t iYear, | |
| 79 int32_t iMonth, | |
| 80 int32_t iDay, | |
| 81 CFX_WideString& wsText); | |
| 82 void ResetEditAlignment(); | |
| 83 void InitProxyForm(); | |
| 84 void OnFocusChanged(CFWL_Message* pMsg, bool bSet); | |
| 85 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
| 86 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
| 87 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
| 88 void OnMouseLeave(CFWL_MsgMouse* pMsg); | |
| 89 | |
| 90 bool DisForm_IsMonthCalendarVisible() const; | |
| 91 void DisForm_ShowMonthCalendar(bool bActivate); | |
| 92 FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) const; | |
| 93 bool DisForm_IsNeedShowButton() const; | |
| 94 void DisForm_Update(); | |
| 95 void DisForm_GetBBox(CFX_RectF& rect) const; | |
| 96 void DisForm_DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); | |
| 97 void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet); | |
| 98 | |
| 99 CFX_RectF m_rtBtn; | |
| 100 CFX_RectF m_rtClient; | |
| 101 int32_t m_iBtnState; | |
| 102 int32_t m_iYear; | |
| 103 int32_t m_iMonth; | |
| 104 int32_t m_iDay; | |
| 105 bool m_bLBtnDown; | |
| 106 std::unique_ptr<CFWL_DateTimeEdit> m_pEdit; | |
| 107 std::unique_ptr<CFWL_MonthCalendar> m_pMonthCal; | |
| 108 std::unique_ptr<CFWL_FormProxy> m_pForm; | |
| 109 FX_FLOAT m_fBtn; | |
| 110 }; | |
| 111 | |
| 112 #endif // XFA_FWL_CORE_CFWL_DATETIMEPICKER_H_ | |
| OLD | NEW |