Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlCustomListItemFormat.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 /**
19 * @file         FUiCtrlCustomListItemFormat.cpp
20 * @brief        This file contains implementation of CustomListItemFormat class
21 */
22
23 #include <FGrpBitmap.h>
24 #include <FGrpRectangle.h>
25 #include <FUiCtrlCustomListItemFormat.h>
26 #include <FBaseSysLog.h>
27 #include "FUiCtrl_CustomListItemFormatImpl.h"
28
29 using namespace Tizen::Graphics;
30
31 namespace Tizen { namespace Ui { namespace Controls
32 {
33
34 CustomListItemFormat::CustomListItemFormat(void)
35         :__pCustomListItemFormatImpl(null)
36 {
37 }
38
39 CustomListItemFormat::~CustomListItemFormat(void)
40 {
41         delete __pCustomListItemFormatImpl;
42         __pCustomListItemFormatImpl = null;
43 }
44
45 result
46 CustomListItemFormat::Construct(void)
47 {
48         SysAssertf((__pCustomListItemFormatImpl == null),
49                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
50
51         __pCustomListItemFormatImpl = _CustomListItemFormatImpl::CreateInstanceN();
52         result r = GetLastResult();
53         SysTryReturn(NID_UI_CTRL, __pCustomListItemFormatImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
54
55         return r;
56 }
57
58 result
59 CustomListItemFormat::AddElement(int elementId, const Rectangle& rect)
60 {
61         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
62
63         SysTryReturnResult(NID_UI_CTRL, (rect.width > 0 && rect.height >0), E_INVALID_ARG, "The width and height should be greater than 0.");
64
65         result r = __pCustomListItemFormatImpl->AddElement(elementId, rect);
66         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r,  "[%s] A System error occurred.", GetErrorMessage(r));
67
68         return r;
69
70 }
71
72 result
73 CustomListItemFormat::AddElement(int elementId, const Rectangle& rect, int textSize)
74 {
75         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
76
77         SysTryReturnResult(NID_UI_CTRL, (rect.width > 0 && rect.height >0), E_INVALID_ARG, "The width and height should be greater than 0.");
78
79         result r = __pCustomListItemFormatImpl->AddElement(elementId, rect, textSize);
80         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r,  "[%s] A System error occurred.", GetErrorMessage(r));
81
82         return r;
83 }
84
85 result
86 CustomListItemFormat::AddElement(int elementId, const Rectangle& rect, int textSize, const Color& normalTextColor, const Color& focusedTextColor)
87 {
88         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
89
90         SysTryReturnResult(NID_UI_CTRL, (rect.width > 0 && rect.height >0), E_INVALID_ARG, "The width and height should be greater than 0.");
91
92         result r = __pCustomListItemFormatImpl->AddElement(elementId, rect, textSize, normalTextColor, focusedTextColor);
93         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r,  "[%s] A System error occurred.", GetErrorMessage(r));
94
95         return r;
96 }
97
98 result
99 CustomListItemFormat::AddElement(int elementId, const Rectangle& rect, int textSize, const Color& normalTextColor, const Color& focusedTextColor, const Color& highlightedTextColor)
100 {
101         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
102
103         SysTryReturnResult(NID_UI_CTRL, (rect.width > 0 && rect.height >0), E_INVALID_ARG, "The width and height should be greater than 0.");
104
105         result r = __pCustomListItemFormatImpl->AddElement(elementId, rect, textSize, normalTextColor, focusedTextColor, highlightedTextColor);
106         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r,  "[%s] A System error occurred.", GetErrorMessage(r));
107
108         return r;
109 }
110
111 Rectangle
112 CustomListItemFormat::GetElement(int elementId) const
113 {
114         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
115         SetLastResult(E_SUCCESS);
116         return __pCustomListItemFormatImpl->GetElement(elementId);
117 }
118
119 int
120 CustomListItemFormat::GetFirstElementId(void) const
121 {
122         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
123         SetLastResult(E_SUCCESS);
124         return __pCustomListItemFormatImpl->GetFirstElementId();
125 }
126
127 int
128 CustomListItemFormat::GetNextElementId(int elementId) const
129 {
130         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
131         SetLastResult(E_SUCCESS);
132         return __pCustomListItemFormatImpl->GetNextElementId(elementId);
133 }
134
135 int
136 CustomListItemFormat::GetFirstEnabledElementId(void) const
137 {
138         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
139         SetLastResult(E_SUCCESS);
140         return __pCustomListItemFormatImpl->GetFirstEnabledElementId();
141 }
142
143 int
144 CustomListItemFormat::GetNextEnabledElementId(int elementId) const
145 {
146         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
147         SetLastResult(E_SUCCESS);
148         return __pCustomListItemFormatImpl->GetNextEnabledElementId(elementId);
149 }
150
151 int
152 CustomListItemFormat::GetPreviousEnabledElementId(int elementId) const
153 {
154         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
155         SetLastResult(E_SUCCESS);
156         return __pCustomListItemFormatImpl->GetPreviousEnabledElementId(elementId);
157 }
158
159 void
160 CustomListItemFormat::SetElementEventEnabled(int elementId, bool enable)
161 {
162         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
163         SetLastResult(E_SUCCESS);
164         __pCustomListItemFormatImpl->SetElementEventEnabled(elementId, enable);
165 }
166
167 bool
168 CustomListItemFormat::IsElementEventEnabled(int elementId)
169 {
170         SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use.");
171         SetLastResult(E_SUCCESS);
172         return __pCustomListItemFormatImpl->IsElementEventEnabled(elementId);
173 }
174
175 }}} //Tizen::Ui::Controls