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