2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file evas_object.cpp
18 * @author Lukasz Wrzosek (l.wrzosel@samsung.com)
20 * @brief This file is the implementation for Evas_Object wrapper from
24 #include "evas_object.h"
25 #include <dpl/foreach.h>
27 Evas_Object* EvasObject::IConnection::GetEvasObject()
29 return m_object->GetObject();
32 void EvasObject::IConnection::Disconnect()
34 m_object->DisconnectCallback(this);
37 EvasObject::IConnection::IConnection(EvasObject::EvasObjectShared* object) :
41 void EvasObject::IConnection::SmartCallbackWrapper(void* data,
42 Evas_Object* /*object*/,
46 IConnection* Calle = static_cast<IConnection*>(data);
47 Calle->Call(event_info);
50 void EvasObject::IConnection::EvasCallbackWrapper(void* data,
52 Evas_Object* /*object*/,
56 IConnection* Calle = static_cast<IConnection*>(data);
57 Calle->Call(event_info);
60 Evas_Object* EvasObject::EvasObjectShared::GetObject()
65 EvasObject::EvasObjectShared::SmartConnectionBase::SmartConnectionBase(
66 const std::string& name,
67 EvasObject::EvasObjectShared* object) :
72 void EvasObject::EvasObjectShared::SmartConnectionBase::ConnectPrv()
74 evas_object_smart_callback_add(GetEvasObject(),
75 m_callbackName.c_str(),
76 &IConnection::SmartCallbackWrapper, this);
79 void EvasObject::EvasObjectShared::SmartConnectionBase::DisconnectPrv()
81 evas_object_smart_callback_del(GetEvasObject(),
82 m_callbackName.c_str(),
83 &IConnection::SmartCallbackWrapper);
86 EvasObject::EvasObjectShared::EvasConnectionBase::EvasConnectionBase(
87 Evas_Callback_Type type,
88 EvasObject::EvasObjectShared* object) :
93 void EvasObject::EvasObjectShared::EvasConnectionBase::ConnectPrv()
95 evas_object_event_callback_add(
96 GetEvasObject(), m_callbackType, &IConnection::EvasCallbackWrapper,
100 void EvasObject::EvasObjectShared::EvasConnectionBase::DisconnectPrv()
102 evas_object_event_callback_del_full(
103 GetEvasObject(), m_callbackType, &IConnection::EvasCallbackWrapper,
107 EvasObject::EvasObjectShared::EvasObjectShared() :
111 EvasObject::EvasObjectShared::EvasObjectShared(Evas_Object* object) :
115 evas_object_event_callback_add(m_object,
121 void EvasObject::EvasObjectShared::SetObject(Evas_Object* object)
123 Assert(m_object == NULL);
124 Assert(object != NULL);
126 evas_object_event_callback_add(m_object,
132 EvasObject::EvasObjectShared::~EvasObjectShared()
136 evas_object_event_callback_del(m_object,
143 bool EvasObject::EvasObjectShared::DisconnectCallback(IConnection* connection)
145 IConnectionsSet::iterator it = m_connections.find(connection);
146 if (it != m_connections.end()) {
147 (*it)->DisconnectPrv();
149 m_connections.erase(it);
155 void EvasObject::EvasObjectShared::DisconnectAll()
157 FOREACH(it, m_connections)
159 (*it)->DisconnectPrv();
162 m_connections.clear();
165 void EvasObject::EvasObjectShared::StaticOnDelEvent(void* data,
171 EvasObjectShared* This = static_cast<EvasObjectShared*>(data);
172 if (This->m_object) {
173 evas_object_event_callback_del(This->m_object,
176 This->DisconnectAll();
177 This->m_object = NULL;
181 EvasObject::EvasObject() :
182 m_object(new EvasObjectShared())
185 EvasObject::EvasObject(Evas_Object* object) :
186 m_object(new EvasObjectShared(object))
189 EvasObject::EvasObject(const EvasObject& other) :
190 m_object(other.m_object)
193 //this destructor must be here to let pimpl with shared_ptr work without warning
194 EvasObject::~EvasObject()
197 EvasObject& EvasObject::operator=(const EvasObject& other)
200 m_object = other.m_object;
204 EvasObject* EvasObject::operator=(Evas_Object* object)
207 m_object->SetObject(object);
211 bool EvasObject::DisconnectCallback(IConnection* connection)
214 return m_object->DisconnectCallback(connection);
217 void EvasObject::DisconnectAll()
220 m_object->DisconnectAll();
223 EvasObject::operator Evas_Object *()
226 return m_object->GetObject();