Fix control properties for C# custom view
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / control-wrapper-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_CONTROL_WRAPPER_H
2 #define DALI_TOOLKIT_INTERNAL_CONTROL_WRAPPER_H
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/devel-api/controls/control-wrapper.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal
32 {
33
34 class ControlWrapper;
35
36 typedef IntrusivePtr< ControlWrapper > ControlWrapperPtr;
37
38 /**
39  * @copydoc Toolkit::ControlWrapper
40  */
41 class DALI_IMPORT_API ControlWrapper : public Control
42 {
43 public:
44
45   // Flags for the constructor
46   enum CustomControlBehaviour
47   {
48     CONTROL_BEHAVIOUR_DEFAULT            = Control::CONTROL_BEHAVIOUR_DEFAULT,
49     DISABLE_SIZE_NEGOTIATION             = CustomActorImpl::DISABLE_SIZE_NEGOTIATION,
50     REQUIRES_KEYBOARD_NAVIGATION_SUPPORT = Control::REQUIRES_KEYBOARD_NAVIGATION_SUPPORT,
51     DISABLE_STYLE_CHANGE_SIGNALS         = Control::DISABLE_STYLE_CHANGE_SIGNALS,
52
53     LAST_CONTROL_BEHAVIOUR_FLAG
54   };
55
56   static const int CONTROL_BEHAVIOUR_FLAG_COUNT = Log< LAST_CONTROL_BEHAVIOUR_FLAG - 1 >::value + 1;      ///< Total count of flags
57
58   /**
59    * @brief Control constructor
60    *
61    * @param[in] behaviourFlags Behavioural flags from CustomControlBehaviour enum
62    */
63   ControlWrapper( CustomControlBehaviour behaviourFlags );
64
65   /**
66    * Create a new ControlWrapper.
67    *
68    * @param[in] typeName The name of the type that is registered with this control
69    * @param[in] controlWrapper The implementation of this control
70    *
71    * @return A public handle to the newly allocated ControlWrapper.
72    */
73   static Dali::Toolkit::ControlWrapper New( const std::string& typeName, ControlWrapper* controlWrapper );
74
75 public: // From CustomActorImpl
76
77   // Size negotiation helpers
78
79   /**
80    * @copydoc Dali::CustomActorImpl::RelayoutRequest()
81    */
82   void RelayoutRequest();
83
84   /**
85    * @copydoc Dali::CustomActorImpl::GetHeightForWidthBase()
86    */
87   float GetHeightForWidthBase( float width );
88
89   /**
90    * @copydoc Dali::CustomActorImpl::GetWidthForHeightBase()
91    */
92   float GetWidthForHeightBase( float height );
93
94   /**
95    * @copydoc Dali::CustomActorImpl::CalculateChildSizeBase()
96    */
97   float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension );
98
99   /**
100    * @copydoc Dali::CustomActorImpl::RelayoutDependentOnChildrenBase()
101    */
102   bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
103
104 public: // From Control
105
106   /**
107    * @copydoc Dali::Toolkit::Internal::Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
108    */
109   void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual );
110
111   /**
112    * @copydoc Dali::Toolkit::Internal::Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
113    */
114   void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
115
116   /**
117    * @copydoc Dali::Toolkit::Internal::Control::UnregisterVisual()
118    */
119   void UnregisterVisual( Property::Index index );
120
121   /**
122    * @copydoc Dali::Toolkit::Internal::Control::GetVisual()
123    */
124   Toolkit::Visual::Base GetVisual( Property::Index index ) const;
125
126   /**
127    * @copydoc Dali::Toolkit::Internal::Control::EnableVisual()
128    */
129   void EnableVisual( Property::Index index, bool enable );
130
131   /**
132    * @copydoc Dali::Toolkit::Internal::Control::IsVisualEnabled()
133    */
134   bool IsVisualEnabled( Property::Index index ) const;
135
136   /**
137    * @copydoc Dali::Toolkit::Internal::Control::CreateTransition()
138    */
139   Dali::Animation CreateTransition( const Toolkit::TransitionData& transitionData );
140
141   /**
142    * @copydoc Dali::Toolkit::Internal::Control::EmitKeyInputFocusSignal()
143    */
144   void EmitKeyInputFocusSignal( bool focusGained );
145
146   /**
147    * @brief Apply the current style
148    *
149    * This method is called after the Control has been initialized.
150    *
151    */
152   void ApplyThemeStyle();
153
154 protected:
155
156   /**
157    * Protected Destructor
158    * A reference counted object may only be deleted by calling Unreference()
159    */
160   virtual ~ControlWrapper();
161
162 private:
163
164   /// @cond internal
165   /// Undefined.
166   DALI_INTERNAL ControlWrapper( const ControlWrapper& );
167
168   /// Undefined.
169   DALI_INTERNAL ControlWrapper& operator=( const ControlWrapper& rhs );
170   /// @endcond
171 };
172
173 } // namespace Internal
174
175 // Helpers for public-api forwarding methods
176
177 inline Toolkit::Internal::ControlWrapper& GetControlWrapperImpl( Toolkit::ControlWrapper& publicObject )
178 {
179   DALI_ASSERT_ALWAYS( publicObject );
180
181   Dali::RefObject& handle = publicObject.GetImplementation();
182
183   return static_cast<Toolkit::Internal::ControlWrapper&>( handle );
184 }
185
186 inline const Toolkit::Internal::ControlWrapper& GetControlWrapperImpl( const Toolkit::ControlWrapper& publicObject )
187 {
188   DALI_ASSERT_ALWAYS( publicObject );
189
190   const Dali::RefObject& handle = publicObject.GetImplementation();
191
192   return static_cast<const Toolkit::Internal::ControlWrapper&>( handle );
193 }
194
195 } // namespace Toolkit
196
197 } // namespace Dali
198
199 #endif // DALI_TOOLKIT_INTERNAL_CONTROL_WRAPPER_H