Add event listener regarding option button.
authorKeuckdo Bang <keuckdo.bang@samsung.net>
Thu, 30 May 2013 14:46:24 +0000 (23:46 +0900)
committerKeuckdo Bang <keuckdo.bang@samsung.net>
Thu, 30 May 2013 14:46:24 +0000 (23:46 +0900)
Change-Id: Iceb56978824ca1cb9f3d6bd3d851a0162d40ffe9

18 files changed:
inc/FUiControls.h
inc/FUiCtrlForm.h
inc/FUiCtrlIFormControlEventListener.h [new file with mode: 0644]
inc/FUiCtrlOptionMenu.h
src/ui/CMakeLists.txt
src/ui/controls/FUiCtrlForm.cpp
src/ui/controls/FUiCtrlOptionMenu.cpp
src/ui/controls/FUiCtrl_ContextMenu.cpp
src/ui/controls/FUiCtrl_Form.cpp
src/ui/controls/FUiCtrl_FormImpl.cpp
src/ui/controls/FUiCtrl_OptionMenuImpl.cpp
src/ui/controls/FUiCtrl_OptionMenuListPresenter.cpp [new file with mode: 0644]
src/ui/inc/FUiCtrl_ContextMenu.h
src/ui/inc/FUiCtrl_Form.h
src/ui/inc/FUiCtrl_FormImpl.h
src/ui/inc/FUiCtrl_IFormControlEventListener.h [new file with mode: 0644]
src/ui/inc/FUiCtrl_OptionMenuImpl.h
src/ui/inc/FUiCtrl_OptionMenuListPresenter.h [new file with mode: 0644]

index 6adbd6b..a8e0447 100644 (file)
@@ -75,6 +75,7 @@
 #include <FUiCtrlIExpandableEditAreaEventListener.h>
 #include <FUiCtrlIFastScrollListener.h>
 #include <FUiCtrlIFormBackEventListener.h>
+#include <FUiCtrlIFormControlEventListener.h>
 #include <FUiCtrlIFrameEventListener.h>
 #include <FUiCtrlIGalleryEventListener.h>
 #include <FUiCtrlIGalleryItemProvider.h>
index 9c5d1a9..17a39da 100644 (file)
@@ -44,6 +44,7 @@ class Header;
 class Footer;
 class Tab;
 class IFormBackEventListener;
+class IFormControlEventListener;
 
 /**
  * @enum FormStyle
@@ -1044,6 +1045,17 @@ public:
 
 
        /**
+     * Sets the %Form control event listener.
+        *
+        * @since       2.1
+        *
+     * @param[in]      pFormControlEventListener               The %Form control event listener to set
+        * @see         Tizen::Ui::Controls::IFormControlEventListener.
+        */
+       void SetFormControlEventListener(IFormControlEventListener* pFormControlEventListener);
+
+
+       /**
         * Gets the data binding context.
         *
         * @since 2.0
diff --git a/inc/FUiCtrlIFormControlEventListener.h b/inc/FUiCtrlIFormControlEventListener.h
new file mode 100644 (file)
index 0000000..164f27b
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FUiCtrlIFormControlventListener.h
+ * @brief              This is the header file for the %IFormControlventListener interface.
+ *
+ * This header file contains the declarations of the %IFormControlventListener interface.
+ */
+#ifndef _FUI_CTRL_IFORM_CONTROL_EVENT_LISTENER_H_
+#define _FUI_CTRL_IFORM_CONTROL_EVENT_LISTENER_H_
+
+// includes
+#include <FBaseRtIEventListener.h>
+
+// namespace declaration
+namespace Tizen { namespace Ui { namespace Controls
+{
+
+class Form;
+
+/**
+ * @interface  IFormControlEventListener
+ * @brief              This interface implements the listener for Form-related events.
+ *
+ * @since              2.0
+ *
+ * The %IFormControlEventListener interface is the listener interface for receiving Form-related events.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_form.htm">Form</a>.
+ */
+class IFormControlEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+// Lifecycle
+public:
+       /**
+        * This is the destructor for this class.
+        *
+        * @since       2.0
+        */
+       virtual ~IFormControlEventListener(void) {}
+
+// Operation
+public:
+       /**
+        * Called when the current Form control needs to be closed to revert back to the previous %Form control.
+        *
+        * @since       2.1
+        *
+        * @param[in]   source          The source of the event
+        * @remarks             This event is fired when the user clicks on the software 'back' button on the Footer control, or the hardware back button on the
+        *                              device.
+        */
+       virtual void OnFormBackButtonRequested(Tizen::Ui::Controls::Form& source) = 0;
+
+       virtual void OnFormOptionButtonRequested(Tizen::Ui::Controls::Form& source) = 0;
+
+// Reserves
+protected:
+       //
+       //This method is for internal use only. Using this method can cause behavioral, security-related,
+       //and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void IFormControlEventListener_Reserved1(void) { }
+
+       //
+       //This method is for internal use only. Using this method can cause behavioral, security-related,
+       //and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void IFormControlEventListener_Reserved2(void) { }
+
+       //
+       //This method is for internal use only. Using this method can cause behavioral, security-related,
+       //and consistency-related issues in the application.
+       //
+       // This method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void IFormControlEventListener_Reserved3(void) { }
+}; // IFormControlEventListener
+
+}}} // Tizen::Ui::Controls
+
+#endif // _FUI_CTRL_IFORM_CONTROL_EVENT_LISTENER_H_
index 4fcd115..87a3a83 100644 (file)
@@ -246,6 +246,8 @@ public:
         */
        result AddItem(const Tizen::Base::String& text, int actionId);
 
+       result AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId);\r
+       result AddItem(const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap=null, const Tizen::Graphics::Bitmap* pHighlightedBitmap=null);\r
        /**
         * @if OSPDEPREC
         * Inserts a specific item at the given index of %OptionMenu.
index 4d67243..691cda9 100644 (file)
@@ -386,6 +386,7 @@ SET (${this_target}_SOURCE_FILES
        controls/FUiCtrl_OptionMenu.cpp
        controls/FUiCtrl_OptionMenuModel.cpp
        controls/FUiCtrl_OptionMenuPresenter.cpp
+       controls/FUiCtrl_OptionMenuListPresenter.cpp\r
        controls/FUiCtrl_OptionMenuItem.cpp
        controls/FUiCtrl_Panel.cpp
        controls/FUiCtrl_PanelPresenter.cpp
index bdcffe9..d2be91d 100644 (file)
@@ -668,6 +668,16 @@ Form::SetFormBackEventListener(IFormBackEventListener* pFormBackEventListener)
        return pImpl->SetFormBackEventListener(pFormBackEventListener);
 }
 
+void
+Form::SetFormControlEventListener(IFormControlEventListener* pFormControlEventListener)
+{
+       _FormImpl* pImpl = _FormImpl::GetInstance(*this);
+       SysAssertf(pImpl != null,
+                               "Not yet constructed. Construct() should be called before use.");
+
+       return pImpl->SetFormControlEventListener(pFormControlEventListener);
+}
+
 DataBindingContext*
 Form::GetDataBindingContextN(void) const
 {
index 36a5467..22ff111 100644 (file)
@@ -24,6 +24,7 @@
 #include <FBaseSysLog.h>
 
 #include "FUiCtrl_OptionMenuImpl.h"
+#include "FUiCtrl_ContextMenuImpl.h"\r
 
 using namespace Tizen::Base;
 
@@ -92,6 +93,33 @@ OptionMenu::AddItem(const String& text, int actionId)
        SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return r;
+}\r
+result\r
+OptionMenu::AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId)\r
+{\r
+    ClearLastResult();\r
+\r
+    _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);\r
+    SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");\r
+\r
+    result r = pOptionMenuImpl->AddItem(normalBitmap, pPressedBitmap, pHighlightedBitmap, actionId);\r
+    SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+    return r;\r
+}\r
+\r
+result\r
+OptionMenu::AddItem(const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
+{\r
+    ClearLastResult();\r
+\r
+    _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);\r
+    SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");\r
+\r
+    result r = pOptionMenuImpl->AddItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
+    SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+    return r;\r
 }
 
 result
index f763947..459b26f 100644 (file)
@@ -82,8 +82,6 @@ _ContextMenu::_ContextMenu(const FloatPoint& point, enum ContextMenuCoreStyle st
                __pArrowNormalBitmap[i] = null;
                __pArrowEffectBitmap[i] = null;
        }
-
-       GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, __layout, __showItemMaxCount);
 }
 
 _ContextMenu::~_ContextMenu(void)
@@ -206,12 +204,24 @@ _ContextMenu::Install(void)
 
        if (__style == CONTEXT_MENU_CORE_STYLE_LIST)
        {
-               _IContextMenuPresenter* pPresenter = new (std::nothrow) _ContextMenuListPresenter(this);
-               SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
-
-               SetPresenter(*pPresenter);
-
-               r = pPresenter->Install();
+           if (__anchorPoint.Equals(FloatPoint(-1.0f ,-1.0f)))\r
+           {\r
+                       _IContextMenuPresenter* pPresenter = new (std::nothrow) _OptionMenuListPresenter(this);\r
+                       SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");\r
+\r
+                       SetPresenter(*pPresenter);\r
+\r
+                       r = pPresenter->Install();\r
+           }\r
+           else\r
+           {\r
+                       _IContextMenuPresenter* pPresenter = new (std::nothrow) _ContextMenuListPresenter(this);
+                       SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+                       SetPresenter(*pPresenter);
+
+                       r = pPresenter->Install();
+           }\r
        }
        else
        {
@@ -312,8 +322,7 @@ _ContextMenu::OnAttachedToMainTree(void)
                __pContextMenuPresenter->CalculateShowItemCount();
        }
 
-       r = __pContextMenuPresenter->CalculateWindowRect();
-       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       __pContextMenuPresenter->CalculateWindowRect();
 
        r = Open();
 
index 9523859..52702da 100644 (file)
@@ -64,6 +64,7 @@ namespace Tizen { namespace Ui { namespace Controls
 _Form::_Form(void)
        : __pFormPresenter(null)
        , __pFormBackEventListener(null)
+       , __pFormControlEventListener(null)
        , __formStyle(0)
        , __pActionEvent(null)
        , __pHeader(null)
@@ -350,6 +351,19 @@ _Form::SetFormBackEventListener(_IFormBackEventListener* pFormBackEventListener)
        SetLastResult(E_SUCCESS);
 }
 
+void
+_Form::SetFormControlEventListener(_IFormControlEventListener* pFormControlEventListener)
+{
+       SysTryReturnVoidResult(NID_UI_CTRL, __pFooter, E_INVALID_STATE, "[E_INVALID_STATE] Footer and Header aren't constructed.");
+       __pFormControlEventListener = pFormControlEventListener;
+       if (__pFooter)
+       {
+               __pFooter->SetOptionEventListener(*this, ID_OPTION_BUTTON);
+       }
+
+       SetLastResult(E_SUCCESS);
+}
+
 unsigned long
 _Form::GetFormStyle(void) const
 {
@@ -2536,7 +2550,7 @@ _Form::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
 bool
 _Form::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
 {
-       if (keyInfo.GetKeyCode() == _KEY_ESC)
+       if (keyInfo.GetKeyCode() == _KEY_ESC || keyInfo.GetKeyCode() == _KEY_CLEAR)
        {
                _Toolbar* pToolbar = GetFooter();
                if (pToolbar == null)
@@ -2551,6 +2565,27 @@ _Form::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
                        {
                                _FormImpl* pDataImpl = static_cast<_FormImpl*>(pData);
                                pDataImpl->OnFormBackRequested(*this);
+                               pDataImpl->OnFormBackButtonRequested(*this);
+                       }
+               }
+
+               return true;
+       }
+       if (keyInfo.GetKeyCode() == _KEY_CONTEXT_MENU)
+       {
+               _Toolbar* pToolbar = GetFooter();
+               if (pToolbar == null)
+               {
+                       return null;
+               }
+
+               if (pToolbar->IsButtonSet(OPTION_BUTTON))
+               {
+                       void* pData = GetUserData();
+                       if (pData)
+                       {
+                               _FormImpl* pDataImpl = static_cast<_FormImpl*>(pData);
+                               pDataImpl->OnFormOptionButtonRequested(*this);
                        }
                }
 
@@ -2704,6 +2739,10 @@ _Form::OnActionPerformed(const _Control& source, int actionId)
                        {
                                __pFormBackEventListener->OnFormBackRequested(*this);
                        }
+                       if (__pFormControlEventListener)
+                       {
+                               __pFormControlEventListener->OnFormBackButtonRequested(*this);
+                       }
                }
                else
                {
@@ -2719,6 +2758,12 @@ _Form::OnActionPerformed(const _Control& source, int actionId)
                        }
                }
                break;
+       case ID_OPTION_BUTTON :
+               if (__pFormControlEventListener)
+               {
+                       __pFormControlEventListener->OnFormOptionButtonRequested(*this);
+               }
+               break;
 
        default:
                break;
index db0fdb3..aa4a0e9 100644 (file)
@@ -100,6 +100,7 @@ _FormImpl::_FormImpl(Form* pPublic, _Form* pCore, Layout* pPublicPortraitLayout,
        : _ContainerImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout)
        , __pForm(null)
        , __pFormBackEventListener(null)
+       , __pFormControlEventListener(null)
        , __pOriAgent(null)
        , __pImeOriAgent(null)
        , __pLeftSoftkeyActionEvent(null)
@@ -845,6 +846,16 @@ _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEvent
 }
 
 void
+_FormImpl::SetFormControlEventListener(const IFormControlEventListener* pFormControlEventListener)
+{
+       SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
+       __pFormControlEventListener = const_cast <IFormControlEventListener*>(pFormControlEventListener);
+       GetCore().SetFormBackEventListener(this);
+       result r = GetLastResult();
+       SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+}
+
+void
 _FormImpl::AddOrientationEventListener(IOrientationEventListener& listener)
 {
        if (__pOriAgent)
@@ -1614,6 +1625,42 @@ _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
        }
 }
 
+void
+_FormImpl::OnFormBackButtonRequested(Tizen::Ui::Controls::_Form& source)
+{
+       if (__pFormControlEventListener)
+       {
+               _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
+               Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
+               if (pForm)
+               {
+                       __pFormControlEventListener->OnFormBackButtonRequested(*pForm);
+               }
+               else
+               {
+                       return;
+               }
+       }
+}
+
+void
+_FormImpl::OnFormOptionButtonRequested(Tizen::Ui::Controls::_Form& source)
+{
+       if (__pFormControlEventListener)
+       {
+               _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
+               Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
+               if (pForm)
+               {
+                       __pFormControlEventListener->OnFormOptionButtonRequested(*pForm);
+               }
+               else
+               {
+                       return;
+               }
+       }
+}
+
 OrientationStatus
 _FormImpl::OnFormOrientationStatusRequested(void)
 {
index 3157d0c..80760a7 100644 (file)
@@ -30,6 +30,8 @@ using namespace Tizen::Base;
 using namespace Tizen::Base::Runtime;
 using namespace Tizen::Ui;
 
+const int MAX_ITEM_COUNT = 7;\r
+\r
 namespace Tizen { namespace Ui { namespace Controls
 {
 
@@ -45,7 +47,7 @@ _OptionMenuImpl::GetInstance(const OptionMenu& optionMenu)
        return static_cast<const _OptionMenuImpl*>(optionMenu._pControlImpl);
 }
 
-_OptionMenuImpl::_OptionMenuImpl(OptionMenu* pPublic, _OptionMenu* pCore)
+_OptionMenuImpl::_OptionMenuImpl(OptionMenu* pPublic, _ContextMenu* pCore)\r
        : _WindowImpl(pPublic, pCore)
        , __pPublicActionEvent(null)
 {
@@ -56,9 +58,10 @@ _OptionMenuImpl::CreateOptionMenuImplN(OptionMenu& control)
 {
        ClearLastResult();
 
-       _OptionMenu* pCore = _OptionMenu::CreateOptionMenuN();
+       _ContextMenu* pCore = _ContextMenu::CreateContextMenuN(Tizen::Graphics::FloatPoint(-1,-1),CONTEXT_MENU_CORE_STYLE_LIST, CONTEXT_MENU_CORE_ALIGN_UP);\r
        result r = GetLastResult();
        SysTryReturn(NID_UI_CTRL, (pCore != null), null, r, "[%s] Propagating.", GetErrorMessage(r));
+       pCore->SetShowItemCount(MAX_ITEM_COUNT);\r
 
        _OptionMenuImpl* pImpl = new (std::nothrow) _OptionMenuImpl(&control, pCore);
        r = CheckConstruction(pCore, pImpl);
@@ -109,8 +112,24 @@ _OptionMenuImpl::AddItem(const String& text, int actionId)
 {
        ClearLastResult();
 
-       return GetCore().AddItem(text, actionId);
+       return GetCore().AddItem(text, actionId, null, null ,null);\r
 }
+result\r
+_OptionMenuImpl::AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId)\r
+{\r
+    ClearLastResult();\r
+\r
+    return GetCore().AddItem(L" ", actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
+}\r
+\r
+result\r
+_OptionMenuImpl::AddItem(const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
+{\r
+    ClearLastResult();\r
+\r
+    return GetCore().AddItem(text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
+}\r
+\r
 
 result
 _OptionMenuImpl::InsertItemAt(int mainIndex, const String& text, int actionId)
@@ -119,7 +138,7 @@ _OptionMenuImpl::InsertItemAt(int mainIndex, const String& text, int actionId)
        SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                                "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex);
 
-       return GetCore().InsertItemAt(mainIndex, text, actionId);
+       return GetCore().InsertItem(mainIndex, text, actionId, null, null, null);\r
 }
 
 result
@@ -129,7 +148,7 @@ _OptionMenuImpl::SetItemAt(int mainIndex, const String& text, int actionId)
        SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                                "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex);
 
-       return GetCore().SetItemAt(mainIndex, text, actionId);
+       return GetCore().SetItem(mainIndex, text, actionId, null, null, null);\r
 }
 
 result
@@ -155,7 +174,7 @@ _OptionMenuImpl::GetItemIndexFromActionId(int actionId) const
 {
        ClearLastResult();
 
-       return GetCore().GetItemIndexFromActionId(actionId);
+       return 0;//GetCore().GetItemIndexFromActionId(actionId);\r
 }
 
 int
@@ -175,7 +194,7 @@ _OptionMenuImpl::AddSubItem(int mainIndex, const String& text, int actionId)
        SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                                "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex);
 
-       return GetCore().AddSubItem(mainIndex, text, actionId);
+       return E_SUCCESS;//GetCore().AddSubItem(mainIndex, text, actionId);\r
 }
 
 result
@@ -187,7 +206,7 @@ _OptionMenuImpl::InsertSubItemAt(int mainIndex, int subIndex, const String& text
        SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                                "[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex);
 
-       return GetCore().InsertSubItemAt(mainIndex, subIndex, text, actionId);
+       return E_SUCCESS;//GetCore().InsertSubItemAt(mainIndex, subIndex, text, actionId);\r
 }
 
 result
@@ -199,7 +218,7 @@ _OptionMenuImpl::SetSubItemAt(int mainIndex, int subIndex, const String& text, i
        SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                                "[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex);
 
-       return GetCore().SetSubItemAt(mainIndex, subIndex, text, actionId);
+       return E_SUCCESS;//GetCore().SetSubItemAt(mainIndex, subIndex, text, actionId);\r
 }
 
 result
@@ -211,7 +230,7 @@ _OptionMenuImpl::RemoveSubItemAt(int mainIndex, int subIndex)
        SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                                "[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex);
 
-       return GetCore().RemoveSubItemAt(mainIndex, subIndex);
+       return E_SUCCESS;//GetCore().RemoveSubItemAt(mainIndex, subIndex);\r
 }
 
 int
@@ -221,7 +240,7 @@ _OptionMenuImpl::GetSubItemCount(int mainIndex) const
        SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                                "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex);
 
-       return GetCore().GetSubItemCount(mainIndex);
+       return 0;//GetCore().GetSubItemCount(mainIndex);\r
 }
 
 int
@@ -229,7 +248,7 @@ _OptionMenuImpl::GetSubItemIndexFromActionId(int actionId) const
 {
        ClearLastResult();
 
-       return GetCore().GetSubItemIndexFromActionId(actionId);
+       return 0;//GetCore().GetSubItemIndexFromActionId(actionId);\r
 }
 
 int
@@ -241,7 +260,7 @@ _OptionMenuImpl::GetSubItemActionIdAt(int mainIndex, int subIndex) const
        SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
                                "[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex);
 
-       return GetCore().GetSubItemActionIdAt(mainIndex, subIndex);
+       return 0;//GetCore().GetSubItemActionIdAt(mainIndex, subIndex);\r
 }
 
 result
@@ -272,16 +291,16 @@ _OptionMenuImpl::GetPublic(void)
        return static_cast <OptionMenu&>(_ControlImpl::GetPublic());
 }
 
-const _OptionMenu&
+const _ContextMenu&\r
 _OptionMenuImpl::GetCore(void) const
 {
-       return static_cast <const _OptionMenu&>(_ControlImpl::GetCore());
+       return static_cast <const _ContextMenu&>(_ControlImpl::GetCore());\r
 }
 
-_OptionMenu&
+_ContextMenu&\r
 _OptionMenuImpl::GetCore(void)
 {
-       return static_cast <_OptionMenu&>(_ControlImpl::GetCore());
+       return static_cast <_ContextMenu&>(_ControlImpl::GetCore());\r
 }
 
 void
diff --git a/src/ui/controls/FUiCtrl_OptionMenuListPresenter.cpp b/src/ui/controls/FUiCtrl_OptionMenuListPresenter.cpp
new file mode 100644 (file)
index 0000000..855f92b
--- /dev/null
@@ -0,0 +1,941 @@
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//     http://www.apache.org/licenses/LICENSE-2.0/\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @file               FUiCtrl_OptionMenuListPresenter.cpp\r
+ * @brief              This is the implementation file for the _OptionMenuListPresenter class.\r
+ */\r
+\r
+#include <FBaseErrorDefine.h>\r
+#include <FBaseSysLog.h>\r
+#include <FGrp_BitmapImpl.h>\r
+#include <FGrp_CanvasImpl.h>\r
+#include <FGrp_TextTextSimple.h>\r
+#include "FUi_AccessibilityContainer.h"\r
+#include "FUi_AccessibilityElement.h"\r
+#include "FUi_CoordinateSystemUtils.h"\r
+#include "FUi_Math.h"\r
+#include "FUi_ResourceManager.h"\r
+#include "FUiCtrl_ActionEvent.h"\r
+#include "FUiCtrl_IActionEventListener.h"\r
+\r
+#include "FUiCtrl_OptionMenuListPresenter.h"\r
+\r
+using namespace Tizen::Graphics;\r
+using namespace Tizen::Ui;\r
+using namespace Tizen::Base;\r
+using namespace Tizen::Base::Runtime;\r
+using namespace Tizen::Graphics::_Text;\r
+\r
+const int MAX_MAIN_ITEM_COUNT = 12;\r
+\r
+namespace {\r
+static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;\r
+static const int CONTEXT_MENU_LIST_ELEMENT_TEXT = 0;\r
+static const int CONTEXT_MENU_LIST_ELEMENT_BITMAP = 1;\r
+}\r
+\r
+namespace Tizen { namespace Ui { namespace Controls\r
+{\r
+\r
+_OptionMenuListPresenter::_OptionMenuListPresenter(_ContextMenu* pContextMenu)\r
+       : __pContextMenu(pContextMenu)\r
+       , __pModel(null)\r
+       , __pFont(null)\r
+       , __layoutSize(FloatDimension(0.0f, 0.0f))\r
+       , __touchOutRect(false)\r
+       , __selectedIndex(-1)\r
+       , __scrollEnable(false)\r
+       , __maxWidth(0.0f)\r
+       , __minWidth(0.0f)\r
+       , __topMargin(0.0f)\r
+       , __bottomMargin(0.0f)\r
+       , __leftMargin(0.0f)\r
+       , __rightMargin(0.0f)\r
+       , __screenTopMargin(0.0f)\r
+       , __screenBottomMargin(0.0f)\r
+       , __screenLeftMargin(0.0f)\r
+       , __screenRightMargin(0.0f)\r
+       , __arrowTopMargin(0.0f)\r
+       , __arrowBottomMargin(0.0f)\r
+       , __arrowRightMargin(0.0f)\r
+       , __arrowLeftMargin(0.0f)\r
+       , __arrowWidth(0.0f)\r
+       , __arrowHeight(0.0f)\r
+       , __itemWidth(0.0f)\r
+       , __itemMinWidth(0.0f)\r
+       , __itemHeight(0.0f)\r
+       , __itemMaxWidth(0.0f)\r
+       , __itemGap(0.0f)\r
+       , __itemBitmapWidth(0.0f)\r
+       , __itemBitmapHeight(0.0f)\r
+       , __itemFontSize(0.0f)\r
+       , __dividerHeight(0.0f)\r
+       , __anchorPopupOverlap(0.0f)\r
+{\r
+\r
+}\r
+\r
+_OptionMenuListPresenter::~_OptionMenuListPresenter(void)\r
+{\r
+       __pContextMenu = null;\r
+\r
+       delete __pModel;\r
+       __pModel = null;\r
+\r
+       __pFont = null;\r
+\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::Install(void)\r
+{\r
+       result r = E_SUCCESS;\r
+\r
+       LoadShape();\r
+\r
+       __pModel = new (std::nothrow) _ContextMenuModel;\r
+       SysTryCatch(NID_UI_CTRL, __pModel != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");\r
+\r
+       r = __pModel->Construct();\r
+       SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create data instance.");\r
+\r
+       __pFont = __pContextMenu->GetFallbackFont();\r
+       r = GetLastResult();\r
+       SysTryCatch(NID_UI_CTRL, (__pFont != null), , r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+       return r;\r
+\r
+CATCH:\r
+       delete __pModel;\r
+       __pModel = null;\r
+\r
+       __pFont = null;\r
+\r
+       return r;\r
+}\r
+\r
+\r
+void\r
+_OptionMenuListPresenter::LoadShape(void)\r
+{\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MIN_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMinWidth);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MAX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMaxWidth);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemHeight);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_GAP, _CONTROL_ORIENTATION_PORTRAIT, __itemGap);\r
+\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __topMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __bottomMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __leftMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __rightMargin);\r
+\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenTopMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenBottomMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenLeftMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenRightMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowTopMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowBottomMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowLeftMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowRightMargin);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __arrowWidth);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __arrowHeight);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ICON_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapWidth);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ICON_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapHeight);\r
+\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __itemFontSize);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::LIST_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __dividerHeight);\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_POPUP_OVERLAP, _CONTROL_ORIENTATION_PORTRAIT, __anchorPopupOverlap);\r
+\r
+       __itemWidth = __itemMinWidth;\r
+}\r
+\r
+_ContextMenuItem*\r
+_OptionMenuListPresenter::CreateItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
+{\r
+       _ContextMenuItem* pItem = _ContextMenuItem::CreateContextMenuItemN();\r
+       SysTryReturn(NID_UI_CTRL, pItem != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");\r
+\r
+       ContextMenuItemDrawingType itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_TEXT;\r
+       _Label* pLabel = null;\r
+       result r = E_SUCCESS;\r
+\r
+       if (pNormalBitmap != null)\r
+       {\r
+               r = pItem->SetBitmap(CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL, pNormalBitmap);\r
+               if (r != E_SUCCESS)\r
+               {\r
+                       delete pItem;\r
+                       return null;\r
+               }\r
+\r
+               // add bitmap label\r
+               pLabel = _Label::CreateLabelN();\r
+               pLabel->SetBackgroundBitmap(*pNormalBitmap);\r
+               pLabel->SetBackgroundColor(Color(0, 0, 0, 0));\r
+\r
+               int bitmapY = (__itemHeight - __itemBitmapHeight ) / 2;\r
+               pLabel->SetBounds(FloatRectangle(__leftMargin, bitmapY,  __itemBitmapWidth, __itemBitmapHeight));\r
+               pLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);\r
+               pItem->AttachChild(*pLabel);\r
+               _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer();\r
+               if (pContainer)\r
+               {\r
+                       pContainer->Activate(false);\r
+               }\r
+               pItem->SetBitmapLabel(pLabel);\r
+\r
+               itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP;\r
+       }\r
+\r
+       if (pPressedBitmap != null)\r
+       {\r
+               r = pItem->SetBitmap(CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED, pPressedBitmap);\r
+               if (r != E_SUCCESS)\r
+               {\r
+                       delete pItem;\r
+                       return null;\r
+               }\r
+       }\r
+\r
+       pItem->SetType(itemType);\r
+       pItem->SetActionId(actionId);\r
+\r
+       pItem->SetTextSize(__itemFontSize);\r
+       r = pItem->SetText(text);\r
+       if (r != E_SUCCESS)\r
+       {\r
+               delete pItem;\r
+               return null;\r
+       }\r
+\r
+       // calculate item size\r
+       float bitmapWidth = (itemType == CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP) ? __itemBitmapWidth : 0.0f;\r
+\r
+       FloatDimension textArea(0.0f, 0.0f);\r
+       FloatDimension itemSize(0.0f, 0.0f);\r
+\r
+       __pFont->GetTextExtent(text, text.GetLength(), textArea);\r
+       float labelLeftMargin = 0.0f, labelTopMargin = 0.0f;\r
+       GET_SHAPE_CONFIG(LABEL::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, labelLeftMargin);\r
+       GET_SHAPE_CONFIG(LABEL::TOP_MARGIN,  _CONTROL_ORIENTATION_PORTRAIT, labelTopMargin);\r
+       textArea.width  += 2.0f * labelLeftMargin;\r
+       textArea.height += 2.0f * labelTopMargin;\r
+       itemSize.height = __itemHeight + (__dividerHeight * 2.0f);\r
+       itemSize.width =  __leftMargin + textArea.width + __rightMargin + bitmapWidth;\r
+\r
+       itemSize.width = itemSize.width < __itemMinWidth ? __itemMinWidth : itemSize.width;\r
+\r
+       if (itemSize.width > __itemMaxWidth)\r
+       {\r
+               textArea.width -= itemSize.width - __itemMaxWidth;\r
+               itemSize.width = __itemMaxWidth;\r
+       }\r
+\r
+       pItem->SetSize(itemSize);\r
+\r
+       // add text label\r
+       float textLabelX = __leftMargin + bitmapWidth;\r
+\r
+       pLabel = _Label::CreateLabelN();\r
+       pLabel->SetText(text);\r
+       ContextMenuCoreItemStatus itemStatus = CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL;\r
+       pLabel->SetTextColor(__pContextMenu->GetTextColor(itemStatus));\r
+       pLabel->SetBackgroundColor(Color(0, 0, 0, 0));\r
+\r
+       itemSize = pItem->GetSize();\r
+       pLabel->SetBounds(FloatRectangle(textLabelX, (itemSize.height - textArea.height) / 2.0f, textArea.width, textArea.height));\r
+       pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);\r
+       pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);\r
+       pLabel->SetTextConfig(__itemFontSize, LABEL_TEXT_STYLE_NORMAL);\r
+\r
+       pLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);\r
+       pItem->AttachChild(*pLabel);\r
+       _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer();\r
+       if (pContainer)\r
+       {\r
+               pContainer->Activate(false);\r
+       }\r
+       pItem->SetTextLabel(pLabel);\r
+\r
+       __itemWidth = __itemWidth < itemSize.width ? itemSize.width : __itemWidth;\r
+\r
+       pItem->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);\r
+       return pItem;\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap,\r
+                                                                  const Tizen::Graphics::Bitmap* pPressedBitmap,\r
+                                                                  const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
+{\r
+    SysTryReturn(NID_UI_CTRL, (__pModel->GetItemCount() < MAX_MAIN_ITEM_COUNT), E_SYSTEM, E_SYSTEM,\r
+                            "[E_SYSTEM] A system error has occurred. The maximum items count is reached.");\r
+       _ContextMenuItem* pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
+       SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+       result r = __pModel->AddItem(pItem);\r
+\r
+       if (r != E_SUCCESS)\r
+       {\r
+               delete pItem;\r
+               SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item.");\r
+       }\r
+\r
+       return r;\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::InsertItem(int index, const Tizen::Base::String& text, int actionId,\r
+                                                                         const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap,\r
+                                                                         const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
+{\r
+       if (text.GetLength() == 0 && normalBitmap == null && pPressedBitmap == null)\r
+       {\r
+               return E_INVALID_ARG;\r
+       }\r
+\r
+       _ContextMenuItem* pItem = null;\r
+\r
+       pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
+       SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+       result r = __pModel->InsertItem(pItem, index);\r
+       if (r != E_SUCCESS)\r
+       {\r
+               delete pItem;\r
+               SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item.");\r
+       }\r
+\r
+       return E_SUCCESS;\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::SetItem(int index, const Tizen::Base::String& text, int actionId,\r
+                                                                  const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap,\r
+                                                                  const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
+{\r
+       if (text.GetLength() == 0 && normalBitmap == null && pPressedBitmap == null)\r
+       {\r
+               return E_INVALID_ARG;\r
+       }\r
+\r
+       result r = __pContextMenu->GetScrollPanel()->DetachChild(*__pModel->GetItem(index));\r
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to detach item.");\r
+\r
+       _ContextMenuItem* pItem = null;\r
+       pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
+       SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+       r = __pModel->SetItem(pItem, index);\r
+       if (r != E_SUCCESS)\r
+       {\r
+               delete pItem;\r
+               SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item.");\r
+       }\r
+\r
+       return E_SUCCESS;\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::DeleteItem(int index)\r
+{\r
+       if (__pContextMenu->GetItemCount() <= 0)\r
+       {\r
+               SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Invalid argument.");\r
+               return E_INVALID_STATE;\r
+       }\r
+\r
+       result r = __pContextMenu->GetScrollPanel()->DetachChild(*__pModel->GetItem(index));\r
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to detach item.");\r
+\r
+       r = __pModel->RemoveItem(index);\r
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to delete item.");\r
+\r
+       return r;\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::DeleteItemAll(void)\r
+{\r
+       if (__pContextMenu->GetItemCount() <= 0)\r
+       {\r
+               SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Invalid argument.");\r
+               return E_INVALID_STATE;\r
+       }\r
+\r
+       __pContextMenu->GetScrollPanel()->DetachAllChildren();\r
+\r
+       result r =  __pModel->RemoveAllItem();\r
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to delete item all.");\r
+\r
+       return r;\r
+}\r
+\r
+\r
+int\r
+_OptionMenuListPresenter::CalculateShowItemCount(void)\r
+{\r
+       int itemMaxCount = 0;\r
+       _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();\r
+       GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, orientation, itemMaxCount);\r
+\r
+       int maxVisibleCount = __pContextMenu->GetShowItemCount();\r
+\r
+       return maxVisibleCount > itemMaxCount ? itemMaxCount : maxVisibleCount;\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::CalculateWindowRect(void)\r
+{\r
+       result r = CalculateRect();\r
+       AdjustItemPosition();\r
+\r
+       return r;\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::ApplyColorProperty(void)\r
+{\r
+       return E_SUCCESS;\r
+}\r
+\r
+\r
+result\r
+_OptionMenuListPresenter::CalculateRect(void)\r
+{\r
+       Tizen::Graphics::FloatRectangle windowRect = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);   // ContextMenu window itself\r
+       Tizen::Graphics::FloatRectangle bodyRect   = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);   // bg surronding showing items, relative to window\r
+       Tizen::Graphics::FloatRectangle arrowRect  = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);   // relative to window\r
+       Tizen::Graphics::FloatRectangle itemRect   = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);   // relative to window\r
+\r
+       float bodyTopMargin = __topMargin;\r
+       float bodyBottomMargin = __bottomMargin;\r
+       float bodyLeftMargin = __leftMargin;\r
+       float bodyRightMargin = __rightMargin;\r
+\r
+\r
+       FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();\r
+\r
+       if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE)\r
+       {\r
+               screen.SetSize(screen.height, screen.width);\r
+       }\r
+\r
+       // calculate layout size (__layoutSize)\r
+       AdjustItemLayout();\r
+\r
+       bodyRect.width = __layoutSize.width + bodyLeftMargin + bodyRightMargin;\r
+       bodyRect.height = __layoutSize.height + bodyTopMargin + bodyBottomMargin;\r
+\r
+       bodyRect.x = 0;\r
+       // Set body position y\r
+       bodyRect.y = screen.height -  bodyRect.height;\r
+       //  - check top margin\r
+\r
+\r
+       float correctLength = __arrowTopMargin - __anchorPopupOverlap;\r
+       windowRect.x = bodyRect.x;\r
+       windowRect.y = bodyRect.y;\r
+       windowRect.width = bodyRect.width;\r
+       windowRect.height = bodyRect.height;\r
+\r
+       bodyRect.x = 0.0f;\r
+       bodyRect.y = 0.0f;\r
+\r
+\r
+       if (_ControlManager::GetInstance()->GetOrientationStatus() == _CONTROL_ROTATION_270)\r
+       {\r
+               windowRect.x = screen.width - bodyRect.width;\r
+       }\r
+\r
+       itemRect.x      = bodyRect.x;\r
+       itemRect.y      = bodyRect.y;\r
+       itemRect.width  = __layoutSize.width;\r
+       itemRect.height = __layoutSize.height;\r
+\r
+       __pContextMenu->SetWindowRect(windowRect);\r
+       __pContextMenu->SetBodyRect(bodyRect);\r
+       __pContextMenu->SetArrowRect(arrowRect);\r
+       __pContextMenu->SetItemRect(itemRect);\r
+\r
+       // _ScrollPanel API call sequence: SetBounds() -> SetScrollAreaBounds()\r
+       // _Scroll visual interaction if Bounds < ScrollAreaBounds\r
+       if (__pContextMenu->IsVisible())\r
+       {\r
+               __pContextMenu->GetScrollPanel()->SetBounds(FloatRectangle(bodyRect.x + bodyLeftMargin, bodyRect.y + bodyTopMargin, __layoutSize.width, __layoutSize.height));\r
+               int itemCount = __pModel->GetItemCount();\r
+               float itemHeight = __itemHeight + (__dividerHeight * 2.0f);\r
+               float layoutClientHeight = itemCount * itemHeight - (__dividerHeight * 2.0f);\r
+               __pContextMenu->GetScrollPanel()->SetClientAreaHeight(layoutClientHeight);\r
+       }\r
+\r
+       __pContextMenu->SetMovable(true);\r
+       __pContextMenu->SetResizable(true);\r
+\r
+       __pContextMenu->SetMinimumSize(FloatDimension(0.0f, 0.0f));\r
+       __pContextMenu->SetMaximumSize(screen);\r
+       __pContextMenu->SetBounds(windowRect);\r
+\r
+       __pContextMenu->SetMovable(false);\r
+       __pContextMenu->SetResizable(false);\r
+\r
+       return E_SUCCESS;\r
+}\r
+\r
+void\r
+_OptionMenuListPresenter::AdjustItemLayout(void)\r
+{\r
+       FloatDimension layoutSize(0.0f, 0.0f);\r
+\r
+       int itemCount = __pModel->GetItemCount();\r
+       if (itemCount <= 0)\r
+       {\r
+               __layoutSize.width = __itemWidth;\r
+               __layoutSize.height = __itemHeight;\r
+               return;\r
+       }\r
+\r
+       layoutSize = AdjustItemLayoutStyle();\r
+\r
+       FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();\r
+       if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE)\r
+       {\r
+               screen.SetSize(screen.height, screen.width);\r
+       }\r
+\r
+       int maxHeight = screen.height;// - __screenTopMargin - __screenBottomMargin - __arrowHeight;\r
+       if (layoutSize.height > maxHeight)\r
+       {\r
+               layoutSize.height = maxHeight;\r
+       }\r
+\r
+       __layoutSize = layoutSize;\r
+}\r
+\r
+\r
+Tizen::Graphics::FloatDimension\r
+_OptionMenuListPresenter::AdjustItemLayoutStyle(void)\r
+{\r
+       int itemMaxCount = CalculateShowItemCount();\r
+\r
+       int itemCount = __pModel->GetItemCount();\r
+       float itemHeight = __itemHeight + (__dividerHeight * 2.0f);\r
+\r
+       FloatDimension layoutSize(__itemWidth, 0.0f);\r
+\r
+       float layoutClientHeight = itemCount * itemHeight - (__dividerHeight * 2.0f);\r
+       float layoutMaxHeight = itemMaxCount * itemHeight - (__dividerHeight * 2.0f);\r
+       if (layoutClientHeight > layoutMaxHeight)\r
+       {\r
+               __scrollEnable = true;\r
+               layoutSize.height = layoutMaxHeight;\r
+       }\r
+       else\r
+       {\r
+               __scrollEnable = false;\r
+               layoutSize.height = layoutClientHeight;\r
+       }\r
+\r
+       return layoutSize;\r
+}\r
+\r
+void\r
+_OptionMenuListPresenter::AdjustItemPosition(void)\r
+{\r
+       int itemCount = __pModel->GetItemCount();\r
+       if (itemCount <= 0)\r
+       {\r
+               return;\r
+       }\r
+\r
+       float itemHeight = __itemHeight + (__dividerHeight * 2.0f);\r
+       float drawItemY = 0.0f;\r
+\r
+       float x = __pContextMenu->GetBodyRect().x;\r
+       float y = __pContextMenu->GetBodyRect().y ;\r
+\r
+       _ContextMenuItem* pItem = null;\r
+\r
+       for (int i = 0; i < itemCount; i++)\r
+       {\r
+               pItem = __pModel->GetItem(i);\r
+\r
+               if (pItem == null)\r
+               {\r
+                       break;\r
+               }\r
+\r
+               FloatRectangle drawRect(x, drawItemY + y, __itemWidth, itemHeight);\r
+\r
+               pItem->SetDrawRect(drawRect);\r
+               pItem->SetUpperDivider(i > 0);\r
+               pItem->SetLowerDivider(i < itemCount - 1);\r
+               pItem->SetParentScrollEnable(__scrollEnable);\r
+               pItem->SetBounds(FloatRectangle(0.0f, drawItemY, drawRect.width, drawRect.height));\r
+\r
+               if (pItem->HasParent() == false)\r
+               {\r
+                       __pContextMenu->GetScrollPanel()->AttachChild(*pItem);\r
+               }\r
+\r
+               drawItemY += itemHeight;\r
+       }\r
+}\r
+\r
+int\r
+_OptionMenuListPresenter::GetItemIndexFromPosition(const Tizen::Graphics::FloatPoint& point) const\r
+{\r
+       int index = -1;\r
+       int itemCount = __pModel->GetItemCount();\r
+\r
+       if (itemCount < 0)\r
+       {\r
+               return -1;\r
+       }\r
+\r
+       _ContextMenuItem* pItem = null;\r
+\r
+       float scrollPosition = __pContextMenu->GetScrollPanel()->GetScrollPosition();\r
+       FloatPoint position(point.x, point.y + scrollPosition);\r
+\r
+       for (int i = 0; i < itemCount; i++)\r
+       {\r
+               pItem = __pModel->GetItem(i);\r
+\r
+               if (pItem == null)\r
+               {\r
+                       break;\r
+               }\r
+\r
+               FloatRectangle drawRect = pItem->GetDrawRect();\r
+\r
+               if (drawRect.Contains(position) == true)\r
+               {\r
+                       index = i;\r
+                       break;\r
+               }\r
+       }\r
+\r
+       return index;\r
+}\r
+\r
+\r
+result\r
+_OptionMenuListPresenter::Draw(void)\r
+{\r
+       result r = E_SUCCESS;\r
+\r
+       Canvas* pCanvas = __pContextMenu->GetCanvasN();\r
+       SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+       // Clear canvas for drawing area of the ContextMenu.\r
+       pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));\r
+       Tizen::Graphics::FloatRectangle bounds(__pContextMenu->GetWindowRect());\r
+       pCanvas->Clear(Tizen::Graphics::FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));\r
+\r
+       r = DrawBackground(pCanvas);\r
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to draw background.");\r
+\r
+       //r = DrawArrow(pCanvas);\r
+       //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to draw arrow.");\r
+\r
+       delete pCanvas;\r
+\r
+       return r;\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::DrawBackground(Canvas* pCanvas)\r
+{\r
+       SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");\r
+\r
+       result r = E_SUCCESS;\r
+\r
+       Tizen::Graphics::FloatRectangle bodyRect = __pContextMenu->GetBodyRect();\r
+\r
+       const Bitmap* pBackgroundNormalBitmap = __pContextMenu->GetBackgroundNormalBitmap();\r
+       const Bitmap* pBackgroundEffectBitmap = __pContextMenu->GetBackgroundEffectBitmap();\r
+\r
+       if (pBackgroundNormalBitmap == null && pBackgroundEffectBitmap == null)\r
+       {\r
+               pCanvas->SetForegroundColor(__pContextMenu->GetColor());\r
+               pCanvas->DrawRectangle(bodyRect);\r
+       }\r
+       else\r
+       {\r
+               if (pBackgroundNormalBitmap != null)\r
+               {\r
+                       r = DrawBitmap(*pCanvas, bodyRect, *pBackgroundNormalBitmap);\r
+               }\r
+\r
+               if (pBackgroundEffectBitmap != null)\r
+               {\r
+                       r = DrawBitmap(*pCanvas, bodyRect, *pBackgroundEffectBitmap);\r
+               }\r
+       }\r
+\r
+       return r;\r
+}\r
+\r
+\r
+result\r
+_OptionMenuListPresenter::DrawArrow(Canvas* pCanvas)\r
+{\r
+       SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");\r
+\r
+       result r = E_SUCCESS;\r
+       Tizen::Graphics::FloatRectangle arrowRect = __pContextMenu->GetArrowRect();\r
+       ContextMenuCoreDropPosition dropPosition = __pContextMenu->GetDropPosition();\r
+\r
+       const Bitmap* pArrowNormalBitmap = __pContextMenu->GetArrowNormalBitmap(dropPosition);\r
+       const Bitmap* pEffectArrowBitmap = __pContextMenu->GetArrowEffectBitmap(dropPosition);\r
+\r
+       if (pArrowNormalBitmap != null)\r
+       {\r
+               r = DrawBitmap(*pCanvas, arrowRect, *pArrowNormalBitmap);\r
+       }\r
+\r
+       if (pEffectArrowBitmap != null)\r
+       {\r
+               r = DrawBitmap(*pCanvas, arrowRect, *pEffectArrowBitmap);\r
+       }\r
+\r
+       return r;\r
+}\r
+\r
+_UiTouchEventDelivery\r
+_OptionMenuListPresenter::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)\r
+{\r
+       return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;\r
+}\r
+\r
+bool\r
+_OptionMenuListPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)\r
+{\r
+       FloatPoint touchPosition = touchinfo.GetCurrentPosition();\r
+       FloatRectangle itemRect = __pContextMenu->GetItemRect();\r
+\r
+       if (!itemRect.Contains(touchPosition))\r
+       {\r
+               __selectedIndex = -1;\r
+               __touchOutRect = true;\r
+               return true;\r
+       }\r
+\r
+       __selectedIndex = GetItemIndexFromPosition(touchPosition);\r
+       __touchOutRect = false;\r
+       return true;\r
+}\r
+\r
+_UiTouchEventDelivery\r
+_OptionMenuListPresenter::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)\r
+{\r
+       return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;\r
+}\r
+\r
+bool\r
+_OptionMenuListPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)\r
+{\r
+       FloatPoint touchPosition = touchinfo.GetCurrentPosition();\r
+\r
+       if (__touchOutRect)\r
+       {\r
+               FloatRectangle itemRect = __pContextMenu->GetItemRect();\r
+               if (!itemRect.Contains(touchPosition))\r
+               {\r
+                       __selectedIndex = -1;\r
+                       __pContextMenu->SetVisibleState(false);\r
+\r
+                       return true;\r
+               }\r
+       }\r
+\r
+       int currentSelectedIndex = GetItemIndexFromPosition(touchPosition);\r
+       if (__selectedIndex != -1 && (__selectedIndex == currentSelectedIndex))\r
+       {\r
+               _ContextMenuItem* pItem = null;\r
+               pItem = __pModel->GetItem(__selectedIndex);\r
+\r
+               __selectedIndex = -1;\r
+               __pContextMenu->SetVisibleState(false);\r
+\r
+               int actionId = pItem->GetActionId();\r
+\r
+               _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();\r
+               if (pActionEvent == null)\r
+               {\r
+                       return true;\r
+               }\r
+\r
+               IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);\r
+               if (pEventArg == null)\r
+               {\r
+                       return true;\r
+               }\r
+\r
+               PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);\r
+               pActionEvent->Fire(*pEventArg);\r
+       }\r
+\r
+       return true;\r
+}\r
+\r
+_UiTouchEventDelivery\r
+_OptionMenuListPresenter::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)\r
+{\r
+       return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;\r
+}\r
+\r
+bool\r
+_OptionMenuListPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)\r
+{\r
+       if (__scrollEnable)\r
+       {\r
+               __selectedIndex = -1;\r
+       }\r
+\r
+       return true;\r
+}\r
+\r
+bool\r
+_OptionMenuListPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)\r
+{\r
+       __pModel->ResetAllItem();\r
+\r
+       return true;\r
+}\r
+\r
+void\r
+_OptionMenuListPresenter::OnFontChanged(Tizen::Graphics::Font* pFont)\r
+{\r
+       __pFont = pFont;\r
+       String fontName = __pContextMenu->GetFont();\r
+\r
+       int itemCount = __pModel->GetItemCount();\r
+       for (int i = 0; i < itemCount; i++)\r
+       {\r
+               _ContextMenuItem* pItem = __pModel->GetItem(i);\r
+               if (pItem != null)\r
+               {\r
+                       pItem->SetFont(fontName);\r
+               }\r
+       }\r
+}\r
+\r
+void\r
+_OptionMenuListPresenter::OnFontInfoRequested(unsigned long& style, float& size)\r
+{\r
+       style = FONT_STYLE_PLAIN;\r
+       size = __itemFontSize;\r
+}\r
+\r
+void\r
+_OptionMenuListPresenter::SetAllAccessibilityElement(void)\r
+{\r
+       _AccessibilityContainer* pContainerContextMenu = __pContextMenu->GetAccessibilityContainer();\r
+       if (pContainerContextMenu != null)\r
+       {\r
+               _AccessibilityElement* pElementContextMenu = new (std::nothrow) _AccessibilityElement(true);\r
+               SysTryReturnVoidResult(NID_UI_CTRL, pElementContextMenu, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");\r
+\r
+               pElementContextMenu->SetSupportOperatingGesture(false);\r
+               pElementContextMenu->SetTrait(L"Contextual popup");\r
+               pElementContextMenu->SetHint(L"double tap to close");\r
+               pElementContextMenu->SetBounds(FloatRectangle(0.0f, 0.0f, __pContextMenu->GetBoundsF().width, __pContextMenu->GetBoundsF().height));\r
+               pContainerContextMenu->AddElement(*pElementContextMenu);\r
+               __pContextMenu->AddAccessibilityElement(*pElementContextMenu);\r
+\r
+               int itemCount = __pModel->GetItemCount();\r
+               for (int i = 0; i < itemCount; i++)\r
+               {\r
+                       _ContextMenuItem* pItem = __pModel->GetItem(i);\r
+                       if (pItem)\r
+                       {\r
+                               _AccessibilityContainer* pContainer = pItem->GetAccessibilityContainer();\r
+                               if (pContainer != null)\r
+                               {\r
+                                       LinkedListT<_AccessibilityElement*> accessibilityElements;\r
+                                       _AccessibilityElement* pElement = null;\r
+\r
+                                       pContainer->GetElements(accessibilityElements);\r
+                                       if (accessibilityElements.GetAt(0, pElement) == E_SUCCESS)\r
+                                       {\r
+                                               pElement->SetName(L"ContextMenuItem" + Integer::ToString(i));\r
+                                               if (pItem->GetType() == CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP)\r
+                                               {\r
+                                                       pElement->SetLabel(L"icon " + pItem->GetText());\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       pElement->SetLabel(pItem->GetText());\r
+                                               }\r
+\r
+                                               pElement->SetBounds(FloatRectangle(0.0f, 0.0f, pItem->GetBoundsF().width, pItem->GetBoundsF().height));\r
+                                       }\r
+                                       pContainerContextMenu->AddChildContainer(*pContainer);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+}\r
+\r
+_ContextMenuItemInfo\r
+_OptionMenuListPresenter::GetItemFromPosition(const FloatPoint& position)\r
+{\r
+       _ContextMenuItemInfo itemInfo;\r
+       int index = GetItemIndexFromPosition(position);\r
+       itemInfo.pContextMenuItem = __pModel->GetItem(index);\r
+\r
+       itemInfo.bListItem = false;\r
+       itemInfo.pListItem = null;\r
+       return itemInfo;\r
+}\r
+\r
+_ContextMenuItemInfo\r
+_OptionMenuListPresenter::FindItem(int index)\r
+{\r
+       _ContextMenuItemInfo itemInfo;\r
+       itemInfo.bListItem = false;\r
+       itemInfo.pListItem = null;\r
+       itemInfo.pContextMenuItem = __pModel->GetItem(index);\r
+       return itemInfo;\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::SetTopDrawnItemIndex(int index)\r
+{\r
+       return E_SUCCESS;\r
+}\r
+\r
+result\r
+_OptionMenuListPresenter::DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Graphics::Bitmap& bitmap)\r
+{\r
+       result r = E_SUCCESS;\r
+       if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))\r
+       {\r
+               r = canvas.DrawNinePatchedBitmap(bounds, bitmap);\r
+               SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw ninepatched bitmap.")\r
+       }\r
+       else\r
+       {\r
+               r = canvas.DrawBitmap(bounds, bitmap);\r
+               SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw bitmap.")\r
+       }\r
+\r
+       return r;\r
+}\r
+\r
+}}} // Tizen::Ui: Control\r
index c7631c5..fd888d0 100644 (file)
@@ -29,6 +29,7 @@
 #include "FUiCtrl_IContextMenuPresenter.h"
 #include "FUiCtrl_ContextMenuGridPresenter.h"
 #include "FUiCtrl_ContextMenuListPresenter.h"
+#include "FUiCtrl_OptionMenuListPresenter.h"\r
 #include "FUiCtrl_ActionEvent.h"
 #include "FUiCtrl_IActionEventListener.h"
 
index 82de4b8..777f1e8 100644 (file)
@@ -42,6 +42,7 @@ class _Indicator;
 class _ActionEvent;
 class _OverlayRegionImpl;
 class _IFormBackEventListener;
+class _IFormControlEventListener;
 
 enum _FormStyle
 {
@@ -97,6 +98,7 @@ public:
        static _Form* CreateFormN(void);
 
        void SetFormBackEventListener(_IFormBackEventListener* pFormBackEventListener);
+       void SetFormControlEventListener(_IFormControlEventListener* pFormControlEventListener);
 
        unsigned long GetFormStyle(void) const;
        _Toolbar* GetFooter(void) const;
@@ -242,6 +244,7 @@ private:
 private:
        _FormPresenter* __pFormPresenter;
        _IFormBackEventListener* __pFormBackEventListener;
+       _IFormControlEventListener* __pFormControlEventListener;
 
        unsigned long __formStyle;
        _ActionEvent* __pActionEvent;
@@ -299,6 +302,7 @@ private:
 
        //Back button action ID
        static const int ID_BACK_BUTTON = -10;
+       static const int ID_OPTION_BUTTON = -20;
 
        //For Focus UI
        mutable std::unique_ptr<Tizen::Base::Collection::IListT<_Control*> > __pFocusControlList;
index 9e11488..a5cb326 100644 (file)
@@ -21,6 +21,7 @@
 #include "FUi_ContainerImpl.h"
 #include "FUiCtrl_Form.h"
 #include "FUiCtrl_IFormBackEventListener.h"
+#include "FUiCtrl_IFormControlEventListener.h"
 
 namespace Tizen { namespace Ui {
 class DataBindingContext;
@@ -39,6 +40,7 @@ class _OSP_EXPORT_ _FormImpl
        : public _ContainerImpl
        , public Tizen::Ui::Controls::_IActionEventListener
        , public Tizen::Ui::Controls::_IFormBackEventListener
+       , public Tizen::Ui::Controls::_IFormControlEventListener
        , virtual public Tizen::Base::Runtime::IEventListener
        , public _IFormOrientationStatusEventListener
 {
@@ -65,6 +67,7 @@ public:
        _ControlImpl* GetFocusControl(void);
 
        void SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener);
+       void SetFormControlEventListener(const IFormControlEventListener* pFormControlEventListener);
 
        unsigned long GetFormStyle(void) const;
        _FooterImpl* GetFooter(void) const;
@@ -145,6 +148,8 @@ public:
        virtual bool IsOpaque(void) const;
 
        virtual void OnFormBackRequested(Tizen::Ui::Controls::_Form& source);
+       virtual void OnFormBackButtonRequested(Tizen::Ui::Controls::_Form& source);
+       virtual void OnFormOptionButtonRequested(Tizen::Ui::Controls::_Form& source);
 
        virtual Tizen::Ui::OrientationStatus OnFormOrientationStatusRequested(void);
 
@@ -175,6 +180,7 @@ private:
 private:
        _Form* __pForm;
        IFormBackEventListener* __pFormBackEventListener;
+       IFormControlEventListener* __pFormControlEventListener;
 
        Tizen::Ui::_OrientationAgent* __pOriAgent;
        Tizen::Ui::_ImeOrientationAgent* __pImeOriAgent;
diff --git a/src/ui/inc/FUiCtrl_IFormControlEventListener.h b/src/ui/inc/FUiCtrl_IFormControlEventListener.h
new file mode 100644 (file)
index 0000000..80cf1e6
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file               FUiCtrl_IFormControlEventListener.h
+ * @brief              This is the header file for the _IFormControlEventListener interface.
+ *
+ * This header file contains the declarations of the _IFormControlEventListener interface.
+ */
+#ifndef _FUI_CTRL_INTERNAL_IFORM_CONTROL_EVENT_LISTENER_H_
+#define _FUI_CTRL_INTERNAL_IFORM_CONTROL_EVENT_LISTENER_H_
+
+// includes
+#include <FBaseRtIEventListener.h>
+
+// namespace declaration
+namespace Tizen { namespace Ui { namespace Controls
+{
+
+class _Form;
+
+/**
+ * @interface  _IFormControlEventListener
+ * @brief              This interface implements the listener for Form related events.
+ * @since              2.0
+ *
+ * The %_IFormControlEventListener interface is the listener interface for receiving Form-related events.
+ *
+ * For more information on the class features, see <a href="../com.osp.cppappprogramming.help/html/dev_guide/ui/implementing_form.htm">Form</a>.
+ */
+class _IFormControlEventListener
+       : virtual public Tizen::Base::Runtime::IEventListener
+{
+// Lifecycle
+public:
+       /**
+        * This is the destructor for this class.
+        * @since       2.0
+        */
+       virtual ~_IFormControlEventListener(void) {}
+
+// Operation
+public:
+       /**
+        *      Called when the current %Form control needs to be closed to revert back to the previous %Form control.
+        *
+        * @since       2.0
+        * @param[in]   source          The source of the event
+        * @remarks             This event is fired when the user clicks on the software 'back' button on the Footer control, or the hardware back button on the
+        *      device.
+        */
+       virtual void OnFormBackButtonRequested(Tizen::Ui::Controls::_Form& source) = 0;
+
+       virtual void OnFormOptionButtonRequested(Tizen::Ui::Controls::_Form& source) = 0;
+
+// Reserves
+protected:
+       //
+       //This method is for internal use only. Using this method can cause behavioral, security-related,
+       //and consistency-related issues in the application.
+       //
+       // Following method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void _IFormControlEventListener_Reserved1(void) { }
+
+       //
+       //This method is for internal use only. Using this method can cause behavioral, security-related,
+       //and consistency-related issues in the application.
+       //
+       // Following method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void _IFormControlEventListener_Reserved2(void) { }
+
+       //
+       //This method is for internal use only. Using this method can cause behavioral, security-related,
+       //and consistency-related issues in the application.
+       //
+       // Following method is reserved and may change its name at any time without
+       // prior notice.
+       //
+       // @since 2.0
+       //
+       virtual void _IFormControlEventListener_Reserved3(void) { }
+}; // _IFormControlEventListener
+
+}}} // Tizen::Ui::Controls
+
+#endif // _FUI_CTRL_INTERNAL_IFORM_CONTROL_EVENT_LISTENER_H_
index 7044e96..25aca21 100644 (file)
@@ -24,7 +24,8 @@
 #define _FUI_CTRL_INTERNAL_OPTION_MENU_IMPL_H_
 
 #include <FUiCtrlOptionMenu.h>
-
+#include <FUiCtrlContextMenu.h>\r
+#include <FUiCtrl_ContextMenu.h>\r
 #include "FUiCtrl_OptionMenu.h"
 #include "FUiCtrl_IActionEventListener.h"
 #include "FUi_WindowImpl.h"
@@ -45,6 +46,10 @@ public:
        result RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener);
 
        result AddItem(const Tizen::Base::String& text, int actionId);
+\r
+       result AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId);\r
+       result AddItem(const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap=null, const Tizen::Graphics::Bitmap* pHighlightedBitmap=null);\r
+\r
 
        result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId);
 
@@ -78,9 +83,9 @@ public:
 
        virtual OptionMenu& GetPublic(void);
 
-       virtual const _OptionMenu& GetCore(void) const;
+       virtual const _ContextMenu& GetCore(void) const;\r
 
-       virtual _OptionMenu& GetCore(void);
+       virtual _ContextMenu& GetCore(void);\r
 
        virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
 
@@ -95,7 +100,7 @@ public:
        virtual result OnAttachedToMainTree(void);
 
 private:
-       _OptionMenuImpl(OptionMenu* pPublic, _OptionMenu* pCore);
+       _OptionMenuImpl(OptionMenu* pPublic, _ContextMenu* pCore);\r
 
        _OptionMenuImpl(const _OptionMenuImpl&);
 
diff --git a/src/ui/inc/FUiCtrl_OptionMenuListPresenter.h b/src/ui/inc/FUiCtrl_OptionMenuListPresenter.h
new file mode 100644 (file)
index 0000000..413fefd
--- /dev/null
@@ -0,0 +1,146 @@
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//     http://www.apache.org/licenses/LICENSE-2.0/\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @file               FUiCtrl_OptionMenuListPresenter.h\r
+ * @brief              This is the header file for the _OptionMenuListPresenter class.\r
+ *\r
+ * This header file contains the declarations of the %_OptionMenuListPresenter class.\r
+ */\r
+#ifndef _FUI_CTRL_INTERNAL_OPTIONMENU_LIST_PRESENTER_H_\r
+#define _FUI_CTRL_INTERNAL_OPTIONMENU_LIST_PRESENTER_H_\r
+\r
+#include <FGrp_TextTextObject.h>\r
+#include "FUi_Control.h"\r
+#include "FUiCtrl_ContextMenu.h"\r
+#include "FUiCtrl_ContextMenuModel.h"\r
+#include "FUiCtrl_IContextMenuPresenter.h"\r
+\r
+namespace Tizen { namespace Ui { namespace Controls\r
+{\r
+\r
+class _ContextMenu;\r
+class _ContextMenuModel;\r
+class _ContextMenuItem;\r
+\r
+/**\r
+ * @class _OptionMenuListPresenter\r
+ * @brief\r
+ * @since 2.0\r
+ *\r
+ *\r
+ *\r
+ *\r
+ */\r
+class _OptionMenuListPresenter\r
+       : public _IContextMenuPresenter\r
+{\r
+// Lifecycle\r
+public:\r
+               _OptionMenuListPresenter(_ContextMenu* pContextMenu);\r
+       virtual ~_OptionMenuListPresenter(void);\r
+\r
+// Operation\r
+public:\r
+       virtual result Install(void);\r
+       virtual result Draw(void);\r
+       virtual result DrawBackground(Tizen::Graphics::Canvas* pCanvas);\r
+       virtual result DrawArrow(Tizen::Graphics::Canvas* pCanvas);\r
+       virtual result AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);\r
+       virtual result InsertItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);\r
+       virtual result SetItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);\r
+       virtual result DeleteItem(int index);\r
+       virtual result DeleteItemAll(void);\r
+       virtual int CalculateShowItemCount(void);\r
+       virtual result CalculateWindowRect(void);\r
+       virtual result ApplyColorProperty(void);\r
+\r
+       virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo);\r
+       virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo);\r
+       virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo);\r
+\r
+       virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);\r
+       virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);\r
+       virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);\r
+       virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);\r
+\r
+       virtual void OnFontChanged(Tizen::Graphics::Font* pFont);\r
+       virtual void OnFontInfoRequested(unsigned long& style, float& size);\r
+\r
+       virtual void SetAllAccessibilityElement(void);\r
+\r
+       virtual _ContextMenuItemInfo GetItemFromPosition(const Tizen::Graphics::FloatPoint& position);\r
+       virtual _ContextMenuItemInfo FindItem(int index);\r
+       virtual result SetTopDrawnItemIndex(int index);\r
+       virtual result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Graphics::Bitmap& bitmap);\r
+\r
+private:\r
+       void LoadShape(void);\r
+       result CalculateRect(void);\r
+       void AdjustItemLayout(void);\r
+       void AdjustItemPosition(void);\r
+       Tizen::Graphics::FloatDimension AdjustItemLayoutStyle(void);\r
+\r
+       _ContextMenuItem* CreateItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);\r
+       int GetItemIndexFromPosition(const Tizen::Graphics::FloatPoint& point) const;\r
+\r
+private:\r
+       _OptionMenuListPresenter(const _OptionMenuListPresenter& rhs);\r
+       _OptionMenuListPresenter& operator =(const _OptionMenuListPresenter& rhs);\r
+\r
+// Attribute\r
+private:\r
+       _ContextMenu* __pContextMenu;\r
+       _ContextMenuModel* __pModel;\r
+\r
+       Tizen::Graphics::Font* __pFont;\r
+       Tizen::Graphics::FloatDimension __layoutSize;\r
+\r
+       bool __touchOutRect;\r
+       int __selectedIndex;\r
+       bool __scrollEnable;\r
+\r
+       float __maxWidth;\r
+       float __minWidth;\r
+       float __topMargin;\r
+       float __bottomMargin;\r
+       float __leftMargin;\r
+       float __rightMargin;\r
+       float __screenTopMargin;\r
+       float __screenBottomMargin;\r
+       float __screenLeftMargin;\r
+       float __screenRightMargin;\r
+       float __arrowTopMargin;\r
+       float __arrowBottomMargin;\r
+       float __arrowRightMargin;\r
+       float __arrowLeftMargin;\r
+       float __arrowWidth;\r
+       float __arrowHeight;\r
+       float __itemWidth;\r
+       float __itemMinWidth;\r
+       float __itemHeight;\r
+       float __itemMaxWidth;\r
+       float __itemGap;\r
+       float __itemBitmapWidth;\r
+       float __itemBitmapHeight;\r
+       float __itemFontSize;\r
+       float __dividerHeight;\r
+       float __anchorPopupOverlap;\r
+}; // _OptionMenuListPresenter\r
+\r
+}}} // Tizen::Ui: Control\r
+\r
+#endif  //_FUI_CTRL_INTERNAL_OPTIONMENU_LIST_PRESENTER_H_\r