Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fwl / src / lightwidget / pushbutton.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_PushButton* CFWL_PushButton::Create()\r
9 {\r
10     return FX_NEW CFWL_PushButton;\r
11 }\r
12 FWL_ERR CFWL_PushButton::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_buttonData;\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_PushButton::Create();\r
32     FWL_ERR ret = ((IFWL_PushButton*)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_PushButton::GetCaption(CFX_WideString &wsCaption)\r
39 {\r
40     wsCaption = m_buttonData.m_wsCaption;\r
41     return FWL_ERR_Succeeded;\r
42 }\r
43 FWL_ERR CFWL_PushButton::SetCaption(FX_WSTR wsCaption)\r
44 {\r
45     m_buttonData.m_wsCaption = wsCaption;\r
46     return FWL_ERR_Succeeded;\r
47 }\r
48 CFX_DIBitmap* CFWL_PushButton::GetPicture()\r
49 {\r
50     return m_buttonData.m_pBitmap;\r
51 }\r
52 FWL_ERR CFWL_PushButton::SetPicture(CFX_DIBitmap *pBitmap)\r
53 {\r
54     m_buttonData.m_pBitmap = pBitmap;\r
55     return FWL_ERR_Succeeded;\r
56 }\r
57 CFWL_PushButton::CFWL_PushButton()\r
58 {\r
59 }\r
60 CFWL_PushButton::~CFWL_PushButton()\r
61 {\r
62 }\r
63 FWL_ERR CFWL_PushButton::CFWL_PushButtonDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)\r
64 {\r
65     wsCaption = m_wsCaption;\r
66     return FWL_ERR_Succeeded;\r
67 }\r
68 CFX_DIBitmap* CFWL_PushButton::CFWL_PushButtonDP::GetPicture(IFWL_Widget *pWidget)\r
69 {\r
70     return m_pBitmap;\r
71 }\r