Merge "Apply auto_hide style to popup." into tizen_2.2
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_ContextMenu.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17 /**
18  * @file                FUiCtrl_ContextMenu.cpp
19  * @brief               This is the implementation file for the _ContextMenu class.
20  */
21
22 #include <FBaseErrorDefine.h>
23 #include <FBaseSysLog.h>
24 #include <FGrp_BitmapImpl.h>
25 #include <FBaseColIEnumeratorT.h>
26 #include "FUi_ControlImplManager.h"
27 #include "FUi_ResourceManager.h"
28 #include "FUiAnim_VisualElement.h"
29 #include "FUiAnim_AnimationManager.h"
30 #include "FUi_AccessibilityContainer.h"
31 #include "FUi_AccessibilityElement.h"
32 #include "FUiCtrl_Form.h"
33 #include "FUiCtrl_Frame.h"
34 #include "FUiCtrl_ContextMenu.h"
35 #include "FUiCtrl_Scroll.h"
36
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Media;
39 using namespace Tizen::Ui::Animations;
40
41 namespace {
42 static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;
43 }
44
45 namespace Tizen { namespace Ui { namespace Controls
46 {
47
48 IMPLEMENT_PROPERTY(_ContextMenu);
49
50 _ContextMenu::_ContextMenu(const FloatPoint& point, enum ContextMenuCoreStyle style, enum ContextMenuCoreAlign contextMenuAlign)
51         : __pContextMenuPresenter(null)
52         , __style(style)
53         , __align(contextMenuAlign)
54         , __showItemCount(MAX_CONTEXTMENU_LIST_SHOW_ITEM)
55         , __showItemMaxCount(0)
56         , __isAttachedToMainTree(false)
57         , __ownerInputEnableState(false)
58         , __anchorPoint(point)
59         , __windowRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
60         , __bodyRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
61         , __arrowRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
62         , __itemRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
63         , __pActionEvent(null)
64         , __pBackgroundNormalBitmap(null)
65         , __pBackgroundEffectBitmap(null)
66         , __dropPosition(CONTEXT_MENU_CORE_DROP_POSITION_INVALID)
67         , __layout(_CONTROL_ORIENTATION_PORTRAIT)
68         , __rotation(_CONTROL_ROTATION_0)
69         , __pScrollPanel(null)
70 {
71         __backgroundColor = Color(255, 255, 255, 255);
72
73         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = Color(255, 255, 255, 255);
74         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = Color(255, 255, 255, 255);
75         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = Color(255, 255, 255, 255);
76
77         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = Color(255, 255, 255, 255);
78         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = Color(255, 255, 255, 255);
79         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = Color(255, 255, 255, 255);
80
81         for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++)
82         {
83                 __pArrowNormalBitmap[i] = null;
84                 __pArrowEffectBitmap[i] = null;
85         }
86
87         GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, __layout, __showItemMaxCount);
88 }
89
90 _ContextMenu::~_ContextMenu(void)
91 {
92         if (__isAttachedToMainTree && GetOwner() != null)
93         {
94                 GetOwner()->UnlockInputEvent();
95         }
96
97         if (__pScrollPanel) {
98                 __pScrollPanel->DetachAllChildren();
99                 DetachChild(*__pScrollPanel);
100                 delete __pScrollPanel;
101                 __pScrollPanel = null;
102         }
103
104         delete __pContextMenuPresenter;
105         __pContextMenuPresenter = null;
106
107         if (__pBackgroundNormalBitmap != null)
108         {
109                 delete __pBackgroundNormalBitmap;
110                 __pBackgroundNormalBitmap = null;
111         }
112
113         if (__pBackgroundEffectBitmap != null)
114         {
115                 delete __pBackgroundEffectBitmap;
116                 __pBackgroundEffectBitmap = null;
117         }
118
119         if (__pActionEvent)
120         {
121                 delete __pActionEvent;
122                 __pActionEvent = null;
123         }
124
125         for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++)
126         {
127                 delete __pArrowNormalBitmap[i];
128                 __pArrowNormalBitmap[i] = null;
129
130                 delete __pArrowEffectBitmap[i];
131                 __pArrowEffectBitmap[i] = null;
132         }
133
134         __actionId.RemoveAll();
135
136         RemoveAllAccessibilityElement();
137 }
138
139 _ContextMenu*
140 _ContextMenu::CreateContextMenuN(const FloatPoint& point, enum ContextMenuCoreStyle style, enum ContextMenuCoreAlign contextMenuAlign)
141 {
142         _ContextMenu* pContextMenu = new (std::nothrow) _ContextMenu(point, style, contextMenuAlign);
143         SysTryReturn(NID_UI_CTRL, pContextMenu != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
144
145         result r = E_SUCCESS;
146
147         r = pContextMenu->CreateRootVisualElement();
148         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
149
150         pContextMenu->SetFocusable(false);
151
152         r = pContextMenu->Initialize();
153         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Initialize.", GetErrorMessage(r));
154
155         r = pContextMenu->Install();
156         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Install.", GetErrorMessage(r));
157
158         pContextMenu->AcquireHandle();
159         pContextMenu->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
160
161         if (pContextMenu->GetAccessibilityContainer() != null)
162         {
163                 pContextMenu->GetAccessibilityContainer()->Activate(true);
164                 pContextMenu->GetAccessibilityContainer()->AddListener(*pContextMenu);
165         }
166
167         if (style == CONTEXT_MENU_CORE_STYLE_LIST)
168         {
169                 float minWidth, minHeight;      // for visible scrollbar when scrollable
170                 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MIN_WIDTH,   _CONTROL_ORIENTATION_PORTRAIT, minWidth);
171                 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, minHeight);
172                 pContextMenu->__pScrollPanel = _ScrollPanel::CreateScrollPanelN(FloatRectangle(0.0f, 0.0f, minWidth, minHeight), SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, false, false);
173                 pContextMenu->__pScrollPanel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
174                 pContextMenu->__pScrollPanel->SetFocusable(false);
175
176                 _Scroll* pScroll = pContextMenu->__pScrollPanel->GetScrollBar();
177                 SysTryCatch(NID_UI_CTRL, pScroll, , E_INVALID_STATE, "[E_INVALID_STATE] _Scroll isn't constructed");
178                 pScroll->SetContextMenuScrollType(true);
179
180                 pContextMenu->AttachChild(*(pContextMenu->__pScrollPanel));
181         }
182
183         return pContextMenu;
184
185 CATCH:
186         delete pContextMenu;
187
188         return null;
189 }
190
191 _ScrollPanel*
192 _ContextMenu::GetScrollPanel(void)
193 {
194         return __pScrollPanel;
195 }
196
197 result
198 _ContextMenu::Install(void)
199 {
200         result r = E_SUCCESS;
201
202         // load bitmap of a background and arrow
203         r = LoadBitmap();
204         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to load bitmap.");
205
206         r = __actionId.Construct();
207         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to construct arraylist.");
208
209         if (__style == CONTEXT_MENU_CORE_STYLE_LIST)
210         {
211                 _IContextMenuPresenter* pPresenter = new (std::nothrow) _ContextMenuListPresenter(this);
212                 SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
213
214                 SetPresenter(*pPresenter);
215
216                 r = pPresenter->Install();
217         }
218         else
219         {
220                 _IContextMenuPresenter* pPresenter = new (std::nothrow) _ContextMenuGridPresenter(this);
221                 SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
222
223                 SetPresenter(*pPresenter);
224
225                 r = pPresenter->Install();
226         }
227
228         return r;
229 }
230
231 result
232 _ContextMenu::Initialize(void)
233 {
234         FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
235         result r = E_SUCCESS;
236
237         Color backgroundColor;
238         Color backgroundSelectedColor;
239         Color itemTextColor;
240         Color itemTextSelectedColor;
241
242         r = SetBounds(FloatRectangle(0.0f, 0.0f, screen.width, screen.height));
243         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "SetBounds failed.");
244
245         SetMovable(false);
246         SetResizable(false);
247
248         GET_COLOR_CONFIG(CONTEXTMENU::BG_NORMAL, backgroundColor);
249         GET_COLOR_CONFIG(CONTEXTMENU::ITEM_BG_PRESSED, backgroundSelectedColor);
250         GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_NORMAL, itemTextColor);
251         GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_PRESSED, itemTextSelectedColor);
252
253         __backgroundColor = backgroundColor;
254         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = backgroundColor;
255         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = backgroundSelectedColor;
256         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = itemTextColor;
257         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = itemTextSelectedColor;
258
259         if (GetVisualElement() != null)
260         {
261                 GetVisualElement()->SetSurfaceOpaque(false);
262         }
263
264         return r;
265
266 }
267
268 result
269 _ContextMenu::SetPresenter(const _IContextMenuPresenter& ContextMenuPresenter)
270 {
271         __pContextMenuPresenter = const_cast <_IContextMenuPresenter*>(&ContextMenuPresenter);
272
273         return E_SUCCESS;
274 }
275
276 void
277 _ContextMenu::OnDraw()
278 {
279         __pContextMenuPresenter->Draw();
280
281         if(unlikely((_AccessibilityManager::IsActivated())))
282         {
283                 _AccessibilityManager::GetInstance()->RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM);
284         }
285 }
286
287 result
288 _ContextMenu::OnAttachedToMainTree(void)
289 {
290         result r = E_SUCCESS;
291
292         __layout = _ControlManager::GetInstance()->GetOrientation();
293         __rotation = _ControlManager::GetInstance()->GetScreenRotation();
294         __isAttachedToMainTree = true;
295         _Control* pOwner = GetOwner();
296         if (pOwner == null)
297         {
298                 _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
299                 SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Current frame instance is not available.");
300
301                 _Form* pForm = pFrame->GetCurrentForm();
302                 pForm != null ? SetOwner(pForm) : SetOwner(pFrame);
303
304                 GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, __layout, __showItemMaxCount);
305         }
306         else
307         {
308                 pOwner->LockInputEvent();
309         }
310
311         AdjustDropPosition();
312
313         if (GetItemCount() <= 0)
314         {
315                 __pContextMenuPresenter->CalculateShowItemCount();
316         }
317
318         r = __pContextMenuPresenter->CalculateWindowRect();
319         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
320
321         r = Open();
322
323         SetVisibleState(true);
324
325         if (__style == CONTEXT_MENU_CORE_STYLE_LIST)
326         {
327                 SetTouchCapture(false, false);
328         }
329         else
330         {
331                 SetTouchCapture(true, false);
332         }
333
334         SetAllAccessibilityElement();
335
336         _VisualElement* pVisualElement = GetVisualElement();
337         FloatRectangle pBounds = pVisualElement->GetBounds();
338         float oldBoundsX = pBounds.x;
339         float oldBoundsY = pBounds.y;
340         float distanceX = 0.0f;
341         float distanceY = 0.0f;
342
343         GET_SHAPE_CONFIG(CONTEXTMENU::APPEARING_ANIMATION_DISTANCE_X, __layout, distanceX);
344         GET_SHAPE_CONFIG(CONTEXTMENU::APPEARING_ANIMATION_DISTANCE_Y, __layout, distanceY);
345
346         switch(GetDropPosition())
347         {
348         case CONTEXT_MENU_CORE_DROP_POSITION_UP:
349                 pBounds.y += distanceY;
350                 break;
351         case CONTEXT_MENU_CORE_DROP_POSITION_DOWN:
352                 pBounds.y -= distanceY;
353                 break;
354         case CONTEXT_MENU_CORE_DROP_POSITION_LEFT:
355                 pBounds.x += distanceX;
356                 break;
357         case CONTEXT_MENU_CORE_DROP_POSITION_RIGHT:
358                 pBounds.x -= distanceX;
359                 break;
360         default:
361                 break;
362         }
363
364         pVisualElement->SetBounds(pBounds);
365         pVisualElement->SetOpacity(0.0f);
366
367         bool enable = pVisualElement->IsImplicitAnimationEnabled();
368
369         pVisualElement->SetImplicitAnimationEnabled(true);
370
371         pBounds.x = oldBoundsX;
372         pBounds.y = oldBoundsY;
373         pVisualElement->SetBounds(pBounds);
374         pVisualElement->SetOpacity(1.0f);
375
376         pVisualElement->SetImplicitAnimationEnabled(enable);
377
378         return r;
379 }
380
381 result
382 _ContextMenu::OnDetachingFromMainTree(void)
383 {
384         result r = E_SUCCESS;
385
386         ReleaseTouchCapture();
387
388         _Control* pOwner = GetOwner();
389         if (pOwner != null)
390         {
391                 pOwner->UnlockInputEvent();
392         }
393
394         __isAttachedToMainTree = false;
395
396         return r;
397 }
398
399 result
400 _ContextMenu::AddItem(const Base::String& text, int actionId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap,
401                                           const Bitmap* pHighlightedBitmap)
402 {
403         result r = E_SUCCESS;
404
405         r = __pContextMenuPresenter->AddItem(text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
406         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to add a item.");
407
408         __actionId.Add(actionId);
409
410         __pContextMenuPresenter->CalculateShowItemCount();
411         __pContextMenuPresenter->CalculateWindowRect();
412
413         return r;
414 }
415
416 result
417 _ContextMenu::InsertItem(int index, const Base::String& text, int actionId, const Bitmap* pNormalBitmap,
418                                                  const Bitmap* pPressedBitmap,
419                                                  const Bitmap* pHighlightedBitmap)
420 {
421         result r = E_SUCCESS;
422
423         r = __pContextMenuPresenter->InsertItem(index, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
424         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to insert a item.");
425
426         __actionId.InsertAt(actionId, index);
427
428         __pContextMenuPresenter->CalculateShowItemCount();
429         __pContextMenuPresenter->CalculateWindowRect();
430
431         return r;
432 }
433
434 result
435 _ContextMenu::SetItem(int index, const Base::String& text, int actionId, const Bitmap* pNormalBitmap,
436                                           const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
437 {
438         result r = E_SUCCESS;
439
440         r = __pContextMenuPresenter->SetItem(index, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
441         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set a item.");
442
443         __actionId.SetAt(actionId, index);
444
445         __pContextMenuPresenter->CalculateWindowRect();
446
447         return r;
448 }
449
450 result
451 _ContextMenu::RemoveItemAt(int index)
452 {
453         result r = E_SUCCESS;
454
455         r = __pContextMenuPresenter->DeleteItem(index);
456         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove a item.");
457
458         __actionId.RemoveAt(index);
459
460         __pContextMenuPresenter->CalculateShowItemCount();
461         __pContextMenuPresenter->CalculateWindowRect();
462
463         return r;
464 }
465
466 result
467 _ContextMenu::RemoveAllItems(void)
468 {
469         result r = E_SUCCESS;
470
471         r = __pContextMenuPresenter->DeleteItemAll();
472         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove all items.");
473
474         __actionId.RemoveAll();
475
476         __pContextMenuPresenter->CalculateShowItemCount();
477         __pContextMenuPresenter->CalculateWindowRect();
478
479         return r;
480 }
481
482 int
483 _ContextMenu::GetItemCount(void) const
484 {
485         return __actionId.GetCount();
486 }
487
488 int
489 _ContextMenu::GetItemIndexAt(int actionId) const
490 {
491         int count = __actionId.GetCount();
492
493         for (int i = 0; i < count; i++)
494         {
495                 int index = GetItemActionIdAt(i);
496
497                 if (actionId == index)
498                 {
499                         return i;
500                 }
501         }
502
503         return -1;
504 }
505
506 int
507 _ContextMenu::GetItemActionIdAt(int index) const
508 {
509         int count = __actionId.GetCount();
510         int actionId = -1;
511
512         if (count <= 0 || index >= count)
513         {
514                 return -1;
515         }
516
517         __actionId.GetAt(index, actionId);
518
519         return actionId;
520 }
521
522 result
523 _ContextMenu::SetAnchorPosition(float x, float y)
524 {
525         __anchorPoint.x = x;
526         __anchorPoint.y = y;
527
528         if (__align == CONTEXT_MENU_CORE_ALIGN_AUTO)
529         {
530                 AdjustDropPosition();
531         }
532
533         __pContextMenuPresenter->CalculateWindowRect();
534         return E_SUCCESS;
535 }
536
537 FloatPoint
538 _ContextMenu::GetAnchorPosition(void) const
539 {
540         return __anchorPoint;
541 }
542
543 result
544 _ContextMenu::SetWindowRect(const FloatRectangle& rect)
545 {
546         __windowRect = rect;
547
548         return E_SUCCESS;
549 }
550
551 FloatRectangle
552 _ContextMenu::GetWindowRect(void) const
553 {
554         return __windowRect;
555 }
556
557 result
558 _ContextMenu::SetBodyRect(const FloatRectangle& rect)
559 {
560         __bodyRect = rect;
561
562         return E_SUCCESS;
563 }
564
565 FloatRectangle
566 _ContextMenu::GetBodyRect(void) const
567 {
568         return __bodyRect;
569 }
570
571 result
572 _ContextMenu::SetArrowRect(const FloatRectangle& rect)
573 {
574         __arrowRect = rect;
575
576         return E_SUCCESS;
577 }
578
579 FloatRectangle
580 _ContextMenu::GetArrowRect(void) const
581 {
582         return __arrowRect;
583 }
584
585 result
586 _ContextMenu::SetItemRect(const FloatRectangle& rect)
587 {
588         __itemRect = rect;
589
590         return E_SUCCESS;
591 }
592
593 FloatRectangle
594 _ContextMenu::GetItemRect(void) const
595 {
596         return __itemRect;
597 }
598
599 result
600 _ContextMenu::SetPropertyMaxVisibleItemsCount(const Variant& count)
601 {
602         int showCount = count.ToInt();
603
604         if (showCount < 1)
605         {
606                 SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Count is invalid.");
607                 return E_INVALID_ARG;
608         }
609
610
611         __showItemCount = showCount;
612
613         return E_SUCCESS;
614 }
615
616 Variant
617 _ContextMenu::GetPropertyMaxVisibleItemsCount(void) const
618 {
619         return Tizen::Ui::Variant(__showItemCount);
620 }
621
622 int
623 _ContextMenu::GetShowItemCount(void) const
624 {
625         Variant count = GetProperty("maxVisibleItemsCount");
626
627         return count.ToInt();
628 }
629
630 int
631 _ContextMenu::GetShowItemMaxCount(void) const
632 {
633         return __showItemMaxCount;
634 }
635
636 result
637 _ContextMenu::SetShowItemCount(int count)
638 {
639         result r;
640
641         r = SetProperty("maxVisibleItemsCount", Variant(count));
642         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set property.");
643
644         if (__style == CONTEXT_MENU_CORE_STYLE_LIST)
645         {
646                 r = __pContextMenuPresenter->CalculateWindowRect();
647                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to calculate window.");
648         }
649
650         return E_SUCCESS;
651 }
652
653 result
654 _ContextMenu::SetPropertyColor(const Variant& color)
655 {
656         __backgroundColor = color.ToColor();
657
658         LoadColorReplacedBitmap(__backgroundColor);
659
660         return E_SUCCESS;
661 }
662
663 Variant
664 _ContextMenu::GetPropertyColor(void) const
665 {
666         return Tizen::Ui::Variant(__backgroundColor);
667 }
668
669 result
670 _ContextMenu::SetColor(const Graphics::Color& color)
671 {
672         return SetProperty("color", Variant(color));
673 }
674
675 Color
676 _ContextMenu::GetColor(void) const
677 {
678         Variant color = GetProperty("color");
679
680         return color.ToColor();
681 }
682
683 result
684 _ContextMenu::SetPropertyNormalItemColor(const Variant& color)
685 {
686         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = color.ToColor();
687
688         return __pContextMenuPresenter->ApplyColorProperty();
689 }
690
691 Variant
692 _ContextMenu::GetPropertyNormalItemColor(void) const
693 {
694         return Tizen::Ui::Variant(__itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL]);
695 }
696
697 result
698 _ContextMenu::SetPropertyPressedItemColor(const Variant& color)
699 {
700         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = color.ToColor();
701
702         return __pContextMenuPresenter->ApplyColorProperty();
703 }
704
705 Variant
706 _ContextMenu::GetPropertyPressedItemColor(void) const
707 {
708         return Tizen::Ui::Variant(__itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED]);
709 }
710
711 result
712 _ContextMenu::SetPropertyHighlightedItemColor(const Variant & color)
713 {
714         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = color.ToColor();
715
716         return __pContextMenuPresenter->ApplyColorProperty();
717 }
718
719 Variant
720 _ContextMenu::GetPropertyHighlightedItemColor(void) const
721 {
722         return Tizen::Ui::Variant(__itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED]);
723 }
724
725 result
726 _ContextMenu::SetItemColor(enum ContextMenuCoreItemStatus status, const Graphics::Color& color)
727 {
728         result r = E_SUCCESS;
729
730         if (status == CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL)
731         {
732                 r = SetProperty("normalItemColor", Variant(color));
733         }
734         else if (status == CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED)
735         {
736                 r = SetProperty("pressedItemColor", Variant(color));
737         }
738         else
739         {
740                 r = SetProperty("highlightedItemColor", Variant(color));
741         }
742
743         return r;
744 }
745
746 Color
747 _ContextMenu::GetItemColor(enum ContextMenuCoreItemStatus status) const
748 {
749         Color itemColor;
750
751         if (status == CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL)
752         {
753                 Variant color = GetProperty("normalItemColor");
754                 itemColor = color.ToColor();
755
756         }
757         else if (status == CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED)
758         {
759                 Variant color = GetProperty("pressedItemColor");
760                 itemColor = color.ToColor();
761
762         }
763         else
764         {
765                 Variant color = GetProperty("highlightedItemColor");
766                 itemColor = color.ToColor();
767         }
768
769         return itemColor;
770
771 }
772
773 result
774 _ContextMenu::SetPropertyNormalItemTextColor(const Variant& color)
775 {
776         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = color.ToColor();
777
778         return __pContextMenuPresenter->ApplyColorProperty();
779 }
780
781 Variant
782 _ContextMenu::GetPropertyNormalItemTextColor(void) const
783 {
784         return Tizen::Ui::Variant(__textColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL]);
785 }
786
787 result
788 _ContextMenu::SetPropertyPressedItemTextColor(const Variant& color)
789 {
790         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = color.ToColor();
791
792         return __pContextMenuPresenter->ApplyColorProperty();
793 }
794
795 Variant
796 _ContextMenu::GetPropertyPressedItemTextColor(void) const
797 {
798         return Tizen::Ui::Variant(__textColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED]);
799 }
800
801 result
802 _ContextMenu::SetPropertyHighlightedItemTextColor(const Variant & color)
803 {
804         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = color.ToColor();
805
806         return __pContextMenuPresenter->ApplyColorProperty();
807 }
808
809 Variant
810 _ContextMenu::GetPropertyHighlightedItemTextColor(void) const
811 {
812         return Tizen::Ui::Variant(__textColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED]);
813 }
814
815 result
816 _ContextMenu::SetTextColor(enum ContextMenuCoreItemStatus status, const Graphics::Color& color)
817 {
818         result r = E_SUCCESS;
819
820         if (status == CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL)
821         {
822                 r = SetProperty("normalItemTextColor", Variant(color));
823         }
824         else if (status == CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED)
825         {
826                 r = SetProperty("pressedItemTextColor", Variant(color));
827         }
828         else
829         {
830                 r = SetProperty("highlightedItemTextColor", Variant(color));
831         }
832
833         return r;
834
835 }
836
837 Color
838 _ContextMenu::GetTextColor(enum ContextMenuCoreItemStatus status) const
839 {
840         Color textColor;
841
842         if (status == CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL)
843         {
844                 Variant color = GetProperty("normalItemTextColor");
845                 textColor = color.ToColor();
846
847         }
848         else if (status == CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED)
849         {
850                 Variant color = GetProperty("pressedItemTextColor");
851                 textColor = color.ToColor();
852
853         }
854         else
855         {
856                 Variant color = GetProperty("highlightedItemTextColor");
857                 textColor = color.ToColor();
858         }
859
860         return textColor;
861 }
862
863 result
864 _ContextMenu::AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener)
865 {
866         result r = E_SUCCESS;
867
868         if (__pActionEvent == null)
869         {
870                 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
871                 SysTryReturn(NID_UI_CTRL, __pActionEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
872                                         "[E_OUT_OF_MEMORY] The memory is insufficient.")
873
874                 r = __pActionEvent->AddListener(listener);
875                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to remove an action event listener.")
876         }
877
878         return r;
879
880 CATCH:
881         delete __pActionEvent;
882         __pActionEvent = null;
883         return r;
884 }
885
886 result
887 _ContextMenu::RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener)
888 {
889         SysTryReturn(NID_UI_CTRL, __pActionEvent != null, E_INVALID_STATE, E_INVALID_STATE,
890                         "[E_INVALID_STATE] The action event instance isn't constructed.")
891
892         result r = E_SUCCESS;
893
894         r = __pActionEvent->RemoveListener(listener);
895         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove an action event listener")
896
897         return r;
898 }
899
900 Tizen::Ui::Controls::_ActionEvent*
901 _ContextMenu::GetActionEvent(void) const
902 {
903         return __pActionEvent;
904 }
905
906 result
907 _ContextMenu::LoadBitmap(void)
908 {
909         Color backgroundColor;
910
911         // Delete old bitmap
912         if (__pBackgroundEffectBitmap != null)
913         {
914                 delete __pBackgroundEffectBitmap;
915                 __pBackgroundEffectBitmap = null;
916         }
917
918         for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++)
919         {
920                 if (__pArrowEffectBitmap[i] != null)
921                 {
922                         delete __pArrowEffectBitmap[i];
923                         __pArrowEffectBitmap[i] = null;
924                 }
925         }
926
927         backgroundColor = GetColor();
928
929
930         result r;
931         r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_EFFECT_UP, BITMAP_PIXEL_FORMAT_ARGB8888,
932                         __pArrowEffectBitmap[CONTEXT_MENU_CORE_DROP_POSITION_UP]);
933         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
934
935         r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_EFFECT_DOWN, BITMAP_PIXEL_FORMAT_ARGB8888,
936                         __pArrowEffectBitmap[CONTEXT_MENU_CORE_DROP_POSITION_DOWN]);
937         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
938
939         r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_EFFECT_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888,
940                         __pArrowEffectBitmap[CONTEXT_MENU_CORE_DROP_POSITION_LEFT]);
941         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
942
943         r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_EFFECT_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888,
944                         __pArrowEffectBitmap[CONTEXT_MENU_CORE_DROP_POSITION_RIGHT]);
945         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
946
947         r = GET_BITMAP_CONFIG_N(CONTEXTMENU::BG_OUTLINE_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundEffectBitmap);
948         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
949
950         r = LoadColorReplacedBitmap(backgroundColor);
951         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
952
953         return r;
954
955 CATCH:
956         delete __pBackgroundEffectBitmap;
957         __pBackgroundEffectBitmap = null;
958
959         for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++)
960         {
961
962                 delete __pArrowEffectBitmap[i];
963                 __pArrowEffectBitmap[i] = null;
964         }
965
966         return r;
967 }
968
969 result
970 _ContextMenu::LoadColorReplacedBitmap(const Tizen::Graphics::Color& color)
971 {
972         Bitmap* ptempNormalBitmap = null;
973
974         // Delete old bitmap
975         if (__pBackgroundNormalBitmap != null)
976         {
977                 delete __pBackgroundNormalBitmap;
978                 __pBackgroundNormalBitmap = null;
979         }
980
981         for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++)
982         {
983                 if (__pArrowNormalBitmap[i] != null)
984                 {
985                         delete __pArrowNormalBitmap[i];
986                         __pArrowNormalBitmap[i] = null;
987                 }
988         }
989
990         result r;
991         r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_NORMAL_UP, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap);
992         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
993         __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_UP] = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap,
994                         Color::GetColor(COLOR_ID_MAGENTA), color);
995         SysTryCatch(NID_UI_CTRL, __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_UP] != null, , GetLastResult(),
996                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
997         delete ptempNormalBitmap;
998         ptempNormalBitmap = null;
999
1000         r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_NORMAL_DOWN, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap);
1001         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
1002         __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_DOWN] = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap,
1003                         Color::GetColor(COLOR_ID_MAGENTA), color);
1004         SysTryCatch(NID_UI_CTRL, __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_DOWN] != null, , GetLastResult(),
1005                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1006         delete ptempNormalBitmap;
1007         ptempNormalBitmap = null;
1008
1009         r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_NORMAL_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap);
1010         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
1011         __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_LEFT] = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap,
1012                         Color::GetColor(COLOR_ID_MAGENTA), color);
1013         SysTryCatch(NID_UI_CTRL, __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_LEFT] != null, , GetLastResult(),
1014                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1015         delete ptempNormalBitmap;
1016         ptempNormalBitmap = null;
1017
1018         r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_NORMAL_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap);
1019         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
1020         __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_RIGHT] = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap,
1021                         Color::GetColor(COLOR_ID_MAGENTA), color);
1022         SysTryCatch(NID_UI_CTRL, __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_RIGHT] != null, , GetLastResult(),
1023                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1024         delete ptempNormalBitmap;
1025         ptempNormalBitmap = null;
1026
1027         r = GET_BITMAP_CONFIG_N(CONTEXTMENU::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap);
1028         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
1029         __pBackgroundNormalBitmap = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
1030         SysTryCatch(NID_UI_CTRL, __pBackgroundNormalBitmap != null, , GetLastResult(), "[%s] Propagating.",
1031                         GetErrorMessage(GetLastResult()));
1032         delete ptempNormalBitmap;
1033
1034         return r;
1035
1036 CATCH:
1037         delete ptempNormalBitmap;
1038
1039         delete __pBackgroundNormalBitmap;
1040         __pBackgroundNormalBitmap = null;
1041
1042         for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++)
1043         {
1044                 delete __pArrowNormalBitmap[i];
1045                 __pArrowNormalBitmap[i] = null;
1046         }
1047
1048         return r;
1049 }
1050
1051 const Bitmap*
1052 _ContextMenu::GetArrowNormalBitmap(ContextMenuCoreDropPosition dropPosition) const
1053 {
1054         if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_INVALID || dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_MAX)
1055         {
1056                 return null;
1057         }
1058
1059         return __pArrowNormalBitmap[dropPosition];
1060 }
1061
1062 const Bitmap*
1063 _ContextMenu::GetArrowEffectBitmap(ContextMenuCoreDropPosition dropPosition) const
1064 {
1065         if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_INVALID || dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_MAX)
1066         {
1067                 return null;
1068         }
1069
1070         return __pArrowEffectBitmap[dropPosition];
1071 }
1072
1073 const Bitmap*
1074 _ContextMenu::GetBackgroundNormalBitmap(void) const
1075 {
1076         return __pBackgroundNormalBitmap;
1077 }
1078
1079 const Bitmap*
1080 _ContextMenu::GetBackgroundEffectBitmap(void) const
1081 {
1082         return __pBackgroundEffectBitmap;
1083 }
1084
1085 enum ContextMenuCoreDropPosition
1086 _ContextMenu::GetDropPosition(void) const
1087 {
1088         return __dropPosition;
1089 }
1090
1091 void
1092 _ContextMenu::AdjustDropPosition(void)
1093 {
1094         FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
1095
1096         if (__align == CONTEXT_MENU_CORE_ALIGN_UP)
1097         {
1098                 __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_UP;
1099         }
1100         else if (__align == CONTEXT_MENU_CORE_ALIGN_DOWN)
1101         {
1102                 __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_DOWN;
1103         }
1104         else if (__align == CONTEXT_MENU_CORE_ALIGN_LEFT)
1105         {
1106                 __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_LEFT;
1107         }
1108         else if (__align == CONTEXT_MENU_CORE_ALIGN_RIGHT)
1109         {
1110                 __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_RIGHT;
1111         }
1112         else
1113         {
1114                 if (__layout == _CONTROL_ORIENTATION_LANDSCAPE)
1115                 {
1116                         screen.SetSize(screen.height, screen.width);
1117                 }
1118
1119                 if (screen.height > screen.width)
1120                 {
1121                         if ((screen.height / 2.0f) > __anchorPoint.y)
1122                         {
1123                                 __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_DOWN;
1124                         }
1125                         else
1126                         {
1127                                 __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_UP;
1128                         }
1129                 }
1130                 else
1131                 {
1132                         if ((screen.width / 2.0f) > __anchorPoint.x)
1133                         {
1134                                 __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_RIGHT;
1135                         }
1136                         else
1137                         {
1138                                 __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_LEFT;
1139                         }
1140                 }
1141         }
1142 }
1143
1144 _UiTouchEventDelivery
1145 _ContextMenu::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1146 {
1147         return __pContextMenuPresenter->OnPreviewTouchPressed(source, touchinfo);
1148 }
1149
1150 bool
1151 _ContextMenu::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1152 {
1153         return __pContextMenuPresenter->OnTouchPressed(source, touchinfo);
1154 }
1155
1156 _UiTouchEventDelivery
1157 _ContextMenu::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1158 {
1159         return __pContextMenuPresenter->OnPreviewTouchMoved(source, touchinfo);
1160 }
1161
1162 bool
1163 _ContextMenu::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1164 {
1165         return __pContextMenuPresenter->OnTouchMoved(source, touchinfo);
1166 }
1167
1168 _UiTouchEventDelivery
1169 _ContextMenu::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1170 {
1171         return __pContextMenuPresenter->OnPreviewTouchReleased(source, touchinfo);
1172 }
1173
1174 bool
1175 _ContextMenu::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1176 {
1177         return __pContextMenuPresenter->OnTouchReleased(source, touchinfo);
1178 }
1179
1180 _UiTouchEventDelivery
1181 _ContextMenu::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1182 {
1183         return __pContextMenuPresenter->OnPreviewTouchCanceled(source, touchinfo);
1184 }
1185
1186 bool
1187 _ContextMenu::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1188 {
1189         __pContextMenuPresenter->OnTouchCanceled(source, touchinfo);
1190
1191         SetVisibleState(false);
1192
1193         return true;
1194 }
1195
1196 void
1197 _ContextMenu::OnFontChanged(Tizen::Graphics::Font* pFont)
1198 {
1199         return __pContextMenuPresenter->OnFontChanged(pFont);
1200 }
1201
1202 void
1203 _ContextMenu::OnFontInfoRequested(unsigned long& style, float& size)
1204 {
1205         return __pContextMenuPresenter->OnFontInfoRequested(style, size);
1206 }
1207
1208 void
1209 _ContextMenu::OnVisibleStateChanged(void)
1210 {
1211         _Window::OnVisibleStateChanged();
1212 }
1213
1214 void
1215 _ContextMenu::OnChangeLayout(_ControlRotation rotation)
1216 {
1217         _ControlOrientation orientation;
1218
1219         orientation = GetOwner()->GetOrientation();
1220
1221         GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, orientation, __showItemMaxCount);
1222
1223         if (__isAttachedToMainTree == true)
1224         {
1225                 if(__rotation != rotation)
1226                 {
1227                         SetVisibleState(false);
1228                 }
1229         }
1230
1231         __layout = orientation;
1232         __rotation =  rotation;
1233 }
1234 void
1235 _ContextMenu::OnOwnerChanged(_Control* pOldOwner)
1236 {
1237         if (!__isAttachedToMainTree)
1238         {
1239                 return;
1240         }
1241
1242         _Control* pOwner = GetOwner();
1243
1244         if (pOldOwner != null)
1245         {
1246                 pOldOwner->UnlockInputEvent();
1247         }
1248
1249         if (pOwner != null)
1250         {
1251                 pOwner->LockInputEvent();
1252         }
1253 }
1254
1255 bool
1256 _ContextMenu::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1257 {
1258         return __pContextMenuPresenter->OnKeyPressed(source, keyInfo);
1259 }
1260
1261 bool
1262 _ContextMenu::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1263 {
1264         return __pContextMenuPresenter->OnKeyReleased(source, keyInfo);
1265 }
1266
1267 bool
1268 _ContextMenu::IsChildControlFocusManage(void) const
1269 {
1270         return __pContextMenuPresenter->IsChildControlFocusManage();
1271 }
1272
1273 void
1274 _ContextMenu::OnDrawFocus(void)
1275 {
1276         __pContextMenuPresenter->OnDrawFocus();
1277 }
1278
1279 void
1280 _ContextMenu::OnFocusModeStateChanged(void)
1281 {
1282         __pContextMenuPresenter->OnFocusModeStateChanged();
1283 }
1284
1285 _AccessibilityElement*
1286 _ContextMenu::GetAccessibilityElement(const int mainIndex) const
1287 {
1288         _AccessibilityElement* pElement = null;
1289         result r = __accessibilityElements.GetAt(mainIndex, pElement);
1290         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed at AccessibilityElement.", GetErrorMessage(r));
1291
1292         return pElement;
1293
1294 CATCH:
1295         delete pElement;
1296
1297         return null;
1298 }
1299
1300 void
1301 _ContextMenu::AddAccessibilityElement(const _AccessibilityElement& element)
1302 {
1303         __accessibilityElements.Add(const_cast<_AccessibilityElement*>(&element));
1304 }
1305
1306 void
1307 _ContextMenu::SetAllAccessibilityElement(void)
1308 {
1309         RemoveAllAccessibilityElement();
1310         __pContextMenuPresenter->SetAllAccessibilityElement();
1311 }
1312
1313 bool
1314 _ContextMenu::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1315 {
1316         return false;
1317 }
1318
1319 bool
1320 _ContextMenu::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1321 {
1322         return false;
1323 }
1324
1325 bool
1326 _ContextMenu::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1327 {
1328         return false;
1329 }
1330
1331 bool
1332 _ContextMenu::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1333 {
1334         return false;
1335 }
1336
1337 bool
1338 _ContextMenu::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1339 {
1340         return false;
1341 }
1342
1343 bool
1344 _ContextMenu::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1345 {
1346         return false;
1347 }
1348
1349 bool
1350 _ContextMenu::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1351 {
1352         SetVisibleState(false);
1353
1354         return true;
1355 }
1356
1357 bool
1358 _ContextMenu::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1359 {
1360         return false;
1361 }
1362
1363 bool
1364 _ContextMenu::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1365 {
1366         return false;
1367 }
1368
1369 void
1370 _ContextMenu::RemoveAllAccessibilityElement(void)
1371 {
1372         _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer();
1373         if (pAccessibilityContainer && pAccessibilityContainer->IsActivated())
1374         {
1375                 pAccessibilityContainer->RemoveAllElement();
1376         }
1377 }
1378
1379 _ContextMenuItemInfo
1380 _ContextMenu::GetItemFromPosition(const FloatPoint& position) const
1381 {
1382         return __pContextMenuPresenter->GetItemFromPosition(position);
1383 }
1384
1385 _ContextMenuItemInfo
1386 _ContextMenu::FindItem(int index) const
1387 {
1388         return __pContextMenuPresenter->FindItem(index);
1389 }
1390
1391 result
1392 _ContextMenu::SetTopDrawnItemIndex(int index)
1393 {
1394         return __pContextMenuPresenter->SetTopDrawnItemIndex(index);
1395 }
1396
1397 _ControlOrientation
1398 _ContextMenu::GetLayout(void) const
1399 {
1400         return __layout;
1401 }
1402
1403 }}} // Tizen::Ui: Control