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