2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FUiCtrl_ContextMenuListPresenter.cpp
19 * @brief This is the implementation file for the _ContextMenuListPresenter class.
22 #include <FBaseErrorDefine.h>
23 #include <FBaseSysLog.h>
24 #include <FGrp_BitmapImpl.h>
25 #include <FGrp_CanvasImpl.h>
26 #include <FGrp_TextTextSimple.h>
27 #include "FUi_AccessibilityContainer.h"
28 #include "FUi_AccessibilityElement.h"
29 #include "FUi_CoordinateSystemUtils.h"
31 #include "FUi_ResourceManager.h"
32 #include "FUiCtrl_ActionEvent.h"
33 #include "FUiCtrl_IActionEventListener.h"
35 #include "FUiCtrl_ContextMenuListPresenter.h"
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Ui;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Runtime;
41 using namespace Tizen::Graphics::_Text;
44 static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;
45 static const int CONTEXT_MENU_LIST_ELEMENT_TEXT = 0;
46 static const int CONTEXT_MENU_LIST_ELEMENT_BITMAP = 1;
49 namespace Tizen { namespace Ui { namespace Controls
52 _ContextMenuListPresenter::_ContextMenuListPresenter(_ContextMenu* pContextMenu)
53 : __pContextMenu(pContextMenu)
56 , __layoutSize(FloatDimension(0.0f, 0.0f))
57 , __touchOutRect(false)
59 , __scrollEnable(false)
63 , __bottomMargin(0.0f)
66 , __screenTopMargin(0.0f)
67 , __screenBottomMargin(0.0f)
68 , __screenLeftMargin(0.0f)
69 , __screenRightMargin(0.0f)
70 , __arrowTopMargin(0.0f)
71 , __arrowBottomMargin(0.0f)
72 , __arrowRightMargin(0.0f)
73 , __arrowLeftMargin(0.0f)
77 , __itemMinWidth(0.0f)
79 , __itemMaxWidth(0.0f)
81 , __itemBitmapWidth(0.0f)
82 , __itemBitmapHeight(0.0f)
83 , __itemFontSize(0.0f)
84 , __dividerHeight(0.0f)
85 , __anchorPopupOverlap(0.0f)
86 , __enterKeyPressed(false)
87 , __backKeyPressed(false)
93 _ContextMenuListPresenter::~_ContextMenuListPresenter(void)
95 __pContextMenu = null;
105 _ContextMenuListPresenter::Install(void)
107 result r = E_SUCCESS;
111 __pModel = new (std::nothrow) _ContextMenuModel;
112 SysTryReturnResult(NID_UI_CTRL, __pModel != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
114 r = __pModel->Construct();
115 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = GetLastResult(), GetLastResult(), "[%s] Memory allocation failed.", GetErrorMessage(GetLastResult()));
117 __pFont = __pContextMenu->GetFallbackFont();
119 SysTryCatch(NID_UI_CTRL, (__pFont != null), , r, "[%s] Propagating.", GetErrorMessage(r));
134 _ContextMenuListPresenter::LoadShape(void)
136 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MIN_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMinWidth);
137 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MAX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMaxWidth);
138 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemHeight);
139 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_GAP, _CONTROL_ORIENTATION_PORTRAIT, __itemGap);
141 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __topMargin);
142 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __bottomMargin);
143 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __leftMargin);
144 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __rightMargin);
146 GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenTopMargin);
147 GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenBottomMargin);
148 GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenLeftMargin);
149 GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenRightMargin);
150 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowTopMargin);
151 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowBottomMargin);
152 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowLeftMargin);
153 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowRightMargin);
154 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __arrowWidth);
155 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __arrowHeight);
156 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ICON_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapWidth);
157 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ICON_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapHeight);
159 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __itemFontSize);
160 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __dividerHeight);
161 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_POPUP_OVERLAP, _CONTROL_ORIENTATION_PORTRAIT, __anchorPopupOverlap);
163 __itemWidth = __itemMinWidth;
167 _ContextMenuListPresenter::CreateItemN(const Base::String& text, int actionId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
169 _ContextMenuItem* pItem = _ContextMenuItem::CreateContextMenuItemN();
170 SysTryReturn(NID_UI_CTRL, pItem != null, null, GetLastResult(), "[%s] pItem must not be null.", GetErrorMessage(GetLastResult()));
172 ContextMenuItemDrawingType itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_TEXT;
173 _Label* pLabel = null;
174 result r = E_SUCCESS;
176 if (pNormalBitmap != null)
178 r = pItem->SetBitmap(CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL, pNormalBitmap);
186 pLabel = _Label::CreateLabelN();
187 pLabel->SetBackgroundBitmap(*pNormalBitmap);
188 pLabel->SetBackgroundColor(Color(0, 0, 0, 0));
190 int bitmapY = (__itemHeight - __itemBitmapHeight) / 2;
191 pLabel->SetBounds(FloatRectangle(__leftMargin, bitmapY, __itemBitmapWidth, __itemBitmapHeight));
192 pLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
193 pItem->AttachChild(*pLabel);
194 _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer();
197 pContainer->Activate(false);
199 pItem->SetBitmapLabel(pLabel);
201 itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP;
204 if (pPressedBitmap != null)
206 r = pItem->SetBitmap(CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED, pPressedBitmap);
214 pItem->SetType(itemType);
215 pItem->SetActionId(actionId);
217 pItem->SetTextSize(__itemFontSize);
218 r = pItem->SetText(text);
225 FloatDimension textArea(0.0f, 0.0f);
226 FloatDimension itemSize(0.0f, 0.0f);
228 CalculateItemSize(text, itemType, textArea, itemSize);
230 pItem->SetSize(itemSize);
232 float textLabelX = 0.0f;
233 if (itemType == CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP)
235 textLabelX = __itemGap + __itemBitmapWidth;
239 pLabel = _Label::CreateLabelN();
240 pLabel->SetText(text);
241 ContextMenuCoreItemStatus itemStatus = CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL;
242 pLabel->SetTextColor(__pContextMenu->GetTextColor(itemStatus));
243 pLabel->SetBackgroundColor(Color(0, 0, 0, 0));
245 itemSize = pItem->GetSize();
246 pLabel->SetBounds(FloatRectangle(textLabelX, (itemSize.height - textArea.height) / 2.0f, textArea.width, textArea.height));
247 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
248 pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
249 pLabel->SetTextConfig(__itemFontSize, LABEL_TEXT_STYLE_NORMAL);
251 pLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
252 pItem->AttachChild(*pLabel);
253 _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer();
256 pContainer->Activate(false);
258 pItem->SetTextLabel(pLabel);
260 __itemWidth = __itemWidth < itemSize.width ? itemSize.width : __itemWidth;
262 pItem->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
267 _ContextMenuListPresenter::CalculateItemSize(const String &text, ContextMenuItemDrawingType itemType, FloatDimension &textArea, FloatDimension &itemSize)
269 float bitmapWidth = (itemType == CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP) ? __itemBitmapWidth : 0.0f;
271 __pFont->GetTextExtent(text, text.GetLength(), textArea);
272 float labelTopMargin = 0.0f;
273 float iconGap = 0.0f;
274 float textGap = 0.0f;
275 GET_SHAPE_CONFIG(LABEL::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, labelTopMargin);
276 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_TEXT_GAP, _CONTROL_ORIENTATION_PORTRAIT, textGap);
279 if (itemType == CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP)
281 textArea.width += 2.0 * iconGap;
282 itemSize.width = textArea.width + bitmapWidth + textGap;
286 textArea.width += 2.0f * textGap;
287 itemSize.width = textArea.width;
290 textArea.height += 2.0f * labelTopMargin;
291 itemSize.height = __itemHeight + (__dividerHeight * 2.0f);
293 itemSize.width = itemSize.width < __itemMinWidth ? __itemMinWidth : itemSize.width;
295 if (itemSize.width > __itemMaxWidth)
297 textArea.width -= itemSize.width - __itemMaxWidth;
298 itemSize.width = __itemMaxWidth;
305 _ContextMenuListPresenter::AddItem(const Base::String& text, int actionId, const Bitmap* pNormalBitmap,
306 const Bitmap* pPressedBitmap,
307 const Bitmap* pHighlightedBitmap)
309 _ContextMenuItem* pItem = CreateItemN(text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
310 SysTryReturnResult(NID_UI_CTRL, pItem != null, GetLastResult(), "Failed to create item.");
312 result r = __pModel->AddItem(pItem);
317 SysTryReturnResult(NID_UI_CTRL, false, r, "Failed to add item.");
324 _ContextMenuListPresenter::InsertItem(int index, const String& text, int actionId,
325 const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap,
326 const Bitmap* pHighlightedBitmap)
329 SysTryReturnResult(NID_UI_CTRL, (text.GetLength() != 0 || pNormalBitmap != null || pPressedBitmap != null), E_INVALID_ARG,
330 "Invalid argument(s) is used. If text is empty then pNormalBitmap or pPressedBitmap must not be null.");
332 _ContextMenuItem* pItem = null;
334 pItem = CreateItemN(text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
335 SysTryReturnResult(NID_UI_CTRL, pItem != null, GetLastResult(), "Failed to create item.");
337 result r = __pModel->InsertItem(pItem, index);
341 SysTryReturnResult(NID_UI_CTRL, false, r, "Failed to add item.");
348 _ContextMenuListPresenter::SetItem(int index, const String& text, int actionId,
349 const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap,
350 const Bitmap* pHighlightedBitmap)
352 _ContextMenuItem* pItem = null;
353 result r = E_SUCCESS;
355 SysTryReturnResult(NID_UI_CTRL, (text.GetLength() != 0 || pNormalBitmap != null || pPressedBitmap != null), E_INVALID_ARG,
356 "Invalid argument(s) is used. If text is empty then pNormalBitmap or pPressedBitmap must not be null.");
358 pItem = __pModel->GetItem(index);
360 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "Failed to get the item.");
362 if (pItem->HasParent())
364 r = __pContextMenu->GetScrollPanel()->DetachChild(*pItem);
365 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to detach item.");
368 pItem = CreateItemN(text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
369 SysTryReturnResult(NID_UI_CTRL, pItem != null, GetLastResult(), "Failed to create item.");
371 r = __pModel->SetItem(pItem, index);
375 SysTryReturnResult(NID_UI_CTRL, false, r, "Failed to add item.");
378 CalculateItemMaximumWidth();
384 _ContextMenuListPresenter::DeleteItem(int index)
386 _ContextMenuItem* pItem = null;
387 result r = E_SUCCESS;
389 SysTryReturnResult(NID_UI_CTRL, __pContextMenu->GetItemCount() > 0, E_INVALID_STATE, "__pContextMenu is in invalid state. Item count is less than or equal to zero.");
391 pItem = __pModel->GetItem(index);
393 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "Failed to get the item.");
395 if (pItem->HasParent())
397 r = __pContextMenu->GetScrollPanel()->DetachChild(*pItem);
398 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to detach item.");
401 r = __pModel->RemoveItem(index);
402 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to delete item.");
404 CalculateItemMaximumWidth();
410 _ContextMenuListPresenter::DeleteItemAll(void)
412 SysTryReturnResult(NID_UI_CTRL, __pContextMenu->GetItemCount() > 0, E_INVALID_STATE, "__pContextMenu is in invalid state. Item count is less than or equal to zero.");
414 __pContextMenu->GetScrollPanel()->DetachAllChildren();
416 result r = __pModel->RemoveAllItem();
417 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to delete item all.");
424 _ContextMenuListPresenter::CalculateShowItemCount(void)
426 int itemMaxCount = 0;
427 GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, _CONTROL_ORIENTATION_PORTRAIT, itemMaxCount);
429 int maxVisibleCount = __pContextMenu->GetShowItemCount();
431 return maxVisibleCount > itemMaxCount ? itemMaxCount : maxVisibleCount;
435 _ContextMenuListPresenter::CalculateWindowRect(void)
437 result r = CalculateRect();
438 AdjustItemPosition();
444 _ContextMenuListPresenter::ApplyColorProperty(void)
447 count = __pContextMenu->GetItemCount();
449 for (int i = 0; i < count; i++)
451 _ContextMenuItem* pItem = null;
452 Color color = __pContextMenu->GetItemColor(CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED);
454 pItem = __pModel->GetItem(i);
455 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_SYSTEM, "A system error has occured. pItem must not be null.");
457 pItem->SetPressedItemColor(color);
464 _ContextMenuListPresenter::CalculateRect(void)
466 FloatRectangle windowRect = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // ContextMenu window itself
467 FloatRectangle bodyRect = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // bg surronding showing items, relative to window
468 FloatRectangle arrowRect = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // relative to window
469 FloatRectangle itemRect = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // relative to window
471 float bodyTopMargin = __topMargin;
472 float bodyBottomMargin = __bottomMargin;
473 float bodyLeftMargin = __leftMargin;
474 float bodyRightMargin = __rightMargin;
476 float screenTopMargin = __screenTopMargin;
477 float screenBottomMargin = __screenBottomMargin;
478 float screenLeftMargin = __screenLeftMargin;
479 float screenRightMargin = __screenRightMargin;
481 int scrollPanelMargin;
482 GET_SHAPE_CONFIG(CONTEXTMENU::SCROLL_PANEL_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, scrollPanelMargin);
484 FloatPoint anchorPosition = __pContextMenu->GetAnchorPosition();
485 FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
487 if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE)
489 screen.SetSize(screen.height, screen.width);
492 // calculate arrow area
493 enum ContextMenuCoreDropPosition dropPosition = __pContextMenu->GetDropPosition();
494 if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_UP || dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_DOWN) // down, up Arrow
496 arrowRect.width = __arrowWidth;
497 arrowRect.height = __arrowHeight;
499 else // left, right Arrow
501 arrowRect.width = __arrowHeight;
502 arrowRect.height = __arrowWidth;
505 // calculate body rect
506 // calculate drawable boundaries for contextmenu
507 float leftBoundary = screenLeftMargin;
508 float rightBoundary = screen.width - screenRightMargin;
509 float topBoundary = screenTopMargin;
510 float bottomBoundary = screen.height - screenBottomMargin;
512 // calculate layout size (__layoutSize)
515 bodyRect.width = __layoutSize.width + bodyLeftMargin + bodyRightMargin;
516 bodyRect.height = __layoutSize.height + bodyTopMargin + bodyBottomMargin + 2 * scrollPanelMargin;
518 // calculate the position of the arrow and body rect.
519 if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_UP) // down Arrow
521 // Check touch position
522 // - Check left margin
523 if (anchorPosition.x <= leftBoundary + arrowRect.width)
525 anchorPosition.x = leftBoundary + arrowRect.width;
527 // - check right margin
528 if (anchorPosition.x >= (rightBoundary - arrowRect.width))
530 anchorPosition.x = rightBoundary - arrowRect.width;
532 // - check top margin
533 if (anchorPosition.y <= topBoundary)
535 anchorPosition.y = topBoundary + bodyRect.height;
537 // - check bottom margin
538 if (anchorPosition.y >= bottomBoundary)
540 anchorPosition.y = bottomBoundary;
543 // Set body position x
544 bodyRect.x = anchorPosition.x - (bodyRect.width / 2.0f);
545 // - Check left margin
546 if (bodyRect.x <= leftBoundary)
548 bodyRect.x = leftBoundary;
550 // - check right margin
551 if ((bodyRect.x + bodyRect.width) >= rightBoundary)
553 bodyRect.x = rightBoundary - bodyRect.width;
555 // Set body position y
556 bodyRect.y = anchorPosition.y - arrowRect.height - bodyRect.height;
557 // - check top margin
558 if (bodyRect.y <= topBoundary)
560 bodyRect.y = topBoundary;
563 float correctLength = __arrowTopMargin - __anchorPopupOverlap;
564 windowRect.x = bodyRect.x;
565 windowRect.y = bodyRect.y + correctLength;
566 windowRect.width = bodyRect.width;
567 windowRect.height = bodyRect.height + arrowRect.height - correctLength;
572 // Set arrow position
573 arrowRect.x = anchorPosition.x - (arrowRect.width / 2.0f) - windowRect.x;
574 arrowRect.y = bodyRect.height - correctLength;
576 else if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_DOWN) // up Arrow
578 // Check touch position
579 // - Check left margin
580 if (anchorPosition.x <= leftBoundary + arrowRect.width)
582 anchorPosition.x = leftBoundary + arrowRect.width;
584 // - check right margin
585 if (anchorPosition.x >= (rightBoundary - arrowRect.width))
587 anchorPosition.x = rightBoundary - arrowRect.width;
589 // - check top margin
590 if (anchorPosition.y <= topBoundary)
592 anchorPosition.y = topBoundary;
594 // - check bottom margin
595 if (anchorPosition.y >= bottomBoundary)
597 anchorPosition.y = bottomBoundary;
600 // Set body position x
601 bodyRect.x = anchorPosition.x - (bodyRect.width / 2.0f);
602 // - Check left margin
603 if (bodyRect.x <= leftBoundary)
605 bodyRect.x = leftBoundary;
607 // - check right margin
608 if ((bodyRect.x + bodyRect.width) >= rightBoundary)
610 bodyRect.x = rightBoundary - bodyRect.width;
612 // Set body position y
613 bodyRect.y = anchorPosition.y + arrowRect.height;
614 // - Check bottom margin
615 if ((bodyRect.y + bodyRect.height) >= bottomBoundary)
617 bodyRect.y = bottomBoundary - bodyRect.height;
620 float correctLength = __arrowBottomMargin - __anchorPopupOverlap;
621 windowRect.x = bodyRect.x;
622 windowRect.y = bodyRect.y - arrowRect.height;
623 windowRect.width = bodyRect.width;
624 windowRect.height = bodyRect.height + arrowRect.height - correctLength;
627 bodyRect.y = arrowRect.height - correctLength;
629 // Set arrow position
630 arrowRect.x = anchorPosition.x - (arrowRect.width / 2.0f) - windowRect.x;
633 else if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_LEFT) // right Arrow
635 // Check touch position
636 // - Check left margin
637 if (anchorPosition.x <= leftBoundary)
639 anchorPosition.x = leftBoundary + bodyRect.width;
641 // - check right margin
642 if (anchorPosition.x >= rightBoundary)
644 anchorPosition.x = rightBoundary;
646 // - Check top margin
647 if (anchorPosition.y <= topBoundary + arrowRect.height)
649 anchorPosition.y = topBoundary + arrowRect.height;
651 // - check bottom margin
652 if (anchorPosition.y >= (bottomBoundary - arrowRect.height))
654 anchorPosition.y = bottomBoundary - arrowRect.height;
657 // Set body position x
658 bodyRect.x = anchorPosition.x - arrowRect.width - bodyRect.width;
659 // - Check left margin
660 if (bodyRect.x <= leftBoundary)
662 bodyRect.x = leftBoundary;
664 // - check right margin
665 if ((bodyRect.x + bodyRect.width + arrowRect.width) >= rightBoundary)
667 bodyRect.x = rightBoundary - bodyRect.width - arrowRect.width;
670 // Set body position y
671 bodyRect.y = anchorPosition.y - (bodyRect.height / 2.0f);
672 // - check top margin
673 if (bodyRect.y <= topBoundary)
675 bodyRect.y = topBoundary;
677 // - check bottom margin
678 if ((bodyRect.y + bodyRect.height) >= bottomBoundary)
680 bodyRect.y = bottomBoundary - bodyRect.height;
683 float correctLength = __arrowRightMargin - __anchorPopupOverlap;
684 windowRect.x = bodyRect.x + correctLength;
685 windowRect.y = bodyRect.y;
686 windowRect.width = bodyRect.width + arrowRect.width - correctLength;
687 windowRect.height = bodyRect.height;
692 // Set arrow position
693 arrowRect.x = bodyRect.width - correctLength;
694 arrowRect.y = anchorPosition.y - (arrowRect.height / 2.0f) - windowRect.y;
698 // Check touch position
699 // - Check top margin
700 if (anchorPosition.x <= leftBoundary)
702 anchorPosition.x = leftBoundary;
704 // - check right margin
705 if (anchorPosition.x >= rightBoundary)
707 anchorPosition.x = rightBoundary - bodyRect.width;
709 // - Check top margin
710 if (anchorPosition.y <= topBoundary + arrowRect.height)
712 anchorPosition.y = topBoundary + arrowRect.height;
714 // - check bottom margin
715 if (anchorPosition.y >= (bottomBoundary - arrowRect.height))
717 anchorPosition.y = bottomBoundary - arrowRect.height;
720 // Set body position x
721 bodyRect.x = anchorPosition.x;
722 // - Check left margin
723 if (bodyRect.x <= leftBoundary)
725 bodyRect.x = leftBoundary;
727 // - check right margin
728 if ((bodyRect.x + bodyRect.width + arrowRect.width) >= rightBoundary)
730 bodyRect.x = rightBoundary - bodyRect.width - arrowRect.width;
732 // Set body position y
733 bodyRect.y = anchorPosition.y - (bodyRect.height / 2.0f);
734 // - check top margin
735 if (bodyRect.y <= topBoundary)
737 bodyRect.y = topBoundary;
739 // - check bottom margin
740 if ((bodyRect.y + bodyRect.height) >= bottomBoundary)
742 bodyRect.y = bottomBoundary - bodyRect.height;
745 float correctLength = __arrowLeftMargin - __anchorPopupOverlap;
746 windowRect.x = bodyRect.x;
747 windowRect.y = bodyRect.y;
748 windowRect.width = bodyRect.width + arrowRect.width - correctLength;
749 windowRect.height = bodyRect.height;
751 bodyRect.x = arrowRect.width - correctLength;
754 // Set arrow position
756 arrowRect.y = anchorPosition.y - (arrowRect.height / 2.0f) - windowRect.y;
759 itemRect.x = bodyRect.x + bodyLeftMargin;
760 itemRect.y = bodyRect.y + bodyTopMargin + scrollPanelMargin;
761 itemRect.width = __layoutSize.width;
762 itemRect.height = __layoutSize.height;
764 __pContextMenu->SetWindowRect(windowRect);
765 __pContextMenu->SetBodyRect(bodyRect);
766 __pContextMenu->SetArrowRect(arrowRect);
767 __pContextMenu->SetItemRect(itemRect);
769 // _ScrollPanel API call sequence: SetBounds() -> SetScrollAreaBounds()
770 // _Scroll visual interaction if Bounds < ScrollAreaBounds
771 if (__pContextMenu->IsVisible())
773 __pContextMenu->GetScrollPanel()->SetBounds(FloatRectangle(bodyRect.x + bodyLeftMargin, bodyRect.y + bodyTopMargin + scrollPanelMargin,
774 __layoutSize.width, __layoutSize.height));
775 int itemCount = __pModel->GetItemCount();
776 float itemHeight = __itemHeight + (__dividerHeight * 2.0f);
777 float layoutClientHeight = itemCount * itemHeight - (__dividerHeight * 2.0f);
778 __pContextMenu->GetScrollPanel()->SetClientAreaHeight(layoutClientHeight);
781 __pContextMenu->SetMovable(true);
782 __pContextMenu->SetResizable(true);
784 __pContextMenu->SetMinimumSize(FloatDimension(0.0f, 0.0f));
785 __pContextMenu->SetMaximumSize(screen);
786 __pContextMenu->SetBounds(windowRect);
788 __pContextMenu->SetMovable(false);
789 __pContextMenu->SetResizable(false);
795 _ContextMenuListPresenter::AdjustItemLayout(void)
797 FloatDimension layoutSize(0.0f, 0.0f);
799 int itemCount = __pModel->GetItemCount();
802 __layoutSize.width = __itemWidth;
803 __layoutSize.height = __itemHeight;
807 layoutSize = AdjustItemLayoutStyle();
809 FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
810 if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE)
812 screen.SetSize(screen.height, screen.width);
815 int maxHeight = screen.height - __screenTopMargin - __screenBottomMargin - __arrowHeight;
816 if (layoutSize.height > maxHeight)
818 layoutSize.height = maxHeight;
821 __layoutSize = layoutSize;
826 _ContextMenuListPresenter::AdjustItemLayoutStyle(void)
828 int itemMaxCount = CalculateShowItemCount();
830 int itemCount = __pModel->GetItemCount();
831 float itemHeight = __itemHeight + (__dividerHeight * 2.0f);
833 FloatDimension layoutSize(__itemWidth, 0.0f);
835 float layoutClientHeight = itemCount * itemHeight - (__dividerHeight * 2.0f);
836 float layoutMaxHeight = itemMaxCount * itemHeight - (__dividerHeight * 2.0f);
837 if (layoutClientHeight > layoutMaxHeight)
839 __scrollEnable = true;
840 layoutSize.height = layoutMaxHeight;
844 __scrollEnable = false;
845 layoutSize.height = layoutClientHeight;
852 _ContextMenuListPresenter::AdjustItemPosition(void)
854 int itemCount = __pModel->GetItemCount();
860 float itemHeight = __itemHeight + (__dividerHeight * 2.0f);
861 float drawItemY = 0.0f;
863 float x = __pContextMenu->GetBodyRect().x + __leftMargin;
864 float y = __pContextMenu->GetBodyRect().y + __topMargin;
866 _ContextMenuItem* pItem = null;
868 for (int i = 0; i < itemCount; i++)
870 pItem = __pModel->GetItem(i);
877 FloatRectangle drawRect(x, drawItemY + y, __itemWidth, itemHeight);
879 pItem->SetDrawRect(drawRect);
880 pItem->SetUpperDivider(i > 0);
881 pItem->SetLowerDivider(i < itemCount - 1);
882 pItem->SetParentScrollEnable(__scrollEnable);
883 pItem->SetBounds(FloatRectangle(0.0f, drawItemY, drawRect.width, drawRect.height));
885 if (pItem->HasParent() == false)
887 __pContextMenu->GetScrollPanel()->AttachChild(*pItem);
890 drawItemY += itemHeight;
895 _ContextMenuListPresenter::CalculateItemMaximumWidth(void)
897 FloatDimension itemSize(0.0f, 0.0f);
898 FloatDimension textArea(0.0f, 0.0f);
899 float maxItemWidth = __itemMinWidth;
901 for (int i = 0; i < __pModel->GetItemCount(); i++)
903 _ContextMenuItem* pItem = null;
905 pItem = __pModel->GetItem(i);
906 SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_SYSTEM, "[%s] A system error occurred. Unable to get the item.", GetErrorMessage(E_SYSTEM));
908 CalculateItemSize(pItem->GetText(), pItem->GetType(), textArea, itemSize);
910 if (maxItemWidth < itemSize.width)
912 maxItemWidth = itemSize.width;
915 __itemWidth = maxItemWidth;
919 _ContextMenuListPresenter::GetItemIndexFromPosition(const FloatPoint& point) const
922 int itemCount = __pModel->GetItemCount();
929 _ContextMenuItem* pItem = null;
931 float scrollPosition = __pContextMenu->GetScrollPanel()->GetScrollPosition();
932 FloatPoint position(point.x, point.y + scrollPosition);
934 for (int i = 0; i < itemCount; i++)
936 pItem = __pModel->GetItem(i);
943 FloatRectangle drawRect = pItem->GetDrawRect();
945 if (drawRect.Contains(position) == true)
957 _ContextMenuListPresenter::Draw(void)
959 result r = E_SUCCESS;
961 Canvas* pCanvas = __pContextMenu->GetCanvasN();
962 SysTryReturnResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "Propagating.");
964 // Clear canvas for drawing area of the ContextMenu.
965 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
966 FloatRectangle bounds(__pContextMenu->GetWindowRect());
967 pCanvas->Clear(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
969 r = DrawBackground(pCanvas);
970 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw background.");
972 r = DrawArrow(pCanvas);
973 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw arrow.");
981 _ContextMenuListPresenter::DrawBackground(Canvas* pCanvas)
983 SysTryReturnResult(NID_UI_CTRL, pCanvas != null, E_SYSTEM, "A system error has occurred. pCanvas is null.");
985 result r = E_SUCCESS;
987 FloatRectangle bodyRect = __pContextMenu->GetBodyRect();
989 const Bitmap* pBackgroundNormalBitmap = __pContextMenu->GetBackgroundNormalBitmap();
990 const Bitmap* pBackgroundEffectBitmap = __pContextMenu->GetBackgroundEffectBitmap();
992 if (pBackgroundNormalBitmap == null && pBackgroundEffectBitmap == null)
994 pCanvas->SetForegroundColor(__pContextMenu->GetColor());
995 pCanvas->DrawRectangle(bodyRect);
999 if (pBackgroundNormalBitmap != null)
1001 r = DrawBitmap(*pCanvas, bodyRect, *pBackgroundNormalBitmap);
1004 if (pBackgroundEffectBitmap != null)
1006 r = DrawBitmap(*pCanvas, bodyRect, *pBackgroundEffectBitmap);
1015 _ContextMenuListPresenter::DrawArrow(Canvas* pCanvas)
1017 SysTryReturnResult(NID_UI_CTRL, pCanvas != null, E_SYSTEM, "A system error has occurred. pCanvas is null.");
1019 result r = E_SUCCESS;
1020 FloatRectangle arrowRect = __pContextMenu->GetArrowRect();
1021 ContextMenuCoreDropPosition dropPosition = __pContextMenu->GetDropPosition();
1023 const Bitmap* pArrowNormalBitmap = __pContextMenu->GetArrowNormalBitmap(dropPosition);
1024 const Bitmap* pEffectArrowBitmap = __pContextMenu->GetArrowEffectBitmap(dropPosition);
1026 if (pArrowNormalBitmap != null)
1028 r = DrawBitmap(*pCanvas, arrowRect, *pArrowNormalBitmap);
1031 if (pEffectArrowBitmap != null)
1033 r = DrawBitmap(*pCanvas, arrowRect, *pEffectArrowBitmap);
1039 _UiTouchEventDelivery
1040 _ContextMenuListPresenter::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1042 return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
1046 _ContextMenuListPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1048 FloatPoint touchPosition = touchinfo.GetCurrentPosition();
1049 FloatRectangle itemRect = __pContextMenu->GetItemRect();
1051 if (!itemRect.Contains(touchPosition))
1053 __selectedIndex = -1;
1054 __touchOutRect = true;
1058 __selectedIndex = GetItemIndexFromPosition(touchPosition);
1059 __touchOutRect = false;
1063 _UiTouchEventDelivery
1064 _ContextMenuListPresenter::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1066 return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
1070 _ContextMenuListPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1072 FloatPoint touchPosition = touchinfo.GetCurrentPosition();
1076 FloatRectangle itemRect = __pContextMenu->GetItemRect();
1077 if (!itemRect.Contains(touchPosition))
1079 __selectedIndex = -1;
1080 __focusedIndex = -1;
1081 __pContextMenu->SetFocused(false);
1082 __pContextMenu->SetVisibleState(false);
1088 int currentSelectedIndex = GetItemIndexFromPosition(touchPosition);
1089 if (__selectedIndex != -1 && (__selectedIndex == currentSelectedIndex))
1091 _ContextMenuItem* pItem = null;
1092 pItem = __pModel->GetItem(__selectedIndex);
1098 __selectedIndex = -1;
1099 __focusedIndex = -1;
1100 __pContextMenu->SetFocused(false);
1101 __pContextMenu->SetVisibleState(false);
1103 int actionId = pItem->GetActionId();
1105 _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
1106 if (pActionEvent == null)
1111 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
1112 if (pEventArg == null)
1117 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pContextMenu);
1118 pActionEvent->Fire(*pEventArg);
1124 _UiTouchEventDelivery
1125 _ContextMenuListPresenter::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1127 return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
1131 _ContextMenuListPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1135 __selectedIndex = -1;
1141 _UiTouchEventDelivery
1142 _ContextMenuListPresenter::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1144 return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
1148 _ContextMenuListPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1150 __pModel->ResetAllItem();
1151 __selectedIndex = -1;
1157 _ContextMenuListPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1159 _KeyCode keyCode = keyInfo.GetKeyCode();
1165 if (__enterKeyPressed)
1167 __enterKeyPressed = false;
1168 _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
1171 pItem->SetAndInvalidate(false);
1175 if (--__focusedIndex < 0)
1180 _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
1183 __focusedIndex = -1;
1187 pItem->SetFocused(true);
1189 __pContextMenu->GetScrollPanel()->OnChildControlFocusMoved(*pItem);
1195 if (__enterKeyPressed)
1197 __enterKeyPressed = false;
1198 _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
1201 pItem->SetAndInvalidate(false);
1205 _ContextMenuItem* pItem = __pModel->GetItem(++__focusedIndex);
1212 pItem->SetFocused(true);
1214 __pContextMenu->GetScrollPanel()->OnChildControlFocusMoved(*pItem);
1220 if (__enterKeyPressed)
1222 __enterKeyPressed = false;
1223 _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
1226 pItem->SetAndInvalidate(false);
1232 _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
1235 __focusedIndex = -1;
1239 pItem->SetFocused(true);
1241 __pContextMenu->GetScrollPanel()->OnChildControlFocusMoved(*pItem);
1247 __enterKeyPressed = true;
1249 _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
1252 pItem->SetAndInvalidate(true);
1257 case _KEY_BACKSPACE:
1259 _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
1262 pItem->SetFocused(false);
1263 pItem->SetAndInvalidate(false);
1266 __enterKeyPressed = false;
1267 __backKeyPressed = false;
1268 __selectedIndex = -1;
1269 __focusedIndex = -1;
1270 __pContextMenu->SetFocused(false);
1271 __pContextMenu->SetVisibleState(false);
1279 case _KEY_CONTEXT_MENU:
1282 __backKeyPressed = true;
1292 _ContextMenuListPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1294 _KeyCode keyCode = keyInfo.GetKeyCode();
1302 case _KEY_BACKSPACE:
1308 if (!__enterKeyPressed)
1313 __enterKeyPressed = false;
1314 __backKeyPressed = false;
1316 _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
1320 __selectedIndex = -1;
1321 __focusedIndex = -1;
1322 __pContextMenu->SetFocused(false);
1323 __pContextMenu->SetVisibleState(false);
1328 int actionId = pItem->GetActionId();
1330 _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();
1331 if (pActionEvent == null)
1336 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
1337 if (pEventArg == null)
1342 pItem->SetFocused(false);
1343 pItem->SetAndInvalidate(false);
1345 __selectedIndex = -1;
1346 __focusedIndex = -1;
1347 __pContextMenu->SetFocused(false);
1348 __pContextMenu->SetVisibleState(false);
1350 pActionEvent->Fire(*pEventArg);
1358 case _KEY_CONTEXT_MENU:
1362 if (!__backKeyPressed)
1367 _ContextMenuItem* pItem = __pModel->GetItem(__focusedIndex);
1370 pItem->SetFocused(false);
1371 pItem->SetAndInvalidate(false);
1374 __enterKeyPressed = false;
1375 __backKeyPressed = false;
1376 __selectedIndex = -1;
1377 __focusedIndex = -1;
1378 __pContextMenu->SetFocused(false);
1379 __pContextMenu->SetVisibleState(false);
1391 _ContextMenuListPresenter::IsChildControlFocusManage(void) const
1398 _ContextMenuListPresenter::OnFocusModeStateChanged(void)
1400 _Control* pFocusedControl = null;
1401 _Window* pTop = __pContextMenu->GetRootWindow();
1404 pFocusedControl = pTop->GetCurrentFocusControl();
1407 if (pFocusedControl != null)
1409 pFocusedControl->SetFocused(false);
1414 _ContextMenuListPresenter::OnFontChanged(Font* pFont)
1417 String fontName = __pContextMenu->GetFont();
1419 int itemCount = __pModel->GetItemCount();
1420 for (int i = 0; i < itemCount; i++)
1422 _ContextMenuItem* pItem = __pModel->GetItem(i);
1425 pItem->SetFont(fontName);
1431 _ContextMenuListPresenter::OnFontInfoRequested(unsigned long& style, float& size)
1433 style = FONT_STYLE_PLAIN;
1434 size = __itemFontSize;
1438 _ContextMenuListPresenter::SetAllAccessibilityElement(void)
1440 _AccessibilityContainer* pContainerContextMenu = __pContextMenu->GetAccessibilityContainer();
1441 if (pContainerContextMenu != null)
1443 _AccessibilityElement* pElementContextMenu = new (std::nothrow) _AccessibilityElement(true);
1444 SysTryReturnVoidResult(NID_UI_CTRL, pElementContextMenu, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1446 pElementContextMenu->SetSupportOperatingGesture(false);
1447 pElementContextMenu->SetTraitWithStringId("IDS_TPLATFORM_BODY_CONTEXTUAL_POP_UP_T_TTS");
1448 pElementContextMenu->SetHintWithStringId("IDS_TPLATFORM_BODY_CONTEXTUAL_POP_UP_IS_OPEN_DOUBLE_TAP_TO_CLOSE_THE_POP_UP_T_TTS");
1449 pElementContextMenu->SetBounds(FloatRectangle(0.0f, 0.0f, __pContextMenu->GetBoundsF().width, __pContextMenu->GetBoundsF().height));
1450 pContainerContextMenu->AddElement(*pElementContextMenu);
1451 __pContextMenu->AddAccessibilityElement(*pElementContextMenu);
1453 int itemCount = __pModel->GetItemCount();
1454 for (int i = 0; i < itemCount; i++)
1456 _ContextMenuItem* pItem = __pModel->GetItem(i);
1459 _AccessibilityContainer* pContainer = pItem->GetAccessibilityContainer();
1460 if (pContainer != null)
1462 LinkedListT<_AccessibilityElement*> accessibilityElements;
1463 _AccessibilityElement* pElement = null;
1465 pContainer->GetElements(accessibilityElements);
1466 if (accessibilityElements.GetAt(0, pElement) == E_SUCCESS)
1468 pElement->SetName(L"ContextMenuItem" + Integer::ToString(i));
1469 if (pItem->GetType() == CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP)
1472 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_ICON, string);
1473 pElement->SetLabel(string + pItem->GetText());
1477 pElement->SetLabel(pItem->GetText());
1480 pElement->SetBounds(FloatRectangle(0.0f, 0.0f, pItem->GetBoundsF().width, pItem->GetBoundsF().height));
1482 pContainerContextMenu->AddChildContainer(*pContainer);
1489 _ContextMenuItemInfo
1490 _ContextMenuListPresenter::GetItemFromPosition(const FloatPoint& position)
1492 _ContextMenuItemInfo itemInfo;
1493 int index = GetItemIndexFromPosition(position);
1494 itemInfo.pContextMenuItem = __pModel->GetItem(index);
1496 itemInfo.bListItem = false;
1497 itemInfo.pListItem = null;
1501 _ContextMenuItemInfo
1502 _ContextMenuListPresenter::FindItem(int index)
1504 _ContextMenuItemInfo itemInfo;
1505 itemInfo.bListItem = false;
1506 itemInfo.pListItem = null;
1507 itemInfo.pContextMenuItem = __pModel->GetItem(index);
1512 _ContextMenuListPresenter::SetTopDrawnItemIndex(int index)
1518 _ContextMenuListPresenter::DrawBitmap(Canvas& canvas, const FloatRectangle& bounds, const Bitmap& bitmap)
1520 result r = E_SUCCESS;
1521 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
1523 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1524 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw ninepatched bitmap.")
1528 r = canvas.DrawBitmap(FloatPoint(bounds.x, bounds.y), bitmap);
1529 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw bitmap.")
1535 }}} // Tizen::Ui: Control