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