add _NativeObjectHandler class for ChatOnV
authorDae young Ryu <karzia@samsung.com>
Mon, 8 Apr 2013 06:57:11 +0000 (15:57 +0900)
committerDae young Ryu <karzia@samsung.com>
Mon, 8 Apr 2013 06:57:11 +0000 (15:57 +0900)
Change-Id: I4880a03d4df0c11d9cf48401ae506a6a3a90d7f5
Signed-off-by: Dae young Ryu <karzia@samsung.com>
src/ui/CMakeLists.txt
src/ui/FUiControl.cpp
src/ui/FUi_NativeObjectHandler.cpp [new file with mode: 0644]
src/ui/FUi_NativeObjectHandler.h [new file with mode: 0755]

index ba08933..7e721eb 100644 (file)
@@ -231,6 +231,7 @@ SET (${this_target}_SOURCE_FILES
        FUi_BidiUtils.cpp
        FUi_DimmingLayer.cpp
        FUi_DimmingManager.cpp
+       FUi_NativeObjectHandler.cpp
        controls/FUiCtrlAnimation.cpp
        controls/FUiCtrlAnimationFrame.cpp
        controls/FUiCtrlButton.cpp
index ff24840..f782935 100644 (file)
 #include "FUi_ContainerImpl.h"
 #include "FUi_ErrorMessages.h"
 #include "FUiAnimVisualElement.h"
-#include "FUiAnimVisualElementSurface.h"
-#include "FUiAnim_VisualElementSurfaceImpl.h"
-
-// for sto
-#include <Evas.h>
-#include "FUiAnim_EflNode.h"
-#include "FUiAnim_EflLayer.h"
-#include "FUiAnim_VisualElementImpl.h"
-#include "FUiAnim_DisplayContextImpl.h"
 
 
 using namespace Tizen::Base;
@@ -45,143 +36,6 @@ using namespace Tizen::Base::Collection;
 using namespace Tizen::Graphics;
 using namespace Tizen::Ui::Animations;
 
-extern "C" _OSP_EXPORT_ void*
-STO_GetNativeHandle(void* pControl)
-{
-       Handle nativeHandle = 0;
-       Tizen::Ui::Control* pControlPointer = (Tizen::Ui::Control*)pControl;
-
-       if (pControlPointer)
-       {
-               Tizen::Ui::_ControlImpl* pControlImpl = Tizen::Ui::_ControlImpl::GetInstance(*pControlPointer);
-
-               if (pControlImpl)
-               {
-                       VisualElement *pVisualElement = pControlImpl->GetVisualElement();
-
-                       if (pVisualElement)
-                       {
-                               VisualElementSurface* pSurface = pVisualElement->GetSurfaceN();
-
-                               if (pSurface)
-                               {
-                                       _VisualElementSurfaceImpl* pSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pSurface);
-                                       if (pSurfaceImpl)
-                                               nativeHandle = pSurfaceImpl->GetNativeHandle();
-
-                                       delete pSurface;
-                               }
-                       }
-               }
-       }
-
-       return (void*)nativeHandle;
-}
-
-extern "C" _OSP_EXPORT_ void
-STO_NativeHandleSetShowState(void* pNative, bool show)
-{
-       if(show)
-               evas_object_show((Evas_Object*)pNative);
-       else
-               evas_object_hide((Evas_Object*)pNative);
-}
-
-extern "C" _OSP_EXPORT_ void*
-STO_GetVisualElement(void* pControl)
-{
-       Tizen::Ui::Control* pControlPointer = (Tizen::Ui::Control*)pControl;
-       Tizen::Ui::_ControlImpl* pControlImpl = Tizen::Ui::_ControlImpl::GetInstance(*pControlPointer);
-
-       return (void *)pControlImpl->GetVisualElement();
-}
-
-extern "C" _OSP_EXPORT_
-void STO_NativeHandleDataSet(void* pEvasObject, void* pData, int width, int height)
-{
-       evas_object_image_size_set((Evas_Object*)pEvasObject, width, height);
-       evas_object_image_data_set((Evas_Object*)pEvasObject, pData);
-}
-
-
-
-extern "C" _OSP_EXPORT_ void
-STO_SetVisualElementNativeObject(void* pVisualElement, void* pNativeObject)
-{
-       VisualElement* pVE = (VisualElement* )pVisualElement;
-       Evas_Object* pEO = (Evas_Object*)pNativeObject;
-
-       _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE);
-
-       _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode();
-       pNode->AddNativeSmartObject(*pVE, pEO);
-
-       int imageWidth = 0;
-       int imageHeight = 0;
-
-       evas_object_image_size_get(pEO, &imageWidth, &imageHeight);
-       evas_object_image_data_update_add(pEO, 0, 0, imageWidth, imageHeight);
-}
-
-extern "C" _OSP_EXPORT_
-void* STO_CreateNativeImageObject(void* pDisplayContext, int width, int height)
-{
-
-       if(!pDisplayContext)
-       {
-               return null;
-       }
-
-       _DisplayContextImpl* pDispImpl =  _DisplayContextImpl::GetInstance(*(DisplayContext*)pDisplayContext);
-
-       if(!pDispImpl->GetNativeLayer())
-       {
-               return null;
-       }
-       Evas* pEvas = ((_EflLayer*)pDispImpl->GetNativeLayer())->GetEvas();
-
-       if(!pEvas)
-       {
-               return null;
-       }
-
-       Evas_Object* pImage = evas_object_image_filled_add(pEvas);
-       evas_object_resize(pImage, width, height);
-       evas_object_move(pImage, 0, 0);
-//     evas_object_show(pImage);
-
-       return pImage;
-
-}
-
-extern "C" _OSP_EXPORT_ void
-STO_FillSet(void* pVisualElement, int x, int y, int w, int h)
-{
-                  VisualElement* pVE = (VisualElement*)pVisualElement;
-
-                  _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE);
-
-                  _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode();
-                  Evas_Object* pEvasObject = pNode->GetNativeObject();
-                  if (pEvasObject)
-                  {
-                                        evas_object_image_fill_set(pEvasObject, x, y, w, h);
-                  }
-}
-
-extern "C" _OSP_EXPORT_ void
-STO_Destroy(void* pVisualElement, void* pEvasObject)
-{
-       VisualElement* pVE = (VisualElement* )pVisualElement;
-
-       _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE);
-
-       _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode();
-       pNode->AddNativeSmartObject(*pVE, null);
-
-       evas_object_del((Evas_Object*)pEvasObject);
-}
-
 
 namespace Tizen { namespace Ui {
 
diff --git a/src/ui/FUi_NativeObjectHandler.cpp b/src/ui/FUi_NativeObjectHandler.cpp
new file mode 100644 (file)
index 0000000..91c4e07
--- /dev/null
@@ -0,0 +1,294 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://floralicense.org/license/
+//
+// 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               FUi_ModalLoopManager.cpp
+ * @brief              This is the implementation file for the _ModalLoopManager class.
+ */
+
+#include <Evas.h>
+#include "FUiAnimDisplayContext.h"
+#include "FUiAnimVisualElement.h"
+
+#include "FUi_NativeObjectHandler.h"
+
+#include "FUiAnim_VisualElementImpl.h"
+#include "FUiAnim_DisplayContextImpl.h"
+#include "FUiAnim_EflNode.h"
+#include "FUiAnim_EflLayer.h"
+
+#include <FUiControl.h>
+#include "FUi_ControlImpl.h"
+
+#define STO_API
+
+#ifdef STO_API
+// for sto
+#include "FUiAnimVisualElementSurface.h"
+#include "FUiAnim_VisualElementSurfaceImpl.h"
+
+#endif
+
+
+
+using namespace Tizen::Ui::Animations;
+
+#ifdef STO_API
+extern "C" _OSP_EXPORT_ void*
+STO_GetNativeHandle(void* pControl)
+{
+       Handle nativeHandle = 0;
+       Tizen::Ui::Control* pControlPointer = (Tizen::Ui::Control*)pControl;
+
+       if (pControlPointer)
+       {
+               Tizen::Ui::_ControlImpl* pControlImpl = Tizen::Ui::_ControlImpl::GetInstance(*pControlPointer);
+
+               if (pControlImpl)
+               {
+                       VisualElement *pVisualElement = pControlImpl->GetVisualElement();
+
+                       if (pVisualElement)
+                       {
+                               VisualElementSurface* pSurface = pVisualElement->GetSurfaceN();
+
+                               if (pSurface)
+                               {
+                                       _VisualElementSurfaceImpl* pSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pSurface);
+                                       if (pSurfaceImpl)
+                                               nativeHandle = pSurfaceImpl->GetNativeHandle();
+
+                                       delete pSurface;
+                               }
+                       }
+               }
+       }
+
+       return (void*)nativeHandle;
+}
+
+extern "C" _OSP_EXPORT_ void
+STO_NativeHandleSetShowState(void* pNative, bool show)
+{
+       if(show)
+               evas_object_show((Evas_Object*)pNative);
+       else
+               evas_object_hide((Evas_Object*)pNative);
+}
+
+extern "C" _OSP_EXPORT_ void*
+STO_GetVisualElement(void* pControl)
+{
+       Tizen::Ui::Control* pControlPointer = (Tizen::Ui::Control*)pControl;
+       Tizen::Ui::_ControlImpl* pControlImpl = Tizen::Ui::_ControlImpl::GetInstance(*pControlPointer);
+
+       return (void *)pControlImpl->GetVisualElement();
+}
+
+extern "C" _OSP_EXPORT_
+void STO_NativeHandleDataSet(void* pEvasObject, void* pData, int width, int height)
+{
+       evas_object_image_size_set((Evas_Object*)pEvasObject, width, height);
+       evas_object_image_data_set((Evas_Object*)pEvasObject, pData);
+}
+
+
+
+extern "C" _OSP_EXPORT_ void
+STO_SetVisualElementNativeObject(void* pVisualElement, void* pNativeObject)
+{
+       VisualElement* pVE = (VisualElement* )pVisualElement;
+       Evas_Object* pEO = (Evas_Object*)pNativeObject;
+
+       _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE);
+
+       _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode();
+       pNode->AddNativeSmartObject(*pVE, pEO);
+
+       int imageWidth = 0;
+       int imageHeight = 0;
+
+       evas_object_image_size_get(pEO, &imageWidth, &imageHeight);
+       evas_object_image_data_update_add(pEO, 0, 0, imageWidth, imageHeight);
+}
+
+extern "C" _OSP_EXPORT_
+void* STO_CreateNativeImageObject(void* pDisplayContext, int width, int height)
+{
+
+       if(!pDisplayContext)
+       {
+               return null;
+       }
+
+       _DisplayContextImpl* pDispImpl =  _DisplayContextImpl::GetInstance(*(DisplayContext*)pDisplayContext);
+
+       if(!pDispImpl->GetNativeLayer())
+       {
+               return null;
+       }
+       Evas* pEvas = ((_EflLayer*)pDispImpl->GetNativeLayer())->GetEvas();
+
+       if(!pEvas)
+       {
+               return null;
+       }
+
+       Evas_Object* pImage = evas_object_image_filled_add(pEvas);
+       evas_object_resize(pImage, width, height);
+       evas_object_move(pImage, 0, 0);
+//     evas_object_show(pImage);
+
+       return pImage;
+
+}
+
+extern "C" _OSP_EXPORT_ void
+STO_FillSet(void* pVisualElement, int x, int y, int w, int h)
+{
+                  VisualElement* pVE = (VisualElement*)pVisualElement;
+
+                  _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE);
+
+                  _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode();
+                  Evas_Object* pEvasObject = pNode->GetNativeObject();
+                  if (pEvasObject)
+                  {
+                                        evas_object_image_fill_set(pEvasObject, x, y, w, h);
+                  }
+}
+
+extern "C" _OSP_EXPORT_ void
+STO_Destroy(void* pVisualElement, void* pEvasObject)
+{
+       VisualElement* pVE = (VisualElement* )pVisualElement;
+
+       _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE);
+
+       _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode();
+       pNode->AddNativeSmartObject(*pVE, null);
+
+       evas_object_del((Evas_Object*)pEvasObject);
+}
+
+#endif //STO_API
+namespace Tizen { namespace Ui {
+
+Handle
+_NativeObjectHandler::CreateNativeImageObjectN(const DisplayContext* pDisplayContext, int width, int height)
+{
+//    * @exception    E_SUCCESS                             The method is successful.
+//    * @exception    E_INVALID_ARG                       The specified @c pDisplayContext is invalid.
+//    * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.
+       if(!pDisplayContext)
+       {
+               return null;
+       }
+
+       _DisplayContextImpl* pDispImpl =  _DisplayContextImpl::GetInstance(*(DisplayContext*)pDisplayContext);
+
+       if(!pDispImpl->GetNativeLayer())
+       {
+               return null;
+       }
+       Evas* pEvas = ((_EflLayer*)pDispImpl->GetNativeLayer())->GetEvas();
+
+       if(!pEvas)
+       {
+               return null;
+       }
+
+       Evas_Object* pImage = evas_object_image_filled_add(pEvas);
+       evas_object_resize(pImage, width, height);
+       evas_object_move(pImage, 0, 0);
+//     evas_object_show(pImage);
+
+       return reinterpret_cast<Handle>(pImage);
+}
+
+result
+_NativeObjectHandler::SetNativeObjectToVisualElement(VisualElement* pVisualElement, Handle nativeObjectHandle)
+{
+//    * @exception    E_SUCCESS                                        The method is successful.
+//    * @exception    E_INVALID_ARG                       The specified @c pNativeObject is @c null.
+//    * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.
+       Evas_Object* pNative = reinterpret_cast<Evas_Object*>(nativeObjectHandle);
+
+       if(!pNative || !pVisualElement)
+       {
+               return E_INVALID_ARG;
+       }
+
+       _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVisualElement);
+
+       _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode();
+       pNode->AddNativeSmartObject(*pVisualElement, pNative);
+
+       int imageWidth = 0;
+       int imageHeight = 0;
+
+       evas_object_image_size_get(pNative, &imageWidth, &imageHeight);
+       evas_object_image_data_update_add(pNative, 0, 0, imageWidth, imageHeight);
+       return E_SUCCESS;
+}
+
+result
+_NativeObjectHandler::SetNativeObjectShowState(Handle nativeObjectHandle, bool show)
+{
+//    * @exception    E_SUCCESS                                        The method is successful.
+//    * @exception    E_INVALID_ARG                       The specified @c pVisualElement or @c pNativeObject is invalid.
+//    * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.
+       Evas_Object* pNative = reinterpret_cast<Evas_Object*>(nativeObjectHandle);
+       if(!pNative)
+       {
+               return E_INVALID_ARG;
+       }
+       if(show)
+       {
+               evas_object_show(pNative);
+       }
+       else
+       {
+               evas_object_hide(pNative);
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_NativeObjectHandler::DestroyNativeObject(VisualElement* pVisualElement, Handle nativeObjectHandle)
+{
+//    * @exception    E_SUCCESS                                        The method is successful.
+//    * @exception    E_INVALID_ARG                       The specified @c pVisualElement or @c pNativeObject is invalid.
+//    * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.
+       Evas_Object* pNative = reinterpret_cast<Evas_Object*>(nativeObjectHandle);
+       if(!pNative || !pVisualElement)
+       {
+               return E_INVALID_ARG;
+       }
+
+       _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVisualElement);
+
+       _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode();
+       pNode->AddNativeSmartObject(*pVisualElement, null);
+
+       evas_object_del(pNative);
+       return E_SUCCESS;
+}
+
+}}  // namespace Tizen { namespace Ui {
+
diff --git a/src/ui/FUi_NativeObjectHandler.h b/src/ui/FUi_NativeObjectHandler.h
new file mode 100755 (executable)
index 0000000..926f289
--- /dev/null
@@ -0,0 +1,113 @@
+#ifndef _FUI_NATIVE_OBJECT_HANDLER_H_\r
+#define _FUI_NATIVE_OBJECT_HANDLER_H_\r
+\r
+#include <FBaseTypes.h>\r
+\r
+namespace Tizen { namespace Ui { namespace Animations {\r
+       class DisplayContext;\r
+       class VisualElement;\r
+}}}\r
+\r
+namespace Tizen { namespace Ui {\r
+\r
+/**\r
+* @class                    _NativeObjectHandler\r
+* @brief                    This class provides utility methods for helping to handle a native image object.\r
+*\r
+* @since 2.1\r
+*\r
+* @final                     This class is not intended for extension.\r
+*\r
+* The %_NativeObjectHandler class provides utility methods for helping to handle a native image object.\r
+*/\r
+class _OSP_EXPORT_ _NativeObjectHandler\r
+{\r
+public:\r
+       /**\r
+       * Creates a native image object.\r
+       *\r
+       * @since 2.1\r
+       *\r
+       * @return       The native image object handle.@n\r
+       *               else @c 0 if an error occurs.\r
+       * @param[in]    pDisplayContext                       The display context of the window\r
+       * @param[in]    width                                 The width of the native image object\r
+       * @param[in]    height                                The height of the native image object\r
+       * @exception    E_SUCCESS                             The method is successful.\r
+       * @exception    E_INVALID_ARG                       The specified @c pDisplayContext is invalid.\r
+       * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.\r
+       * @remarks      The specific error code can be accessed using the GetLastResult() method.\r
+       */\r
+       static Handle CreateNativeImageObjectN(const Tizen::Ui::Animations::DisplayContext* pDisplayContext, int width, int height);\r
+\r
+       /**\r
+       * Sets a native image object to the visual element.\r
+       *\r
+       * @since 2.1\r
+       *\r
+       * @return       An error code\r
+       * @param[in]    pVisualElement                        The visual element to set the native image object\r
+       * @param[in]    nativeObjectHandle                  The handle of native image object\r
+       * @exception   E_SUCCESS                                        The method is successful.\r
+       * @exception    E_INVALID_ARG                       The specified @c pVisualElement or @c pNativeObject is invalid.\r
+       * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.\r
+       */\r
+       static result SetNativeObjectToVisualElement(Tizen::Ui::Animations::VisualElement* pVisualElement, Handle nativeObjectHandle);\r
+\r
+       /**\r
+       * Sets the show state of the native image object.\r
+       *\r
+       * @since 2.1\r
+       *\r
+       * @return                  An error code\r
+       * @param[in]    pNativeObject                  The native image object\r
+       * @param[in]    show                                               The new show state\r
+       * @exception    E_SUCCESS                                        The method is successful.\r
+       * @exception    E_INVALID_ARG                       The specified @c pNativeObject is @c null.\r
+       * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.\r
+       */\r
+       static result SetNativeObjectShowState(Handle nativeObjectHandle, bool show);\r
+\r
+       /**\r
+       * Deallocates the native image object.\r
+       *\r
+       * @since 2.1\r
+       *\r
+       * @return                  An error code\r
+       * @param[in]    pVisualElement                        The display context\r
+       * @param[in]    pNativeObject                  The native image object\r
+       * @exception    E_SUCCESS                                        The method is successful.\r
+       * @exception    E_INVALID_ARG                       The specified @c pVisualElement or @c pNativeObject is invalid.\r
+       * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.\r
+       */\r
+       static result DestroyNativeObject(Tizen::Ui::Animations::VisualElement* pVisualElement, Handle nativeObjectHandle);\r
+\r
+\r
+private:\r
+       //\r
+       // This default constructor is intentionally declared as private because this class cannot be constructed.\r
+       //\r
+       _NativeObjectHandler(void);\r
+\r
+       //\r
+       // This destructor is intentionally declared as private because this class cannot be constructed.\r
+       //\r
+       virtual ~_NativeObjectHandler(void);\r
+\r
+       //\r
+       // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.\r
+       //\r
+       // @param[in]    rhs                 An instance of %_NativeObjectHandler\r
+       //\r
+       _NativeObjectHandler(const _NativeObjectHandler& rhs);\r
+\r
+       //\r
+       // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.\r
+       //\r
+       // @param[in]    rhs                 An instance of %_NativeObjectHandler\r
+       //\r
+       _NativeObjectHandler& operator =(const _NativeObjectHandler& rhs);\r
+}; //_NativeObjectHandler\r
+}}  // namespace Tizen { namespace Ui {\r
+\r
+#endif //_FUI_NATIVE_OBJECT_HANDLER_H_\r