Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlButtonItem.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18 * @file                 FUiCtrlButtonItem.cpp
19 * @brief                This is the implementation file for ButtonItem class.
20 */
21
22 #include <new>
23 #include <FUiCtrlButtonItem.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_ButtonItemImpl.h"
26
27 namespace Tizen { namespace Ui { namespace Controls
28 {
29
30 ButtonItem::ButtonItem(void)
31         : __pImpl(null)
32 {
33 }
34
35 ButtonItem::~ButtonItem(void)
36 {
37         if (__pImpl)
38         {
39                 delete __pImpl;
40                 __pImpl = null;
41         }
42 }
43
44 result
45 ButtonItem::Construct(ButtonItemStyle style, int actionId)
46 {
47         result r = E_SUCCESS;
48
49         SysTryReturnResult(NID_UI_CTRL, (actionId >= BUTTON_ITEM_ACTION_ID_MIN && actionId <= BUTTON_ITEM_ACTION_ID_MAX), E_INVALID_ARG,
50                            "[E_INVALID_ARG] The actionId is invalid.");
51
52         _ButtonItemImpl* pImpl = _ButtonItemImpl::GetInstance(*this);
53         SysAssertf(pImpl == null,
54                                 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
55
56         __pImpl = new (std::nothrow) _ButtonItemImpl(this);
57         SysTryReturnResult(NID_UI_CTRL, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Impl instance is not constructed");
58
59         r = __pImpl->Construct(style, actionId);
60
61         if (IsFailed(r))
62         {
63                 delete __pImpl;
64                 __pImpl = null;
65                 SysLog(NID_UI_CTRL, "[%s] Propagated.", GetErrorMessage(r));
66                 return r;
67         }
68
69         return r;
70 }
71
72 int
73 ButtonItem::GetActionId(void) const
74 {
75         SysAssertf(__pImpl != null,
76                                 "Not yet constructed. Construct() should be called before use.");
77
78         return __pImpl->GetActionId();
79 }
80
81 Tizen::Base::String
82 ButtonItem::GetText(void) const
83 {
84         SysAssertf(__pImpl != null,
85                                 "Not yet constructed. Construct() should be called before use.");
86
87         return __pImpl->GetText();
88 }
89
90 result
91 ButtonItem::SetActionId(int actionId)
92 {
93         SysAssertf(__pImpl != null,
94                                 "Not yet constructed. Construct() should be called before use.");
95
96         return __pImpl->SetActionId(actionId);
97 }
98
99 result
100 ButtonItem::SetBackgroundBitmap(ButtonItemStatus status, const Tizen::Graphics::Bitmap* pBitmap)
101 {
102         SysAssertf(__pImpl != null,
103                                 "Not yet constructed. Construct() should be called before use.");
104
105         return __pImpl->SetBackgroundBitmap(status, pBitmap);
106 }
107
108 result
109 ButtonItem::SetIcon(ButtonItemStatus status, const Tizen::Graphics::Bitmap* pIcon)
110 {
111         SysAssertf(__pImpl != null,
112                                 "Not yet constructed. Construct() should be called before use.");
113
114         return __pImpl->SetIcon(status, pIcon);
115 }
116
117 result
118 ButtonItem::SetText(const Tizen::Base::String& text)
119 {
120         SysAssertf(__pImpl != null,
121                                 "Not yet constructed. Construct() should be called before use.");
122
123         return __pImpl->SetText(text);
124 }
125
126 }}} // Tizen::Ui::Controls