2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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.
18 #include <dali-toolkit/public-api/controls/control.h>
19 #include <dali-toolkit/public-api/controls/control-impl.h>
27 const char* const Control::ACTION_CONTROL_ACTIVATED = "control-activated";
28 const char* const Control::SIGNAL_KEY_EVENT = "key-event";
30 Control Control::New()
32 // Use TypeRegistry to create instance of control so that the type-info matches Control rather than ControlImpl
33 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(Control) );
34 DALI_ASSERT_ALWAYS( typeInfo && "TypeRegistry returning Invalid TypeInfo" );
36 BaseHandle handle = typeInfo.CreateInstance();
37 DALI_ASSERT_ALWAYS( handle && "Unable to Create Control" );
39 Control control = DownCast( handle );
40 DALI_ASSERT_ALWAYS( handle && "TypeRegistry did not create a Control" );
49 Control::Control(const Control& uiControl)
50 : CustomActor( uiControl ? static_cast<const ControlImpl&>( uiControl.GetImplementation() ).GetOwner() : NULL)
58 Control& Control::operator=( const Control& handle )
62 CustomActor::operator=( handle );
67 Control Control::DownCast( BaseHandle handle )
69 return DownCast<Control, ControlImpl>(handle);
72 ControlImpl& Control::GetImplementation()
74 return static_cast<ControlImpl&>(CustomActor::GetImplementation());
77 const ControlImpl& Control::GetImplementation() const
79 return static_cast<const ControlImpl&>(CustomActor::GetImplementation());
82 void Control::SetSizePolicy( SizePolicy widthPolicy, SizePolicy heightPolicy )
84 GetImplementation().SetSizePolicy( widthPolicy, heightPolicy );
87 void Control::GetSizePolicy( SizePolicy& widthPolicy, SizePolicy& heightPolicy ) const
89 GetImplementation().GetSizePolicy( widthPolicy, heightPolicy );
92 void Control::SetMinimumSize( const Vector3& size )
94 GetImplementation().SetMinimumSize( size );
97 const Vector3& Control::GetMinimumSize() const
99 return GetImplementation().GetMinimumSize();
102 void Control::SetMaximumSize( const Vector3& size )
104 GetImplementation().SetMaximumSize( size );
107 const Vector3& Control::GetMaximumSize() const
109 return GetImplementation().GetMaximumSize();
112 Vector3 Control::GetNaturalSize()
114 return GetImplementation().GetNaturalSize();
117 float Control::GetHeightForWidth( float width )
119 return GetImplementation().GetHeightForWidth( width );
122 float Control::GetWidthForHeight( float height )
124 return GetImplementation().GetWidthForHeight( height );
127 void Control::SetKeyInputFocus()
129 GetImplementation().SetKeyInputFocus();
132 bool Control::HasKeyInputFocus()
134 return GetImplementation().HasKeyInputFocus();
137 void Control::ClearKeyInputFocus()
139 GetImplementation().ClearKeyInputFocus();
142 PinchGestureDetector Control::GetPinchGestureDetector() const
144 return GetImplementation().GetPinchGestureDetector();
147 PanGestureDetector Control::GetPanGestureDetector() const
149 return GetImplementation().GetPanGestureDetector();
152 TapGestureDetector Control::GetTapGestureDetector() const
154 return GetImplementation().GetTapGestureDetector();
157 LongPressGestureDetector Control::GetLongPressGestureDetector() const
159 return GetImplementation().GetLongPressGestureDetector();
162 void Control::SetBackgroundColor( const Vector4& color )
164 GetImplementation().SetBackgroundColor( color );
167 Vector4 Control::GetBackgroundColor() const
169 return GetImplementation().GetBackgroundColor();
172 void Control::SetBackground( Image image )
174 GetImplementation().SetBackground( image );
177 void Control::ClearBackground()
179 GetImplementation().ClearBackground();
182 Actor Control::GetBackgroundActor() const
184 return GetImplementation().GetBackgroundActor();
187 Control::KeyEventSignalV2& Control::KeyEventSignal()
189 return GetImplementation().KeyEventSignal();
193 * @copydoc ConnectionTrackerInterface::SignalConnected
195 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
197 GetImplementation().SignalConnected(slotObserver, callback );
201 * @copydoc ConnectionTrackerInterface::SignalDisconnected
203 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
205 GetImplementation().SignalDisconnected(slotObserver, callback );
209 * @copydoc ConnectionTrackerInterface::GetConnectionCount
211 std::size_t Control::GetConnectionCount() const
213 return GetImplementation().GetConnectionCount( );
217 Control::Control(ControlImpl& implementation)
218 : CustomActor(implementation)
222 Control::Control(Dali::Internal::CustomActor* internal)
223 : CustomActor(internal)
225 VerifyCustomActorPointer<ControlImpl>(internal);
228 } // namespace Toolkit