adb2f857cd7554e64c409f366fa8ad61445eafb8
[platform/framework/native/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 "FUi_KeyEventManager.h"
29 #include "FUiAnim_VisualElement.h"
30 #include "FUiAnim_AnimationManager.h"
31 #include "FUi_AccessibilityContainer.h"
32 #include "FUi_AccessibilityElement.h"
33 #include "FUiCtrl_Form.h"
34 #include "FUiCtrl_Frame.h"
35 #include "FUiCtrl_ContextMenu.h"
36 #include "FUiCtrl_Scroll.h"
37
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Media;
40 using namespace Tizen::Ui::Animations;
41
42 namespace {
43 static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;
44 }
45
46 namespace Tizen { namespace Ui { namespace Controls
47 {
48
49 IMPLEMENT_PROPERTY(_ContextMenu);
50
51 _ContextMenu::_ContextMenu(const FloatPoint& point, enum ContextMenuCoreStyle style, enum ContextMenuCoreAlign contextMenuAlign)
52         : __pContextMenuPresenter(null)
53         , __style(style)
54         , __align(contextMenuAlign)
55         , __showItemCount(MAX_CONTEXTMENU_LIST_SHOW_ITEM)
56         , __showItemMaxCount(0)
57         , __isAttachedToMainTree(false)
58         , __ownerInputEnableState(false)
59         , __anchorPoint(point)
60         , __windowRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
61         , __bodyRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
62         , __arrowRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
63         , __itemRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
64         , __pActionEvent(null)
65         , __pBackgroundNormalBitmap(null)
66         , __pBackgroundEffectBitmap(null)
67         , __dropPosition(CONTEXT_MENU_CORE_DROP_POSITION_INVALID)
68         , __layout(_CONTROL_ORIENTATION_PORTRAIT)
69         , __rotation(_CONTROL_ROTATION_0)
70         , __pScrollPanel(null)
71 {
72         __backgroundColor = Color(255, 255, 255, 255);
73
74         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = Color(255, 255, 255, 255);
75         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = Color(255, 255, 255, 255);
76         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = Color(255, 255, 255, 255);
77
78         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = Color(255, 255, 255, 255);
79         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = Color(255, 255, 255, 255);
80         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = Color(255, 255, 255, 255);
81
82         for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++)
83         {
84                 __pArrowNormalBitmap[i] = null;
85                 __pArrowEffectBitmap[i] = null;
86         }
87
88         GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, __layout, __showItemMaxCount);
89 }
90
91 _ContextMenu::~_ContextMenu(void)
92 {
93         if (__isAttachedToMainTree && GetOwner() != null)
94         {
95                 GetOwner()->UnlockInputEvent();
96         }
97
98         if (__pScrollPanel) {
99                 __pScrollPanel->DetachAllChildren();
100                 DetachChild(*__pScrollPanel);
101                 delete __pScrollPanel;
102                 __pScrollPanel = null;
103         }
104
105         delete __pContextMenuPresenter;
106         __pContextMenuPresenter = null;
107
108         if (__pBackgroundNormalBitmap != null)
109         {
110                 delete __pBackgroundNormalBitmap;
111                 __pBackgroundNormalBitmap = null;
112         }
113
114         if (__pBackgroundEffectBitmap != null)
115         {
116                 delete __pBackgroundEffectBitmap;
117                 __pBackgroundEffectBitmap = null;
118         }
119
120         if (__pActionEvent)
121         {
122                 delete __pActionEvent;
123                 __pActionEvent = null;
124         }
125
126         for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++)
127         {
128                 delete __pArrowNormalBitmap[i];
129                 __pArrowNormalBitmap[i] = null;
130
131                 delete __pArrowEffectBitmap[i];
132                 __pArrowEffectBitmap[i] = null;
133         }
134
135         __actionId.RemoveAll();
136
137         RemoveAllAccessibilityElement();
138 }
139
140 _ContextMenu*
141 _ContextMenu::CreateContextMenuN(const FloatPoint& point, enum ContextMenuCoreStyle style, enum ContextMenuCoreAlign contextMenuAlign)
142 {
143         _ContextMenu* pContextMenu = new (std::nothrow) _ContextMenu(point, style, contextMenuAlign);
144         SysTryReturn(NID_UI_CTRL, pContextMenu != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
145
146         result r = E_SUCCESS;
147
148         r = pContextMenu->CreateRootVisualElement();
149         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
150
151         pContextMenu->SetFocusable(false);
152
153         r = pContextMenu->Initialize();
154         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Initialize.", GetErrorMessage(r));
155
156         r = pContextMenu->Install();
157         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Install.", GetErrorMessage(r));
158
159         pContextMenu->AcquireHandle();
160         pContextMenu->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
161
162         if (pContextMenu->GetAccessibilityContainer() != null)
163         {
164                 pContextMenu->GetAccessibilityContainer()->Activate(true);
165                 pContextMenu->GetAccessibilityContainer()->AddListener(*pContextMenu);
166         }
167
168         if (style == CONTEXT_MENU_CORE_STYLE_LIST)
169         {
170                 float minWidth, minHeight;      // for visible scrollbar when scrollable
171                 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MIN_WIDTH,   _CONTROL_ORIENTATION_PORTRAIT, minWidth);
172                 GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, minHeight);
173                 pContextMenu->__pScrollPanel = _ScrollPanel::CreateScrollPanelN(FloatRectangle(0.0f, 0.0f, minWidth, minHeight), SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, false, false);
174                 pContextMenu->__pScrollPanel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
175                 pContextMenu->__pScrollPanel->SetFocusable(false);
176
177                 _Scroll* pScroll = pContextMenu->__pScrollPanel->GetScrollBar();
178                 SysTryCatch(NID_UI_CTRL, pScroll, , E_INVALID_STATE, "[E_INVALID_STATE] _Scroll isn't constructed");
179                 pScroll->SetContextMenuScrollType(true);
180
181                 pContextMenu->AttachChild(*(pContextMenu->__pScrollPanel));
182         }
183
184         return pContextMenu;
185
186 CATCH:
187         delete pContextMenu;
188
189         return null;
190 }
191
192 _ScrollPanel*
193 _ContextMenu::GetScrollPanel(void)
194 {
195         return __pScrollPanel;
196 }
197
198 result
199 _ContextMenu::Install(void)
200 {
201         result r = E_SUCCESS;
202
203         // load bitmap of a background and arrow
204         r = LoadBitmap();
205         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to load bitmap.");
206
207         r = __actionId.Construct();
208         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to construct arraylist.");
209
210         if (__style == CONTEXT_MENU_CORE_STYLE_LIST)
211         {
212                 _IContextMenuPresenter* pPresenter = new (std::nothrow) _ContextMenuListPresenter(this);
213                 SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
214
215                 SetPresenter(*pPresenter);
216
217                 r = pPresenter->Install();
218         }
219         else
220         {
221                 _IContextMenuPresenter* pPresenter = new (std::nothrow) _ContextMenuGridPresenter(this);
222                 SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
223
224                 SetPresenter(*pPresenter);
225
226                 r = pPresenter->Install();
227         }
228
229         return r;
230 }
231
232 result
233 _ContextMenu::Initialize(void)
234 {
235         FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
236         result r = E_SUCCESS;
237
238         Color backgroundColor;
239         Color backgroundSelectedColor;
240         Color itemTextColor;
241         Color itemTextSelectedColor;
242
243         r = SetBounds(FloatRectangle(0.0f, 0.0f, screen.width, screen.height));
244         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "SetBounds failed.");
245
246         SetMovable(false);
247         SetResizable(false);
248
249         GET_COLOR_CONFIG(CONTEXTMENU::BG_NORMAL, backgroundColor);
250         GET_COLOR_CONFIG(CONTEXTMENU::ITEM_BG_PRESSED, backgroundSelectedColor);
251         GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_NORMAL, itemTextColor);
252         GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_PRESSED, itemTextSelectedColor);
253
254         __backgroundColor = backgroundColor;
255         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = backgroundColor;
256         __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = backgroundSelectedColor;
257         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = itemTextColor;
258         __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = itemTextSelectedColor;
259
260         if (GetVisualElement() != null)
261         {
262                 GetVisualElement()->SetSurfaceOpaque(false);
263         }
264
265         return r;
266
267 }
268
269 result
270 _ContextMenu::SetPresenter(const _IContextMenuPresenter& ContextMenuPresenter)
271 {
272         __pContextMenuPresenter = const_cast <_IContextMenuPresenter*>(&ContextMenuPresenter);
273
274         return E_SUCCESS;
275 }
276
277 void
278 _ContextMenu::OnDraw()
279 {
280         __pContextMenuPresenter->Draw();
281
282         if(unlikely((_AccessibilityManager::IsActivated())))
283         {
284                 _AccessibilityManager::GetInstance()->RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM);
285         }
286 }
287
288 result
289 _ContextMenu::OnAttachedToMainTree(void)
290 {
291         result r = E_SUCCESS;
292
293         __layout = _ControlManager::GetInstance()->GetOrientation();
294         __rotation = _ControlManager::GetInstance()->GetScreenRotation();
295         __isAttachedToMainTree = true;
296         _Control* pOwner = GetOwner();
297         if (pOwner == null)
298         {
299                 _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
300                 SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Current frame instance is not available.");
301
302                 _Form* pForm = pFrame->GetCurrentForm();
303                 pForm != null ? SetOwner(pForm) : SetOwner(pFrame);
304
305                 GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, __layout, __showItemMaxCount);
306         }
307         else
308         {
309                 pOwner->LockInputEvent();
310         }
311
312         AdjustDropPosition();
313
314         if (GetItemCount() <= 0)
315         {
316                 __pContextMenuPresenter->CalculateShowItemCount();
317         }
318
319         r = __pContextMenuPresenter->CalculateWindowRect();
320         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
321
322         if (__pScrollPanel != null)
323         {
324                 __pScrollPanel->SetScrollPosition(0.0f, false);
325         }
326
327         r = Open();
328
329         SetVisibleState(true);
330
331         if (__style == CONTEXT_MENU_CORE_STYLE_LIST)
332         {
333                 SetTouchCapture(false, false);
334         }
335         else
336         {
337                 SetTouchCapture(true, false);
338         }
339
340         SetAllAccessibilityElement();
341
342         _VisualElement* pVisualElement = GetVisualElement();
343         FloatRectangle pBounds = pVisualElement->GetBounds();
344         float oldBoundsX = pBounds.x;
345         float oldBoundsY = pBounds.y;
346         float distanceX = 0.0f;
347         float distanceY = 0.0f;
348
349         GET_SHAPE_CONFIG(CONTEXTMENU::APPEARING_ANIMATION_DISTANCE_X, __layout, distanceX);
350         GET_SHAPE_CONFIG(CONTEXTMENU::APPEARING_ANIMATION_DISTANCE_Y, __layout, distanceY);
351
352         switch(GetDropPosition())
353         {
354         case CONTEXT_MENU_CORE_DROP_POSITION_UP:
355                 pBounds.y += distanceY;
356                 break;
357         case CONTEXT_MENU_CORE_DROP_POSITION_DOWN:
358                 pBounds.y -= distanceY;
359                 break;
360         case CONTEXT_MENU_CORE_DROP_POSITION_LEFT:
361                 pBounds.x += distanceX;
362                 break;
363         case CONTEXT_MENU_CORE_DROP_POSITION_RIGHT:
364                 pBounds.x -= distanceX;
365                 break;
366         default:
367                 break;
368         }
369
370         pVisualElement->SetBounds(pBounds);
371         pVisualElement->SetOpacity(0.0f);
372
373         bool enable = pVisualElement->IsImplicitAnimationEnabled();
374
375         pVisualElement->SetImplicitAnimationEnabled(true);
376
377         pBounds.x = oldBoundsX;
378         pBounds.y = oldBoundsY;
379         pVisualElement->SetBounds(pBounds);
380         pVisualElement->SetOpacity(1.0f);
381
382         pVisualElement->SetImplicitAnimationEnabled(enable);
383
384         return r;
385 }
386
387 result
388 _ContextMenu::OnDetachingFromMainTree(void)
389 {
390         result r = E_SUCCESS;
391
392         ReleaseTouchCapture();
393
394         _Control* pOwner = GetOwner();
395         if (pOwner != null)
396         {
397                 pOwner->UnlockInputEvent();
398         }
399
400         __isAttachedToMainTree = false;
401
402         return r;
403 }
404
405 result
406 _ContextMenu::AddItem(const Base::String& text, int actionId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap,
407                                           const Bitmap* pHighlightedBitmap)
408 {
409         result r = E_SUCCESS;
410
411         r = __pContextMenuPresenter->AddItem(text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
412         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to add a item.");
413
414         __actionId.Add(actionId);
415
416         __pContextMenuPresenter->CalculateShowItemCount();
417         __pContextMenuPresenter->CalculateWindowRect();
418
419         return r;
420 }
421
422 result
423 _ContextMenu::InsertItem(int index, const Base::String& text, int actionId, const Bitmap* pNormalBitmap,
424                                                  const Bitmap* pPressedBitmap,
425                                                  const Bitmap* pHighlightedBitmap)
426 {
427         result r = E_SUCCESS;
428
429         r = __pContextMenuPresenter->InsertItem(index, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
430         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to insert a item.");
431
432         __actionId.InsertAt(actionId, index);
433
434         __pContextMenuPresenter->CalculateShowItemCount();
435         __pContextMenuPresenter->CalculateWindowRect();
436
437         return r;
438 }
439
440 result
441 _ContextMenu::SetItem(int index, const Base::String& text, int actionId, const Bitmap* pNormalBitmap,
442                                           const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
443 {
444         result r = E_SUCCESS;
445
446         r = __pContextMenuPresenter->SetItem(index, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
447         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set a item.");
448
449         __actionId.SetAt(actionId, index);
450
451         __pContextMenuPresenter->CalculateWindowRect();
452
453         return r;
454 }
455
456 result
457 _ContextMenu::RemoveItemAt(int index)
458 {
459         result r = E_SUCCESS;
460
461         r = __pContextMenuPresenter->DeleteItem(index);
462         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove a item.");
463
464         __actionId.RemoveAt(index);
465
466         __pContextMenuPresenter->CalculateShowItemCount();
467         __pContextMenuPresenter->CalculateWindowRect();
468
469         return r;
470 }
471
472 result
473 _ContextMenu::RemoveAllItems(void)
474 {
475         result r = E_SUCCESS;
476
477         r = __pContextMenuPresenter->DeleteItemAll();
478         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove all items.");
479
480         __actionId.RemoveAll();
481
482         __pContextMenuPresenter->CalculateShowItemCount();
483         __pContextMenuPresenter->CalculateWindowRect();
484
485         return r;
486 }
487
488 int
489 _ContextMenu::GetItemCount(void) const
490 {
491         return __actionId.GetCount();
492 }
493
494 int
495 _ContextMenu::GetItemIndexAt(int actionId) const
496 {
497         int count = __actionId.GetCount();
498
499         for (int i = 0; i < count; i++)
500         {
501                 int index = GetItemActionIdAt(i);
502
503                 if (actionId == index)
504                 {
505                         return i;
506                 }
507         }
508
509         return -1;
510 }
511
512 int
513 _ContextMenu::GetItemActionIdAt(int index) const
514 {
515         int count = __actionId.GetCount();
516         int actionId = -1;
517         result r = E_SUCCESS;
518
519         if (count <= 0 || index >= count)
520         {
521                 return -1;
522         }
523
524         r = __actionId.GetAt(index, actionId);
525         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, actionId, r, "[%s] Propagating.", GetErrorMessage(r));
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 _UiTouchEventDelivery
1189 _ContextMenu::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1190 {
1191         return __pContextMenuPresenter->OnPreviewTouchCanceled(source, touchinfo);
1192 }
1193
1194 bool
1195 _ContextMenu::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1196 {
1197         __pContextMenuPresenter->OnTouchCanceled(source, touchinfo);
1198
1199         SetVisibleState(false);
1200
1201         return true;
1202 }
1203
1204 void
1205 _ContextMenu::OnFontChanged(Tizen::Graphics::Font* pFont)
1206 {
1207         return __pContextMenuPresenter->OnFontChanged(pFont);
1208 }
1209
1210 void
1211 _ContextMenu::OnFontInfoRequested(unsigned long& style, float& size)
1212 {
1213         return __pContextMenuPresenter->OnFontInfoRequested(style, size);
1214 }
1215
1216 void
1217 _ContextMenu::OnVisibleStateChanged(void)
1218 {
1219         _Window::OnVisibleStateChanged();
1220 }
1221
1222 void
1223 _ContextMenu::OnChangeLayout(_ControlRotation rotation)
1224 {
1225         _ControlOrientation orientation;
1226
1227         orientation = GetOwner()->GetOrientation();
1228
1229         GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, orientation, __showItemMaxCount);
1230
1231         if (__isAttachedToMainTree == true)
1232         {
1233                 if(__rotation != rotation)
1234                 {
1235                         SetVisibleState(false);
1236                 }
1237         }
1238
1239         __layout = orientation;
1240         __rotation =  rotation;
1241 }
1242 void
1243 _ContextMenu::OnOwnerChanged(_Control* pOldOwner)
1244 {
1245         if (!__isAttachedToMainTree)
1246         {
1247                 return;
1248         }
1249
1250         _Control* pOwner = GetOwner();
1251
1252         if (pOldOwner != null)
1253         {
1254                 pOldOwner->UnlockInputEvent();
1255         }
1256
1257         if (pOwner != null)
1258         {
1259                 pOwner->LockInputEvent();
1260         }
1261 }
1262
1263 void
1264 _ContextMenu::OnTouchCaptureGained(void)
1265 {
1266         if (__style == CONTEXT_MENU_CORE_STYLE_LIST)
1267         {
1268                 SetTouchCapture(false, false);
1269         }
1270         else
1271         {
1272                 SetTouchCapture(true, false);
1273         }
1274 }
1275
1276 void
1277 _ContextMenu::OnTouchCaptureLost(void)
1278 {
1279 }
1280
1281 bool
1282 _ContextMenu::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1283 {
1284         return __pContextMenuPresenter->OnKeyPressed(source, keyInfo);
1285 }
1286
1287 bool
1288 _ContextMenu::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1289 {
1290         return __pContextMenuPresenter->OnKeyReleased(source, keyInfo);
1291 }
1292
1293 bool
1294 _ContextMenu::IsChildControlFocusManage(void) const
1295 {
1296         return __pContextMenuPresenter->IsChildControlFocusManage();
1297 }
1298
1299 void
1300 _ContextMenu::OnDrawFocus(void)
1301 {
1302         __pContextMenuPresenter->OnDrawFocus();
1303 }
1304
1305 void
1306 _ContextMenu::OnFocusModeStateChanged(void)
1307 {
1308         __pContextMenuPresenter->OnFocusModeStateChanged();
1309 }
1310
1311 _AccessibilityElement*
1312 _ContextMenu::GetAccessibilityElement(const int mainIndex) const
1313 {
1314         _AccessibilityElement* pElement = null;
1315         result r = __accessibilityElements.GetAt(mainIndex, pElement);
1316         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed at AccessibilityElement.", GetErrorMessage(r));
1317
1318         return pElement;
1319
1320 CATCH:
1321         delete pElement;
1322
1323         return null;
1324 }
1325
1326 void
1327 _ContextMenu::AddAccessibilityElement(const _AccessibilityElement& element)
1328 {
1329         __accessibilityElements.Add(const_cast<_AccessibilityElement*>(&element));
1330 }
1331
1332 void
1333 _ContextMenu::SetAllAccessibilityElement(void)
1334 {
1335         RemoveAllAccessibilityElement();
1336         __pContextMenuPresenter->SetAllAccessibilityElement();
1337 }
1338
1339 bool
1340 _ContextMenu::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1341 {
1342         return false;
1343 }
1344
1345 bool
1346 _ContextMenu::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1347 {
1348         return false;
1349 }
1350
1351 bool
1352 _ContextMenu::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1353 {
1354         return false;
1355 }
1356
1357 bool
1358 _ContextMenu::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1359 {
1360         return false;
1361 }
1362
1363 bool
1364 _ContextMenu::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1365 {
1366         return false;
1367 }
1368
1369 bool
1370 _ContextMenu::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1371 {
1372         return false;
1373 }
1374
1375 bool
1376 _ContextMenu::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1377 {
1378         SetVisibleState(false);
1379
1380         return true;
1381 }
1382
1383 bool
1384 _ContextMenu::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1385 {
1386         return false;
1387 }
1388
1389 bool
1390 _ContextMenu::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1391 {
1392         return false;
1393 }
1394
1395 void
1396 _ContextMenu::RemoveAllAccessibilityElement(void)
1397 {
1398         _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer();
1399         if (pAccessibilityContainer && pAccessibilityContainer->IsActivated())
1400         {
1401                 pAccessibilityContainer->RemoveAllElement();
1402         }
1403 }
1404
1405 _ContextMenuItemInfo
1406 _ContextMenu::GetItemFromPosition(const FloatPoint& position) const
1407 {
1408         return __pContextMenuPresenter->GetItemFromPosition(position);
1409 }
1410
1411 _ContextMenuItemInfo
1412 _ContextMenu::FindItem(int index) const
1413 {
1414         return __pContextMenuPresenter->FindItem(index);
1415 }
1416
1417 result
1418 _ContextMenu::SetTopDrawnItemIndex(int index)
1419 {
1420         return __pContextMenuPresenter->SetTopDrawnItemIndex(index);
1421 }
1422
1423 _ControlOrientation
1424 _ContextMenu::GetLayout(void) const
1425 {
1426         return __layout;
1427 }
1428
1429 }}} // Tizen::Ui: Control