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