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::SetProgressValue(int value)
790 if ((value < 0) || (value > 100))
792 if (__pProgress != null)
794 __pProgress->SetVisibleState(false);
800 if (__pProgress == null)
802 __pProgress = _Progress::CreateProgressN();
803 SysTryReturn(NID_UI_CTRL, (__pProgress != null), false, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
805 __pProgress->SetRange(0, 100);
807 AttachChild(*__pProgress);
809 AdjustProgressBounds();
812 __pProgress->SetValue(value);
813 __pProgress->SetVisibleState(true);
819 _ListViewItem::SetProgressMargins(float leftMargin, float rightMargin)
821 if ((leftMargin < 0.0f) || (rightMargin < 0.0f) || (GetBoundsF().width - leftMargin - rightMargin <= 0.0f))
826 __progressLeftMargin = leftMargin;
827 __progressRightMargin = rightMargin;
829 AdjustProgressBounds();
835 _ListViewItem::AdjustProgressBounds(void)
837 if (__pProgress != null)
839 FloatRectangle progressRect = GetBoundsF();
840 float progressHeight = 0.0f;
841 float bottomMargin = 0.0f;
843 // Calculate progress position
844 GET_SHAPE_CONFIG(SLIDER::BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, progressHeight);
845 GET_SHAPE_CONFIG(SLIDER::BAR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, bottomMargin);
847 progressHeight = progressHeight + (bottomMargin * 2.0f);
848 progressRect.x = __progressLeftMargin;
849 progressRect.y = progressRect.height - progressHeight;
850 progressRect.height = progressHeight;
851 progressRect.width = progressRect.width - __progressLeftMargin - __progressRightMargin;
853 progressRect.y -= ((__descriptionTextShowState) ? GetDescriptionTextHeight() : 0.0f);
855 __pProgress->SetBounds(progressRect);
860 _ListViewItem::SetDescriptionText(const String& text)
864 if (__pDescriptionText != null)
866 DetachChild(*__pDescriptionText);
868 delete __pDescriptionText;
869 __pDescriptionText = null;
876 if (__pDescriptionText == null)
878 __pDescriptionText = _Label::CreateLabelN();
879 result r = GetLastResult();
880 SysTryReturn(NID_UI_CTRL, (__pDescriptionText != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
882 __pDescriptionText->SetVisibleState(false);
883 __pDescriptionText->SetMargin(0.0f, 0.0f, 0.0f, 0.0f);
884 __pDescriptionText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
886 AttachChild(*__pDescriptionText);
889 FloatRectangle bounds = GetBoundsF();
890 FloatRectangle textBounds;
891 float textSize = 0.0f;
894 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textBounds.x);
895 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textBounds.y);
896 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textSize);
898 textBounds.width = bounds.width - (textBounds.x * 2.0f);
900 TextObject* pText = new (std::nothrow) TextObject();
901 SysTryReturn(NID_UI_CTRL, (pText != null), false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
905 TextSimple* pSimpleText = new (std::nothrow) TextSimple((const_cast<wchar_t*>(text.GetPointer())), text.GetLength());
906 SysTryCatch(NID_UI_CTRL, (pSimpleText != null), (ret = false), E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
908 pText->AppendElement(*pSimpleText);
909 pText->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
910 pText->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
911 pText->SetFont(GetFont(FONT_STYLE_PLAIN, textSize), 0, pText->GetTextLength());
912 pText->SetBounds(FloatRectangle(0.0f, 0.0f, textBounds.width, 1.0f));
915 textBounds.height = pText->GetTotalHeight();
917 __pDescriptionText->SetBounds(FloatRectangle(textBounds.x, bounds.height + textBounds.y, textBounds.width, textBounds.height));
918 __pDescriptionText->SetBackgroundColor(Color(0, 0, 0, 0));
919 __pDescriptionText->SetTextColor(__descriptionTextColor);
920 __pDescriptionText->SetTextConfig(textSize, LABEL_TEXT_STYLE_NORMAL);
921 __pDescriptionText->SetText(text);
931 _ListViewItem::SetDescriptionTextColor(const Color& color)
933 __descriptionTextColor = color;
937 _ListViewItem::GetDescriptionTextHeight(void)
939 if (__pDescriptionText != null)
942 GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, margin);
944 return ((margin * 2.0f) + __pDescriptionText->GetBoundsF().height);
951 _ListViewItem::SetDescriptionTextShowState(bool show)
953 if (__descriptionTextShowState != show)
955 __descriptionTextShowState = show;
957 if (__pDescriptionText != null)
959 __pDescriptionText->SetVisibleState(__descriptionTextShowState);
961 FloatDimension itemDimension = GetSizeF();
962 float descriptionTextHeight = GetDescriptionTextHeight();
964 itemDimension.height += ((__descriptionTextShowState) ? (descriptionTextHeight) : (-descriptionTextHeight));
966 // Set position & item height
967 SetItemCustomHeight((__descriptionTextShowState ? (itemDimension.height - descriptionTextHeight) : 0.0f));
968 SetItemHeight(itemDimension.height);
970 SetSize(itemDimension);
972 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
974 if ((__pAccessibilityElement != null) && (pContainer != null))
976 SetAccessibilityElement();
978 _AccessibilityManager::GetInstance()->RequestToDrawFocusUi();
985 _ListViewItem::SetContextItemEventListener(_IActionEventListener& listener)
987 __pContextItemEventListener = &listener;
991 _ListViewItem::SetContextItemActivationState(bool activate)
993 _ListViewContextItem* pContextItem = static_cast<_ListViewContextItem*>(GetContextItem());
995 if ((pContextItem != null) && (__pContextItemEventListener != null))
999 pContextItem->AddContextItemEventListener(*__pContextItemEventListener);
1003 pContextItem->RemoveContextItemEventListener(*__pContextItemEventListener);
1009 _ListViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1011 if ((&source != this) && (source.GetParent() != this))
1016 ClearLastStateChangedInfo();
1017 StopTextSlideTimer();
1019 FloatPoint pos = touchinfo.GetCurrentPosition();
1020 __prevTouchPos.SetPosition(pos.x, pos.y);
1022 __selectedElementId = GetElementIdFromPosition(pos);
1024 _ListViewItemElement* pElement = GetElement(__selectedElementId);
1026 if (pElement != null)
1028 if ((pElement->actionElement) && (pElement->selectionEnabled))
1030 __selectionEabledBgColor = GetItemBackgroundColor(LIST_ITEM_STATE_PRESSED);
1031 SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, GetItemBackgroundColor(LIST_ITEM_STATE_NORMAL));
1033 __selectionEabled = true;
1036 if (pElement->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
1038 SetCutlinkTextFocus(pos);
1040 if (pElement->pTextElement->textSlidingEnabled)
1042 pElement->pTextElement->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT);
1043 pElement->pTextElement->pTextObject->Compose();
1045 if (pElement->pTextElement->pTextObject->IsActionOn())
1047 StartTextSlideTimer();
1053 __touchPressed = true;
1055 SetLastStateChangedInfo();
1057 _TableViewItem::OnTouchPressed(source, touchinfo);
1063 _ListViewItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1065 if ((&source != this) && (source.GetParent() != this))
1071 ResetCutlinkFocus();
1073 if (__selectionEabled)
1075 SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, __selectionEabledBgColor);
1076 __selectionEabled = false;
1079 __selectedElementId = -1;
1080 __touchPressed = false;
1082 _TableViewItem::OnTouchReleased(source, touchinfo);
1088 _ListViewItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1092 ClearLastStateChangedInfo();
1097 __selectedElementId = -1;
1098 __touchPressed = false;
1100 _TableViewItem::OnTouchMoved(source, touchinfo);
1106 _ListViewItem::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1110 if (__selectionEabled)
1112 SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, __selectionEabledBgColor);
1113 __selectionEabled = false;
1116 _TableViewItem::OnTouchCanceled(source, touchinfo);
1122 _ListViewItem::OnDraw(void)
1124 _TableViewItem::OnDraw();
1131 _ListViewItem::OnBoundsChanging(const FloatRectangle& bounds)
1133 FloatDimension currentSize = GetSizeF();
1135 if (!_FloatCompare(currentSize.width, bounds.width) || !_FloatCompare(currentSize.height, bounds.height))
1137 __needAlignContextItem = true;
1144 _ListViewItem::OnBoundsChanged(void)
1146 _TableViewItem::OnBoundsChanged();
1148 if (__needAlignContextItem)
1150 _ListViewContextItem* pContextItem = static_cast<_ListViewContextItem*>(GetContextItem());
1152 if (pContextItem != null)
1154 FloatRectangle bounds = GetBoundsF();
1155 pContextItem->AdjustItemBounds(bounds);
1157 __needAlignContextItem = false;
1162 ListViewItemDrawingStatus
1163 _ListViewItem::GetItemDrawingStatus(void)
1165 TableViewItemDrawingStatus parentStatus = GetDrawingStatus();
1166 ListViewItemDrawingStatus status;
1168 switch (parentStatus)
1170 case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED:
1171 status = LISTVIEW_ITEM_STATUS_PRESSED;
1174 case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED:
1175 status = LISTVIEW_ITEM_STATUS_HIGHLIGHTED;
1179 status = LISTVIEW_ITEM_STATUS_NORMAL;
1187 _ListViewItem::DrawElement(_ListViewItemElement* pElement)
1189 // Get Current TableViewItem drawing status
1190 ListViewItemDrawingStatus status = GetItemDrawingStatus();
1191 FloatRectangle elementRect;
1193 // Check element selection enabled
1194 if (status != LISTVIEW_ITEM_STATUS_NORMAL)
1196 if (__selectedElementId == -1)
1198 if ((pElement->actionElement) && (pElement->selectionEnabled))
1200 status = LISTVIEW_ITEM_STATUS_NORMAL;
1203 else if (__selectedElementId != pElement->elementId)
1205 bool enabled = false;
1206 if (GetElementSelectionEnabled(__selectedElementId, enabled) && enabled)
1208 status = LISTVIEW_ITEM_STATUS_NORMAL;
1210 else if ((pElement->actionElement) && (pElement->selectionEnabled))
1212 status = LISTVIEW_ITEM_STATUS_NORMAL;
1217 Canvas* pCanvas = null;
1219 switch (pElement->elementType)
1221 case LISTVIEW_ITEM_ELEMENT_TEXT:
1222 DrawText(pElement->bounds, status, pElement->pTextElement);
1225 case LISTVIEW_ITEM_ELEMENT_BITMAP:
1226 DrawBitmap(pElement->bounds, status, pElement->pBitmapElement);
1229 case LISTVIEW_ITEM_ELEMENT_OBJ:
1230 pCanvas = pElement->pCustomElement->pVE->GetCanvasN();
1232 if (pCanvas != null)
1234 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1236 elementRect.SetBounds(0.0f, 0.0f, pElement->bounds.width, pElement->bounds.height);
1238 pElement->pCustomElement->pCustom->DrawElement(pCanvas, elementRect, status);
1250 _ListViewItem::DrawElements(void)
1252 _LinkedList <_ListViewItemElement>::_Iterator iter;
1254 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1256 DrawElement(&(*iter));
1261 _ListViewItem::DrawText(FloatRectangle& rect, ListViewItemDrawingStatus status, _ListViewItemElementText* pText)
1263 SysTryReturn(NID_UI_CTRL, (pText != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Text element is null.");
1265 FloatRectangle bounds(rect.x, rect.y, rect.width, rect.height);
1267 if (pText->pVE->GetParent() == null)
1269 GetVisualElement()->AttachChild(*(pText->pVE));
1270 pText->pVE->SetShowState(true);
1273 if (pText->textSize > 0)
1275 pText->pTextObject->SetFont(GetFont(FONT_STYLE_PLAIN, pText->textSize), 0, pText->pTextObject->GetTextLength());
1278 // Calculate Text element bounds
1279 if (pText->pEnrichedText == null)
1281 FloatDimension textDimension = pText->pTextObject->GetTextExtentF(0, pText->pTextObject->GetTextLength());
1282 TextObjectAlignment textAlign = pText->pTextObject->GetAlignment();
1284 if (__itemType == LISTVIEW_ITEM_TYPE_CUSTOM)
1286 if (textDimension.width < bounds.width)
1288 bounds.width = textDimension.width;
1290 if ((0x0007 & textAlign) == TEXT_OBJECT_ALIGNMENT_CENTER)
1292 bounds.x = rect.x + ((rect.width - bounds.width) / 2.0f);
1294 else if ((0x0007 & textAlign) == TEXT_OBJECT_ALIGNMENT_RIGHT)
1296 bounds.x = rect.x + (rect.width - bounds.width);
1299 if (textDimension.height < bounds.height)
1301 bounds.height = textDimension.height;
1303 if ((0x0700 & textAlign) == TEXT_OBJECT_ALIGNMENT_MIDDLE)
1305 bounds.y = rect.y + ((rect.height - bounds.height) / 2.0f);
1307 else if ((0x0700 & textAlign) == TEXT_OBJECT_ALIGNMENT_BOTTOM)
1309 bounds.y = rect.y + (rect.height - bounds.height);
1315 if ((!_FloatCompare(bounds.width, textDimension.width)) || (!_FloatCompare(bounds.height, textDimension.height)))
1317 float itemWidth = GetBoundsF().width;
1320 bounds.y = rect.y + ((rect.height - textDimension.height) / 2.0f);
1321 bounds.width = ((itemWidth > bounds.x + textDimension.width) ? textDimension.width : (itemWidth - bounds.x));
1322 bounds.height = textDimension.height;
1329 pText->pVE->SetBounds(bounds);
1331 // Check to EnrichedText contains Cutlink
1332 if ((pText->pEnrichedText != null) && (pText->cutlinkViewModeEnabled) && (pText->cutlinkParseEnabled)
1333 && (pText->pTextObject->GetTotalCutLinkElementCount() <= 0))
1335 if (ParseCutlinkText(pText))
1337 pText->pTextObject->SetCutLinkViewMode(true);
1342 if (IsItemEnabled())
1344 pText->pTextObject->SetForegroundColor(pText->textColor[status], 0, pText->pTextObject->GetTextLength());
1348 Color disableTextColor;
1349 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_DISABLED, disableTextColor);
1351 pText->pTextObject->SetForegroundColor(disableTextColor, 0, pText->pTextObject->GetTextLength());
1355 pText->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1356 pText->pTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
1358 Canvas* pCanvas = pText->pVE->GetCanvasN();
1359 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1361 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1364 pText->pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1372 _ListViewItem::DrawBitmap(FloatRectangle& rect, ListViewItemDrawingStatus status, _ListViewItemElementBitmap* pBitmap)
1374 SysTryReturn(NID_UI_CTRL, (pBitmap != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null.");
1376 Bitmap* pDrawBitmap = pBitmap->pBitmap[status];
1377 if ((pDrawBitmap == null) && (status != LISTVIEW_ITEM_STATUS_NORMAL))
1379 pDrawBitmap = pBitmap->pBitmap[LISTVIEW_ITEM_STATUS_NORMAL];
1382 SysTryReturn(NID_UI_CTRL, (pDrawBitmap != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null.");
1384 if (pBitmap->pVE->GetParent() == null)
1386 GetVisualElement()->AttachChild(*(pBitmap->pVE));
1387 pBitmap->pVE->SetShowState(true);
1390 pBitmap->pVE->SetBounds(rect);
1392 Canvas* pCanvas = pBitmap->pVE->GetCanvasN();
1393 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1395 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1398 if (pDrawBitmap->IsNinePatchedBitmap())
1400 pCanvas->DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, rect.width, rect.height), *pDrawBitmap);
1404 pCanvas->DrawBitmap(FloatRectangle(0.0f, 0.0f, rect.width, rect.height), *pDrawBitmap);
1413 _ListViewItem::DrawDivider(void)
1415 if ((__itemType == LISTVIEW_ITEM_TYPE_GROUP) && (GetItemBackgroundBitmap(LIST_ITEM_STATE_NORMAL) == null))
1417 float lineHeight = 0.0f;
1418 float lineLeftMargin = 0.0f;
1419 float lineBottomMargin = 0.0f;
1420 float lineTopMargin = 0.0f;
1421 GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
1422 GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
1423 GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineBottomMargin);
1425 FloatRectangle textBounds;
1426 FloatRectangle bitmapBounds;
1427 _ListViewItemElementText* pElementText = GetElementText(LIST_ITEM_RESERVED_ID_3);
1428 _ListViewItemElementBitmap* pElementBitmap = GetElementBitmap(LIST_ITEM_RESERVED_ID_2);
1430 if ((pElementText != null) && (pElementText->pVE != null))
1432 textBounds = pElementText->pVE->GetBounds();
1435 if ((pElementBitmap != null) && (pElementBitmap->pVE != null))
1437 bitmapBounds = pElementBitmap->pVE->GetBounds();
1440 float textBottomPos = textBounds.y + textBounds.height;
1441 float bitmapBottomPos = bitmapBounds.y + bitmapBounds.height;
1443 lineTopMargin = (textBottomPos > bitmapBottomPos) ? textBottomPos : bitmapBottomPos;
1445 FloatRectangle bounds = GetBoundsF();
1446 float defaultMargin = bounds.height - lineBottomMargin;
1447 lineTopMargin = (lineTopMargin > defaultMargin) ? lineTopMargin : defaultMargin;
1449 if (bounds.height <= lineTopMargin)
1454 if (__pDivider == null)
1456 __pDivider = _Label::CreateLabelN();
1457 SysTryReturnVoidResult(NID_UI_CTRL, __pDivider != null, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1459 AttachSystemChild(*__pDivider);
1461 _AccessibilityContainer* pContainer = __pDivider->GetAccessibilityContainer();
1462 if (pContainer != null)
1464 pContainer->Activate(false);
1468 Color underLineColor;
1469 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_NORMAL, underLineColor);
1471 __pDivider->SetBounds(FloatRectangle(lineLeftMargin, lineTopMargin, bounds.width - lineLeftMargin * 2.0f, lineHeight));
1472 __pDivider->SetBackgroundColor(underLineColor);
1473 __pDivider->Invalidate();
1478 _ListViewItem::StartTextSlideTimer(void)
1480 result r = E_SUCCESS;
1482 if (__pTextSlideTimer == null)
1484 __pTextSlideTimer = new (std::nothrow) Timer();
1486 r = __pTextSlideTimer->Construct(*this);
1487 SysTryCatch(NID_UI, (r == E_SUCCESS), ,E_SYSTEM, ("[E_SYSTEM] Timer cannot construct."));
1491 __pTextSlideTimer->Cancel();
1494 r = __pTextSlideTimer->Start(TEXT_SLIDING_TIMER_DURATION);
1495 SysTryCatch(NID_UI, (r == E_SUCCESS), , E_SYSTEM, ("[E_SYSTEM] Timer Start failed."));
1500 StopTextSlideTimer();
1504 _ListViewItem::StopTextSlideTimer(void)
1506 delete __pTextSlideTimer;
1507 __pTextSlideTimer = null;
1511 _ListViewItem::IsTextSlideTimerRunning(void)
1513 return (__pTextSlideTimer != null);
1517 _ListViewItem::OnTextSlideTimerExpired(void)
1519 if (__selectedElementId != -1)
1521 _ListViewItemElement* pElement = GetElement(__selectedElementId);
1523 if ((pElement != null) && (pElement->pTextElement->pTextObject != null))
1525 TextObject* pTextObject = pElement->pTextElement->pTextObject;
1527 Canvas* pCanvas = (pElement->pTextElement->pVE)->GetCanvasN();
1528 SysTryReturnVoidResult(NID_UI_CTRL, (pCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1530 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1533 pTextObject->SetForegroundColor(pElement->pTextElement->textColor[LISTVIEW_ITEM_STATUS_PRESSED], 0, pTextObject->GetTextLength());
1534 pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT);
1535 pTextObject->Compose();
1536 pTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas));
1538 pCanvas->Show(_CoordinateSystemUtils::ConvertToInteger(pElement->bounds));
1539 StartTextSlideTimer();
1548 _ListViewItem::ResetTextSlide(void)
1550 if (IsTextSlideTimerRunning())
1552 StopTextSlideTimer();
1554 _ListViewItemElement* pElement = GetElement(__selectedElementId);
1556 if ((pElement != null) && (pElement->pTextElement->pTextObject != null))
1558 pElement->pTextElement->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1559 pElement->pTextElement->pTextObject->SetForegroundColor(pElement->pTextElement->textColor[LISTVIEW_ITEM_STATUS_NORMAL],
1560 0, pElement->pTextElement->pTextObject->GetTextLength());
1566 _ListViewItem::OnTimerExpired(Timer& timer)
1568 _TableViewItem::OnTimerExpired(timer);
1570 if (&timer == __pTextSlideTimer)
1572 OnTextSlideTimerExpired();
1577 _ListViewItem::ParseCutlinkText(_ListViewItemElementText* pElementText)
1579 if ((pElementText == null) || (pElementText->pEnrichedText == null))
1584 TextObject* pTextObject = pElementText->pTextObject;
1585 unsigned long cutlinkMaskType = pElementText->cutlinkMaskType;
1586 TextLinkInfo* pTextLinkInfo = null;
1587 TextLinkInfo* pNextLinkInfo = null;
1588 int currentOffset = 0;
1589 bool isChangingCutlink = false;
1590 wchar_t* pCutlinkString = null;
1593 int strLength = pTextObject->GetTextLength();
1594 wchar_t* pStr = new (std::nothrow) wchar_t[strLength + 1];
1595 SysTryReturn(NID_UI, (pStr != null), false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
1597 pTextObject->GetText(pStr, strLength);
1599 TextCutLinkParser* pParser = new (std::nothrow) TextCutLinkParser();
1600 SysTryCatch(NID_UI, (pParser != null), (ret = false), E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
1602 pParser->SetCutLinkMask(cutlinkMaskType);
1604 pTextLinkInfo = pParser->Parse(pStr, strLength, 0);
1605 SysTryCatch(NID_UI, (pTextLinkInfo != null), (ret = false), E_SYSTEM, ("[E_SYSTEM] TextLinkInfo is not valid."));
1607 // remove all text element in _EnrichedTextImpl
1608 pElementText->pEnrichedText->RemoveAllTextElements(true);
1610 while (pTextLinkInfo != null)
1612 isChangingCutlink = false;
1614 switch (pTextLinkInfo->linkType)
1617 if (cutlinkMaskType & LINK_TYPE_URL)
1619 isChangingCutlink = true;
1623 case LINK_TYPE_EMAIL:
1624 if (cutlinkMaskType & LINK_TYPE_EMAIL)
1626 isChangingCutlink = true;
1630 case LINK_TYPE_TEL_NUM:
1631 if (cutlinkMaskType & LINK_TYPE_TEL_NUM)
1633 isChangingCutlink = true;
1637 case LINK_TYPE_APPCONTROL:
1638 if (cutlinkMaskType & LINK_TYPE_APPCONTROL)
1640 isChangingCutlink = true;
1644 case LINK_TYPE_MIME:
1645 if (cutlinkMaskType & LINK_TYPE_MIME)
1647 isChangingCutlink = true;
1655 pCutlinkString = new (std::nothrow) wchar_t[pTextLinkInfo->length + 1];
1657 if (pCutlinkString == null)
1659 while (pTextLinkInfo != null)
1661 pNextLinkInfo = pTextLinkInfo->pNextLinkInfo;
1662 delete pTextLinkInfo;
1663 pTextLinkInfo = pNextLinkInfo;
1665 SysTryCatch(NID_UI, (pTextLinkInfo != null), (ret = false), E_SYSTEM, ("[E_SYSTEM] TextLinkInfo is not valid."));
1668 for (int i = 0; i < pTextLinkInfo->length; i++)
1670 pCutlinkString[i] = pStr[pTextLinkInfo->srcOffset + i];
1673 pCutlinkString[pTextLinkInfo->length] = null;
1675 if (currentOffset < pTextLinkInfo->srcOffset)
1677 TextSimple* pSimpleText = new (std::nothrow) TextSimple(pStr + currentOffset, pTextLinkInfo->srcOffset - currentOffset);
1678 pTextObject->AppendElement(*pSimpleText);
1681 if (isChangingCutlink == true)
1683 TextCutLink* pTextElement = new (std::nothrow) TextCutLink(false, pTextLinkInfo->linkType, pStr + pTextLinkInfo->srcOffset,
1684 pTextLinkInfo->length);
1685 pTextElement->SetEditModeEnable(true);
1686 pTextObject->AppendElement(*pTextElement);
1690 TextSimple* pSimpleText = new (std::nothrow) TextSimple(pCutlinkString, pTextLinkInfo->length);
1691 pTextObject->AppendElement(*pSimpleText);
1694 currentOffset = pTextLinkInfo->srcOffset + pTextLinkInfo->length;
1696 pNextLinkInfo = pTextLinkInfo->pNextLinkInfo;
1697 delete pTextLinkInfo;
1698 pTextLinkInfo = pNextLinkInfo;
1700 delete[] pCutlinkString;
1701 pCutlinkString = null;
1704 if (strLength != currentOffset)
1706 TextSimple* pSimpleText = new (std::nothrow) TextSimple(pStr + currentOffset, strLength - currentOffset);
1707 pTextObject->AppendElement(*pSimpleText);
1710 //pTextObject->SetRange(0, pTextObject->GetLength());
1711 //pTextObject->NotifyTextChanged(0, pTextObject->GetLength());
1712 pTextObject->Compose();
1728 _ListViewItem::IsCutlinkTextSelected(const FloatPoint& position, int* index, _ListViewItemUiLinkInfo** ppInfo) const
1730 int elementId = GetElementIdFromPosition(position);
1731 _ListViewItemElementText* pElement = GetElementText(elementId);
1733 if ((pElement != null) && (pElement->pTextObject) && (pElement->cutlinkViewModeEnabled))
1735 TextObject* pTextObject = pElement->pTextObject;
1736 FloatRectangle displayRect = pTextObject->GetBoundsF();
1737 int selectedIndex = pTextObject->GetCutLinkIndexFromPositionData(position.x - displayRect.x, position.y - displayRect.y);
1739 if (selectedIndex >= 0)
1741 *index = selectedIndex;
1742 TextCutLink* pCutLinkObject = dynamic_cast<TextCutLink*>(pTextObject->GetCutLinkElementAtCutLinkElementIndex(selectedIndex));
1743 if (pCutLinkObject == null)
1748 String cutLinkString(pCutLinkObject->GetText());
1749 LinkType baseLinkType = pCutLinkObject->GetCutLinkType();
1751 if (baseLinkType & pElement->cutlinkMaskType)
1753 _ListViewItemUiLinkInfo* pUiLinkInfo = new (std::nothrow) _ListViewItemUiLinkInfo();
1755 pUiLinkInfo->textInfo = cutLinkString;
1756 pUiLinkInfo->linkType = baseLinkType;
1757 pUiLinkInfo->linkInfo = cutLinkString;
1759 *ppInfo = pUiLinkInfo;
1770 _ListViewItem::SetCutlinkTextFocus(const FloatPoint& position)
1772 int elementId = GetElementIdFromPosition(position);
1773 _ListViewItemElementText* pElement = GetElementText(elementId);
1775 if ((pElement != null) && (pElement->pTextObject != null) && (pElement->cutlinkViewModeEnabled))
1777 TextObject* pTextObject = pElement->pTextObject;
1778 FloatRectangle displayRect = pTextObject->GetBoundsF();
1780 int index = pTextObject->GetCutLinkIndexFromPositionData(position.x - displayRect.x, position.y - displayRect.y);
1784 pTextObject->ChangeCutLinkState(index, true);
1793 _ListViewItem::ResetCutlinkFocus(void)
1795 _LinkedList <_ListViewItemElement>::_Iterator iter;
1797 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1799 if ((iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT) && (iter->pTextElement->pTextObject))
1801 iter->pTextElement->pTextObject->ResetAllCutLinkElementsState();
1809 _ListViewItem::GetFont(unsigned long fontStyle, float fontSize)
1811 __fontStyle = fontStyle;
1812 __fontSize = fontSize;
1814 return GetFallbackFont();
1818 _ListViewItem::OnFontChanged(Font* pFont)
1820 __fontName = _Control::GetFont();
1822 if (__pDescriptionText != null)
1824 __pDescriptionText->SetFont(__fontName);
1827 if (GetContextItem() != null)
1829 GetContextItem()->SetFont(__fontName);
1834 _ListViewItem::OnFontInfoRequested(unsigned long& style, int& size)
1836 style = __fontStyle;
1837 size = _CoordinateSystemUtils::ConvertToInteger(__fontSize);
1841 _ListViewItem::OnFontInfoRequested(unsigned long& style, float& size)
1843 style = __fontStyle;
1847 _ListViewItem::OnAncestorEnableStateChanged(const _Control& control)
1849 _LinkedList <_ListViewItemElement>::_Iterator iter;
1851 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1853 if (iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
1855 DrawText(iter->bounds, GetItemDrawingStatus(), iter->pTextElement);
1861 CompareAccessibilityElement(_ListViewItemElement* a, _ListViewItemElement* b)
1863 if (_FloatCompare(a->bounds.y, b->bounds.y))
1865 return (a->bounds.x < b->bounds.x);
1868 return (a->bounds.y < b->bounds.y);
1872 _ListViewItem::SetAccessibilityElement(void)
1874 if (!_AccessibilityManager::IsActivated())
1879 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1881 if (pContainer != null)
1883 if (__pAccessibilityElement == null)
1885 _LinkedList <_ListViewItemElement*> accessibilityElementList;
1886 _LinkedList <_ListViewItemElement>::_Iterator iter;
1888 for (iter = __elements.begin(); iter != __elements.end(); iter++)
1890 if (iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT)
1892 accessibilityElementList.push_back(&(*iter));
1896 accessibilityElementList.sort(CompareAccessibilityElement);
1898 _LinkedList <_ListViewItemElement*>::_Iterator accessibilityIter;
1899 _ListViewItemElement* pElement = null;
1900 String accessibilityLable;
1902 for (accessibilityIter = accessibilityElementList.begin(); accessibilityIter != accessibilityElementList.end(); accessibilityIter++)
1904 pElement = *accessibilityIter;
1906 int textLength = pElement->pTextElement->pTextObject->GetTextLength();
1910 wchar_t* pAccessibilityText = new (std::nothrow) wchar_t[textLength + 1];
1911 SysTryReturnVoidResult(NID_UI_CTRL, (pAccessibilityText != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1913 pElement->pTextElement->pTextObject->GetText(pAccessibilityText, textLength);
1915 accessibilityLable += String(pAccessibilityText);
1917 delete[] pAccessibilityText;
1921 accessibilityElementList.clear();
1923 __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1924 SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityElement != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1926 __pAccessibilityElement->SetBounds(Rectangle(0, 0, _CoordinateSystemUtils::ConvertToInteger(GetBoundsF().width), _CoordinateSystemUtils::ConvertToInteger(GetBoundsF().height)));
1927 __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
1928 __pAccessibilityElement->SetName(L"ListViewItem");
1930 if (accessibilityLable.IsEmpty())
1932 accessibilityLable = L"ListViewItem";
1935 __pAccessibilityElement->SetLabel(accessibilityLable);
1937 pContainer->AddElement(*__pAccessibilityElement);
1941 __pAccessibilityElement->SetBounds(Rectangle(0, 0, _CoordinateSystemUtils::ConvertToInteger(GetBoundsF().width), _CoordinateSystemUtils::ConvertToInteger(GetBoundsF().height)));
1947 _ListViewItem::SetAccessibilityElementLabel(void)
1952 _ListViewItemHitTestVEDelegator::_ListViewItemHitTestVEDelegator(void)
1956 _ListViewItemHitTestVEDelegator::~_ListViewItemHitTestVEDelegator(void)
1961 _ListViewItemHitTestVEDelegator::HitTest(VisualElement& target, const FloatPoint& point)
1963 return HIT_TEST_NOWHERE;
1966 }}} // Tizen::Ui::Controls