Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / FUi_NativeObjectHandler.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FUi_NativeObjectHandler.cpp
20  * @brief               This is the implementation file for the _NativeObjectHandler class.
21  */
22
23 #include <Evas.h>
24 #include "FUiAnimDisplayContext.h"
25 #include "FUiAnimVisualElement.h"
26
27 #include "FUi_NativeObjectHandler.h"
28
29 #include "FUiAnim_VisualElementImpl.h"
30 #include "FUiAnim_DisplayContextImpl.h"
31 #include "FUiAnim_EflNode.h"
32 #include "FUiAnim_EflLayer.h"
33
34 #include <FUiControl.h>
35 #include "FUi_ControlImpl.h"
36
37
38
39
40 using namespace Tizen::Ui::Animations;
41
42 namespace Tizen { namespace Ui {
43
44 Handle
45 _NativeObjectHandler::CreateNativeImageObjectN(const DisplayContext* pDisplayContext, int width, int height)
46 {
47 //    * @exception    E_SUCCESS                             The method is successful.
48 //    * @exception    E_INVALID_ARG                       The specified @c pDisplayContext is invalid.
49 //    * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.
50         if(!pDisplayContext)
51         {
52                 return null;
53         }
54
55         _DisplayContextImpl* pDispImpl =  _DisplayContextImpl::GetInstance(*(DisplayContext*)pDisplayContext);
56
57         if(!pDispImpl->GetNativeLayer())
58         {
59                 return null;
60         }
61         Evas* pEvas = ((_EflLayer*)pDispImpl->GetNativeLayer())->GetEvas();
62
63         if(!pEvas)
64         {
65                 return null;
66         }
67
68         Evas_Object* pImage = evas_object_image_filled_add(pEvas);
69         evas_object_resize(pImage, width, height);
70         evas_object_move(pImage, 0, 0);
71 //      evas_object_show(pImage);
72
73         return reinterpret_cast<Handle>(pImage);
74 }
75
76 result
77 _NativeObjectHandler::SetNativeObjectToVisualElement(VisualElement* pVisualElement, Handle nativeObjectHandle)
78 {
79 //    * @exception    E_SUCCESS                                        The method is successful.
80 //    * @exception    E_INVALID_ARG                       The specified @c pNativeObject is @c null.
81 //    * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.
82         Evas_Object* pNative = reinterpret_cast<Evas_Object*>(nativeObjectHandle);
83
84         if(!pNative || !pVisualElement)
85         {
86                 return E_INVALID_ARG;
87         }
88
89         _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVisualElement);
90
91         _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode();
92         pNode->AddNativeSmartObject(*pVisualElement, pNative);
93
94         const char* pName = null;
95         evas_object_image_file_get(pNative, &pName, null);
96         if (!pName)
97         {
98                 int imageWidth = 0;
99                 int imageHeight = 0;
100
101                 evas_object_image_size_get(pNative, &imageWidth, &imageHeight);
102                 evas_object_image_data_update_add(pNative, 0, 0, imageWidth, imageHeight);
103         }
104         return E_SUCCESS;
105 }
106
107
108 result
109 _NativeObjectHandler::SetNativeObjectShowState(Handle nativeObjectHandle, bool show)
110 {
111 //    * @exception    E_SUCCESS                                        The method is successful.
112 //    * @exception    E_INVALID_ARG                       The specified @c pVisualElement or @c pNativeObject is invalid.
113 //    * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.
114         Evas_Object* pNative = reinterpret_cast<Evas_Object*>(nativeObjectHandle);
115         if(!pNative)
116         {
117                 return E_INVALID_ARG;
118         }
119         if(show)
120         {
121                 evas_object_show(pNative);
122         }
123         else
124         {
125                 evas_object_hide(pNative);
126         }
127
128         return E_SUCCESS;
129 }
130
131
132 result
133 _NativeObjectHandler::DestroyNativeObject(VisualElement* pVisualElement, Handle nativeObjectHandle)
134 {
135 //    * @exception    E_SUCCESS                                        The method is successful.
136 //    * @exception    E_UNSUPPORTED_OPERATION             This operation is not supported.
137
138         if(pVisualElement)
139         {
140                 _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVisualElement);
141
142                 _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode();
143                 pNode->AddNativeSmartObject(*pVisualElement, null);
144
145         }
146         Evas_Object* pNative = reinterpret_cast<Evas_Object*>(nativeObjectHandle);
147         if(pNative)
148         {
149                 evas_object_del(pNative);
150
151         }
152         return E_SUCCESS;
153 }
154
155 }}  // namespace Tizen { namespace Ui {
156