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.
18 * @file FUiCtrlIconList.cpp
19 * @brief This is the implementation file for FUiCtrlIconList class
21 * This file contains the implementation of FUiCtrlIconList class
24 #include <FUiCtrlIconList.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_IconListImpl.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Ui;
30 using namespace Tizen::Ui::Controls;
31 using namespace Tizen::Graphics;
33 namespace Tizen { namespace Ui { namespace Controls
36 IconList::IconList(void)
40 IconList::~IconList(void)
45 IconList::Construct(const Rectangle& rect, IconListStyle style, int itemWidth, int itemHeight)
49 SysAssertf((_IconListImpl::GetInstance(*this) == null),
50 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
52 _IconListImpl* pImpl = _IconListImpl::CreateIconListImplN(this);
54 SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
56 _pControlImpl = pImpl;
58 r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height);
59 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error");
61 // Set Initial Parameters
63 r = pImpl->SetIconListStyle(style);
64 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error");
66 r = pImpl->InitializeIconList(itemWidth, itemHeight);
67 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error");
69 r = pImpl->SetItemProvider();
70 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error");
72 r = pImpl->SetListener();
73 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error");
75 r = pImpl->SetNonSlidable();
76 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error");
86 IconList::AddItemEventListener(IItemEventListener& listener)
88 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
89 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
91 pImpl->AddItemEventListener(listener);
95 IconList::RemoveItemEventListener(IItemEventListener& listener)
97 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
98 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
100 pImpl->RemoveItemEventListener(listener);
104 IconList::SetBackgroundBitmap(const Bitmap& bitmap)
106 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
107 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
109 pImpl->SetBackgroundBitmap(bitmap);
114 IconList::SetMargin(int topMargin, int leftMargin)
116 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
117 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
119 return pImpl->SetMargin(topMargin, leftMargin);
123 IconList::GetTopMargin(void) const
125 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
126 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
128 return pImpl->GetTopMargin();
132 IconList::GetLeftMargin(void) const
134 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
135 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
137 return pImpl->GetLeftMargin();
141 IconList::AddItem(const String* pText, const Bitmap* pNormalBitmap, const Bitmap* pFocusedBitmap, int itemId)
143 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
144 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
146 return pImpl->AddItem(pText, pNormalBitmap, pFocusedBitmap, itemId);
150 IconList::InsertItemAt(int index, const String* pText, const Bitmap* pNormalBitmap, const Bitmap* pFocusedBitmap, int itemId)
152 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
153 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
155 return pImpl->InsertItemAt(index, pText, pNormalBitmap, pFocusedBitmap, itemId);
159 IconList::SetItemAt(int index, const String* pText, const Bitmap* pNormalBitmap, const Bitmap* pFocusedBitmap, int itemId)
161 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
162 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
164 return pImpl->SetItemAt(index, pText, pNormalBitmap, pFocusedBitmap, itemId);
168 IconList::RemoveItemAt(int index)
170 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
171 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
173 return pImpl->RemoveItemAt(index);
177 IconList::RemoveAllItems(void)
179 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
180 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
182 return pImpl->RemoveAllItems();
186 IconList::GetColumnCount(void) const
188 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
189 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
191 return pImpl->GetColumnCount();
195 IconList::GetItemCount(void) const
197 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
198 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
200 return pImpl->GetItemCount();
204 IconList::SetItemChecked(int index, bool check)
206 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
207 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
209 return pImpl->SetItemChecked(index, check);
213 IconList::IsItemChecked(int index) const
215 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
216 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
218 return pImpl->IsItemChecked(index);
222 IconList::SetAllItemsChecked(bool check)
224 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
225 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
227 return pImpl->SetAllItemsChecked(check);
231 IconList::RemoveAllCheckedItems(void)
233 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
234 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
236 return pImpl->RemoveAllCheckedItems();
240 IconList::GetFirstCheckedItemIndex(void) const
242 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
243 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
245 return pImpl->GetFirstCheckedItemIndex();
249 IconList::GetLastCheckedItemIndex(void) const
251 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
252 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
254 return pImpl->GetLastCheckedItemIndex();
258 IconList::GetNextCheckedItemIndexAfter(int index) const
260 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
261 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
263 return pImpl->GetNextCheckedItemIndexAfter(index);
267 IconList::GetItemIndexFromPosition(int x, int y) const
269 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
270 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
272 return pImpl->GetItemIndexFromPosition(Point(x, y));
276 IconList::GetItemIndexFromPosition(const Point& position) const
278 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
279 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
281 return pImpl->GetItemIndexFromPosition(position);
285 IconList::SetTextHorizontalAlignment(HorizontalAlignment alignment)
287 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
288 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
290 return pImpl->SetTextHorizontalAlignment(alignment);
294 IconList::SetTextVerticalAlignment(VerticalAlignment alignment)
296 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
297 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
299 return pImpl->SetTextVerticalAlignment(alignment);
303 IconList::GetTextHorizontalAlignment(void) const
305 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
306 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
308 return pImpl->GetTextHorizontalAlignment();
312 IconList::GetTextVerticalAlignment(void) const
314 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
315 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
317 return pImpl->GetTextVerticalAlignment();
321 IconList::SetBackgroundColor(const Color& color)
323 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
324 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
326 pImpl->SetBackgroundColor(color);
330 IconList::SetTextOfEmptyList(const String& text)
332 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
333 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
335 pImpl->SetTextOfEmptyList(text);
339 IconList::SetTextColorOfEmptyList(const Color& color)
341 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
342 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
344 pImpl->SetTextColorOfEmptyList(color);
348 IconList::GetTextColorOfEmptyList(void) const
350 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
351 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
353 return pImpl->GetTextColorOfEmptyList();
357 IconList::SetItemTextColor(const Color& textColor)
359 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
360 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
362 pImpl->SetItemTextColor(textColor);
366 IconList::GetItemTextColor(void) const
368 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
369 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
371 return pImpl->GetItemTextColor();
376 IconList::SetTextSize(int size)
378 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
379 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
381 pImpl->SetTextSize(size);
385 IconList::GetTextSize(void) const
387 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
388 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
390 return pImpl->GetTextSize();
394 IconList::GetItemIndexFromItemId(int itemId) const
396 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
397 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
399 return pImpl->GetItemIndexFromItemId(itemId);
403 IconList::GetItemIdAt(int index) const
405 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
406 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
408 return pImpl->GetItemIdAt(index);
412 IconList::SetCheckBoxPosition(IconListCheckBoxPosition position)
414 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
415 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
417 pImpl->SetCheckBoxPosition(position);
420 IconListCheckBoxPosition
421 IconList::GetCheckBoxPosition(void) const
423 const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
424 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
426 return pImpl->GetCheckBoxPosition();
430 IconList::SetFocusAnimationEnabled(bool enable)
432 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
433 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
435 pImpl->SetFocusAnimationEnabled(enable);
439 IconList::ScrollToBottom(void)
441 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
442 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
444 return pImpl->ScrollToBottom();
448 IconList::ScrollToTop(void)
450 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
451 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
453 return pImpl->ScrollToTop();
457 IconList::ScrollToTop(int itemIndex)
459 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
460 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
462 return pImpl->ScrollToTop(itemIndex);
466 IconList::RefreshItem(int index)
468 _IconListImpl* pImpl = _IconListImpl::GetInstance(*this);
469 SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use.");
471 return pImpl->RefreshItem(index);
474 }}} // Tizen::Ui::Controls