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_ListViewItem.cpp
20 * @brief This is the implementation file for _ListViewItem class.
22 * This file contains the implementation of _ListViewItem class.
25 #include <FBaseSysLog.h>
26 #include <FGrp_BitmapImpl.h>
27 #include <FGrp_EnrichedTextImpl.h>
28 #include <FGrp_TextElementImpl.h>
29 #include <FGrp_TextTextCutLink.h>
30 #include <FGrp_TextTextCutLinkParser.h>
31 #include <FGrp_TextTextSimple.h>
32 #include "FUi_AccessibilityContainer.h"
33 #include "FUi_AccessibilityElement.h"
34 #include "FUi_AccessibilityManager.h"
35 #include "FUi_CoordinateSystemUtils.h"
37 #include "FUi_ResourceManager.h"
38 #include "FUiAnim_VisualElement.h"
39 #include "FUiCtrl_Label.h"
40 #include "FUiCtrl_ListViewContextItem.h"
41 #include "FUiCtrl_ListViewItem.h"
42 #include "FUiCtrl_Progress.h"
43 #include "FUiCtrl_UiListViewItemEvent.h"
44 #include "FUiCtrl_UiListViewItemEventArg.h"
46 #ifdef MEMORY_LEAK_CHECK
47 #include "mem_leak_check.h"
50 using namespace Tizen::Base;
51 using namespace Tizen::Base::Runtime;
52 using namespace Tizen::Base::Utility;
53 using namespace Tizen::Graphics;
54 using namespace Tizen::Graphics::_Text;
55 using namespace Tizen::Ui;
56 using namespace Tizen::Ui::Animations;
58 namespace Tizen { namespace Ui { namespace Controls
61 _ListViewItem::_ListViewItem(float itemHeight)
62 : _TableViewItem(itemHeight)
63 , __needAlignContextItem(false)
64 , __touchPressed(false)
65 , __selectedElementId(-1)
66 , __progressLeftMargin(0.0f)
67 , __progressRightMargin(0.0f)
69 , __descriptionTextShowState(false)
70 , __pDescriptionText(null)
72 , __selectionEabled(false)
76 , __prevTouchPos(-1.0f, -1.0f)
77 , __pTextSlideTimer(null)
78 , __pAccessibilityElement(null)
80 GET_COLOR_CONFIG(TABLEVIEW::ITEM_DESCRIPTION_TEXT_NORMAL, __descriptionTextColor);
82 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_SELECTED;
83 ___stateChangedInfo.elementId = -1;
84 ___stateChangedInfo.pUiLinkInfo = null;
87 _ListViewItem::~_ListViewItem(void)
91 delete ___stateChangedInfo.pUiLinkInfo;
92 ___stateChangedInfo.pUiLinkInfo = null;
94 delete __pTextSlideTimer;
95 __pTextSlideTimer = null;
97 if (__pProgress != null)
99 DetachChild(*__pProgress);
105 if (__pDescriptionText != null)
107 DetachChild(*__pDescriptionText);
109 delete __pDescriptionText;
110 __pDescriptionText = null;
113 if (__pDivider != null)
115 DetachChild(*__pDivider);
121 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
123 if ((__pAccessibilityElement != null) && (pContainer != null))
125 pContainer->RemoveAllElement();
126 __pAccessibilityElement = null;
131 _ListViewItem::CreateListViewItemN(float itemHeight)
133 _ListViewItem* pItem = new (std::nothrow) _ListViewItem(itemHeight);
134 SysTryReturn(NID_UI_CTRL, (pItem != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
136 pItem->AcquireHandle();
138 result r = pItem->Initialize();
139 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] Unable to create _ListViewItem");
150 _ListViewItem::SetListViewItemType(ListViewItemType type)
156 _ListViewItem::AddElement(FloatRectangle& rect, int elementId, const String& text, bool textSliding)
158 result r = E_SUCCESS;
160 SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG,
161 ("[E_INVALID_ARG] This elementId already exists."));
163 // Convert String to TextObject
164 TextObject* pText = new (std::nothrow) TextObject();
167 if (text.IsEmpty() == false)
169 TextSimple* pSimpleText = new (std::nothrow) TextSimple(const_cast <wchar_t*>(text.GetPointer()), text.GetLength());
170 pText->AppendElement(*pSimpleText);
172 pText->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
173 pText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
176 // Make element object
177 _ListViewItemElement element;
178 memset(&element, 0, sizeof(_ListViewItemElement));
180 element.elementId = elementId;
181 element.elementType = LISTVIEW_ITEM_ELEMENT_TEXT;
182 element.bounds = rect;
184 element.pTextElement = new (std::nothrow) _ListViewItemElementText();
185 SysTryReturn(NID_UI_CTRL, (element.pTextElement != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(r));
187 element.pTextElement->pTextObject = pText;
188 element.pTextElement->textSlidingEnabled = textSliding;
190 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, element.pTextElement->textSize);
191 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_NORMAL, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_NORMAL]);
192 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_PRESSED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_PRESSED]);
193 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_HIGHLIGHTED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_HIGHLIGHTED]);
195 // Set Visual element for this element
196 _VisualElement* pVE = new (std::nothrow) _VisualElement();
198 pVE->SetImplicitAnimationEnabled(false);
199 pVE->SetContentProvider(&__hitTestVEDelegator);
200 element.pTextElement->pVE = pVE;
202 __elements.push_back(element);
208 _ListViewItem::AddElement(FloatRectangle& rect, int elementId, const EnrichedText* pEnrichedText, bool textSliding)
210 SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG,
211 ("[E_INVALID_ARG] This elementId already exists."));
213 SysTryReturn(NID_GRP, (pEnrichedText != null) && (_EnrichedTextImpl::GetInstance(*pEnrichedText) != null),
214 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This _EnrichedText element is null.");
217 _EnrichedTextImpl* pCloneText = _EnrichedTextImpl::GetInstance(*pEnrichedText)->GetCloneN();
218 SysTryReturn(NID_GRP, (pCloneText != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This _EnrichedText element can not clone.");
220 TextObject* pText = pCloneText->GetTextObject();
222 // Make element object
223 _ListViewItemElement element;
224 memset(&element, 0, sizeof(_ListViewItemElement));
226 element.elementId = elementId;
227 element.elementType = LISTVIEW_ITEM_ELEMENT_TEXT;
228 element.bounds = rect;
230 element.pTextElement = new (std::nothrow) _ListViewItemElementText();
231 SysTryReturn(NID_UI_CTRL, (element.pTextElement != null), GetLastResult(), GetLastResult(), "[%s] Propagating.",
232 GetErrorMessage(GetLastResult()));
234 element.pTextElement->pTextObject = pText;
235 element.pTextElement->pEnrichedText = pCloneText;
236 element.pTextElement->textSlidingEnabled = textSliding;
238 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_NORMAL, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_NORMAL]);
239 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_PRESSED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_PRESSED]);
240 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_HIGHLIGHTED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_HIGHLIGHTED]);
242 // Set Visual element for this element
243 _VisualElement* pVE = new (std::nothrow) _VisualElement();
245 pVE->SetImplicitAnimationEnabled(false);
246 pVE->SetContentProvider(&__hitTestVEDelegator);
247 element.pTextElement->pVE = pVE;
249 __elements.push_back(element);
255 _ListViewItem::AddElement(FloatRectangle& rect, int elementId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
257 SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG,
258 ("[E_INVALID_ARG] This elementId already exists."));
260 SysTryReturn(NID_GRP, (pNormalBitmap != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null.");
262 _ListViewItemElement element;
263 _VisualElement* pVE = null;
264 Bitmap* pClonePressedBitmap = null;
265 Bitmap* pCloneHighlightedBitmap = null;
266 result r = E_SUCCESS;
268 Bitmap* pCloneNormalBitmap = _BitmapImpl::CloneN(*pNormalBitmap);
269 SysTryReturn(NID_UI_CTRL, (pCloneNormalBitmap != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
271 if (pPressedBitmap != null)
273 pClonePressedBitmap = _BitmapImpl::CloneN(*pPressedBitmap);
274 SysTryCatch(NID_UI_CTRL, (pClonePressedBitmap != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
277 if (pHighlightedBitmap != null)
279 pCloneHighlightedBitmap = _BitmapImpl::CloneN(*pHighlightedBitmap);
280 SysTryCatch(NID_UI_CTRL, (pCloneHighlightedBitmap != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
283 // Make element object
284 memset(&element, 0, sizeof(_ListViewItemElement));
286 element.elementId = elementId;
287 element.elementType = LISTVIEW_ITEM_ELEMENT_BITMAP;
288 element.bounds = rect;
290 element.pBitmapElement = new (std::nothrow) _ListViewItemElementBitmap();
291 SysTryCatch(NID_UI_CTRL, (element.pBitmapElement != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
293 element.pBitmapElement->pBitmap[LISTVIEW_ITEM_STATUS_NORMAL] = pCloneNormalBitmap;
294 element.pBitmapElement->pBitmap[LISTVIEW_ITEM_STATUS_PRESSED] = pClonePressedBitmap;
295 element.pBitmapElement->pBitmap[LISTVIEW_ITEM_STATUS_HIGHLIGHTED] = pCloneHighlightedBitmap;
297 pVE = new (std::nothrow) _VisualElement();
299 pVE->SetImplicitAnimationEnabled(false);
300 pVE->SetContentProvider(&__hitTestVEDelegator);
301 element.pBitmapElement->pVE = pVE;
303 __elements.push_back(element);
308 delete pCloneNormalBitmap;
309 delete pClonePressedBitmap;
310 delete pCloneHighlightedBitmap;
316 _ListViewItem::AddElement(FloatRectangle& rect, int elementId, const _ICustomElement* pCustom)
318 SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG,
319 ("[E_INVALID_ARG] This elementId already exists."));
321 SysTryReturn(NID_GRP, (pCustom != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This Custom element is null.");
323 // Make element object
324 _ListViewItemElement element;
325 memset(&element, 0, sizeof(_ListViewItemElement));
327 element.elementId = elementId;
328 element.elementType = LISTVIEW_ITEM_ELEMENT_OBJ;
329 element.bounds = rect;
331 element.pCustomElement = new (std::nothrow) _ListViewItemElementCustom();
332 SysTryReturn(NID_UI_CTRL, (element.pCustomElement != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
334 element.pCustomElement->pCustom = const_cast<_ICustomElement*>(pCustom);
336 _VisualElement* pVE = new (std::nothrow) _VisualElement();
338 pVE->SetImplicitAnimationEnabled(false);
339 pVE->SetContentProvider(&__hitTestVEDelegator);
340 element.pCustomElement->pVE = pVE;
342 if (pVE->GetParent() == null)
344 GetVisualElement()->AttachChild(*(pVE));
345 pVE->SetShowState(true);
346 pVE->SetBounds(rect);
349 __elements.push_back(element);
355 _ListViewItem::DeleteElement(int elementId)
357 _LinkedList <_ListViewItemElement>::_Iterator iter;
359 for (iter = __elements.begin(); iter != __elements.end(); iter++)
361 if (iter->elementId == elementId)
363 DeleteElement(&(*iter));
364 __elements.erase(iter);
374 _ListViewItem::DeleteAllElement(void)
376 _LinkedList <_ListViewItemElement>::_Iterator iter;
378 for (iter = __elements.begin(); iter != __elements.end(); iter++)
380 DeleteElement(&(*iter));
387 _ListViewItem::DeleteElement(_ListViewItemElement* pElement)
389 if (pElement->pTextElement != null)
391 if (pElement->pTextElement->pEnrichedText != null)
393 (pElement->pTextElement->pEnrichedText)->RemoveAllTextElements(true);
395 delete pElement->pTextElement->pEnrichedText;
396 pElement->pTextElement->pEnrichedText = null;
398 pElement->pTextElement->pTextObject = null;
402 delete pElement->pTextElement->pTextObject;
403 pElement->pTextElement->pTextObject = null;
406 if (pElement->pTextElement->pVE != null)
408 pElement->pTextElement->pVE->Destroy();
409 pElement->pTextElement->pVE = null;
412 delete pElement->pTextElement;
413 pElement->pTextElement = null;
416 if (pElement->pBitmapElement != null)
418 for (int i = 0; i < LISTVIEW_ITEM_STATUS_MAX; i++)
420 delete pElement->pBitmapElement->pBitmap[i];
421 pElement->pBitmapElement->pBitmap[i] = null;
424 if (pElement->pBitmapElement->pVE != null)
426 pElement->pBitmapElement->pVE->Destroy();
427 pElement->pBitmapElement->pVE = null;
430 delete pElement->pBitmapElement;
431 pElement->pBitmapElement = null;
434 if (pElement->pCustomElement)
436 delete pElement->pCustomElement->pCustom;
437 pElement->pCustomElement->pCustom = null;
439 if (pElement->pCustomElement->pVE != null)
441 pElement->pCustomElement->pVE->Destroy();
442 pElement->pCustomElement->pVE = null;
445 delete pElement->pCustomElement;
446 pElement->pCustomElement = null;
451 _ListViewItem::HasElement(int elementId)
453 _ListViewItemElement* pElement = GetElement(elementId);
455 return (pElement != null);
459 _ListViewItem::RefreshElement(int elementId)
461 _ListViewItemElement* pElement = GetElement(elementId);
463 if (pElement != null)
465 DrawElement(pElement);
468 return (pElement != null);
472 _ListViewItem::SetLastStateChangedInfo(void)
474 ClearLastStateChangedInfo();
476 int elementId = GetElementIdFromCurrentTouchPosition();
477 _ListViewItemElement* pElement = GetElement(elementId);
479 if ((pElement != null) && (__itemType == LISTVIEW_ITEM_TYPE_CUSTOM))
481 _ListViewItemUiLinkInfo* pInfo = null;
482 int cutlinkTextTouchedIndex = -1;
484 if (IsCutlinkTextSelected(__prevTouchPos, &cutlinkTextTouchedIndex, &pInfo))
486 if ((GetItemStyle() == TABLE_VIEW_ANNEX_STYLE_DETAILED)
487 && (pElement->actionElement == true) && (pElement->selectionEnabled == false))
492 if (cutlinkTextTouchedIndex >= 0)
494 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_UILINK_SELECTED;
495 ___stateChangedInfo.elementId = elementId;
496 ___stateChangedInfo.pUiLinkInfo = pInfo;
500 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_ELEMENT_SELECTED;
501 ___stateChangedInfo.elementId = elementId;
506 if ((GetItemStyle() == TABLE_VIEW_ANNEX_STYLE_DETAILED)
507 && (pElement->actionElement == true) && (pElement->selectionEnabled == false))
512 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_ELEMENT_SELECTED;
513 ___stateChangedInfo.elementId = elementId;
518 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_ELEMENT_SELECTED;
519 ___stateChangedInfo.elementId = -1;
524 _ListViewItem::GetLastStateChangedInfo(_ListViewItemStateChangedInfo& changedInfo) const
526 changedInfo = ___stateChangedInfo;
528 return (___stateChangedInfo.selectionType != LISTVIEW_ITEM_SELECTED);
532 _ListViewItem::ClearLastStateChangedInfo(void)
534 delete ___stateChangedInfo.pUiLinkInfo;
536 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_SELECTED;
537 ___stateChangedInfo.elementId = -1;
538 ___stateChangedInfo.pUiLinkInfo = null;
542 _ListViewItem::GetElementIdFromPosition(const FloatPoint& position) const
544 _LinkedList <_ListViewItemElement>::_ReverseIterator reverseIter;
546 for (reverseIter = __elements.rbegin(); reverseIter != __elements.rend(); reverseIter++)
548 if ((*reverseIter).bounds.Contains(position))
550 return (*reverseIter).elementId;
558 _ListViewItem::GetElementIdFromCurrentTouchPosition(void) const
560 return GetElementIdFromPosition(__prevTouchPos);
563 _ListViewItemElement*
564 _ListViewItem::GetElement(int elementId) const
566 _LinkedList <_ListViewItemElement>::_Iterator iter;
568 for (iter = __elements.begin(); iter != __elements.end(); iter++)
570 if (iter->elementId == elementId)
579 ListViewItemElementType
580 _ListViewItem::GetElementType(int elementId) const
582 _ListViewItemElement* pElement = GetElement(elementId);
584 return ((pElement != null) ? pElement->elementType : LISTVIEW_ITEM_ELEMENT_INVALID);
588 _ListViewItem::GetTextObjectInElement(int elementId) const
590 _ListViewItemElementText* pElement = GetElementText(elementId);
592 return ((pElement != null) ? pElement->pTextObject : null);
595 _ListViewItemElementText*
596 _ListViewItem::GetElementText(int elementId) const
598 _ListViewItemElement* pElement = GetElement(elementId);
600 if ((pElement != null) && (pElement->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
601 && (pElement->pTextElement->pTextObject != null))
603 return pElement->pTextElement;
609 _ListViewItemElementBitmap*
610 _ListViewItem::GetElementBitmap(int elementId) const
612 _ListViewItemElement* pElement = GetElement(elementId);
614 if ((pElement != null) && (pElement->elementType == LISTVIEW_ITEM_ELEMENT_BITMAP))
616 return pElement->pBitmapElement;
623 _ListViewItem::SetElementSelectionEnabled(int elementId, bool enable)
625 _ListViewItemElement* pElement = GetElement(elementId);
627 if (pElement == null)
632 pElement->actionElement = true;
633 pElement->selectionEnabled = enable;
639 _ListViewItem::GetElementSelectionEnabled(int elementId, bool& enable)
641 _ListViewItemElement* pElement = GetElement(elementId);
643 if ((pElement == null) || (pElement->actionElement == false))
648 enable = pElement->selectionEnabled;
654 _ListViewItem::SetTextCutlinkMask(int elementId, unsigned long mask)
656 _ListViewItemElementText* pElement = GetElementText(elementId);
658 if (pElement == null)
663 pElement->cutlinkMaskType = mask;
669 _ListViewItem::SetTextCutlinkViewMode(int elementId, bool cutlinkViewMode, bool cutlinkParseEnable)
671 _ListViewItemElementText* pElement = GetElementText(elementId);
673 if (pElement == null)
678 pElement->cutlinkViewModeEnabled = cutlinkViewMode;
679 pElement->cutlinkParseEnabled = cutlinkParseEnable;
680 pElement->cutlinkMaskType = LINK_TYPE_MAX;
686 _ListViewItem::SetTextAlignment(int elementId, TextObjectAlignment textAlignment)
688 TextObject* pTextObject = GetTextObjectInElement(elementId);
690 if (pTextObject == null)
695 TextObjectAlignment originAlign = pTextObject->GetAlignment();
697 // reset original alignment
698 if ((0x0007 & textAlignment) != 0x0000) // TextHorizontalAlignment
700 originAlign &= 0x0700;
702 else if ((0x0700 & textAlignment) != 0x0000) // TextVerticalAlignment
704 originAlign &= 0x0007;
707 pTextObject->SetAlignment(originAlign | textAlignment);
713 _ListViewItem::GetTextAlignment(int elementId, TextObjectAlignment& textAlignment) const
715 TextObject* pTextObject = GetTextObjectInElement(elementId);
717 if (pTextObject == null)
722 textAlignment = pTextObject->GetAlignment();
728 _ListViewItem::SetTextWrapType(int elementId, TextObjectWrapType wrapType)
730 TextObject* pTextObject = GetTextObjectInElement(elementId);
732 if (pTextObject == null)
737 pTextObject->SetWrap(wrapType);
743 _ListViewItem::SetTextSize(int elementId, float textSize)
745 _ListViewItemElementText* pElement = GetElementText(elementId);
747 if ((pElement != null) && (textSize > 0.0f))
749 pElement->textSize = textSize;
758 _ListViewItem::SetTextColor(int elementId, Color textColor, ListViewItemDrawingStatus status)
760 _ListViewItemElementText* pElement = GetElementText(elementId);
762 if (pElement == null)
767 pElement->textColor[status] = textColor;
773 _ListViewItem::GetTextColor(int elementId, Color& textColor, ListViewItemDrawingStatus status) const
775 _ListViewItemElementText* pElement = GetElementText(elementId);
777 if (pElement == null)
782 textColor = pElement->textColor[status];
788 _ListViewItem::AdjustProgressBounds(void)
790 if (__pProgress != null)
792 FloatRectangle progressRect = GetBoundsF();
793 float progressHeight = 0.0f;
794 float bottomMargin = 0.0f;
796 // Calculate progress position
797 GET_SHAPE_CONFIG(SLIDER::BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, progressHeight);
798 GET_SHAPE_CONFIG(SLIDER::BAR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, bottomMargin);
800 progressHeight = progressHeight + (bottomMargin * 2.0f);
801 progressRect.x = __progressLeftMargin;
802 progressRect.y = progressRect.height - progressHeight;
803 progressRect.height = progressHeight;
804 progressRect.width = progressRect.width - __progressLeftMargin - __progressRightMargin;
806 progressRect.y -= ((__descriptionTextShowState) ? GetDescriptionTextHeight() : 0.0f);
808 __pProgress->SetBounds(progressRect);
813 _ListViewItem::SetDescriptionText(const String& text)
817 if (__pDescriptionText != null)
819 DetachChild(*__pDescriptionText);
821 delete __pDescriptionText;
822 __pDescriptionText = null;
829 if (__pDescriptionText == null)
831 __pDescriptionText = _Label::CreateLabelN();
832 result r = GetLastResult();
833 SysTryReturn(NID_UI_CTRL, (__pDescriptionText != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
835 __pDescriptionText->SetVisibleState(false);
836 __pDescriptionText->SetMargin(0.0f, 0.0f, 0.0f, 0.0f);
837 __pDescriptionText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
839 AttachChild(*__pDescriptionText);
842 FloatRectangle bounds = GetBoundsF();
843 FloatRectangle textBounds;
844 float textSize = 0.0f;
847 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textBounds.x);
848 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textBounds.y);
849 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textSize);
851 textBounds.width = bounds.width - (textBounds.x * 2.0f);
853 TextObject* pText = new (std::nothrow) TextObject();
854 SysTryReturn(NID_UI_CTRL, (pText != null), false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
858 TextSimple* pSimpleText = new (std::nothrow) TextSimple((const_cast<wchar_t*>(text.GetPointer())), text.GetLength());
859 SysTryCatch(NID_UI_CTRL, (pSimpleText != null), (ret = false), E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
861 pText->AppendElement(*pSimpleText);
862 pText->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
863 pText->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
864 pText->SetFont(GetFont(FONT_STYLE_PLAIN, textSize), 0, pText->GetTextLength());
865 pText->SetBounds(FloatRectangle(0.0f, 0.0f, textBounds.width, 1.0f));
868 textBounds.height = pText->GetTotalHeight();
870 __pDescriptionText->SetBounds(FloatRectangle(textBounds.x, bounds.height + textBounds.y, textBounds.width, textBounds.height));
871 __pDescriptionText->SetBackgroundColor(Color(0, 0, 0, 0));
872 __pDescriptionText->SetTextColor(__descriptionTextColor);
873 __pDescriptionText->SetTextConfig(textSize, LABEL_TEXT_STYLE_NORMAL);
874 __pDescriptionText->SetText(text);
884 _ListViewItem::SetDescriptionTextColor(const Color& color)
886 __descriptionTextColor = color;
890 _ListViewItem::GetDescriptionTextHeight(void)
892 if (__pDescriptionText != null)
895 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, margin);
897 return ((margin * 2.0f) + __pDescriptionText->GetBoundsF().height);
904 _ListViewItem::SetDescriptionTextShowState(bool show)
906 if (__descriptionTextShowState != show)
908 __descriptionTextShowState = show;
910 if (__pDescriptionText != null)
912 __pDescriptionText->SetVisibleState(__descriptionTextShowState);
914 FloatDimension itemDimension = GetSizeF();
915 float descriptionTextHeight = GetDescriptionTextHeight();
917 itemDimension.height += ((__descriptionTextShowState) ? (descriptionTextHeight) : (-descriptionTextHeight));
919 // Set position & item height
920 SetItemCustomHeight((__descriptionTextShowState ? (itemDimension.height - descriptionTextHeight) : 0.0f));
921 SetItemHeight(itemDimension.height);
923 SetSize(itemDimension);
925 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
927 if ((__pAccessibilityElement != null) && (pContainer != null))
929 SetAccessibilityElement();
931 _AccessibilityManager::GetInstance()->RequestToDrawFocusUi();
938 _ListViewItem::SetContextItemEventListener(_IActionEventListener& listener)
940 __pContextItemEventListener = &listener;
944 _ListViewItem::SetContextItemActivationState(bool activate)
946 _ListViewContextItem* pContextItem = static_cast<_ListViewContextItem*>(GetContextItem());
948 if ((pContextItem != null) && (__pContextItemEventListener != null))
952 pContextItem->AddContextItemEventListener(*__pContextItemEventListener);
956 pContextItem->RemoveContextItemEventListener(*__pContextItemEventListener);
962 _ListViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
964 if ((&source != this) && (source.GetParent() != this))
969 ClearLastStateChangedInfo();
970 StopTextSlideTimer();
972 FloatPoint pos = touchinfo.GetCurrentPosition();
973 __prevTouchPos.SetPosition(pos.x, pos.y);
975 __selectedElementId = GetElementIdFromPosition(pos);
977 _ListViewItemElement* pElement = GetElement(__selectedElementId);
979 if (pElement != null)
981 if ((pElement->actionElement) && (pElement->selectionEnabled))
983 __selectionEabledBgColor = GetItemBackgroundColor(LIST_ITEM_STATE_PRESSED);
984 SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, GetItemBackgroundColor(LIST_ITEM_STATE_NORMAL));
986 __selectionEabled = true;
989 if (pElement->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
991 SetCutlinkTextFocus(pos);
993 if (pElement->pTextElement->textSlidingEnabled)
995 pElement->pTextElement->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT);
996 pElement->pTextElement->pTextObject->Compose();
998 if (pElement->pTextElement->pTextObject->IsActionOn())
1000 StartTextSlideTimer();
1006 __touchPressed = true;
1008 SetLastStateChangedInfo();
1010 _TableViewItem::OnTouchPressed(source, touchinfo);
1016 _ListViewItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1018 if ((&source != this) && (source.GetParent() != this))
1024 ResetCutlinkFocus();
1026 if (__selectionEabled)
1028 SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, __selectionEabledBgColor);
1029 __selectionEabled = false;
1032 __selectedElementId = -1;
1033 __touchPressed = false;
1035 _TableViewItem::OnTouchReleased(source, touchinfo);
1041 _ListViewItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1045 ClearLastStateChangedInfo();
1050 __selectedElementId = -1;
1051 __touchPressed = false;
1053 _TableViewItem::OnTouchMoved(source, touchinfo);
1059 _ListViewItem::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1063 if (__selectionEabled)
1065 SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, __selectionEabledBgColor);
1066 __selectionEabled = false;
1069 _TableViewItem::OnTouchCanceled(source, touchinfo);
1075 _ListViewItem::OnDraw(void)
1077 _TableViewItem::OnDraw();
1084 _ListViewItem::OnBoundsChanging(const FloatRectangle& bounds)
1086 FloatDimension currentSize = GetSizeF();
1088 if (!_FloatCompare(currentSize.width, bounds.width) || !_FloatCompare(currentSize.height, bounds.height))
1090 __needAlignContextItem = true;
1097 _ListViewItem::OnBoundsChanged(void)
1099 _TableViewItem::OnBoundsChanged();
1101 if (__needAlignContextItem)
1103 _ListViewContextItem* pContextItem = static_cast<_ListViewContextItem*>(GetContextItem());
1105 if (pContextItem != null)
1107 FloatRectangle bounds = GetBoundsF();
1108 pContextItem->AdjustItemBounds(bounds);
1110 __needAlignContextItem = false;
1115 ListViewItemDrawingStatus
1116 _ListViewItem::GetItemDrawingStatus(void)
1118 TableViewItemDrawingStatus parentStatus = GetDrawingStatus();
1119 ListViewItemDrawingStatus status;
1121 switch (parentStatus)
1123 case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED:
1124 status = LISTVIEW_ITEM_STATUS_PRESSED;
1127 case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED:
1128 status = LISTVIEW_ITEM_STATUS_HIGHLIGHTED;
1132 status = LISTVIEW_ITEM_STATUS_NORMAL;
1140 _ListViewItem::DrawElement(_ListViewItemElement* pElement)
1142 // Get Current TableViewItem drawing status
1143 ListViewItemDrawingStatus status = GetItemDrawingStatus();
1144 FloatRectangle elementRect;
1146 // Check element selection enabled
1147 if (status != LISTVIEW_ITEM_STATUS_NORMAL)
1149 if (__selectedElementId == -1)
1151 if ((pElement->actionElement) && (pElement->selectionEnabled))
1153 status = LISTVIEW_ITEM_STATUS_NORMAL;
1156 else if (__selectedElementId != pElement->elementId)
1158 bool enabled = false;
1159 if (GetElementSelectionEnabled(__selectedElementId, enabled) && enabled)
1161 status = LISTVIEW_ITEM_STATUS_NORMAL;
1163 else if ((pElement->actionElement) && (pElement->selectionEnabled))
1165 status = LISTVIEW_ITEM_STATUS_NORMAL;
1170 Canvas* pCanvas = null;
1172 switch (pElement->elementType)
1174 case LISTVIEW_ITEM_ELEMENT_TEXT:
1175 DrawText(pElement->bounds, status, pElement->pTextElement);
1178 case LISTVIEW_ITEM_ELEMENT_BITMAP:
1179 DrawBitmap(pElement->bounds, status, pElement->pBitmapElement);
1182 case LISTVIEW_ITEM_ELEMENT_OBJ:
1183 pCanvas = pElement->pCustomElement->pVE->GetCanvasN();
1185 if (pCanvas != null)
1187 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1189 elementRect.SetBounds(0.0f, 0.0f, pElement->bounds.width, pElement->bounds.height);
1191 pElement->pCustomElement->pCustom->DrawElement(pCanvas, elementRect, status);
1203 _ListViewItem::DrawElements(void)
1205 _LinkedList <_ListViewItemElement>::_Iterator iter;
1207 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1209 DrawElement(&(*iter));
1214 _ListViewItem::DrawText(FloatRectangle& rect, ListViewItemDrawingStatus status, _ListViewItemElementText* pText)
1216 SysTryReturn(NID_UI_CTRL, (pText != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Text element is null.");
1218 FloatRectangle bounds(rect.x, rect.y, rect.width, rect.height);
1220 if (pText->pVE->GetParent() == null)
1222 GetVisualElement()->AttachChild(*(pText->pVE));
1223 pText->pVE->SetShowState(true);
1226 if (pText->textSize > 0)
1228 pText->pTextObject->SetFont(GetFont(FONT_STYLE_PLAIN, pText->textSize), 0, pText->pTextObject->GetTextLength());
1231 // Calculate Text element bounds
1232 if (pText->pEnrichedText == null)
1234 FloatDimension textDimension = pText->pTextObject->GetTextExtentF(0, pText->pTextObject->GetTextLength());
1235 TextObjectAlignment textAlign = pText->pTextObject->GetAlignment();
1237 if (__itemType == LISTVIEW_ITEM_TYPE_CUSTOM)
1239 if (textDimension.width < bounds.width)
1241 bounds.width = textDimension.width;
1243 if ((0x0007 & textAlign) == TEXT_OBJECT_ALIGNMENT_CENTER)
1245 bounds.x = rect.x + ((rect.width - bounds.width) / 2.0f);
1247 else if ((0x0007 & textAlign) == TEXT_OBJECT_ALIGNMENT_RIGHT)
1249 bounds.x = rect.x + (rect.width - bounds.width);
1252 if (textDimension.height < bounds.height)
1254 bounds.height = textDimension.height;
1256 if ((0x0700 & textAlign) == TEXT_OBJECT_ALIGNMENT_MIDDLE)
1258 bounds.y = rect.y + ((rect.height - bounds.height) / 2.0f);
1260 else if ((0x0700 & textAlign) == TEXT_OBJECT_ALIGNMENT_BOTTOM)
1262 bounds.y = rect.y + (rect.height - bounds.height);
1268 if ((!_FloatCompare(bounds.width, textDimension.width)) || (!_FloatCompare(bounds.height, textDimension.height)))
1271 bounds.y = rect.y + ((rect.height - textDimension.height) / 2.0f);
1272 bounds.width = (bounds.width > textDimension.width) ? textDimension.width : bounds.width;
1273 bounds.height = textDimension.height;
1280 pText->pVE->SetBounds(bounds);
1282 // Check to EnrichedText contains Cutlink
1283 if ((pText->pEnrichedText != null) && (pText->cutlinkViewModeEnabled) && (pText->cutlinkParseEnabled)
1284 && (pText->pTextObject->GetTotalCutLinkElementCount() <= 0))
1286 if (ParseCutlinkText(pText))
1288 pText->pTextObject->SetCutLinkViewMode(true);
1293 if (IsItemEnabled())
1295 pText->pTextObject->SetForegroundColor(pText->textColor[status], 0, pText->pTextObject->GetTextLength());
1299 Color disableTextColor;
1300 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_DISABLED, disableTextColor);
1302 pText->pTextObject->SetForegroundColor(disableTextColor, 0, pText->pTextObject->GetTextLength());
1306 pText->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1307 pText->pTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
1309 Canvas* pCanvas = pText->pVE->GetCanvasN();
1310 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1312 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1315 pText->pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1323 _ListViewItem::DrawBitmap(FloatRectangle& rect, ListViewItemDrawingStatus status, _ListViewItemElementBitmap* pBitmap)
1325 SysTryReturn(NID_UI_CTRL, (pBitmap != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null.");
1327 Bitmap* pDrawBitmap = pBitmap->pBitmap[status];
1328 if ((pDrawBitmap == null) && (status != LISTVIEW_ITEM_STATUS_NORMAL))
1330 pDrawBitmap = pBitmap->pBitmap[LISTVIEW_ITEM_STATUS_NORMAL];
1333 SysTryReturn(NID_UI_CTRL, (pDrawBitmap != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null.");
1335 if (pBitmap->pVE->GetParent() == null)
1337 GetVisualElement()->AttachChild(*(pBitmap->pVE));
1338 pBitmap->pVE->SetShowState(true);
1341 pBitmap->pVE->SetBounds(rect);
1343 Canvas* pCanvas = pBitmap->pVE->GetCanvasN();
1344 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1346 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1349 if (pDrawBitmap->IsNinePatchedBitmap())
1351 pCanvas->DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, rect.width, rect.height), *pDrawBitmap);
1355 pCanvas->DrawBitmap(FloatRectangle(0.0f, 0.0f, rect.width, rect.height), *pDrawBitmap);
1364 _ListViewItem::DrawDivider(void)
1366 if ((__itemType == LISTVIEW_ITEM_TYPE_GROUP) && (GetItemBackgroundBitmap(LIST_ITEM_STATE_NORMAL) == null))
1368 float lineHeight = 0.0f;
1369 float lineLeftMargin = 0.0f;
1370 float lineBottomMargin = 0.0f;
1371 float lineTopMargin = 0.0f;
1372 GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
1373 GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
1374 GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineBottomMargin);
1376 FloatRectangle textBounds;
1377 FloatRectangle bitmapBounds;
1378 _ListViewItemElementText* pElementText = GetElementText(LIST_ITEM_RESERVED_ID_3);
1379 _ListViewItemElementBitmap* pElementBitmap = GetElementBitmap(LIST_ITEM_RESERVED_ID_2);
1381 if ((pElementText != null) && (pElementText->pVE != null))
1383 textBounds = pElementText->pVE->GetBounds();
1386 if ((pElementBitmap != null) && (pElementBitmap->pVE != null))
1388 bitmapBounds = pElementBitmap->pVE->GetBounds();
1391 float textBottomPos = textBounds.y + textBounds.height;
1392 float bitmapBottomPos = bitmapBounds.y + bitmapBounds.height;
1394 lineTopMargin = (textBottomPos > bitmapBottomPos) ? textBottomPos : bitmapBottomPos;
1396 FloatRectangle bounds = GetBoundsF();
1397 float defaultMargin = bounds.height - lineBottomMargin;
1398 lineTopMargin = (lineTopMargin > defaultMargin) ? lineTopMargin : defaultMargin;
1400 if (bounds.height <= lineTopMargin)
1405 if (__pDivider == null)
1407 __pDivider = _Label::CreateLabelN();
1408 SysTryReturnVoidResult(NID_UI_CTRL, __pDivider != null, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1410 AttachSystemChild(*__pDivider);
1412 _AccessibilityContainer* pContainer = __pDivider->GetAccessibilityContainer();
1413 if (pContainer != null)
1415 pContainer->Activate(false);
1419 Color underLineColor;
1420 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_NORMAL, underLineColor);
1422 __pDivider->SetBounds(FloatRectangle(lineLeftMargin, lineTopMargin, bounds.width - lineLeftMargin * 2.0f, lineHeight));
1423 __pDivider->SetBackgroundColor(underLineColor);
1424 __pDivider->Invalidate();
1429 _ListViewItem::StartTextSlideTimer(void)
1431 result r = E_SUCCESS;
1433 if (__pTextSlideTimer == null)
1435 __pTextSlideTimer = new (std::nothrow) Timer();
1437 r = __pTextSlideTimer->Construct(*this);
1438 SysTryCatch(NID_UI, (r == E_SUCCESS), ,E_SYSTEM, ("[E_SYSTEM] Timer cannot construct."));
1442 __pTextSlideTimer->Cancel();
1445 r = __pTextSlideTimer->Start(TEXT_SLIDING_TIMER_DURATION);
1446 SysTryCatch(NID_UI, (r == E_SUCCESS), , E_SYSTEM, ("[E_SYSTEM] Timer Start failed."));
1451 StopTextSlideTimer();
1455 _ListViewItem::StopTextSlideTimer(void)
1457 delete __pTextSlideTimer;
1458 __pTextSlideTimer = null;
1462 _ListViewItem::IsTextSlideTimerRunning(void)
1464 return (__pTextSlideTimer != null);
1468 _ListViewItem::OnTextSlideTimerExpired(void)
1470 if (__selectedElementId != -1)
1472 _ListViewItemElement* pElement = GetElement(__selectedElementId);
1474 if ((pElement != null) && (pElement->pTextElement->pTextObject != null))
1476 TextObject* pTextObject = pElement->pTextElement->pTextObject;
1478 Canvas* pCanvas = (pElement->pTextElement->pVE)->GetCanvasN();
1479 SysTryReturnVoidResult(NID_UI_CTRL, (pCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1481 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1484 pTextObject->SetForegroundColor(pElement->pTextElement->textColor[LISTVIEW_ITEM_STATUS_PRESSED], 0, pTextObject->GetTextLength());
1485 pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT);
1486 pTextObject->Compose();
1487 pTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas));
1489 pCanvas->Show(_CoordinateSystemUtils::ConvertToInteger(pElement->bounds));
1490 StartTextSlideTimer();
1499 _ListViewItem::ResetTextSlide(void)
1501 if (IsTextSlideTimerRunning())
1503 StopTextSlideTimer();
1505 _ListViewItemElement* pElement = GetElement(__selectedElementId);
1507 if ((pElement != null) && (pElement->pTextElement->pTextObject != null))
1509 pElement->pTextElement->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1510 pElement->pTextElement->pTextObject->SetForegroundColor(pElement->pTextElement->textColor[LISTVIEW_ITEM_STATUS_NORMAL],
1511 0, pElement->pTextElement->pTextObject->GetTextLength());
1517 _ListViewItem::OnTimerExpired(Timer& timer)
1519 _TableViewItem::OnTimerExpired(timer);
1521 if (&timer == __pTextSlideTimer)
1523 OnTextSlideTimerExpired();
1528 _ListViewItem::ParseCutlinkText(_ListViewItemElementText* pElementText)
1530 if ((pElementText == null) || (pElementText->pEnrichedText == null))
1535 TextObject* pTextObject = pElementText->pTextObject;
1536 unsigned long cutlinkMaskType = pElementText->cutlinkMaskType;
1537 TextLinkInfo* pTextLinkInfo = null;
1538 TextLinkInfo* pNextLinkInfo = null;
1539 int currentOffset = 0;
1540 bool isChangingCutlink = false;
1541 wchar_t* pCutlinkString = null;
1544 int strLength = pTextObject->GetTextLength();
1545 wchar_t* pStr = new (std::nothrow) wchar_t[strLength + 1];
1546 SysTryReturn(NID_UI, (pStr != null), false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
1548 pTextObject->GetText(pStr, strLength);
1550 TextCutLinkParser* pParser = new (std::nothrow) TextCutLinkParser();
1551 SysTryCatch(NID_UI, (pParser != null), (ret = false), E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
1553 pParser->SetCutLinkMask(cutlinkMaskType);
1555 pTextLinkInfo = pParser->Parse(pStr, strLength, 0);
1556 SysTryCatch(NID_UI, (pTextLinkInfo != null), (ret = false), E_SYSTEM, ("[E_SYSTEM] TextLinkInfo is not valid."));
1558 // remove all text element in _EnrichedTextImpl
1559 pElementText->pEnrichedText->RemoveAllTextElements(true);
1561 while (pTextLinkInfo != null)
1563 isChangingCutlink = false;
1565 switch (pTextLinkInfo->linkType)
1568 if (cutlinkMaskType & LINK_TYPE_URL)
1570 isChangingCutlink = true;
1574 case LINK_TYPE_EMAIL:
1575 if (cutlinkMaskType & LINK_TYPE_EMAIL)
1577 isChangingCutlink = true;
1581 case LINK_TYPE_TEL_NUM:
1582 if (cutlinkMaskType & LINK_TYPE_TEL_NUM)
1584 isChangingCutlink = true;
1588 case LINK_TYPE_APPCONTROL:
1589 if (cutlinkMaskType & LINK_TYPE_APPCONTROL)
1591 isChangingCutlink = true;
1595 case LINK_TYPE_MIME:
1596 if (cutlinkMaskType & LINK_TYPE_MIME)
1598 isChangingCutlink = true;
1606 pCutlinkString = new (std::nothrow) wchar_t[pTextLinkInfo->length + 1];
1608 if (pCutlinkString == null)
1610 while (pTextLinkInfo != null)
1612 pNextLinkInfo = pTextLinkInfo->pNextLinkInfo;
1613 delete pTextLinkInfo;
1614 pTextLinkInfo = pNextLinkInfo;
1616 SysTryCatch(NID_UI, (pTextLinkInfo != null), (ret = false), E_SYSTEM, ("[E_SYSTEM] TextLinkInfo is not valid."));
1619 for (int i = 0; i < pTextLinkInfo->length; i++)
1621 pCutlinkString[i] = pStr[pTextLinkInfo->srcOffset + i];
1624 pCutlinkString[pTextLinkInfo->length] = null;
1626 if (currentOffset < pTextLinkInfo->srcOffset)
1628 TextSimple* pSimpleText = new (std::nothrow) TextSimple(pStr + currentOffset, pTextLinkInfo->srcOffset - currentOffset);
1629 pTextObject->AppendElement(*pSimpleText);
1632 if (isChangingCutlink == true)
1634 TextCutLink* pTextElement = new (std::nothrow) TextCutLink(false, pTextLinkInfo->linkType, pStr + pTextLinkInfo->srcOffset,
1635 pTextLinkInfo->length);
1636 pTextElement->SetEditModeEnable(true);
1637 pTextObject->AppendElement(*pTextElement);
1641 TextSimple* pSimpleText = new (std::nothrow) TextSimple(pCutlinkString, pTextLinkInfo->length);
1642 pTextObject->AppendElement(*pSimpleText);
1645 currentOffset = pTextLinkInfo->srcOffset + pTextLinkInfo->length;
1647 pNextLinkInfo = pTextLinkInfo->pNextLinkInfo;
1648 delete pTextLinkInfo;
1649 pTextLinkInfo = pNextLinkInfo;
1651 delete[] pCutlinkString;
1652 pCutlinkString = null;
1655 if (strLength != currentOffset)
1657 TextSimple* pSimpleText = new (std::nothrow) TextSimple(pStr + currentOffset, strLength - currentOffset);
1658 pTextObject->AppendElement(*pSimpleText);
1661 //pTextObject->SetRange(0, pTextObject->GetLength());
1662 //pTextObject->NotifyTextChanged(0, pTextObject->GetLength());
1663 pTextObject->Compose();
1679 _ListViewItem::IsCutlinkTextSelected(const FloatPoint& position, int* index, _ListViewItemUiLinkInfo** ppInfo) const
1681 int elementId = GetElementIdFromPosition(position);
1682 _ListViewItemElementText* pElement = GetElementText(elementId);
1684 if ((pElement != null) && (pElement->pTextObject) && (pElement->cutlinkViewModeEnabled))
1686 TextObject* pTextObject = pElement->pTextObject;
1687 FloatRectangle displayRect = pTextObject->GetBoundsF();
1688 int selectedIndex = pTextObject->GetCutLinkIndexFromPositionData(position.x - displayRect.x, position.y - displayRect.y);
1690 if (selectedIndex >= 0)
1692 *index = selectedIndex;
1693 TextCutLink* pCutLinkObject = dynamic_cast<TextCutLink*>(pTextObject->GetCutLinkElementAtCutLinkElementIndex(selectedIndex));
1694 if (pCutLinkObject == null)
1699 String cutLinkString(pCutLinkObject->GetText());
1700 LinkType baseLinkType = pCutLinkObject->GetCutLinkType();
1702 if (baseLinkType & pElement->cutlinkMaskType)
1704 _ListViewItemUiLinkInfo* pUiLinkInfo = new (std::nothrow) _ListViewItemUiLinkInfo();
1706 pUiLinkInfo->textInfo = cutLinkString;
1707 pUiLinkInfo->linkType = baseLinkType;
1708 pUiLinkInfo->linkInfo = cutLinkString;
1710 *ppInfo = pUiLinkInfo;
1721 _ListViewItem::SetCutlinkTextFocus(const FloatPoint& position)
1723 int elementId = GetElementIdFromPosition(position);
1724 _ListViewItemElementText* pElement = GetElementText(elementId);
1726 if ((pElement != null) && (pElement->pTextObject != null) && (pElement->cutlinkViewModeEnabled))
1728 TextObject* pTextObject = pElement->pTextObject;
1729 FloatRectangle displayRect = pTextObject->GetBoundsF();
1731 int index = pTextObject->GetCutLinkIndexFromPositionData(position.x - displayRect.x, position.y - displayRect.y);
1735 pTextObject->ChangeCutLinkState(index, true);
1744 _ListViewItem::ResetCutlinkFocus(void)
1746 _LinkedList <_ListViewItemElement>::_Iterator iter;
1748 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1750 if ((iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT) && (iter->pTextElement->pTextObject))
1752 iter->pTextElement->pTextObject->ResetAllCutLinkElementsState();
1760 _ListViewItem::GetFont(unsigned long fontStyle, float fontSize)
1762 __fontStyle = fontStyle;
1763 __fontSize = fontSize;
1765 return GetFallbackFont();
1769 _ListViewItem::OnFontChanged(Font* pFont)
1771 __fontName = _Control::GetFont();
1773 if (__pDescriptionText != null)
1775 __pDescriptionText->SetFont(__fontName);
1778 if (GetContextItem() != null)
1780 GetContextItem()->SetFont(__fontName);
1785 _ListViewItem::OnFontInfoRequested(unsigned long& style, int& size)
1787 style = __fontStyle;
1788 size = _CoordinateSystemUtils::ConvertToInteger(__fontSize);
1792 _ListViewItem::OnFontInfoRequested(unsigned long& style, float& size)
1794 style = __fontStyle;
1798 _ListViewItem::OnAncestorEnableStateChanged(const _Control& control)
1800 _LinkedList <_ListViewItemElement>::_Iterator iter;
1802 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1804 if (iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
1806 DrawText(iter->bounds, GetItemDrawingStatus(), iter->pTextElement);
1812 CompareAccessibilityElement(_ListViewItemElement* a, _ListViewItemElement* b)
1814 if (_FloatCompare(a->bounds.y, b->bounds.y))
1816 return (a->bounds.x < b->bounds.x);
1819 return (a->bounds.y < b->bounds.y);
1823 _ListViewItem::SetAccessibilityElement(void)
1825 if (!_AccessibilityManager::IsActivated())
1830 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1832 if (pContainer != null)
1834 if (__pAccessibilityElement == null)
1836 _LinkedList <_ListViewItemElement*> accessibilityElementList;
1837 _LinkedList <_ListViewItemElement>::_Iterator iter;
1839 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1841 if (iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
1843 accessibilityElementList.push_back(&(*iter));
1847 accessibilityElementList.sort(CompareAccessibilityElement);
1849 _LinkedList <_ListViewItemElement*>::_Iterator accessibilityIter;
1850 _ListViewItemElement* pElement = null;
1851 String accessibilityLable;
1853 for (accessibilityIter = accessibilityElementList.begin(); accessibilityIter != accessibilityElementList.end(); accessibilityIter++)
1855 pElement = *accessibilityIter;
1857 int textLength = pElement->pTextElement->pTextObject->GetTextLength();
1861 wchar_t* pAccessibilityText = new (std::nothrow) wchar_t[textLength + 1];
1862 SysTryReturnVoidResult(NID_UI_CTRL, (pAccessibilityText != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1864 pElement->pTextElement->pTextObject->GetText(pAccessibilityText, textLength);
1866 accessibilityLable += String(pAccessibilityText);
1868 delete[] pAccessibilityText;
1872 accessibilityElementList.clear();
1874 __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1875 SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityElement != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1877 __pAccessibilityElement->SetBounds(Rectangle(0, 0, _CoordinateSystemUtils::ConvertToInteger(GetBoundsF().width), _CoordinateSystemUtils::ConvertToInteger(GetBoundsF().height)));
1878 __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
1879 __pAccessibilityElement->SetName(L"ListViewItem");
1881 if (accessibilityLable.IsEmpty())
1883 accessibilityLable = L"ListViewItem";
1886 __pAccessibilityElement->SetLabel(accessibilityLable);
1888 pContainer->AddElement(*__pAccessibilityElement);
1892 __pAccessibilityElement->SetBounds(Rectangle(0, 0, _CoordinateSystemUtils::ConvertToInteger(GetBoundsF().width), _CoordinateSystemUtils::ConvertToInteger(GetBoundsF().height)));
1898 _ListViewItem::SetAccessibilityElementLabel(void)
1903 _ListViewItemHitTestVEDelegator::_ListViewItemHitTestVEDelegator(void)
1907 _ListViewItemHitTestVEDelegator::~_ListViewItemHitTestVEDelegator(void)
1912 _ListViewItemHitTestVEDelegator::HitTest(VisualElement& target, const FloatPoint& point)
1914 return HIT_TEST_NOWHERE;
1917 }}} // Tizen::Ui::Controls