Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fwl / src / lightwidget / checkbox.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_CheckBox* CFWL_CheckBox::Create()\r
9 {\r
10     return FX_NEW CFWL_CheckBox;\r
11 }\r
12 FWL_ERR CFWL_CheckBox::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_ctmOnParent = m_pProperties->m_ctmOnParent;\r
20     prop.m_rtWidget = m_pProperties->m_rtWidget;\r
21     prop.m_dwStyles = m_pProperties->m_dwStyles;\r
22     prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;\r
23     prop.m_dwStates = m_pProperties->m_dwStates;\r
24     prop.m_pDataProvider = &m_checkboxData;\r
25     if (m_pProperties->m_pParent) {\r
26         prop.m_pParent = m_pProperties->m_pParent->GetWidget();\r
27     }\r
28     if (m_pProperties->m_pOwner) {\r
29         prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();\r
30     }\r
31     m_pImp = IFWL_CheckBox::Create();\r
32     FWL_ERR ret = ((IFWL_CheckBox*)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_CheckBox::SetCaption(FX_WSTR wsCaption)\r
39 {\r
40     m_checkboxData.m_wsCaption = wsCaption;\r
41     return FWL_ERR_Succeeded;\r
42 }\r
43 FWL_ERR CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight)\r
44 {\r
45     m_checkboxData.m_fBoxHeight = fHeight;\r
46     return FWL_ERR_Succeeded;\r
47 }\r
48 FX_INT32 CFWL_CheckBox::GetCheckState()\r
49 {\r
50     return ((IFWL_CheckBox*)m_pImp)->GetCheckState();\r
51 }\r
52 FWL_ERR CFWL_CheckBox::SetCheckState(FX_INT32 iCheck)\r
53 {\r
54     return ((IFWL_CheckBox*)m_pImp)->SetCheckState(iCheck);\r
55 }\r
56 CFWL_CheckBox::CFWL_CheckBox()\r
57 {\r
58 }\r
59 CFWL_CheckBox::~CFWL_CheckBox()\r
60 {\r
61 }\r
62 CFWL_CheckBox::CFWL_CheckBoxDP::CFWL_CheckBoxDP()\r
63     : m_fBoxHeight(16.0f)\r
64     , m_wsCaption(L"Check box")\r
65 {\r
66 }\r
67 FWL_ERR CFWL_CheckBox::CFWL_CheckBoxDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)\r
68 {\r
69     wsCaption = m_wsCaption;\r
70     return FWL_ERR_Succeeded;\r
71 }\r
72 FX_FLOAT CFWL_CheckBox::CFWL_CheckBoxDP::GetBoxSize(IFWL_Widget *pWidget)\r
73 {\r
74     return m_fBoxHeight;\r
75 }\r