Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fwl / src / lightwidget / datetimepicker.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../../foxitlib.h"\r
8 CFWL_DateTimePicker* CFWL_DateTimePicker::Create()\r
9 {\r
10     return FX_NEW CFWL_DateTimePicker;\r
11 }\r
12 FWL_ERR CFWL_DateTimePicker::Initialize(const CFWL_WidgetProperties *pProperties )\r
13 {\r
14     _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);\r
15     if (pProperties) {\r
16         *m_pProperties = *pProperties;\r
17     }\r
18     CFWL_WidgetImpProperties prop;\r
19     prop.m_dwStyles = m_pProperties->m_dwStyles;\r
20     prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;\r
21     prop.m_dwStates = m_pProperties->m_dwStates;\r
22     prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;\r
23     prop.m_pDataProvider = &m_DateTimePickerDP;\r
24     if (m_pProperties->m_pParent) {\r
25         prop.m_pParent = m_pProperties->m_pParent->GetWidget();\r
26     }\r
27     if (m_pProperties->m_pOwner) {\r
28         prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();\r
29     }\r
30     prop.m_rtWidget = m_pProperties->m_rtWidget;\r
31     m_pImp = IFWL_DateTimePicker::Create();\r
32     FWL_ERR ret = ((IFWL_DateTimePicker*)m_pImp)->Initialize(prop);\r
33     if (ret == FWL_ERR_Succeeded) {\r
34         CFWL_Widget::Initialize();\r
35     }\r
36     return ret;\r
37 }\r
38 FWL_ERR CFWL_DateTimePicker::SetToday(FX_INT32 iYear, FX_INT32 iMonth, FX_INT32 iDay)\r
39 {\r
40     m_DateTimePickerDP.m_iYear = iYear;\r
41     m_DateTimePickerDP.m_iMonth = iMonth;\r
42     m_DateTimePickerDP.m_iDay = iDay;\r
43     return FWL_ERR_Succeeded;\r
44 }\r
45 FX_INT32 CFWL_DateTimePicker::CountSelRanges()\r
46 {\r
47     return ((IFWL_DateTimePicker*)m_pImp)->CountSelRanges();\r
48 }\r
49 FX_INT32 CFWL_DateTimePicker::GetSelRange(FX_INT32 nIndex, FX_INT32 &nStart)\r
50 {\r
51     return ((IFWL_DateTimePicker*)m_pImp)->GetSelRange(nIndex, nStart);\r
52 }\r
53 FWL_ERR CFWL_DateTimePicker::GetEditText(CFX_WideString &wsText)\r
54 {\r
55     return ((IFWL_DateTimePicker*)m_pImp)->GetEditText(wsText);\r
56 }\r
57 FWL_ERR CFWL_DateTimePicker::SetEditText(FX_WSTR wsText)\r
58 {\r
59     return ((IFWL_DateTimePicker*)m_pImp)->SetEditText(wsText);\r
60 }\r
61 FWL_ERR CFWL_DateTimePicker::GetCurSel(FX_INT32 &iYear, FX_INT32 &iMonth, FX_INT32 &iDay)\r
62 {\r
63     return ((IFWL_DateTimePicker*)m_pImp)->GetCurSel(iYear, iMonth, iDay);\r
64 }\r
65 FWL_ERR CFWL_DateTimePicker::SetCurSel(FX_INT32 iYear, FX_INT32 iMonth, FX_INT32 iDay)\r
66 {\r
67     return ((IFWL_DateTimePicker*)m_pImp)->SetCurSel(iYear, iMonth, iDay);\r
68 }\r
69 CFWL_DateTimePicker::CFWL_DateTimePicker()\r
70 {\r
71 }\r
72 CFWL_DateTimePicker::~CFWL_DateTimePicker()\r
73 {\r
74 }\r
75 CFWL_DateTimePicker::CFWL_DateTimePickerDP::CFWL_DateTimePickerDP()\r
76 {\r
77     m_iYear = 2011;\r
78     m_iMonth = 1;\r
79     m_iDay = 1;\r
80 }\r
81 FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)\r
82 {\r
83     wsCaption = m_wsData;\r
84     return FWL_ERR_Succeeded;\r
85 }\r
86 FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday(IFWL_Widget *pWidget, FX_INT32 &iYear, FX_INT32 &iMonth, FX_INT32 &iDay)\r
87 {\r
88     iYear = m_iYear;\r
89     iMonth = m_iMonth;\r
90     iDay = m_iDay;\r
91     return FWL_ERR_Succeeded;\r
92 }\r
93 FX_BOOL CFWL_DateTimePicker::CanUndo()\r
94 {\r
95     return ((IFWL_DateTimePicker*)m_pImp)->CanUndo();\r
96 }\r
97 FX_BOOL CFWL_DateTimePicker::CanRedo()\r
98 {\r
99     return ((IFWL_DateTimePicker*)m_pImp)->CanRedo();\r
100 }\r
101 FX_BOOL CFWL_DateTimePicker::Undo()\r
102 {\r
103     return ((IFWL_DateTimePicker*)m_pImp)->Undo();\r
104 }\r
105 FX_BOOL CFWL_DateTimePicker::Redo()\r
106 {\r
107     return ((IFWL_DateTimePicker*)m_pImp)->Redo();\r
108 }\r
109 FX_BOOL CFWL_DateTimePicker::CanCopy()\r
110 {\r
111     return ((IFWL_DateTimePicker*)m_pImp)->CanCopy();\r
112 }\r
113 FX_BOOL CFWL_DateTimePicker::CanCut()\r
114 {\r
115     return ((IFWL_DateTimePicker*)m_pImp)->CanCut();\r
116 }\r
117 FX_BOOL CFWL_DateTimePicker::CanSelectAll()\r
118 {\r
119     return ((IFWL_DateTimePicker*)m_pImp)->CanSelectAll();\r
120 }\r
121 FX_BOOL CFWL_DateTimePicker::Copy(CFX_WideString &wsCopy)\r
122 {\r
123     return ((IFWL_DateTimePicker*)m_pImp)->Copy(wsCopy);\r
124 }\r
125 FX_BOOL CFWL_DateTimePicker::Cut(CFX_WideString &wsCut)\r
126 {\r
127     return ((IFWL_DateTimePicker*)m_pImp)->Copy(wsCut);\r
128 }\r
129 FX_BOOL CFWL_DateTimePicker::Paste(const CFX_WideString &wsPaste)\r
130 {\r
131     return ((IFWL_DateTimePicker*)m_pImp)->Paste(wsPaste);\r
132 }\r
133 FX_BOOL CFWL_DateTimePicker::SelectAll()\r
134 {\r
135     return ((IFWL_DateTimePicker*)m_pImp)->SelectAll();\r
136 }\r
137 FX_BOOL CFWL_DateTimePicker::Delete()\r
138 {\r
139     return ((IFWL_DateTimePicker*)m_pImp)->Delete();\r
140 }\r
141 FX_BOOL CFWL_DateTimePicker::DeSelect()\r
142 {\r
143     return ((IFWL_DateTimePicker*)m_pImp)->DeSelect();\r
144 }\r
145 FWL_ERR CFWL_DateTimePicker::GetBBox(CFX_RectF &rect)\r
146 {\r
147     return ((IFWL_DateTimePicker*)m_pImp)->GetBBox(rect);\r
148 }\r
149 FWL_ERR CFWL_DateTimePicker::SetEditLimit(FX_INT32 nLimit)\r
150 {\r
151     return ((IFWL_DateTimePicker*)m_pImp)->SetEditLimit(nLimit);\r
152 }\r
153 FWL_ERR CFWL_DateTimePicker::ModifyEditStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved)\r
154 {\r
155     return ((IFWL_DateTimePicker*)m_pImp)->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved);\r
156 }\r