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