2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 #include <dali-toolkit/public-api/controls/control.h>
18 #include <dali-toolkit/public-api/controls/control-impl.h>
26 const char* const Control::ACTION_CONTROL_ACTIVATED = "control-activated";
27 const char* const Control::SIGNAL_KEY_EVENT = "key-event";
29 Control Control::New()
31 // Use TypeRegistry to create instance of control so that the type-info matches Control rather than ControlImpl
32 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(Control) );
33 DALI_ASSERT_ALWAYS( typeInfo && "TypeRegistry returning Invalid TypeInfo" );
35 BaseHandle handle = typeInfo.CreateInstance();
36 DALI_ASSERT_ALWAYS( handle && "Unable to Create Control" );
38 Control control = DownCast( handle );
39 DALI_ASSERT_ALWAYS( handle && "TypeRegistry did not create a Control" );
48 Control::Control(const Control& uiControl)
49 : CustomActor( uiControl ? static_cast<const ControlImpl&>( uiControl.GetImplementation() ).GetOwner() : NULL)
57 Control& Control::operator=( const Control& handle )
61 CustomActor::operator=( handle );
66 Control Control::DownCast( BaseHandle handle )
68 return DownCast<Control, ControlImpl>(handle);
71 ControlImpl& Control::GetImplementation()
73 return static_cast<ControlImpl&>(CustomActor::GetImplementation());
76 const ControlImpl& Control::GetImplementation() const
78 return static_cast<const ControlImpl&>(CustomActor::GetImplementation());
81 void Control::SetSizePolicy( SizePolicy widthPolicy, SizePolicy heightPolicy )
83 GetImplementation().SetSizePolicy( widthPolicy, heightPolicy );
86 void Control::GetSizePolicy( SizePolicy& widthPolicy, SizePolicy& heightPolicy ) const
88 GetImplementation().GetSizePolicy( widthPolicy, heightPolicy );
91 void Control::SetMinimumSize( const Vector3& size )
93 GetImplementation().SetMinimumSize( size );
96 const Vector3& Control::GetMinimumSize() const
98 return GetImplementation().GetMinimumSize();
101 void Control::SetMaximumSize( const Vector3& size )
103 GetImplementation().SetMaximumSize( size );
106 const Vector3& Control::GetMaximumSize() const
108 return GetImplementation().GetMaximumSize();
111 Vector3 Control::GetNaturalSize()
113 return GetImplementation().GetNaturalSize();
116 float Control::GetHeightForWidth( float width )
118 return GetImplementation().GetHeightForWidth( width );
121 float Control::GetWidthForHeight( float height )
123 return GetImplementation().GetWidthForHeight( height );
126 void Control::SetKeyInputFocus()
128 GetImplementation().SetKeyInputFocus();
131 bool Control::HasKeyInputFocus()
133 return GetImplementation().HasKeyInputFocus();
136 void Control::ClearKeyInputFocus()
138 GetImplementation().ClearKeyInputFocus();
141 PinchGestureDetector Control::GetPinchGestureDetector() const
143 return GetImplementation().GetPinchGestureDetector();
146 PanGestureDetector Control::GetPanGestureDetector() const
148 return GetImplementation().GetPanGestureDetector();
151 TapGestureDetector Control::GetTapGestureDetector() const
153 return GetImplementation().GetTapGestureDetector();
156 LongPressGestureDetector Control::GetLongPressGestureDetector() const
158 return GetImplementation().GetLongPressGestureDetector();
161 void Control::SetBackgroundColor( const Vector4& color )
163 GetImplementation().SetBackgroundColor( color );
166 Vector4 Control::GetBackgroundColor() const
168 return GetImplementation().GetBackgroundColor();
171 void Control::SetBackground( Image image )
173 GetImplementation().SetBackground( image );
176 void Control::ClearBackground()
178 GetImplementation().ClearBackground();
181 Actor Control::GetBackgroundActor() const
183 return GetImplementation().GetBackgroundActor();
186 Control::KeyEventSignalV2& Control::KeyEventSignal()
188 return GetImplementation().KeyEventSignal();
192 * @copydoc ConnectionTrackerInterface::SignalConnected
194 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
196 GetImplementation().SignalConnected(slotObserver, callback );
200 * @copydoc ConnectionTrackerInterface::SignalDisconnected
202 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
204 GetImplementation().SignalDisconnected(slotObserver, callback );
208 * @copydoc ConnectionTrackerInterface::GetConnectionCount
210 std::size_t Control::GetConnectionCount() const
212 return GetImplementation().GetConnectionCount( );
216 Control::Control(ControlImpl& implementation)
217 : CustomActor(implementation)
221 Control::Control(Dali::Internal::CustomActor* internal)
222 : CustomActor(internal)
224 VerifyCustomActorPointer<ControlImpl>(internal);
227 } // namespace Toolkit