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_TableViewItemImpl.cpp
20 * @brief This is the implementation file for _TableViewItemImpl class.
22 * This file contains the implementation of _TableViewItemImpl class.
25 #include <FUiAnimControlAnimator.h>
26 #include <FUiCtrlTableViewContextItem.h>
27 #include "FUiCtrl_TableViewItemImpl.h"
28 #include "FUiCtrl_TableViewItem.h"
29 #include "FUi_LayoutImpl.h"
30 #include "FUi_ResourceManager.h"
31 #include "FUi_ResourceSizeInfo.h"
32 #include "FUi_ResourceManager.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Graphics;
37 namespace Tizen { namespace Ui { namespace Controls
40 Tizen::Graphics::Dimension
41 _TableViewItemImpl::TableViewItemSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const
43 return Dimension(0, 0);
47 _TableViewItemImpl::GetInstance(TableViewItemBase& tableViewItem)
49 return static_cast <_TableViewItemImpl*>(tableViewItem._pControlImpl);
52 const _TableViewItemImpl*
53 _TableViewItemImpl::GetInstance(const TableViewItemBase& tableViewItem)
55 return static_cast <const _TableViewItemImpl*>(tableViewItem._pControlImpl);
58 _TableViewItemImpl::_TableViewItemImpl(TableViewItemBase* pPublic, _TableViewItem* pCore, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout)
59 : _ContainerImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout)
63 _TableViewItemImpl::~_TableViewItemImpl(void)
69 _TableViewItemImpl::GetPublicClassName(void) const
71 return "Tizen::Ui::Controls::TableViewItem";
75 _TableViewItemImpl::GetPublic(void) const
77 return static_cast <const TableViewItem&>(_ContainerImpl::GetPublic());
81 _TableViewItemImpl::GetPublic(void)
83 return static_cast <TableViewItem&>(_ContainerImpl::GetPublic());
87 _TableViewItemImpl::GetCore(void) const
89 return static_cast <const _TableViewItem&>(_ControlImpl::GetCore());
93 _TableViewItemImpl::GetCore(void)
95 return static_cast <_TableViewItem&>(_ControlImpl::GetCore());
99 _TableViewItemImpl::CreateTableViewItemImplN(TableViewItemBase* pPublic, const Dimension& itemSize, const TableViewAnnexStyle style, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout)
101 result r = E_SUCCESS;
103 r = GET_SIZE_INFO(TableViewItem).CheckInitialSizeValid(Dimension(itemSize.width, itemSize.height), _CONTROL_ORIENTATION_PORTRAIT);
104 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
106 if (pPublicPortraitLayout != null)
108 _LayoutImpl* pPortraitLayoutImpl = _LayoutImpl::GetInstance(*pPublicPortraitLayout);
109 SysTryReturn(NID_UI_CTRL, pPortraitLayoutImpl != null, null, E_INVALID_ARG, "[E_INVALID_ARG] Portrait layout is invalid object");
112 if (pPublicLandscapeLayout != null)
114 _LayoutImpl* pLandscapeLayoutImpl = _LayoutImpl::GetInstance(*pPublicLandscapeLayout);
115 SysTryReturn(NID_UI_CTRL, pLandscapeLayoutImpl != null, null, E_INVALID_ARG, "[E_INVALID_ARG] Landscape layout is invalid object");
118 _TableViewItem* pCore = _TableViewItem::CreateTableViewItemN(itemSize.height);
119 SysTryReturn(NID_UI_CTRL, pCore != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
121 _TableViewItemImpl* pImpl = new (std::nothrow) _TableViewItemImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout);
122 SysTryReturn(NID_UI_CTRL, pImpl != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
124 r = pImpl->Construct(itemSize, style);
125 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
127 r = pImpl->SetSize(itemSize);
128 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
140 _TableViewItemImpl::Construct(const Dimension& itemSize, const TableViewAnnexStyle style)
142 result r = E_SUCCESS;
144 SysTryReturn(NID_UI_CTRL, (itemSize.width >= 0 && itemSize.height >= 0), E_INVALID_ARG, E_INVALID_ARG, ("[E_INVALID_ARG] The item size should be greater than 0"));
146 GetCore().SetItemStyle(style);
147 GetCore().SetItemWidth(itemSize.width);
153 _TableViewItemImpl::SetContextItem(_TableViewItemImpl* pItem)
157 GetCore().SetContextItem(null);
161 GetCore().SetContextItem(&pItem->GetCore());
163 _TableViewItemImpl* pItemImpl = pItem;
165 TableViewContextItem* pContextItem = static_cast <TableViewContextItem*>(&pItemImpl->_ContainerImpl::GetPublic());
166 pItemImpl->GetCore().SetAppInfo(pContextItem);
172 _TableViewItemImpl::SetSelectionStyle(TableViewItemSelectionStyle style)
174 return GetCore().SetSelectionStyle(style);
177 TableViewItemSelectionStyle
178 _TableViewItemImpl::GetSelectionStyle(void) const
180 return GetCore().GetSelectionStyle();
184 _TableViewItemImpl::SetBackgroundBitmap(TableViewItemDrawingStatus status, const Bitmap* pBitmap)
186 SysTryReturn(NID_UI_CTRL, pBitmap, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] It is invalid argument");
188 ListItemState itemState;
192 case TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL:
193 itemState = LIST_ITEM_STATE_NORMAL;
196 case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED:
197 itemState = LIST_ITEM_STATE_PRESSED;
200 case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED:
201 itemState = LIST_ITEM_STATE_HIGHLIGHTED;
208 GetCore().SetItemBackgroundBitmap(itemState, pBitmap);
214 _TableViewItemImpl::SetBackgroundColor(TableViewItemDrawingStatus status, const Color& color)
216 ListItemState itemState;
220 case TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL:
221 itemState = LIST_ITEM_STATE_NORMAL;
224 case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED:
225 itemState = LIST_ITEM_STATE_PRESSED;
228 case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED:
229 itemState = LIST_ITEM_STATE_HIGHLIGHTED;
236 GetCore().SetItemBackgroundColor(itemState, color);
242 _TableViewItemImpl::GetBackgroundColor(TableViewItemDrawingStatus status) const
244 ListItemState itemState;
247 case TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL:
248 itemState = LIST_ITEM_STATE_NORMAL;
251 case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED:
252 itemState = LIST_ITEM_STATE_PRESSED;
255 case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED:
256 itemState = LIST_ITEM_STATE_HIGHLIGHTED;
263 return GetCore().GetItemBackgroundColor(itemState);
267 _TableViewItemImpl::SetSimpleItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap, bool groupType)
269 return GetCore().SetSimpleItemContents(text, pBitmap, groupType);
273 _TableViewItemImpl::SetSimpleItemTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status)
275 return GetCore().SetSimpleTextColor(color, status);
278 Tizen::Graphics::Color
279 _TableViewItemImpl::GetSimpleItemTextColor(TableViewItemDrawingStatus status) const
281 return GetCore().GetSimpleItemTextColor(status);
285 _TableViewItemImpl::SetSimpleItemTextSize(int size)
287 return GetCore().SetSimpleItemTextSize(size);
291 _TableViewItemImpl::GetSimpleItemTextSize(void) const
293 return GetCore().GetSimpleItemTextSize();
297 _TableViewItemImpl::GetAnnexWidth(TableViewAnnexStyle style)
303 case TABLE_VIEW_ANNEX_STYLE_NORMAL:
307 case TABLE_VIEW_ANNEX_STYLE_MARK:
308 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
311 case TABLE_VIEW_ANNEX_STYLE_RADIO:
312 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
315 case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
316 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
319 case TABLE_VIEW_ANNEX_STYLE_DETAILED:
320 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
331 _TableViewItemImpl::SetIndividualSelectionEnabled(const Tizen::Ui::_ControlImpl& controlImpl, bool enable)
333 return GetCore().SetIndividualSelectionEnabled(controlImpl.GetCore(), enable);
337 _TableViewItemImpl::IsIndividualSelectionEnabled(const Tizen::Ui::_ControlImpl& controlImpl)
339 return GetCore().IsIndividualSelectionEnabled(controlImpl.GetCore());
343 }}} // Tizen::Ui::Controls