| 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 "third_party/base/ptr_util.h" | 11 #include "third_party/base/ptr_util.h" |
| 12 #include "xfa/fwl/core/fwl_error.h" | 12 #include "xfa/fwl/core/fwl_error.h" |
| 13 #include "xfa/fwl/core/ifwl_datetimepicker.h" | 13 #include "xfa/fwl/core/ifwl_datetimepicker.h" |
| 14 #include "xfa/fwl/core/ifwl_widget.h" | 14 #include "xfa/fwl/core/ifwl_widget.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 IFWL_DateTimePicker* ToDateTimePicker(IFWL_Widget* widget) { | 18 IFWL_DateTimePicker* ToDateTimePicker(IFWL_Widget* widget) { |
| 19 return static_cast<IFWL_DateTimePicker*>(widget); | 19 return static_cast<IFWL_DateTimePicker*>(widget); |
| 20 } | 20 } |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 CFWL_DateTimePicker::CFWL_DateTimePicker(const IFWL_App* app) | 24 CFWL_DateTimePicker::CFWL_DateTimePicker(const IFWL_App* app) |
| 25 : CFWL_Widget(app) {} | 25 : CFWL_Widget(app), m_iYear(2011), m_iMonth(1), m_iDay(1) {} |
| 26 | 26 |
| 27 CFWL_DateTimePicker::~CFWL_DateTimePicker() {} | 27 CFWL_DateTimePicker::~CFWL_DateTimePicker() {} |
| 28 | 28 |
| 29 void CFWL_DateTimePicker::Initialize() { | 29 void CFWL_DateTimePicker::Initialize() { |
| 30 ASSERT(!m_pIface); | 30 ASSERT(!m_pIface); |
| 31 | 31 |
| 32 m_pIface = pdfium::MakeUnique<IFWL_DateTimePicker>( | 32 m_pIface = pdfium::MakeUnique<IFWL_DateTimePicker>( |
| 33 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(&m_DateTimePickerDP)); | 33 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(this)); |
| 34 | 34 |
| 35 CFWL_Widget::Initialize(); | 35 CFWL_Widget::Initialize(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 FWL_Error CFWL_DateTimePicker::SetToday(int32_t iYear, | 38 FWL_Error CFWL_DateTimePicker::SetToday(int32_t iYear, |
| 39 int32_t iMonth, | 39 int32_t iMonth, |
| 40 int32_t iDay) { | 40 int32_t iDay) { |
| 41 m_DateTimePickerDP.m_iYear = iYear; | 41 m_iYear = iYear; |
| 42 m_DateTimePickerDP.m_iMonth = iMonth; | 42 m_iMonth = iMonth; |
| 43 m_DateTimePickerDP.m_iDay = iDay; | 43 m_iDay = iDay; |
| 44 return FWL_Error::Succeeded; | 44 return FWL_Error::Succeeded; |
| 45 } | 45 } |
| 46 | 46 |
| 47 int32_t CFWL_DateTimePicker::CountSelRanges() { | 47 int32_t CFWL_DateTimePicker::CountSelRanges() { |
| 48 return ToDateTimePicker(GetWidget())->CountSelRanges(); | 48 return ToDateTimePicker(GetWidget())->CountSelRanges(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { | 51 int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { |
| 52 return ToDateTimePicker(GetWidget())->GetSelRange(nIndex, nStart); | 52 return ToDateTimePicker(GetWidget())->GetSelRange(nIndex, nStart); |
| 53 } | 53 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 65 int32_t& iDay) { | 65 int32_t& iDay) { |
| 66 return ToDateTimePicker(GetWidget())->GetCurSel(iYear, iMonth, iDay); | 66 return ToDateTimePicker(GetWidget())->GetCurSel(iYear, iMonth, iDay); |
| 67 } | 67 } |
| 68 | 68 |
| 69 FWL_Error CFWL_DateTimePicker::SetCurSel(int32_t iYear, | 69 FWL_Error CFWL_DateTimePicker::SetCurSel(int32_t iYear, |
| 70 int32_t iMonth, | 70 int32_t iMonth, |
| 71 int32_t iDay) { | 71 int32_t iDay) { |
| 72 return ToDateTimePicker(GetWidget())->SetCurSel(iYear, iMonth, iDay); | 72 return ToDateTimePicker(GetWidget())->SetCurSel(iYear, iMonth, iDay); |
| 73 } | 73 } |
| 74 | 74 |
| 75 CFWL_DateTimePicker::CFWL_DateTimePickerDP::CFWL_DateTimePickerDP() { | 75 FWL_Error CFWL_DateTimePicker::GetCaption(IFWL_Widget* pWidget, |
| 76 m_iYear = 2011; | 76 CFX_WideString& wsCaption) { |
| 77 m_iMonth = 1; | |
| 78 m_iDay = 1; | |
| 79 } | |
| 80 | |
| 81 FWL_Error CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption( | |
| 82 IFWL_Widget* pWidget, | |
| 83 CFX_WideString& wsCaption) { | |
| 84 wsCaption = m_wsData; | 77 wsCaption = m_wsData; |
| 85 return FWL_Error::Succeeded; | 78 return FWL_Error::Succeeded; |
| 86 } | 79 } |
| 87 | 80 |
| 88 FWL_Error CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday( | 81 FWL_Error CFWL_DateTimePicker::GetToday(IFWL_Widget* pWidget, |
| 89 IFWL_Widget* pWidget, | 82 int32_t& iYear, |
| 90 int32_t& iYear, | 83 int32_t& iMonth, |
| 91 int32_t& iMonth, | 84 int32_t& iDay) { |
| 92 int32_t& iDay) { | |
| 93 iYear = m_iYear; | 85 iYear = m_iYear; |
| 94 iMonth = m_iMonth; | 86 iMonth = m_iMonth; |
| 95 iDay = m_iDay; | 87 iDay = m_iDay; |
| 96 return FWL_Error::Succeeded; | 88 return FWL_Error::Succeeded; |
| 97 } | 89 } |
| 98 | 90 |
| 99 bool CFWL_DateTimePicker::CanUndo() { | 91 bool CFWL_DateTimePicker::CanUndo() { |
| 100 return ToDateTimePicker(GetWidget())->CanUndo(); | 92 return ToDateTimePicker(GetWidget())->CanUndo(); |
| 101 } | 93 } |
| 102 | 94 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 146 |
| 155 FWL_Error CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { | 147 FWL_Error CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { |
| 156 return ToDateTimePicker(GetWidget())->SetEditLimit(nLimit); | 148 return ToDateTimePicker(GetWidget())->SetEditLimit(nLimit); |
| 157 } | 149 } |
| 158 | 150 |
| 159 FWL_Error CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, | 151 FWL_Error CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, |
| 160 uint32_t dwStylesExRemoved) { | 152 uint32_t dwStylesExRemoved) { |
| 161 return ToDateTimePicker(GetWidget()) | 153 return ToDateTimePicker(GetWidget()) |
| 162 ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved); | 154 ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 163 } | 155 } |
| OLD | NEW |