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