Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlRadioGroup.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         FUiCtrlRadioGroup.cpp
19 * @brief        This file contains implementation of RadioGroup class
20 */
21
22 #include <FUiCtrlRadioGroup.h>
23 #include <FBaseSysLog.h>
24 #include "FUiCtrl_RadioGroupImpl.h"
25
26 using namespace Tizen::Base;
27 using namespace Tizen::Graphics;
28
29 namespace Tizen { namespace Ui { namespace Controls
30 {
31
32 RadioGroup::RadioGroup(void)
33 {
34
35 }
36
37 RadioGroup::~RadioGroup(void)
38 {
39
40 }
41
42 result
43 RadioGroup::Construct(void)
44 {
45         result r = E_SUCCESS;
46         _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this);
47
48         SysAssertf(pRadioGroupImpl == null,
49                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
50
51         pRadioGroupImpl = _RadioGroupImpl::CreateRadioGroupImplN(this);
52         r = GetLastResult();
53         SysTryReturn(NID_UI_CTRL, pRadioGroupImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
54
55         _pControlImpl = pRadioGroupImpl;
56
57         return E_SUCCESS;
58 }
59
60 result
61 RadioGroup::Add(const CheckButton& checkButton)
62 {
63         _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this);
64         SysTryReturn(NID_UI_CTRL, pRadioGroupImpl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
65
66         result r = pRadioGroupImpl->Add(checkButton);
67         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
68
69         return E_SUCCESS;
70 }
71
72 result
73 RadioGroup::Add(CheckButton* pCheckButton)
74 {
75         SysTryReturn(NID_UI_CTRL, pCheckButton, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
76
77         return Add(*pCheckButton);
78 }
79
80 result
81 RadioGroup::Remove(const CheckButton& checkButton)
82 {
83         _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this);
84         SysTryReturn(NID_UI_CTRL, pRadioGroupImpl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.\n");
85
86         result r = pRadioGroupImpl->Remove(checkButton);
87         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
88
89         return E_SUCCESS;
90 }
91
92 result
93 RadioGroup::Remove(CheckButton* pCheckButton)
94 {
95         SysTryReturn(NID_UI_CTRL, pCheckButton, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
96
97         return Remove(*pCheckButton);
98 }
99
100 int
101 RadioGroup::GetItemCount(void) const
102 {
103         const _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this);
104         SysAssertf(pRadioGroupImpl != null,
105                                 "Not yet constructed. Construct() should be called before use.");
106
107         return pRadioGroupImpl->GetItemCount();
108 }
109
110 void
111 RadioGroup::SetSelectedItem(const CheckButton& checkButton)
112 {
113         _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this);
114         SysAssertf(pRadioGroupImpl != null,
115                                         "Not yet constructed. Construct() should be called before use.");
116
117         pRadioGroupImpl->SetSelectedItem(checkButton);
118
119         return;
120 }
121
122 void
123 RadioGroup::SetSelectedItem(CheckButton* pCheckButton)
124 {
125         SysTryReturnVoidResult(NID_UI_CTRL, pCheckButton, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
126
127         return SetSelectedItem(*pCheckButton);
128 }
129
130 const CheckButton*
131 RadioGroup::GetSelectedItem(void) const
132 {
133         const _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this);
134         SysAssertf(pRadioGroupImpl != null,
135                                         "Not yet constructed. Construct() should be called before use.");
136
137         return pRadioGroupImpl->GetSelectedItem();
138 }
139
140 }}} // Tizen::Ui::Controls