2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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
9 // http://floralicense.org/license/
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.
19 * @file FUiCtrl_ListItemBaseImpl.cpp
20 * @brief This is the implementation file for _ListItemBaseImpl class.
22 * This file contains the implementation of _ListItemBaseImpl class.
25 #include <FBaseSysLog.h>
26 #include <FUiCtrlListItemBase.h>
27 #include <FGrp_BitmapImpl.h>
28 #include "FUi_CoordinateSystemUtils.h"
29 #include "FUi_ResourceManager.h"
30 #include "FUiCtrl_ListContextItemImpl.h"
31 #include "FUiCtrl_ListItemBaseImpl.h"
32 #include "FUiCtrl_ListViewContextItem.h"
33 #include "FUiCtrl_ListViewItem.h"
34 #include "FUiCtrl_UiListViewItemEvent.h"
35 #include "FUiCtrl_UiListViewItemEventArg.h"
37 #ifdef MEMORY_LEAK_CHECK
38 #include "mem_leak_check.h"
41 using namespace Tizen::Base;
42 using namespace Tizen::Graphics;
43 using namespace Tizen::Graphics::_Text;
45 namespace Tizen { namespace Ui { namespace Controls
49 _ListItemBaseImpl::GetInstance(ListItemBase& listItemBase)
51 return listItemBase._pImpl;
54 const _ListItemBaseImpl*
55 _ListItemBaseImpl::GetInstance(const ListItemBase& listItemBase)
57 return listItemBase._pImpl;
60 _ListItemBaseImpl::_ListItemBaseImpl(ListItemBase* pPublic)
62 , __pListViewItem(null)
63 , __style(LIST_ANNEX_STYLE_NORMAL)
69 _ListItemBaseImpl::~_ListItemBaseImpl(void)
71 if (__pListViewItem != null)
73 __pListViewItem->Release();
81 _ListItemBaseImpl::GetPublicClassName(void) const
83 return "Tizen::Ui::Controls::ListItemBase";
87 _ListItemBaseImpl::GetPublic(void) const
89 return static_cast <const ListItemBase&>(*__pPublic);
93 _ListItemBaseImpl::GetPublic(void)
99 _ListItemBaseImpl::CreateListItemBaseImplN(ListItemBase* pPublic, const FloatDimension& itemSize, ListAnnexStyle style)
101 _ListItemBaseImpl* pImpl = new (std::nothrow) _ListItemBaseImpl(pPublic);
102 SysTryReturn(NID_UI_CTRL, (pImpl != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
104 result r = pImpl->Construct(itemSize, style);
105 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
117 _ListItemBaseImpl::Construct(const FloatDimension& itemSize, ListAnnexStyle style)
119 SysTryReturn(NID_UI_CTRL, (itemSize.width >= 0.0f) && (itemSize.height >= 0.0f), E_INVALID_ARG, E_INVALID_ARG,
120 ("[E_INVALID_ARG] The item size should be greater than 0.0f"));
122 __pListViewItem = _ListViewItem::CreateListViewItemN(itemSize.height);
123 SysTryReturn(NID_UI_CTRL, (__pListViewItem != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
125 __pListViewItem->SetSize(itemSize);
126 __pListViewItem->SetBounds(FloatRectangle(0.0f, 0.0f, itemSize.width, itemSize.height));
127 __pListViewItem->SetBackgroundColor(Color(0, 0, 0, 0));
128 __pListViewItem->SetSelectionStyle(TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE);
130 __itemSize = itemSize;
137 _ListItemBaseImpl::GetListViewItem(void) const
139 return __pListViewItem;
143 _ListItemBaseImpl::GetItemSize(void) const
149 _ListItemBaseImpl::SetBackgroundBitmap(ListItemDrawingStatus status, const Bitmap* pBitmap)
151 SysTryReturn(NID_UI_CTRL, (pBitmap != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] It is invalid argument.");
153 ListItemState itemState;
157 case LIST_ITEM_DRAWING_STATUS_NORMAL:
158 itemState = LIST_ITEM_STATE_NORMAL;
161 case LIST_ITEM_DRAWING_STATUS_PRESSED:
162 itemState = LIST_ITEM_STATE_PRESSED;
165 case LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED:
166 itemState = LIST_ITEM_STATE_HIGHLIGHTED;
170 SysTryReturn(NID_UI_CTRL, false, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to set background image.");
173 bool ret = __pListViewItem->SetItemBackgroundBitmap(itemState, pBitmap);
174 __pListViewItem->SetItemChanged(ret);
180 _ListItemBaseImpl::SetBackgroundColor(ListItemDrawingStatus status, const Color& color)
182 ListItemState itemState;
186 case LIST_ITEM_DRAWING_STATUS_NORMAL:
187 itemState = LIST_ITEM_STATE_NORMAL;
190 case LIST_ITEM_DRAWING_STATUS_PRESSED:
191 itemState = LIST_ITEM_STATE_PRESSED;
194 case LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED:
195 itemState = LIST_ITEM_STATE_HIGHLIGHTED;
199 SysTryReturn(NID_UI_CTRL, false, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to set background color.");
202 __pListViewItem->SetItemBackgroundColor(itemState, color);
203 __pListViewItem->SetItemChanged(true);
209 _ListItemBaseImpl::GetBackgroundColor(ListItemDrawingStatus status) const
211 ListItemState itemState;
215 case LIST_ITEM_DRAWING_STATUS_NORMAL:
216 itemState = LIST_ITEM_STATE_NORMAL;
219 case LIST_ITEM_DRAWING_STATUS_PRESSED:
220 itemState = LIST_ITEM_STATE_PRESSED;
223 case LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED:
224 itemState = LIST_ITEM_STATE_HIGHLIGHTED;
228 SysTryReturn(NID_UI_CTRL, false, Color(0), E_SYSTEM, "[E_SYSTEM] Unable to get background color.");
231 return __pListViewItem->GetItemBackgroundColor(itemState);
235 _ListItemBaseImpl::SetContextItem(const _ListContextItemImpl* pItem)
239 __pListViewItem->SetContextItem(null);
243 _ListViewContextItem* pContextItem = const_cast<_ListContextItemImpl*>(pItem)->GetContextItem();
245 if (pContextItem != null)
247 __pListViewItem->SetItemWidth(__itemSize.width);
248 __pListViewItem->SetContextItem(pContextItem);
249 __pListViewItem->SetContextItemEventListener(*this);
258 _ListItemBaseImpl::SetDescriptionText(const String& text)
260 SysTryReturn(NID_UI_CTRL, (__pListViewItem->SetDescriptionText(text) == true), E_SYSTEM, E_SYSTEM,
261 ("[E_SYSTEM] Unable to set description text."));
267 _ListItemBaseImpl::SetDescriptionTextColor(const Color& color)
269 __pListViewItem->SetDescriptionTextColor(color);
275 _ListItemBaseImpl::GetAnnexWidth(ListAnnexStyle style)
277 float annexWidth = 0.0f;
281 case LIST_ANNEX_STYLE_NORMAL:
285 case LIST_ANNEX_STYLE_MARK:
286 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
289 case LIST_ANNEX_STYLE_ONOFF_SLIDING:
290 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
293 case LIST_ANNEX_STYLE_DETAILED:
294 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
297 case LIST_ANNEX_STYLE_RADIO:
298 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
301 case LIST_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
302 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
313 _ListItemBaseImpl::GetListItemAnnexStyle(void)
319 _ListItemBaseImpl::SetTextColor(int elementId, Color textColor)
321 bool ret = __pListViewItem->SetTextColor(elementId, textColor);
322 __pListViewItem->SetItemChanged(ret);
328 _ListItemBaseImpl::GetTextColor(int elementId, Color& textColor) const
330 return __pListViewItem->GetTextColor(elementId, textColor);
334 _ListItemBaseImpl::AddListViewItemEventListener(_IUiListViewItemEventListener& listener)
336 if (__pEvent == null)
338 __pEvent = new (std::nothrow) _UiListViewItemEvent();
339 SysTryReturnVoidResult(NID_UI_CTRL, __pEvent != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
342 __pEvent->AddListener(listener);
346 _ListItemBaseImpl::RemoveListViewItemEventListener(_IUiListViewItemEventListener& listener)
348 if (__pEvent != null)
350 __pEvent->RemoveListener(listener);
355 _ListItemBaseImpl::OnActionPerformed(const _Control& source, int actionId)
357 if (__pEvent != null)
362 __pListViewItem->GetItemIndex(groupIndex, itemIndex);
363 __pEvent->SetSource(__pListViewItem);
365 _UiListViewItemEventArg* pArg = new (std::nothrow) _UiListViewItemEventArg(groupIndex, itemIndex, actionId, NOTIFY_TYPE_CONTEXTITEM_SELCTED);
366 __pEvent->Fire(*pArg);
370 }}} // Tizen::Ui::Controls