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