| 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 #include "xfa/include/fwl/lightwidget/datetimepicker.h" | 7 #include "xfa/fwl/lightwidget/cfwl_datetimepicker.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" | 11 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" |
| 12 #include "xfa/fwl/core/fwl_error.h" | 12 #include "xfa/fwl/core/fwl_error.h" |
| 13 #include "xfa/fwl/core/ifwl_widget.h" | 13 #include "xfa/fwl/core/ifwl_widget.h" |
| 14 | 14 |
| 15 CFWL_DateTimePicker* CFWL_DateTimePicker::Create() { | 15 CFWL_DateTimePicker* CFWL_DateTimePicker::Create() { |
| 16 return new CFWL_DateTimePicker; | 16 return new CFWL_DateTimePicker; |
| 17 } | 17 } |
| 18 |
| 18 FWL_ERR CFWL_DateTimePicker::Initialize( | 19 FWL_ERR CFWL_DateTimePicker::Initialize( |
| 19 const CFWL_WidgetProperties* pProperties) { | 20 const CFWL_WidgetProperties* pProperties) { |
| 20 if (m_pIface) | 21 if (m_pIface) |
| 21 return FWL_ERR_Indefinite; | 22 return FWL_ERR_Indefinite; |
| 22 if (pProperties) { | 23 if (pProperties) { |
| 23 *m_pProperties = *pProperties; | 24 *m_pProperties = *pProperties; |
| 24 } | 25 } |
| 25 std::unique_ptr<IFWL_DateTimePicker> pDateTimePicker( | 26 std::unique_ptr<IFWL_DateTimePicker> pDateTimePicker( |
| 26 IFWL_DateTimePicker::Create( | 27 IFWL_DateTimePicker::Create( |
| 27 m_pProperties->MakeWidgetImpProperties(&m_DateTimePickerDP), | 28 m_pProperties->MakeWidgetImpProperties(&m_DateTimePickerDP), |
| 28 nullptr)); | 29 nullptr)); |
| 29 FWL_ERR ret = pDateTimePicker->Initialize(); | 30 FWL_ERR ret = pDateTimePicker->Initialize(); |
| 30 if (ret != FWL_ERR_Succeeded) { | 31 if (ret != FWL_ERR_Succeeded) { |
| 31 return ret; | 32 return ret; |
| 32 } | 33 } |
| 33 m_pIface = pDateTimePicker.release(); | 34 m_pIface = pDateTimePicker.release(); |
| 34 CFWL_Widget::Initialize(); | 35 CFWL_Widget::Initialize(); |
| 35 return FWL_ERR_Succeeded; | 36 return FWL_ERR_Succeeded; |
| 36 } | 37 } |
| 37 | 38 |
| 38 FWL_ERR CFWL_DateTimePicker::SetToday(int32_t iYear, | 39 FWL_ERR CFWL_DateTimePicker::SetToday(int32_t iYear, |
| 39 int32_t iMonth, | 40 int32_t iMonth, |
| 40 int32_t iDay) { | 41 int32_t iDay) { |
| 41 m_DateTimePickerDP.m_iYear = iYear; | 42 m_DateTimePickerDP.m_iYear = iYear; |
| 42 m_DateTimePickerDP.m_iMonth = iMonth; | 43 m_DateTimePickerDP.m_iMonth = iMonth; |
| 43 m_DateTimePickerDP.m_iDay = iDay; | 44 m_DateTimePickerDP.m_iDay = iDay; |
| 44 return FWL_ERR_Succeeded; | 45 return FWL_ERR_Succeeded; |
| 45 } | 46 } |
| 47 |
| 46 int32_t CFWL_DateTimePicker::CountSelRanges() { | 48 int32_t CFWL_DateTimePicker::CountSelRanges() { |
| 47 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CountSelRanges(); | 49 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CountSelRanges(); |
| 48 } | 50 } |
| 51 |
| 49 int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { | 52 int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { |
| 50 return static_cast<IFWL_DateTimePicker*>(m_pIface) | 53 return static_cast<IFWL_DateTimePicker*>(m_pIface) |
| 51 ->GetSelRange(nIndex, nStart); | 54 ->GetSelRange(nIndex, nStart); |
| 52 } | 55 } |
| 56 |
| 53 FWL_ERR CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) { | 57 FWL_ERR CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) { |
| 54 return static_cast<IFWL_DateTimePicker*>(m_pIface)->GetEditText(wsText); | 58 return static_cast<IFWL_DateTimePicker*>(m_pIface)->GetEditText(wsText); |
| 55 } | 59 } |
| 60 |
| 56 FWL_ERR CFWL_DateTimePicker::SetEditText(const CFX_WideStringC& wsText) { | 61 FWL_ERR CFWL_DateTimePicker::SetEditText(const CFX_WideStringC& wsText) { |
| 57 return static_cast<IFWL_DateTimePicker*>(m_pIface)->SetEditText(wsText); | 62 return static_cast<IFWL_DateTimePicker*>(m_pIface)->SetEditText(wsText); |
| 58 } | 63 } |
| 64 |
| 59 FWL_ERR CFWL_DateTimePicker::GetCurSel(int32_t& iYear, | 65 FWL_ERR CFWL_DateTimePicker::GetCurSel(int32_t& iYear, |
| 60 int32_t& iMonth, | 66 int32_t& iMonth, |
| 61 int32_t& iDay) { | 67 int32_t& iDay) { |
| 62 return static_cast<IFWL_DateTimePicker*>(m_pIface) | 68 return static_cast<IFWL_DateTimePicker*>(m_pIface) |
| 63 ->GetCurSel(iYear, iMonth, iDay); | 69 ->GetCurSel(iYear, iMonth, iDay); |
| 64 } | 70 } |
| 71 |
| 65 FWL_ERR CFWL_DateTimePicker::SetCurSel(int32_t iYear, | 72 FWL_ERR CFWL_DateTimePicker::SetCurSel(int32_t iYear, |
| 66 int32_t iMonth, | 73 int32_t iMonth, |
| 67 int32_t iDay) { | 74 int32_t iDay) { |
| 68 return static_cast<IFWL_DateTimePicker*>(m_pIface) | 75 return static_cast<IFWL_DateTimePicker*>(m_pIface) |
| 69 ->SetCurSel(iYear, iMonth, iDay); | 76 ->SetCurSel(iYear, iMonth, iDay); |
| 70 } | 77 } |
| 78 |
| 71 CFWL_DateTimePicker::CFWL_DateTimePicker() {} | 79 CFWL_DateTimePicker::CFWL_DateTimePicker() {} |
| 80 |
| 72 CFWL_DateTimePicker::~CFWL_DateTimePicker() {} | 81 CFWL_DateTimePicker::~CFWL_DateTimePicker() {} |
| 82 |
| 73 CFWL_DateTimePicker::CFWL_DateTimePickerDP::CFWL_DateTimePickerDP() { | 83 CFWL_DateTimePicker::CFWL_DateTimePickerDP::CFWL_DateTimePickerDP() { |
| 74 m_iYear = 2011; | 84 m_iYear = 2011; |
| 75 m_iMonth = 1; | 85 m_iMonth = 1; |
| 76 m_iDay = 1; | 86 m_iDay = 1; |
| 77 } | 87 } |
| 88 |
| 78 FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption( | 89 FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption( |
| 79 IFWL_Widget* pWidget, | 90 IFWL_Widget* pWidget, |
| 80 CFX_WideString& wsCaption) { | 91 CFX_WideString& wsCaption) { |
| 81 wsCaption = m_wsData; | 92 wsCaption = m_wsData; |
| 82 return FWL_ERR_Succeeded; | 93 return FWL_ERR_Succeeded; |
| 83 } | 94 } |
| 95 |
| 84 FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday( | 96 FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday( |
| 85 IFWL_Widget* pWidget, | 97 IFWL_Widget* pWidget, |
| 86 int32_t& iYear, | 98 int32_t& iYear, |
| 87 int32_t& iMonth, | 99 int32_t& iMonth, |
| 88 int32_t& iDay) { | 100 int32_t& iDay) { |
| 89 iYear = m_iYear; | 101 iYear = m_iYear; |
| 90 iMonth = m_iMonth; | 102 iMonth = m_iMonth; |
| 91 iDay = m_iDay; | 103 iDay = m_iDay; |
| 92 return FWL_ERR_Succeeded; | 104 return FWL_ERR_Succeeded; |
| 93 } | 105 } |
| 106 |
| 94 FX_BOOL CFWL_DateTimePicker::CanUndo() { | 107 FX_BOOL CFWL_DateTimePicker::CanUndo() { |
| 95 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanUndo(); | 108 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanUndo(); |
| 96 } | 109 } |
| 110 |
| 97 FX_BOOL CFWL_DateTimePicker::CanRedo() { | 111 FX_BOOL CFWL_DateTimePicker::CanRedo() { |
| 98 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanRedo(); | 112 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanRedo(); |
| 99 } | 113 } |
| 114 |
| 100 FX_BOOL CFWL_DateTimePicker::Undo() { | 115 FX_BOOL CFWL_DateTimePicker::Undo() { |
| 101 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Undo(); | 116 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Undo(); |
| 102 } | 117 } |
| 118 |
| 103 FX_BOOL CFWL_DateTimePicker::Redo() { | 119 FX_BOOL CFWL_DateTimePicker::Redo() { |
| 104 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Redo(); | 120 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Redo(); |
| 105 } | 121 } |
| 122 |
| 106 FX_BOOL CFWL_DateTimePicker::CanCopy() { | 123 FX_BOOL CFWL_DateTimePicker::CanCopy() { |
| 107 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanCopy(); | 124 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanCopy(); |
| 108 } | 125 } |
| 126 |
| 109 FX_BOOL CFWL_DateTimePicker::CanCut() { | 127 FX_BOOL CFWL_DateTimePicker::CanCut() { |
| 110 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanCut(); | 128 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanCut(); |
| 111 } | 129 } |
| 130 |
| 112 FX_BOOL CFWL_DateTimePicker::CanSelectAll() { | 131 FX_BOOL CFWL_DateTimePicker::CanSelectAll() { |
| 113 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanSelectAll(); | 132 return static_cast<IFWL_DateTimePicker*>(m_pIface)->CanSelectAll(); |
| 114 } | 133 } |
| 134 |
| 115 FX_BOOL CFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) { | 135 FX_BOOL CFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) { |
| 116 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Copy(wsCopy); | 136 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Copy(wsCopy); |
| 117 } | 137 } |
| 138 |
| 118 FX_BOOL CFWL_DateTimePicker::Cut(CFX_WideString& wsCut) { | 139 FX_BOOL CFWL_DateTimePicker::Cut(CFX_WideString& wsCut) { |
| 119 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Copy(wsCut); | 140 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Copy(wsCut); |
| 120 } | 141 } |
| 142 |
| 121 FX_BOOL CFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) { | 143 FX_BOOL CFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) { |
| 122 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Paste(wsPaste); | 144 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Paste(wsPaste); |
| 123 } | 145 } |
| 146 |
| 124 FX_BOOL CFWL_DateTimePicker::SelectAll() { | 147 FX_BOOL CFWL_DateTimePicker::SelectAll() { |
| 125 return static_cast<IFWL_DateTimePicker*>(m_pIface)->SelectAll(); | 148 return static_cast<IFWL_DateTimePicker*>(m_pIface)->SelectAll(); |
| 126 } | 149 } |
| 150 |
| 127 FX_BOOL CFWL_DateTimePicker::Delete() { | 151 FX_BOOL CFWL_DateTimePicker::Delete() { |
| 128 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Delete(); | 152 return static_cast<IFWL_DateTimePicker*>(m_pIface)->Delete(); |
| 129 } | 153 } |
| 154 |
| 130 FX_BOOL CFWL_DateTimePicker::DeSelect() { | 155 FX_BOOL CFWL_DateTimePicker::DeSelect() { |
| 131 return static_cast<IFWL_DateTimePicker*>(m_pIface)->DeSelect(); | 156 return static_cast<IFWL_DateTimePicker*>(m_pIface)->DeSelect(); |
| 132 } | 157 } |
| 158 |
| 133 FWL_ERR CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { | 159 FWL_ERR CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { |
| 134 return static_cast<IFWL_DateTimePicker*>(m_pIface)->GetBBox(rect); | 160 return static_cast<IFWL_DateTimePicker*>(m_pIface)->GetBBox(rect); |
| 135 } | 161 } |
| 162 |
| 136 FWL_ERR CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { | 163 FWL_ERR CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { |
| 137 return static_cast<IFWL_DateTimePicker*>(m_pIface)->SetEditLimit(nLimit); | 164 return static_cast<IFWL_DateTimePicker*>(m_pIface)->SetEditLimit(nLimit); |
| 138 } | 165 } |
| 166 |
| 139 FWL_ERR CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, | 167 FWL_ERR CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, |
| 140 uint32_t dwStylesExRemoved) { | 168 uint32_t dwStylesExRemoved) { |
| 141 return static_cast<IFWL_DateTimePicker*>(m_pIface) | 169 return static_cast<IFWL_DateTimePicker*>(m_pIface) |
| 142 ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved); | 170 ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 143 } | 171 } |
| OLD | NEW |