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_ITouchLongPressGestureEventListener.h"
36 #include "FUi_ResourceManager.h"
37 #include "FUi_TouchLongPressGestureDetector.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(int itemHeight)
62 : _TableViewItem(itemHeight)
63 , __touchPressed(false)
64 , __selectedElementId(-1)
65 , __progressLeftMargin(0)
66 , __progressRightMargin(0)
68 , __descriptionTextShowState(false)
69 , __pDescriptionText(null)
71 , __selectionEabled(false)
75 , __prevTouchPos(-1, -1)
76 , __pTextSlideTimer(null)
77 , __pLongPressedGesture(null)
79 GET_COLOR_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_NORMAL, __descriptionTextColor);
81 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_SELECTED;
82 ___stateChangedInfo.elementId = -1;
83 ___stateChangedInfo.pUiLinkInfo = null;
86 _ListViewItem::~_ListViewItem(void)
90 delete ___stateChangedInfo.pUiLinkInfo;
91 ___stateChangedInfo.pUiLinkInfo = null;
93 delete __pTextSlideTimer;
94 __pTextSlideTimer = null;
96 if (__pLongPressedGesture != null)
98 RemoveGestureDetector(*__pLongPressedGesture);
100 delete __pLongPressedGesture;
101 __pLongPressedGesture = null;
104 if (__pProgress != null)
106 DetachChild(*__pProgress);
112 if (__pDescriptionText != null)
114 DetachChild(*__pDescriptionText);
116 delete __pDescriptionText;
117 __pDescriptionText = null;
120 if (__pDivider != null)
122 DetachChild(*__pDivider);
130 _ListViewItem::CreateListViewItemN(int itemHeight)
132 _ListViewItem* pItem = new (std::nothrow) _ListViewItem(itemHeight);
133 SysTryReturn(NID_UI_CTRL, (pItem != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
135 pItem->AcquireHandle();
137 result r = pItem->Initialize();
138 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] Unable to create _ListViewItem");
149 _ListViewItem::SetListViewItemType(ListViewItemType type)
155 _ListViewItem::AddTouchLongPressGestureEventListener(_ITouchLongPressGestureEventListener& listener)
157 if (__pLongPressedGesture == null)
159 __pLongPressedGesture = new (std::nothrow) _TouchLongPressGestureDetector();
160 SysTryReturnVoidResult(NID_UI_CTRL, (__pLongPressedGesture != null), E_OUT_OF_MEMORY,
161 "[E_OUT_OF_MEMORY] The memory is insufficient.");
163 __pLongPressedGesture->SetDuration(TOUCH_LONGPRESSED_EVENT_DURATION);
164 AddGestureDetector(*__pLongPressedGesture);
167 result r = __pLongPressedGesture->AddGestureListener(listener);
168 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to add gesture listener.", GetErrorMessage(r));
172 _ListViewItem::RemoveTouchLongPressGestureEventListener(_ITouchLongPressGestureEventListener& listener)
174 if (__pLongPressedGesture != null)
176 __pLongPressedGesture->RemoveGestureListener(listener);
181 _ListViewItem::AddElement(Rectangle& rect, int elementId, const String& text, bool textSliding)
183 result r = E_SUCCESS;
185 SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG,
186 ("[E_INVALID_ARG] This elementId already exists."));
188 // Convert String to TextObject
189 TextObject* pText = new (std::nothrow) TextObject();
192 if (text.IsEmpty() == false)
194 TextSimple* pSimpleText = new (std::nothrow) TextSimple(const_cast <wchar_t*>(text.GetPointer()), text.GetLength());
195 pText->AppendElement(*pSimpleText);
197 pText->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
198 pText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
201 // Make element object
202 _ListViewItemElement element;
203 memset(&element, 0, sizeof(_ListViewItemElement));
205 element.elementId = elementId;
206 element.elementType = LISTVIEW_ITEM_ELEMENT_TEXT;
207 element.bounds = rect;
209 element.pTextElement = new (std::nothrow) _ListViewItemElementText();
210 SysTryReturn(NID_UI_CTRL, (element.pTextElement != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(r));
212 element.pTextElement->pTextObject = pText;
213 element.pTextElement->textSlidingEnabled = textSliding;
215 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, element.pTextElement->textSize);
216 GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_NORMAL, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_NORMAL]);
217 GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_PRESSED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_PRESSED]);
218 GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_HIGHLIGHTED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_HIGHLIGHTED]);
220 // Set Visual element for this element
221 _VisualElement* pVE = new (std::nothrow) _VisualElement();
223 pVE->SetImplicitAnimationEnabled(false);
224 pVE->SetContentProvider(&__hitTestVEDelegator);
225 element.pTextElement->pVE = pVE;
227 __elements.push_back(element);
233 _ListViewItem::AddElement(Rectangle& rect, int elementId, const EnrichedText* pEnrichedText, bool textSliding)
235 SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG,
236 ("[E_INVALID_ARG] This elementId already exists."));
238 SysTryReturn(NID_GRP, (pEnrichedText != null) && (_EnrichedTextImpl::GetInstance(*pEnrichedText) != null),
239 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This _EnrichedText element is null.");
242 _EnrichedTextImpl* pCloneText = _EnrichedTextImpl::GetInstance(*pEnrichedText)->GetCloneN();
243 SysTryReturn(NID_GRP, (pCloneText != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This _EnrichedText element can not clone.");
245 TextObject* pText = pCloneText->GetTextObject();
247 // Make element object
248 _ListViewItemElement element;
249 memset(&element, 0, sizeof(_ListViewItemElement));
251 element.elementId = elementId;
252 element.elementType = LISTVIEW_ITEM_ELEMENT_TEXT;
253 element.bounds = rect;
255 element.pTextElement = new (std::nothrow) _ListViewItemElementText();
256 SysTryReturn(NID_UI_CTRL, (element.pTextElement != null), GetLastResult(), GetLastResult(), "[%s] Propagating.",
257 GetErrorMessage(GetLastResult()));
259 element.pTextElement->pTextObject = pText;
260 element.pTextElement->pEnrichedText = pCloneText;
261 element.pTextElement->textSlidingEnabled = textSliding;
263 GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_NORMAL, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_NORMAL]);
264 GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_PRESSED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_PRESSED]);
265 GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_HIGHLIGHTED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_HIGHLIGHTED]);
267 // Set Visual element for this element
268 _VisualElement* pVE = new (std::nothrow) _VisualElement();
270 pVE->SetImplicitAnimationEnabled(false);
271 pVE->SetContentProvider(&__hitTestVEDelegator);
272 element.pTextElement->pVE = pVE;
274 __elements.push_back(element);
280 _ListViewItem::AddElement(Rectangle& rect, int elementId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
282 SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG,
283 ("[E_INVALID_ARG] This elementId already exists."));
285 SysTryReturn(NID_GRP, (pNormalBitmap != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null.");
287 _ListViewItemElement element;
288 _VisualElement* pVE = null;
289 Bitmap* pClonePressedBitmap = null;
290 Bitmap* pCloneHighlightedBitmap = null;
291 result r = E_SUCCESS;
293 Bitmap* pCloneNormalBitmap = _BitmapImpl::CloneN(*pNormalBitmap);
294 SysTryReturn(NID_UI_CTRL, (pCloneNormalBitmap != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
296 if (pPressedBitmap != null)
298 pClonePressedBitmap = _BitmapImpl::CloneN(*pPressedBitmap);
299 SysTryCatch(NID_UI_CTRL, (pClonePressedBitmap != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
302 if (pHighlightedBitmap != null)
304 pCloneHighlightedBitmap = _BitmapImpl::CloneN(*pHighlightedBitmap);
305 SysTryCatch(NID_UI_CTRL, (pCloneHighlightedBitmap != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
308 // Make element object
309 memset(&element, 0, sizeof(_ListViewItemElement));
311 element.elementId = elementId;
312 element.elementType = LISTVIEW_ITEM_ELEMENT_BITMAP;
313 element.bounds = rect;
315 element.pBitmapElement = new (std::nothrow) _ListViewItemElementBitmap();
316 SysTryCatch(NID_UI_CTRL, (element.pBitmapElement != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
318 element.pBitmapElement->pBitmap[LISTVIEW_ITEM_STATUS_NORMAL] = pCloneNormalBitmap;
319 element.pBitmapElement->pBitmap[LISTVIEW_ITEM_STATUS_PRESSED] = pClonePressedBitmap;
320 element.pBitmapElement->pBitmap[LISTVIEW_ITEM_STATUS_HIGHLIGHTED] = pCloneHighlightedBitmap;
322 pVE = new (std::nothrow) _VisualElement();
324 pVE->SetImplicitAnimationEnabled(false);
325 pVE->SetContentProvider(&__hitTestVEDelegator);
326 element.pBitmapElement->pVE = pVE;
328 __elements.push_back(element);
333 delete pCloneNormalBitmap;
334 delete pClonePressedBitmap;
335 delete pCloneHighlightedBitmap;
341 _ListViewItem::AddElement(Rectangle& rect, int elementId, const _ICustomElement* pCustom)
343 SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG,
344 ("[E_INVALID_ARG] This elementId already exists."));
346 SysTryReturn(NID_GRP, (pCustom != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This Custom element is null.");
348 // Make element object
349 _ListViewItemElement element;
350 memset(&element, 0, sizeof(_ListViewItemElement));
352 element.elementId = elementId;
353 element.elementType = LISTVIEW_ITEM_ELEMENT_OBJ;
354 element.bounds = rect;
356 element.pCustomElement = new (std::nothrow) _ListViewItemElementCustom();
357 SysTryReturn(NID_UI_CTRL, (element.pCustomElement != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
359 element.pCustomElement->pCustom = const_cast<_ICustomElement*>(pCustom);
361 _VisualElement* pVE = new (std::nothrow) _VisualElement();
363 pVE->SetImplicitAnimationEnabled(false);
364 pVE->SetContentProvider(&__hitTestVEDelegator);
365 element.pCustomElement->pVE = pVE;
367 if (pVE->GetParent() == null)
369 GetVisualElement()->AttachChild(*(pVE));
370 pVE->SetShowState(true);
371 pVE->SetBounds(FloatRectangle(rect.x, rect.y, rect.width, rect.height));
374 __elements.push_back(element);
380 _ListViewItem::DeleteElement(int elementId)
382 _LinkedList <_ListViewItemElement>::_Iterator iter;
384 for (iter = __elements.begin(); iter != __elements.end(); iter++)
386 if (iter->elementId == elementId)
388 DeleteElement(&(*iter));
389 __elements.erase(iter);
399 _ListViewItem::DeleteAllElement(void)
401 _LinkedList <_ListViewItemElement>::_Iterator iter;
403 for (iter = __elements.begin(); iter != __elements.end(); iter++)
405 DeleteElement(&(*iter));
412 _ListViewItem::DeleteElement(_ListViewItemElement* pElement)
414 if (pElement->pTextElement != null)
416 if (pElement->pTextElement->pEnrichedText != null)
418 (pElement->pTextElement->pEnrichedText)->RemoveAllTextElements(true);
420 delete pElement->pTextElement->pEnrichedText;
421 pElement->pTextElement->pEnrichedText = null;
423 pElement->pTextElement->pTextObject = null;
427 delete pElement->pTextElement->pTextObject;
428 pElement->pTextElement->pTextObject = null;
431 if (pElement->pTextElement->pVE != null)
433 pElement->pTextElement->pVE->Destroy();
434 pElement->pTextElement->pVE = null;
437 if (pElement->pTextElement->pAccessibilityElement)
439 pElement->pTextElement->pAccessibilityElement->Activate(false);
440 pElement->pTextElement->pAccessibilityElement = null;
443 delete pElement->pTextElement;
444 pElement->pTextElement = null;
447 if (pElement->pBitmapElement != null)
449 for (int i = 0; i < LISTVIEW_ITEM_STATUS_MAX; i++)
451 delete pElement->pBitmapElement->pBitmap[i];
452 pElement->pBitmapElement->pBitmap[i] = null;
455 if (pElement->pBitmapElement->pVE != null)
457 pElement->pBitmapElement->pVE->Destroy();
458 pElement->pBitmapElement->pVE = null;
461 delete pElement->pBitmapElement;
462 pElement->pBitmapElement = null;
465 if (pElement->pCustomElement)
467 delete pElement->pCustomElement->pCustom;
468 pElement->pCustomElement->pCustom = null;
470 if (pElement->pCustomElement->pVE != null)
472 pElement->pCustomElement->pVE->Destroy();
473 pElement->pCustomElement->pVE = null;
476 delete pElement->pCustomElement;
477 pElement->pCustomElement = null;
482 _ListViewItem::HasElement(int elementId)
484 _ListViewItemElement* pElement = GetElement(elementId);
486 return (pElement != null);
490 _ListViewItem::RefreshElement(int elementId)
492 _ListViewItemElement* pElement = GetElement(elementId);
494 if (pElement != null)
496 DrawElement(pElement);
499 return (pElement != null);
503 _ListViewItem::SetLastStateChangedInfo(void)
505 ClearLastStateChangedInfo();
507 int elementId = GetElementIdFromCurrentTouchPosition();
508 _ListViewItemElement* pElement = GetElement(elementId);
510 if ((pElement != null) && (__itemType == LISTVIEW_ITEM_TYPE_CUSTOM))
512 _ListViewItemUiLinkInfo* pInfo = null;
513 int cutlinkTextTouchedIndex = -1;
515 if (IsCutlinkTextSelected(__prevTouchPos, &cutlinkTextTouchedIndex, &pInfo))
517 if ((GetItemStyle() == TABLE_VIEW_ANNEX_STYLE_DETAILED)
518 && (pElement->actionElement == true) && (pElement->selectionEnabled == false))
523 if (cutlinkTextTouchedIndex >= 0)
525 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_UILINK_SELECTED;
526 ___stateChangedInfo.elementId = elementId;
527 ___stateChangedInfo.pUiLinkInfo = pInfo;
531 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_ELEMENT_SELECTED;
532 ___stateChangedInfo.elementId = elementId;
537 if ((GetItemStyle() == TABLE_VIEW_ANNEX_STYLE_DETAILED)
538 && (pElement->actionElement == true) && (pElement->selectionEnabled == false))
543 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_ELEMENT_SELECTED;
544 ___stateChangedInfo.elementId = elementId;
549 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_ELEMENT_SELECTED;
550 ___stateChangedInfo.elementId = -1;
555 _ListViewItem::GetLastStateChangedInfo(_ListViewItemStateChangedInfo& changedInfo) const
557 changedInfo = ___stateChangedInfo;
559 return (___stateChangedInfo.selectionType != LISTVIEW_ITEM_SELECTED);
563 _ListViewItem::ClearLastStateChangedInfo(void)
565 delete ___stateChangedInfo.pUiLinkInfo;
567 ___stateChangedInfo.selectionType = LISTVIEW_ITEM_SELECTED;
568 ___stateChangedInfo.elementId = -1;
569 ___stateChangedInfo.pUiLinkInfo = null;
573 _ListViewItem::GetElementIdFromPosition(const Point& position) const
575 _LinkedList <_ListViewItemElement>::_ReverseIterator reverseIter;
577 for (reverseIter = __elements.rbegin(); reverseIter != __elements.rend(); reverseIter++)
579 if ((*reverseIter).bounds.Contains(position))
581 return (*reverseIter).elementId;
589 _ListViewItem::GetElementIdFromCurrentTouchPosition(void) const
591 return GetElementIdFromPosition(__prevTouchPos);
594 _ListViewItemElement*
595 _ListViewItem::GetElement(int elementId) const
597 _LinkedList <_ListViewItemElement>::_Iterator iter;
599 for (iter = __elements.begin(); iter != __elements.end(); iter++)
601 if (iter->elementId == elementId)
610 ListViewItemElementType
611 _ListViewItem::GetElementType(int elementId) const
613 _ListViewItemElement* pElement = GetElement(elementId);
615 return ((pElement != null) ? pElement->elementType : LISTVIEW_ITEM_ELEMENT_INVALID);
619 _ListViewItem::GetTextObjectInElement(int elementId) const
621 _ListViewItemElementText* pElement = GetElementText(elementId);
623 return ((pElement != null) ? pElement->pTextObject : null);
626 _ListViewItemElementText*
627 _ListViewItem::GetElementText(int elementId) const
629 _ListViewItemElement* pElement = GetElement(elementId);
631 if ((pElement != null) && (pElement->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
632 && (pElement->pTextElement->pTextObject != null))
634 return pElement->pTextElement;
640 _ListViewItemElementBitmap*
641 _ListViewItem::GetElementBitmap(int elementId) const
643 _ListViewItemElement* pElement = GetElement(elementId);
645 if ((pElement != null) && (pElement->elementType == LISTVIEW_ITEM_ELEMENT_BITMAP))
647 return pElement->pBitmapElement;
654 _ListViewItem::SetElementSelectionEnabled(int elementId, bool enable)
656 _ListViewItemElement* pElement = GetElement(elementId);
658 if (pElement == null)
663 pElement->actionElement = true;
664 pElement->selectionEnabled = enable;
670 _ListViewItem::GetElementSelectionEnabled(int elementId, bool& enable)
672 _ListViewItemElement* pElement = GetElement(elementId);
674 if ((pElement == null) || (pElement->actionElement == false))
679 enable = pElement->selectionEnabled;
685 _ListViewItem::SetTextCutlinkMask(int elementId, unsigned long mask)
687 _ListViewItemElementText* pElement = GetElementText(elementId);
689 if (pElement == null)
694 pElement->cutlinkMaskType = mask;
700 _ListViewItem::SetTextCutlinkViewMode(int elementId, bool cutlinkViewMode, bool cutlinkParseEnable)
702 _ListViewItemElementText* pElement = GetElementText(elementId);
704 if (pElement == null)
709 pElement->cutlinkViewModeEnabled = cutlinkViewMode;
710 pElement->cutlinkParseEnabled = cutlinkParseEnable;
711 pElement->cutlinkMaskType = LINK_TYPE_MAX;
717 _ListViewItem::SetTextAlignment(int elementId, TextObjectAlignment textAlignment)
719 TextObject* pTextObject = GetTextObjectInElement(elementId);
721 if (pTextObject == null)
726 TextObjectAlignment originAlign = pTextObject->GetAlignment();
728 // reset original alignment
729 if ((0x0007 & textAlignment) != 0x0000) // TextHorizontalAlignment
731 originAlign &= 0x0700;
733 else if ((0x0700 & textAlignment) != 0x0000) // TextVerticalAlignment
735 originAlign &= 0x0007;
738 pTextObject->SetAlignment(originAlign | textAlignment);
744 _ListViewItem::GetTextAlignment(int elementId, TextObjectAlignment& textAlignment) const
746 TextObject* pTextObject = GetTextObjectInElement(elementId);
748 if (pTextObject == null)
753 textAlignment = pTextObject->GetAlignment();
759 _ListViewItem::SetTextWrapType(int elementId, TextObjectWrapType wrapType)
761 TextObject* pTextObject = GetTextObjectInElement(elementId);
763 if (pTextObject == null)
768 pTextObject->SetWrap(wrapType);
774 _ListViewItem::SetTextSize(int elementId, int textSize)
776 _ListViewItemElementText* pElement = GetElementText(elementId);
778 if ((pElement != null) && (textSize > 0))
780 pElement->textSize = textSize;
789 _ListViewItem::SetTextColor(int elementId, Color textColor, ListViewItemDrawingStatus status)
791 _ListViewItemElementText* pElement = GetElementText(elementId);
793 if (pElement == null)
798 pElement->textColor[status] = textColor;
804 _ListViewItem::GetTextColor(int elementId, Color& textColor, ListViewItemDrawingStatus status) const
806 _ListViewItemElementText* pElement = GetElementText(elementId);
808 if (pElement == null)
813 textColor = pElement->textColor[status];
819 _ListViewItem::SetProgressValue(int value)
821 if ((value < 0) || (value > 100))
823 if (__pProgress != null)
825 __pProgress->SetVisibleState(false);
831 if (__pProgress == null)
833 __pProgress = _Progress::CreateProgressN();
834 SysTryReturn(NID_UI_CTRL, (__pProgress != null), false, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
836 __pProgress->SetRange(0, 100);
837 AttachChild(*__pProgress);
839 AdjustProgressBounds();
842 __pProgress->SetValue(value);
843 __pProgress->SetVisibleState(true);
849 _ListViewItem::SetProgressMargins(int leftMargin, int rightMargin)
851 if ((leftMargin < 0) || (rightMargin < 0) || (GetBounds().width - leftMargin - rightMargin <= 0))
856 __progressLeftMargin = leftMargin;
857 __progressRightMargin = rightMargin;
859 AdjustProgressBounds();
865 _ListViewItem::AdjustProgressBounds(void)
867 if (__pProgress != null)
869 Rectangle progressRect = GetBounds();
870 int progressHeight = 0;
871 int bottomMargin = 0;
873 // Calculate progress position
874 GET_SHAPE_CONFIG(SLIDER::BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, progressHeight);
875 GET_SHAPE_CONFIG(LISTVIEW::ITEM_PROGRESS_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, bottomMargin);
877 progressRect.x = __progressLeftMargin;
878 progressRect.y = progressRect.height - progressHeight - bottomMargin;
879 progressRect.width = progressRect.width - __progressLeftMargin - __progressRightMargin;
880 progressRect.height = progressHeight;
882 progressRect.y -= ((__descriptionTextShowState) ? GetDescriptionTextHeight() : 0);
884 __pProgress->SetBounds(progressRect);
889 _ListViewItem::SetDescriptionText(const String& text)
893 if (__pDescriptionText != null)
895 DetachChild(*__pDescriptionText);
897 delete __pDescriptionText;
898 __pDescriptionText = null;
905 if (__pDescriptionText == null)
907 __pDescriptionText = _Label::CreateLabelN();
908 result r = GetLastResult();
909 SysTryReturn(NID_UI_CTRL, (__pDescriptionText != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
911 __pDescriptionText->SetVisibleState(false);
912 __pDescriptionText->SetMargin(0, 0);
913 __pDescriptionText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
915 SetAccessibilityElement();
917 AttachChild(*__pDescriptionText);
920 Rectangle bounds = GetBounds();
921 Rectangle textBounds;
925 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textBounds.x);
926 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textBounds.y);
927 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textSize);
929 textBounds.width = bounds.width - (textBounds.x * 2);
931 TextObject* pText = new (std::nothrow) TextObject();
932 SysTryReturn(NID_UI_CTRL, (pText != null), false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
936 TextSimple* pSimpleText = new (std::nothrow) TextSimple((const_cast<wchar_t*>(text.GetPointer())), text.GetLength());
937 SysTryCatch(NID_UI_CTRL, (pSimpleText != null), (ret = false), E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
939 pText->AppendElement(*pSimpleText);
940 pText->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
941 pText->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
942 pText->SetFont(GetFont(FONT_STYLE_PLAIN, textSize), 0, pText->GetTextLength());
943 pText->SetBounds(Rectangle(0, 0, textBounds.width, 1));
946 textBounds.height = pText->GetTotalHeight();
948 __pDescriptionText->SetBounds(Rectangle(textBounds.x, bounds.height + textBounds.y, textBounds.width, textBounds.height));
949 __pDescriptionText->SetBackgroundColor(Color(0, 0, 0, 0));
950 __pDescriptionText->SetTextColor(__descriptionTextColor);
951 __pDescriptionText->SetTextConfig(textSize, LABEL_TEXT_STYLE_NORMAL);
952 __pDescriptionText->SetText(text);
962 _ListViewItem::SetDescriptionTextColor(const Color& color)
964 __descriptionTextColor = color;
968 _ListViewItem::GetDescriptionTextHeight(void)
970 if (__pDescriptionText != null)
973 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, margin);
975 return ((margin * 2) + __pDescriptionText->GetBounds().height);
982 _ListViewItem::SetDescriptionTextShowState(bool show)
984 if (__descriptionTextShowState != show)
986 __descriptionTextShowState = show;
988 if (__pDescriptionText != null)
990 __pDescriptionText->SetVisibleState(__descriptionTextShowState);
992 Dimension itemDimension = GetSize();
993 int descriptionTextHeight = GetDescriptionTextHeight();
995 itemDimension.height += ((__descriptionTextShowState) ? (descriptionTextHeight) : (-descriptionTextHeight));
997 // Set position & item height
998 SetItemCustomHeight((__descriptionTextShowState ? (itemDimension.height - descriptionTextHeight) : 0));
999 SetItemHeight(itemDimension.height);
1001 SetSize(itemDimension);
1007 _ListViewItem::SetContextItemEventListener(_IActionEventListener& listener)
1009 __pContextItemEventListener = &listener;
1013 _ListViewItem::SetContextItemActivationState(bool activate)
1015 _ListViewContextItem* pContextItem = static_cast<_ListViewContextItem*>(GetContextItem());
1017 if ((pContextItem != null) && (__pContextItemEventListener != null))
1021 pContextItem->AddContextItemEventListener(*__pContextItemEventListener);
1025 pContextItem->RemoveContextItemEventListener(*__pContextItemEventListener);
1031 _ListViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1033 _TableViewItem::OnTouchPressed(source, touchinfo);
1035 if ((&source != this) && (source.GetParent() != this))
1040 ClearLastStateChangedInfo();
1041 StopTextSlideTimer();
1043 Point pos = touchinfo.GetCurrentPosition();
1044 __prevTouchPos.SetPosition(pos.x, pos.y);
1046 __selectedElementId = GetElementIdFromPosition(pos);
1048 _ListViewItemElement* pElement = GetElement(__selectedElementId);
1050 if (pElement != null)
1052 if ((pElement->actionElement) && (pElement->selectionEnabled))
1054 __selectionEabledBgColor = GetItemBackgroundColor(LIST_ITEM_STATE_PRESSED);
1055 SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, GetItemBackgroundColor(LIST_ITEM_STATE_NORMAL));
1057 __selectionEabled = true;
1060 if (pElement->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
1062 SetCutlinkTextFocus(pos);
1064 if (pElement->pTextElement->textSlidingEnabled)
1066 pElement->pTextElement->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT);
1067 pElement->pTextElement->pTextObject->Compose();
1069 if (pElement->pTextElement->pTextObject->IsActionOn())
1071 StartTextSlideTimer();
1077 __touchPressed = true;
1079 SetLastStateChangedInfo();
1086 _ListViewItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1088 _TableViewItem::OnTouchReleased(source, touchinfo);
1090 if ((&source != this) && (source.GetParent() != this))
1096 ResetCutlinkFocus();
1098 if (__selectionEabled)
1100 SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, __selectionEabledBgColor);
1101 __selectionEabled = false;
1104 __selectedElementId = -1;
1105 __touchPressed = false;
1113 _ListViewItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1115 _TableViewItem::OnTouchMoved(source, touchinfo);
1119 ClearLastStateChangedInfo();
1124 __selectedElementId = -1;
1125 __touchPressed = false;
1133 _ListViewItem::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1135 _TableViewItem::OnTouchCanceled(source, touchinfo);
1139 if (__selectionEabled)
1141 SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, __selectionEabledBgColor);
1142 __selectionEabled = false;
1151 _ListViewItem::OnDraw(void)
1153 _TableViewItem::OnDraw();
1160 _ListViewItem::OnBoundsChanged(void)
1162 _TableViewItem::OnBoundsChanged();
1164 _ListViewContextItem* pContextItem = static_cast<_ListViewContextItem*>(GetContextItem());
1166 if (pContextItem != null)
1168 Rectangle bounds = GetBounds();
1169 pContextItem->AdjustItemBounds(bounds);
1173 ListViewItemDrawingStatus
1174 _ListViewItem::GetItemDrawingStatus(void)
1176 TableViewItemDrawingStatus parentStatus = GetDrawingStatus();
1177 ListViewItemDrawingStatus status;
1179 switch (parentStatus)
1181 case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED:
1182 status = LISTVIEW_ITEM_STATUS_PRESSED;
1185 case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED:
1186 status = LISTVIEW_ITEM_STATUS_HIGHLIGHTED;
1190 status = LISTVIEW_ITEM_STATUS_NORMAL;
1198 _ListViewItem::DrawElement(_ListViewItemElement* pElement)
1200 // Get Current TableViewItem drawing status
1201 ListViewItemDrawingStatus status = GetItemDrawingStatus();
1202 Rectangle elementRect;
1204 // Check element selection enabled
1205 if (status != LISTVIEW_ITEM_STATUS_NORMAL)
1207 if (__selectedElementId == -1)
1209 if ((pElement->actionElement) && (pElement->selectionEnabled))
1211 status = LISTVIEW_ITEM_STATUS_NORMAL;
1214 else if (__selectedElementId == pElement->elementId)
1216 if ((pElement->actionElement) && (pElement->selectionEnabled))
1218 status = LISTVIEW_ITEM_STATUS_NORMAL;
1223 bool enabled = false;
1225 if (GetElementSelectionEnabled(__selectedElementId, enabled) && enabled)
1227 status = LISTVIEW_ITEM_STATUS_NORMAL;
1232 Canvas* pCanvas = null;
1234 switch (pElement->elementType)
1236 case LISTVIEW_ITEM_ELEMENT_TEXT:
1237 DrawText(pElement->bounds, status, pElement->pTextElement);
1240 case LISTVIEW_ITEM_ELEMENT_BITMAP:
1241 DrawBitmap(pElement->bounds, status, pElement->pBitmapElement);
1244 case LISTVIEW_ITEM_ELEMENT_OBJ:
1245 pCanvas = pElement->pCustomElement->pVE->GetCanvasN();
1247 if (pCanvas != null)
1249 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1251 elementRect.SetBounds(0, 0, pElement->bounds.width, pElement->bounds.height);
1253 pElement->pCustomElement->pCustom->DrawElement(pCanvas, elementRect, status);
1265 _ListViewItem::DrawElements(void)
1267 _LinkedList <_ListViewItemElement>::_Iterator iter;
1269 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1271 DrawElement(&(*iter));
1276 _ListViewItem::DrawText(Rectangle& rect, ListViewItemDrawingStatus status, _ListViewItemElementText* pText)
1278 SysTryReturn(NID_UI_CTRL, (pText != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Text element is null.");
1280 Rectangle bounds(rect.x, rect.y, rect.width, rect.height);
1282 if (pText->pVE->GetParent() == null)
1284 GetVisualElement()->AttachChild(*(pText->pVE));
1285 pText->pVE->SetShowState(true);
1288 if (pText->textSize > 0)
1290 pText->pTextObject->SetFont(GetFont(FONT_STYLE_PLAIN, pText->textSize), 0, pText->pTextObject->GetTextLength());
1293 // Calculate Text element bounds
1294 if (pText->pEnrichedText == null)
1296 Dimension textDimension = pText->pTextObject->GetTextExtent(0, pText->pTextObject->GetTextLength());
1297 TextObjectAlignment textAlign = pText->pTextObject->GetAlignment();
1299 if (__itemType == LISTVIEW_ITEM_TYPE_CUSTOM)
1301 if (textDimension.width < bounds.width)
1303 bounds.width = textDimension.width;
1305 if ((0x0007 & textAlign) == TEXT_OBJECT_ALIGNMENT_CENTER)
1307 bounds.x = rect.x + ((rect.width - bounds.width) / 2);
1309 else if ((0x0007 & textAlign) == TEXT_OBJECT_ALIGNMENT_RIGHT)
1311 bounds.x = rect.x + (rect.width - bounds.width);
1314 if (textDimension.height < bounds.height)
1316 bounds.height = textDimension.height;
1318 if ((0x0700 & textAlign) == TEXT_OBJECT_ALIGNMENT_MIDDLE)
1320 bounds.y = rect.y + ((rect.height - bounds.height) / 2);
1322 else if ((0x0700 & textAlign) == TEXT_OBJECT_ALIGNMENT_BOTTOM)
1324 bounds.y = rect.y + (rect.height - bounds.height);
1330 if ((bounds.width != textDimension.width) || (bounds.height != textDimension.height))
1332 int itemWidth = GetBounds().width;
1335 bounds.y = rect.y + ((rect.height - textDimension.height) / 2);
1336 bounds.width = ((itemWidth > bounds.x + textDimension.width) ? textDimension.width : (itemWidth - bounds.x));
1337 bounds.height = textDimension.height;
1344 pText->pVE->SetBounds(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height));
1346 // Check to EnrichedText contains Cutlink
1347 if ((pText->cutlinkViewModeEnabled == true) && (pText->cutlinkParseEnabled == true)
1348 && (pText->pTextObject->GetTotalCutLinkElementCount() <= 0))
1350 if (ParseCutlinkText(pText) == true)
1352 pText->pTextObject->SetCutLinkViewMode(true);
1355 else if (pText->pEnrichedText == null)
1357 if (IsItemEnabled() == true)
1359 pText->pTextObject->SetForegroundColor(pText->textColor[status], 0, pText->pTextObject->GetTextLength());
1363 Color disableTextColor;
1364 GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_DISABLED, disableTextColor);
1366 pText->pTextObject->SetForegroundColor(disableTextColor, 0, pText->pTextObject->GetTextLength());
1370 pText->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1371 pText->pTextObject->SetBounds(Rectangle(0, 0, bounds.width, bounds.height));
1373 Canvas* pCanvas = pText->pVE->GetCanvasN();
1374 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1376 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1379 pText->pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1387 _ListViewItem::DrawBitmap(Rectangle& rect, ListViewItemDrawingStatus status, _ListViewItemElementBitmap* pBitmap)
1389 SysTryReturn(NID_UI_CTRL, (pBitmap != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null.");
1391 Bitmap* pDrawBitmap = pBitmap->pBitmap[status];
1392 if ((pDrawBitmap == null) && (status != LISTVIEW_ITEM_STATUS_NORMAL))
1394 pDrawBitmap = pBitmap->pBitmap[LISTVIEW_ITEM_STATUS_NORMAL];
1397 SysTryReturn(NID_UI_CTRL, (pDrawBitmap != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null.");
1399 if (pBitmap->pVE->GetParent() == null)
1401 GetVisualElement()->AttachChild(*(pBitmap->pVE));
1402 pBitmap->pVE->SetShowState(true);
1405 pBitmap->pVE->SetBounds(FloatRectangle(rect.x, rect.y, rect.width, rect.height));
1407 Canvas* pCanvas = pBitmap->pVE->GetCanvasN();
1408 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1410 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1413 if (pDrawBitmap->IsNinePatchedBitmap())
1415 pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, rect.width, rect.height), *pDrawBitmap);
1419 pCanvas->DrawBitmap(Rectangle(0, 0, rect.width, rect.height), *pDrawBitmap);
1428 _ListViewItem::DrawDivider(void)
1430 if ((__itemType == LISTVIEW_ITEM_TYPE_GROUP) && (GetItemBackgroundBitmap(LIST_ITEM_STATE_NORMAL) == null))
1433 int lineLeftMargin = 0;
1434 int lineBottomMargin = 0;
1435 int lineTopMargin = 0;
1436 GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
1437 GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
1438 GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineBottomMargin);
1440 Rectangle bounds = GetBounds();
1441 _ListViewItemElementText* pElementText = GetElementText(LIST_ITEM_RESERVED_ID_3);
1442 if ((pElementText != null) && (pElementText->pVE != null))
1444 FloatRectangle textBounds = pElementText->pVE->GetBounds();
1445 lineTopMargin = (int)(textBounds.y + textBounds.height);
1449 lineTopMargin = bounds.height - lineBottomMargin;
1452 if (bounds.height <= lineTopMargin)
1457 if (__pDivider == null)
1459 __pDivider = _Label::CreateLabelN();
1460 SysTryReturnVoidResult(NID_UI_CTRL, __pDivider != null, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1462 AttachSystemChild(*__pDivider);
1465 Color underLineColor;
1466 GET_COLOR_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_NORMAL, underLineColor);
1468 __pDivider->SetBounds(Rectangle(lineLeftMargin, lineTopMargin, bounds.width - lineLeftMargin * 2, lineHeight));
1469 __pDivider->SetBackgroundColor(underLineColor);
1470 __pDivider->Invalidate();
1475 _ListViewItem::StartTextSlideTimer(void)
1477 result r = E_SUCCESS;
1479 if (__pTextSlideTimer == null)
1481 __pTextSlideTimer = new (std::nothrow) Timer();
1483 r = __pTextSlideTimer->Construct(*this);
1484 SysTryCatch(NID_UI, (r == E_SUCCESS), ,E_SYSTEM, ("[E_SYSTEM] Timer cannot construct."));
1488 __pTextSlideTimer->Cancel();
1491 r = __pTextSlideTimer->Start(TEXT_SLIDING_TIMER_DURATION);
1492 SysTryCatch(NID_UI, (r == E_SUCCESS), , E_SYSTEM, ("[E_SYSTEM] Timer Start failed."));
1497 StopTextSlideTimer();
1501 _ListViewItem::StopTextSlideTimer(void)
1503 delete __pTextSlideTimer;
1504 __pTextSlideTimer = null;
1508 _ListViewItem::IsTextSlideTimerRunning(void)
1510 return (__pTextSlideTimer != null);
1514 _ListViewItem::OnTextSlideTimerExpired(void)
1516 if (__selectedElementId != -1)
1518 _ListViewItemElement* pElement = GetElement(__selectedElementId);
1520 if ((pElement != null) && (pElement->pTextElement->pTextObject != null))
1522 TextObject* pTextObject = pElement->pTextElement->pTextObject;
1524 Canvas* pCanvas = (pElement->pTextElement->pVE)->GetCanvasN();
1525 SysTryReturnVoidResult(NID_UI_CTRL, (pCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1527 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1530 pTextObject->SetForegroundColor(pElement->pTextElement->textColor[LISTVIEW_ITEM_STATUS_PRESSED], 0, pTextObject->GetTextLength());
1531 pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT);
1532 pTextObject->Compose();
1533 pTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas));
1535 pCanvas->Show(pElement->bounds);
1536 StartTextSlideTimer();
1545 _ListViewItem::ResetTextSlide(void)
1547 if (IsTextSlideTimerRunning())
1549 StopTextSlideTimer();
1551 _ListViewItemElement* pElement = GetElement(__selectedElementId);
1553 if ((pElement != null) && (pElement->pTextElement->pTextObject != null))
1555 pElement->pTextElement->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1556 pElement->pTextElement->pTextObject->SetForegroundColor(pElement->pTextElement->textColor[LISTVIEW_ITEM_STATUS_NORMAL],
1557 0, pElement->pTextElement->pTextObject->GetTextLength());
1563 _ListViewItem::OnTimerExpired(Timer& timer)
1565 _TableViewItem::OnTimerExpired(timer);
1567 if (&timer == __pTextSlideTimer)
1569 OnTextSlideTimerExpired();
1574 _ListViewItem::ParseCutlinkText(_ListViewItemElementText* pElementText)
1576 if ((pElementText == null) || (pElementText->pEnrichedText == null))
1581 TextObject* pTextObject = pElementText->pTextObject;
1582 unsigned long cutlinkMaskType = pElementText->cutlinkMaskType;
1583 TextLinkInfo* pTextLinkInfo = null;
1584 TextLinkInfo* pNextLinkInfo = null;
1585 int currentOffset = 0;
1586 bool isChangingCutlink = false;
1587 wchar_t* pCutlinkString = null;
1590 int strLength = pTextObject->GetTextLength();
1591 wchar_t* pStr = new (std::nothrow) wchar_t[strLength + 1];
1592 SysTryReturn(NID_UI, (pStr != null), false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
1594 pTextObject->GetText(pStr, strLength);
1596 TextCutLinkParser* pParser = new (std::nothrow) TextCutLinkParser();
1597 SysTryCatch(NID_UI, (pParser != null), (ret = false), E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
1599 pParser->SetCutLinkMask(cutlinkMaskType);
1601 pTextLinkInfo = pParser->Parse(pStr, strLength, 0);
1602 SysTryCatch(NID_UI, (pTextLinkInfo != null), (ret = false), E_SYSTEM, ("[E_SYSTEM] TextLinkInfo is not valid."));
1604 // remove all text element in _EnrichedTextImpl
1605 pElementText->pEnrichedText->RemoveAllTextElements(true);
1607 while (pTextLinkInfo != null)
1609 isChangingCutlink = false;
1611 switch (pTextLinkInfo->linkType)
1614 if (cutlinkMaskType & LINK_TYPE_URL)
1616 isChangingCutlink = true;
1620 case LINK_TYPE_EMAIL:
1621 if (cutlinkMaskType & LINK_TYPE_EMAIL)
1623 isChangingCutlink = true;
1627 case LINK_TYPE_TEL_NUM:
1628 if (cutlinkMaskType & LINK_TYPE_TEL_NUM)
1630 isChangingCutlink = true;
1634 case LINK_TYPE_APPCONTROL:
1635 if (cutlinkMaskType & LINK_TYPE_APPCONTROL)
1637 isChangingCutlink = true;
1641 case LINK_TYPE_MIME:
1642 if (cutlinkMaskType & LINK_TYPE_MIME)
1644 isChangingCutlink = true;
1652 pCutlinkString = new (std::nothrow) wchar_t[pTextLinkInfo->length + 1];
1654 if (pCutlinkString == null)
1656 while (pTextLinkInfo != null)
1658 pNextLinkInfo = pTextLinkInfo->pNextLinkInfo;
1659 delete pTextLinkInfo;
1660 pTextLinkInfo = pNextLinkInfo;
1662 SysTryCatch(NID_UI, (pTextLinkInfo != null), (ret = false), E_SYSTEM, ("[E_SYSTEM] TextLinkInfo is not valid."));
1665 for (int i = 0; i < pTextLinkInfo->length; i++)
1667 pCutlinkString[i] = pStr[pTextLinkInfo->srcOffset + i];
1670 pCutlinkString[pTextLinkInfo->length] = null;
1672 if (currentOffset < pTextLinkInfo->srcOffset)
1674 TextSimple* pSimpleText = new (std::nothrow) TextSimple(pStr + currentOffset, pTextLinkInfo->srcOffset - currentOffset);
1675 pTextObject->AppendElement(*pSimpleText);
1678 if (isChangingCutlink == true)
1680 TextCutLink* pTextElement = new (std::nothrow) TextCutLink(false, pTextLinkInfo->linkType, pStr + pTextLinkInfo->srcOffset,
1681 pTextLinkInfo->length);
1682 pTextElement->SetEditModeEnable(true);
1683 pTextObject->AppendElement(*pTextElement);
1687 TextSimple* pSimpleText = new (std::nothrow) TextSimple(pCutlinkString, pTextLinkInfo->length);
1688 pTextObject->AppendElement(*pSimpleText);
1691 currentOffset = pTextLinkInfo->srcOffset + pTextLinkInfo->length;
1693 pNextLinkInfo = pTextLinkInfo->pNextLinkInfo;
1694 delete pTextLinkInfo;
1695 pTextLinkInfo = pNextLinkInfo;
1697 delete[] pCutlinkString;
1698 pCutlinkString = null;
1701 if (strLength != currentOffset)
1703 TextSimple* pSimpleText = new (std::nothrow) TextSimple(pStr + currentOffset, strLength - currentOffset);
1704 pTextObject->AppendElement(*pSimpleText);
1707 //pTextObject->SetRange(0, pTextObject->GetLength());
1708 //pTextObject->NotifyTextChanged(0, pTextObject->GetLength());
1709 pTextObject->Compose();
1725 _ListViewItem::IsCutlinkTextSelected(const Point& position, int* index, _ListViewItemUiLinkInfo** ppInfo) const
1727 int elementId = GetElementIdFromPosition(position);
1728 _ListViewItemElementText* pElement = GetElementText(elementId);
1730 if ((pElement != null) && (pElement->pTextObject) && (pElement->cutlinkViewModeEnabled))
1732 TextObject* pTextObject = pElement->pTextObject;
1733 Rectangle displayRect = pTextObject->GetBounds();
1734 int selectedIndex = pTextObject->GetCutLinkIndexFromPositionData(position.x - displayRect.x, position.y - displayRect.y);
1736 if (selectedIndex >= 0)
1738 *index = selectedIndex;
1739 TextCutLink* pCutLinkObject = dynamic_cast<TextCutLink*>(pTextObject->GetCutLinkElementAtCutLinkElementIndex(selectedIndex));
1740 if (pCutLinkObject == null)
1745 String cutLinkString(pCutLinkObject->GetText());
1746 LinkType baseLinkType = pCutLinkObject->GetCutLinkType();
1748 if (baseLinkType & pElement->cutlinkMaskType)
1750 _ListViewItemUiLinkInfo* pUiLinkInfo = new (std::nothrow) _ListViewItemUiLinkInfo();
1752 pUiLinkInfo->textInfo = cutLinkString;
1753 pUiLinkInfo->linkType = baseLinkType;
1754 pUiLinkInfo->linkInfo = cutLinkString;
1756 *ppInfo = pUiLinkInfo;
1767 _ListViewItem::SetCutlinkTextFocus(const Point& position)
1769 int elementId = GetElementIdFromPosition(position);
1770 _ListViewItemElementText* pElement = GetElementText(elementId);
1772 if ((pElement != null) && (pElement->pTextObject != null) && (pElement->cutlinkViewModeEnabled))
1774 TextObject* pTextObject = pElement->pTextObject;
1775 Rectangle displayRect = pTextObject->GetBounds();
1777 int index = pTextObject->GetCutLinkIndexFromPositionData(position.x - displayRect.x, position.y - displayRect.y);
1781 pTextObject->ChangeCutLinkState(index, true);
1790 _ListViewItem::ResetCutlinkFocus(void)
1792 _LinkedList <_ListViewItemElement>::_Iterator iter;
1794 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1796 if ((iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT) && (iter->pTextElement->pTextObject))
1798 iter->pTextElement->pTextObject->ResetAllCutLinkElementsState();
1806 _ListViewItem::GetFont(unsigned long fontStyle, int fontSize)
1808 __fontStyle = fontStyle;
1809 __fontSize = fontSize;
1811 return GetFallbackFont();
1815 _ListViewItem::OnFontChanged(Font* pFont)
1817 __fontName = _Control::GetFont();
1819 if (__pDescriptionText != null)
1821 __pDescriptionText->SetFont(__fontName);
1824 if (GetContextItem() != null)
1826 GetContextItem()->SetFont(__fontName);
1831 _ListViewItem::OnFontInfoRequested(unsigned long& style, int& size)
1833 style = __fontStyle;
1838 _ListViewItem::OnAncestorEnableStateChanged(const _Control& control)
1840 _LinkedList <_ListViewItemElement>::_Iterator iter;
1842 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1844 if (iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
1846 DrawText(iter->bounds, GetItemDrawingStatus(), iter->pTextElement);
1852 CompareAccessibilityElement(_ListViewItemElement* a, _ListViewItemElement* b)
1854 if (a->bounds.y == b->bounds.y)
1856 return (a->bounds.x < b->bounds.x);
1859 return (a->bounds.y < b->bounds.y);
1863 _ListViewItem::SetAccessibilityElement(void)
1865 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1869 pContainer->RemoveAllElement();
1871 _LinkedList <_ListViewItemElement*> accessibilityElementList;
1873 _LinkedList <_ListViewItemElement>::_Iterator iter;
1875 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1877 if (iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
1879 accessibilityElementList.push_back(&(*iter));
1883 accessibilityElementList.sort(CompareAccessibilityElement);
1885 _LinkedList <_ListViewItemElement*>::_Iterator accessibilityIter;
1886 _ListViewItemElement* pElement = null;
1888 for (accessibilityIter = accessibilityElementList.begin(); accessibilityIter != accessibilityElementList.end(); accessibilityIter++)
1890 pElement = *accessibilityIter;
1892 int textLength = pElement->pTextElement->pTextObject->GetTextLength();
1894 wchar_t* pAccessibilityText = new (std::nothrow) wchar_t[textLength + 1];
1895 SysTryReturnVoidResult(NID_UI_CTRL, (pAccessibilityText != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1897 pElement->pTextElement->pTextObject->GetText(pAccessibilityText, textLength);
1899 pElement->pTextElement->pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1900 SysTryReturnVoidResult(NID_UI_CTRL, (pElement->pTextElement->pAccessibilityElement != null), E_OUT_OF_MEMORY,
1901 "[E_OUT_OF_MEMORY] The memory is insufficient.");
1903 pElement->pTextElement->pAccessibilityElement->SetBounds(pElement->bounds);
1904 pElement->pTextElement->pAccessibilityElement->SetLabel(String(pAccessibilityText));
1905 pElement->pTextElement->pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_LIST);
1906 pElement->pTextElement->pAccessibilityElement->SetName(L"ListViewItemText");
1908 pContainer->AddElement(*(pElement->pTextElement->pAccessibilityElement));
1910 delete[] pAccessibilityText;
1913 accessibilityElementList.clear();
1915 if (__pDivider != null)
1917 _AccessibilityContainer* pDividerContainer = __pDivider->GetAccessibilityContainer();
1918 if (pDividerContainer != null)
1920 pDividerContainer->Activate(false);
1926 _ListViewItemHitTestVEDelegator::_ListViewItemHitTestVEDelegator(void)
1930 _ListViewItemHitTestVEDelegator::~_ListViewItemHitTestVEDelegator(void)
1935 _ListViewItemHitTestVEDelegator::HitTest(VisualElement& target, const FloatPoint& point)
1937 return HIT_TEST_NOWHERE;
1940 }}} // Tizen::Ui::Controls