[NUI]Refactor Components (#1152)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / CustomView.cs
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System.ComponentModel;
18 using Tizen.NUI.Binding;
19
20 namespace Tizen.NUI.BaseComponents
21 {
22     /// <summary>
23     /// CustomView provides some common functionality required by all views.
24     /// </summary>
25     /// <since_tizen> 3 </since_tizen>
26     public class CustomView : ViewWrapper
27     {
28         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
29         [EditorBrowsable(EditorBrowsableState.Never)]
30         public static readonly BindableProperty FocusNavigationSupportProperty = BindableProperty.Create("FocusNavigationSupport", typeof(bool), typeof(CustomView), false, propertyChanged: (bindable, oldValue, newValue) =>
31         {
32             var customView = (CustomView)bindable;
33             if (newValue != null)
34             {
35                 customView.SetKeyboardNavigationSupport((bool)newValue);
36             }
37         },
38         defaultValueCreator: (bindable) =>
39         {
40             var customView = (CustomView)bindable;
41             return customView.IsKeyboardNavigationSupported();
42         });
43
44         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
45         [EditorBrowsable(EditorBrowsableState.Never)]
46         public static readonly BindableProperty FocusGroupProperty = BindableProperty.Create("FocusGroup", typeof(bool), typeof(CustomView), false, propertyChanged: (bindable, oldValue, newValue) =>
47         {
48             var customView = (CustomView)bindable;
49             if (newValue != null)
50             {
51                 customView.SetAsKeyboardFocusGroup((bool)newValue);
52             }
53         },
54         defaultValueCreator: (bindable) =>
55         {
56             var customView = (CustomView)bindable;
57             return customView.IsKeyboardFocusGroup();
58         });
59
60         /// <summary>
61         /// Create an instance of customView.
62         /// </summary>
63         /// <param name="typeName">typename</param>
64         /// <param name="behaviour">CustomView Behaviour</param>
65         /// <since_tizen> 3 </since_tizen>
66         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
67         [EditorBrowsable(EditorBrowsableState.Never)]
68         public CustomView(string typeName, CustomViewBehaviour behaviour, ViewStyle viewStyle) : base(typeName, new ViewWrapperImpl(behaviour), viewStyle)
69         {
70             Initialize();
71         }
72
73         /// <summary>
74         /// Create an instance of customView.
75         /// </summary>
76         /// <param name="typeName">typename</param>
77         /// <param name="behaviour">CustomView Behaviour</param>
78         /// <since_tizen> 3 </since_tizen>
79         public CustomView(string typeName, CustomViewBehaviour behaviour) : base(typeName, new ViewWrapperImpl(behaviour))
80         {
81             Initialize();
82         }
83
84         /// <summary>
85         /// Sets whether this control supports two dimensional keyboard navigation
86         /// (i.e., whether it knows how to handle the keyboard focus movement between its child views).<br />
87         /// The control doesn't support it by default.<br />
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         public bool FocusNavigationSupport
91         {
92             get
93             {
94                 return (bool)GetValue(FocusNavigationSupportProperty);
95             }
96             set
97             {
98                 SetValue(FocusNavigationSupportProperty, value);
99             }
100         }
101
102         /// <summary>
103         /// Sets or gets whether this control is a focus group for keyboard navigation.
104         /// </summary>
105         /// <returns>True if this control is set as a focus group for keyboard navigation.</returns>
106         /// <since_tizen> 3 </since_tizen>
107         public bool FocusGroup
108         {
109             get
110             {
111                 return (bool)GetValue(FocusGroupProperty);
112             }
113             set
114             {
115                 SetValue(FocusGroupProperty, value);
116             }
117         }
118
119         /// <summary>
120         /// Sets the background with a property map.
121         /// </summary>
122         /// <param name="map">The background property map.</param>
123         /// <since_tizen> 3 </since_tizen>
124         public void SetBackground(Tizen.NUI.PropertyMap map)
125         {
126             viewWrapperImpl.SetBackground(map);
127         }
128
129         /// <summary>
130         /// Allows deriving classes to enable any of the gesture detectors that are available.<br />
131         /// Gesture detection can be enabled one at a time or in a bitwise format.<br />
132         /// </summary>
133         /// <param name="type">The gesture type(s) to enable.</param>
134         /// <since_tizen> 3 </since_tizen>
135         public void EnableGestureDetection(Gesture.GestureType type)
136         {
137             viewWrapperImpl.EnableGestureDetection(type);
138         }
139
140         /// <summary>
141         /// This method is called after the control has been initialized.<br />
142         /// Derived classes should do any second phase initialization by overriding this method.<br />
143         /// </summary>
144         /// <since_tizen> 3 </since_tizen>
145         public virtual void OnInitialize()
146         {
147         }
148
149         /// <summary>
150         /// Called after the view has been connected to the stage.<br />
151         /// When a view is connected, it will be directly or indirectly parented to the root view.<br />
152         /// The root view is provided automatically by Tizen.NUI.Stage, and is always considered to be connected.<br />
153         /// When the parent of a set of views is connected to the stage, then all of the children will receive this callback.<br />
154         /// </summary>
155         /// <param name="depth">The depth in the hierarchy for the view.</param>
156         /// <since_tizen> 3 </since_tizen>
157         public virtual void OnStageConnection(int depth)
158         {
159         }
160
161         /// <summary>
162         /// Called after the view has been disconnected from the stage.<br />
163         /// If a view is disconnected, it either has no parent, or is parented to a disconnected view.<br />
164         /// When the parent of a set of views is disconnected to the stage, then all of the children will receive this callback, starting with the leaf views.<br />
165         /// </summary>
166         /// <since_tizen> 3 </since_tizen>
167         public virtual void OnStageDisconnection()
168         {
169         }
170
171         /// <summary>
172         /// Called after a child has been added to the owning view.
173         /// </summary>
174         /// <param name="view">The child which has been added.</param>
175         /// <since_tizen> 3 </since_tizen>
176         public virtual void OnChildAdd(View view)
177         {
178         }
179
180         /// <summary>
181         /// Called after the owning view has attempted to remove a child( regardless of whether it succeeded or not ).
182         /// </summary>
183         /// <param name="view">The child being removed.</param>
184         /// <since_tizen> 3 </since_tizen>
185         public virtual void OnChildRemove(View view)
186         {
187         }
188
189         /// <summary>
190         /// Called when the owning view property is set.
191         /// </summary>
192         /// <param name="index">The property index that was set.</param>
193         /// <param name="propertyValue">The value to set.</param>
194         /// <since_tizen> 3 </since_tizen>
195         public virtual void OnPropertySet(int index, Tizen.NUI.PropertyValue propertyValue)
196         {
197         }
198
199         /// <summary>
200         /// Called when the owning view's size is set, for example, using View.SetSize().
201         /// </summary>
202         /// <param name="targetSize">The target size.</param>
203         /// <since_tizen> 3 </since_tizen>
204         public virtual void OnSizeSet(Vector3 targetSize)
205         {
206         }
207
208         /// <summary>
209         /// Called when the owning view's size is animated, for example, using Animation::AnimateTo( Property ( view, View::Property::SIZE ), ... ).
210         /// </summary>
211         /// <param name="animation">The object which is animating the owning view.</param>
212         /// <param name="targetSize">The target size.</param>
213         /// <since_tizen> 3 </since_tizen>
214         public virtual void OnSizeAnimation(Animation animation, Vector3 targetSize)
215         {
216         }
217
218         /// <summary>
219         /// Called after a touch event is received by the owning view.<br />
220         /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
221         /// </summary>
222         /// <param name="touch">The touch event.</param>
223         /// <returns>True if the event should be consumed.</returns>
224         /// <since_tizen> 3 </since_tizen>
225         public virtual bool OnTouch(Touch touch)
226         {
227             return false; // Do not consume
228         }
229
230         /// <summary>
231         /// Called after a hover event is received by the owning view.<br />
232         /// CustomViewBehaviour.REQUIRES_HOVER_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
233         /// </summary>
234         /// <param name="hover">The hover event.</param>
235         /// <returns>True if the hover event should be consumed.</returns>
236         /// <since_tizen> 3 </since_tizen>
237         public virtual bool OnHover(Hover hover)
238         {
239             return false; // Do not consume
240         }
241
242         /// <summary>
243         /// Called after a key event is received by the view that has had its focus set.
244         /// </summary>
245         /// <param name="key">The key event.</param>
246         /// <returns>True if the key event should be consumed.</returns>
247         /// <since_tizen> 3 </since_tizen>
248         public virtual bool OnKey(Key key)
249         {
250             return false; // Do not consume
251         }
252
253         /// <summary>
254         /// Called after a wheel event is received by the owning view.<br />
255         /// CustomViewBehaviour.REQUIRES_WHEEL_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
256         /// </summary>
257         /// <param name="wheel">The wheel event.</param>
258         /// <returns>True if the wheel event should be consumed.</returns>
259         /// <since_tizen> 3 </since_tizen>
260         public virtual bool OnWheel(Wheel wheel)
261         {
262             return false; // Do not consume
263         }
264
265         /// <summary>
266         /// Called after the size negotiation has been finished for this control.<br />
267         /// The control is expected to assign this given size to itself or its children.<br />
268         /// Should be overridden by derived classes if they need to layout views differently after certain operations like add or remove views, resize, or after changing specific properties.<br />
269         /// As this function is called from inside the size negotiation algorithm, you cannot call RequestRelayout (the call would just be ignored).<br />
270         /// </summary>
271         /// <param name="size">The allocated size.</param>
272         /// <param name="container">The control should add views to this container that it is not able to allocate a size for.</param>
273         /// <since_tizen> 3 </since_tizen>
274         public virtual void OnRelayout(Vector2 size, RelayoutContainer container)
275         {
276         }
277
278         /// <summary>
279         /// Notification for deriving classes.
280         /// </summary>
281         /// <param name="policy">The policy being set.</param>
282         /// <param name="dimension">The policy is being set for.</param>
283         /// <since_tizen> 3 </since_tizen>
284         public virtual void OnSetResizePolicy(ResizePolicyType policy, DimensionType dimension)
285         {
286         }
287
288         /// <summary>
289         /// Returns the natural size of the view.
290         /// </summary>
291         /// <returns>The view's natural size</returns>
292         /// <since_tizen> 3 </since_tizen>
293         public new virtual Size2D GetNaturalSize()
294         {
295             return sizeSetExplicitly;  // Returns the size set explicitly on View unless Overridden.
296         }
297
298         /// <summary>
299         /// Calculates the size for a child.
300         /// </summary>
301         /// <param name="child">The child view to calculate the size for.</param>
302         /// <param name="dimension">The dimension to calculate the size, for example, the width or the height.</param>
303         /// <returns>Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found.</returns>
304         /// <since_tizen> 3 </since_tizen>
305         public virtual float CalculateChildSize(View child, DimensionType dimension)
306         {
307             return viewWrapperImpl.CalculateChildSizeBase(child, dimension);
308         }
309
310         /// <summary>
311         /// This method is called during size negotiation when a height is required for a given width.<br />
312         /// Derived classes should override this if they wish to customize the height returned.<br />
313         /// </summary>
314         /// <param name="width">Width to use</param>
315         /// <returns>The height based on the width</returns>
316         /// <since_tizen> 3 </since_tizen>
317         public new virtual float GetHeightForWidth(float width)
318         {
319             return viewWrapperImpl.GetHeightForWidthBase(width);
320         }
321
322         /// <summary>
323         /// This method is called during size negotiation when a width is required for a given height.<br />
324         /// Derived classes should override this if they wish to customize the width returned.<br />
325         /// </summary>
326         /// <param name="height">Height to use</param>
327         /// <returns>The width based on the width</returns>
328         /// <since_tizen> 3 </since_tizen>
329         public new virtual float GetWidthForHeight(float height)
330         {
331             return viewWrapperImpl.GetWidthForHeightBase(height);
332         }
333
334         /// <summary>
335         /// Determines if this view is dependent on it's children for relayout.
336         /// </summary>
337         /// <param name="dimension">The dimension(s) to check for.</param>
338         /// <returns>Return if the view is dependent on it's children.</returns>
339         /// <since_tizen> 3 </since_tizen>
340         public virtual bool RelayoutDependentOnChildren(DimensionType dimension)
341         {
342             return viewWrapperImpl.RelayoutDependentOnChildrenBase(dimension);
343         }
344
345         /// <summary>
346         /// Determines if this view is dependent on it's children for relayout from the base class.
347         /// </summary>
348         /// <returns>Return true if the view is dependent on it's children.</returns>
349         /// <since_tizen> 3 </since_tizen>
350         public virtual bool RelayoutDependentOnChildren()
351         {
352             return viewWrapperImpl.RelayoutDependentOnChildrenBase();
353         }
354
355         /// <summary>
356         /// The virtual method to notify deriving classes that relayout dependencies have been
357         /// met and the size for this object is about to be calculated for the given dimension.
358         /// </summary>
359         /// <param name="dimension">The dimension that is about to be calculated.</param>
360         /// <since_tizen> 3 </since_tizen>
361         public virtual void OnCalculateRelayoutSize(DimensionType dimension)
362         {
363         }
364
365         /// <summary>
366         /// The virtual method to notify deriving classes that the size for a dimension has just been negotiated.
367         /// </summary>
368         /// <param name="size">The new size for the given dimension.</param>
369         /// <param name="dimension">The dimension that was just negotiated.</param>
370         /// <since_tizen> 3 </since_tizen>
371         public virtual void OnLayoutNegotiated(float size, DimensionType dimension)
372         {
373         }
374
375         /// <summary>
376         /// This method should be overridden by deriving classes requiring notifications when the style changes.
377         /// </summary>
378         /// <param name="styleManager">The StyleManager object.</param>
379         /// <param name="change">Information denoting what has changed.</param>
380         /// <since_tizen> 3 </since_tizen>
381         public virtual void OnStyleChange(StyleManager styleManager, StyleChangeType change)
382         {
383         }
384
385         /// <summary>
386         /// Called when the control gain key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is gained.
387         /// </summary>
388         /// <since_tizen> 3 </since_tizen>
389         public virtual void OnFocusGained()
390         {
391         }
392
393         /// <summary>
394         /// Called when the control loses key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is lost.
395         /// </summary>
396         /// <since_tizen> 3 </since_tizen>
397         public virtual void OnFocusLost()
398         {
399         }
400
401         /// <summary>
402         /// Gets the next keyboard focusable view in this control towards the given direction.<br />
403         /// A control needs to override this function in order to support two dimensional keyboard navigation.<br />
404         /// </summary>
405         /// <param name="currentFocusedView">The current focused view.</param>
406         /// <param name="direction">The direction to move the focus towards.</param>
407         /// <param name="loopEnabled">Whether the focus movement should be looped within the control.</param>
408         /// <returns>The next keyboard focusable view in this control or an empty handle if no view can be focused.</returns>
409         /// <since_tizen> 3 </since_tizen>
410         public virtual View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
411         {
412             return new View();
413         }
414
415         /// <summary>
416         /// Informs this control that its chosen focusable view will be focused.<br />
417         /// This allows the application to preform any actions it wishes before the focus is actually moved to the chosen view.<br />
418         /// </summary>
419         /// <param name="commitedFocusableView">The commited focused view.</param>
420         /// <since_tizen> 3 </since_tizen>
421         public virtual void OnFocusChangeCommitted(View commitedFocusableView)
422         {
423         }
424
425         /// <summary>
426         /// This method is called when the control has enter pressed on it.<br />
427         /// Derived classes should override this to perform custom actions.<br />
428         /// </summary>
429         /// <returns>True if this control supported this action.</returns>
430         /// <since_tizen> 3 </since_tizen>
431         public virtual bool OnKeyboardEnter()
432         {
433             return false;
434         }
435
436         /// <summary>
437         /// Called whenever a pan gesture is detected on this control.<br />
438         /// This should be overridden by deriving classes when pan detection is enabled.<br />
439         /// There is no default behavior with panning.<br />
440         /// Pan detection should be enabled via EnableGestureDetection().<br />
441         /// </summary>
442         /// <param name="pan">The pan gesture.</param>
443         /// <since_tizen> 3 </since_tizen>
444         public virtual void OnPan(PanGesture pan)
445         {
446         }
447
448         /// <summary>
449         /// Called whenever a tap gesture is detected on this control.<br />
450         /// This should be overridden by deriving classes when tap detection is enabled.<br />
451         /// There is no default behavior with a tap.<br />
452         /// Tap detection should be enabled via EnableGestureDetection().<br />
453         /// </summary>
454         /// <param name="tap">The tap gesture.</param>
455         /// <since_tizen> 3 </since_tizen>
456         public virtual void OnTap(TapGesture tap)
457         {
458         }
459
460         /// <summary>
461         /// This method is called when the control accessibility is activated.<br />
462         /// Derived classes should override this to perform custom accessibility activation.<br />
463         /// </summary>
464         /// <returns>True if this control can perform accessibility activation.</returns>
465         internal virtual bool OnAccessibilityActivated()
466         {
467             return false;
468         }
469
470         /// <summary>
471         /// This method should be overridden by deriving classes when they wish to respond the accessibility.
472         /// </summary>
473         /// <param name="gestures">The pan gesture.</param>
474         /// <returns>True if the pan gesture has been consumed by this control.</returns>
475         internal virtual bool OnAccessibilityPan(PanGesture gestures)
476         {
477             return false;
478         }
479
480         /// <summary>
481         /// This method should be overridden by deriving classes when they wish to respond the accessibility.
482         /// </summary>
483         /// <param name="touch">The touch gesture.</param>
484         /// <returns>True if the touch event has been consumed by this control.</returns>
485         internal virtual bool OnAccessibilityTouch(Touch touch)
486         {
487             return false;
488         }
489
490         /// <summary>
491         /// This method should be overridden by deriving classes when they wish to respond the accessibility up and down action (i.e., value change of slider control).
492         /// </summary>
493         /// <param name="isIncrease">Whether the value should be increased or decreased.</param>
494         /// <returns>True if the value changed action has been consumed by this control.</returns>
495         internal virtual bool OnAccessibilityValueChange(bool isIncrease)
496         {
497             return false;
498         }
499
500         /// <summary>
501         /// This method should be overridden by deriving classes when they wish to respond the accessibility zoom action.
502         /// </summary>
503         /// <returns>True if the zoom action has been consumed by this control.</returns>
504         internal virtual bool OnAccessibilityZoom()
505         {
506             return false;
507         }
508
509         /// <summary>
510         /// Allows deriving classes to disable any of the gesture detectors.<br />
511         /// Like EnableGestureDetection, this can also be called using bitwise or one at a time.<br />
512         /// </summary>
513         /// <param name="type">The gesture type(s) to disable.</param>
514         internal void DisableGestureDetection(Gesture.GestureType type)
515         {
516             viewWrapperImpl.DisableGestureDetection(type);
517         }
518
519         internal void SetKeyboardNavigationSupport(bool isSupported)
520         {
521             viewWrapperImpl.SetKeyboardNavigationSupport(isSupported);
522         }
523
524         /// <summary>
525         /// Gets whether this control supports two-dimensional keyboard navigation.
526         /// </summary>
527         /// <returns>True if this control supports two-dimensional keyboard navigation.</returns>
528         internal bool IsKeyboardNavigationSupported()
529         {
530             return viewWrapperImpl.IsKeyboardNavigationSupported();
531         }
532
533         /// <summary>
534         /// Sets whether this control is a focus group for keyboard navigation.
535         /// (i.e., the scope of keyboard focus movement can be limitied to its child views). The control is not a focus group by default.
536         /// </summary>
537         /// <param name="isFocusGroup">Whether this control is set as a focus group for keyboard navigation.</param>
538         internal void SetAsKeyboardFocusGroup(bool isFocusGroup)
539         {
540             viewWrapperImpl.SetAsFocusGroup(isFocusGroup);
541         }
542
543         /// <summary>
544         /// Gets whether this control is a focus group for keyboard navigation.
545         /// </summary>
546         internal bool IsKeyboardFocusGroup()
547         {
548             return viewWrapperImpl.IsFocusGroup();
549         }
550
551         /// <summary>
552         /// Called whenever a pinch gesture is detected on this control.<br />
553         /// This can be overridden by deriving classes when pinch detection is enabled. The default behavior is to scale the control by the pinch scale.<br />
554         /// If overridden, then the default behavior will not occur.<br />
555         /// Pinch detection should be enabled via EnableGestureDetection().<br />
556         /// </summary>
557         /// <param name="pinch">The pinch tap gesture.</param>
558         internal virtual void OnPinch(PinchGesture pinch)
559         {
560         }
561
562         /// <summary>
563         /// Called whenever a long press gesture is detected on this control.<br />
564         /// This should be overridden by deriving classes when long press detection is enabled.<br />
565         /// There is no default behavior associated with a long press.<br />
566         /// Long press detection should be enabled via EnableGestureDetection().<br />
567         /// </summary>
568         /// <param name="longPress">The long press gesture.</param>
569         internal virtual void OnLongPress(LongPressGesture longPress)
570         {
571         }
572
573         /// <summary>
574         /// Requests a relayout, which means performing a size negotiation on this view, its parent, and children (and potentially whole scene).<br />
575         /// This method can also be called from a derived class every time it needs a different size.<br />
576         /// At the end of event processing, the relayout process starts and all controls which requested relayout will have their sizes (re)negotiated.<br />
577         /// It can be called multiple times; the size negotiation is still only performed once, i.e., there is no need to keep track of this in the calling side.<br />
578         /// </summary>
579         /// <since_tizen> 3 </since_tizen>
580         protected void RelayoutRequest()
581         {
582             viewWrapperImpl.RelayoutRequest();
583         }
584
585         /// <summary>
586         /// Provides the view implementation of GetHeightForWidth.
587         /// </summary>
588         /// <param name="width">The width to use.</param>
589         /// <returns>The height based on the width.</returns>
590         /// <since_tizen> 3 </since_tizen>
591         protected float GetHeightForWidthBase(float width)
592         {
593             return viewWrapperImpl.GetHeightForWidthBase(width);
594         }
595
596         /// <summary>
597         /// Provides the view implementation of GetWidthForHeight.
598         /// </summary>
599         /// <param name="height">The height to use.</param>
600         /// <returns>The width based on the height.</returns>
601         /// <since_tizen> 3 </since_tizen>
602         protected float GetWidthForHeightBase(float height)
603         {
604             return viewWrapperImpl.GetWidthForHeightBase(height);
605         }
606
607         /// <summary>
608         /// Calculates the size for a child using the base view object.
609         /// </summary>
610         /// <param name="child">The child view to calculate the size for.</param>
611         /// <param name="dimension">The dimension to calculate the size, for example, the width or the height.</param>
612         /// <returns>Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found.</returns>
613         /// <since_tizen> 3 </since_tizen>
614         protected float CalculateChildSizeBase(View child, DimensionType dimension)
615         {
616             return viewWrapperImpl.CalculateChildSizeBase(child, dimension);
617         }
618
619         /// <summary>
620         /// Determines if this view is dependent on it's children for relayout from the base class.
621         /// </summary>
622         /// <param name="dimension">The dimension(s) to check for.</param>
623         /// <returns>Return if the view is dependent on it's children.</returns>
624         /// <since_tizen> 3 </since_tizen>
625         protected bool RelayoutDependentOnChildrenBase(DimensionType dimension)
626         {
627             return viewWrapperImpl.RelayoutDependentOnChildrenBase(dimension);
628         }
629
630         /// <summary>
631         /// Determines if this view is dependent on it's children for relayout from the base class.
632         /// </summary>
633         /// <returns>Return if the view is dependent on it's children.</returns>
634         /// <since_tizen> 3 </since_tizen>
635         protected bool RelayoutDependentOnChildrenBase()
636         {
637             return viewWrapperImpl.RelayoutDependentOnChildrenBase();
638         }
639
640         /// <summary>
641         /// Registers a visual by property index, linking a view to visual when required.<br />
642         /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br />
643         /// No parenting is done during registration, this should be done by a derived class.<br />
644         /// </summary>
645         /// <param name="index">The property index of the visual used to reference visual.</param>
646         /// <param name="visual">The visual to register.</param>
647         /// <since_tizen> 3 </since_tizen>
648         protected void RegisterVisual(int index, VisualBase visual)
649         {
650             viewWrapperImpl.RegisterVisual(index, visual);
651         }
652
653         /// <summary>
654         /// Registers a visual by the property index, linking a view to visual when required.<br />
655         /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br />
656         /// If enabled is false, then the visual is not set on the stage until enabled by the derived class.<br />
657         /// </summary>
658         /// <param name="index">The property index of the visual used to reference visual.</param>
659         /// <param name="visual">The visual to register.</param>
660         /// <param name="enabled">False if derived class wants to control when the visual is set on the stage.</param>
661         /// <since_tizen> 3 </since_tizen>
662         protected void RegisterVisual(int index, VisualBase visual, bool enabled)
663         {
664             viewWrapperImpl.RegisterVisual(index, visual, enabled);
665         }
666
667         /// <summary>
668         /// Erases the entry matching the given index from the list of registered visuals.
669         /// </summary>
670         /// <param name="index">The property index of the visual used to reference visual.</param>
671         /// <since_tizen> 3 </since_tizen>
672         protected void UnregisterVisual(int index)
673         {
674             viewWrapperImpl.UnregisterVisual(index);
675         }
676
677         /// <summary>
678         /// Retrieves the visual associated with the given property index.<br />
679         /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
680         /// </summary>
681         /// <param name="index">The property index of the visual used to reference visual.</param>
682         /// <returns>The registered visual if exists, otherwise an empty handle.</returns>
683         /// <since_tizen> 3 </since_tizen>
684         protected VisualBase GetVisual(int index)
685         {
686             return viewWrapperImpl.GetVisual(index);
687         }
688
689         /// <summary>
690         /// Sets the given visual to be displayed or not when parent staged.<br />
691         /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
692         /// </summary>
693         /// <param name="index">The property index of the visual, used to reference visual.</param>
694         /// <param name="enable">Flag set to enabled or disabled.</param>
695         /// <since_tizen> 3 </since_tizen>
696         protected void EnableVisual(int index, bool enable)
697         {
698             viewWrapperImpl.EnableVisual(index, enable);
699         }
700
701         /// <summary>
702         /// Queries if the given visual is to be displayed when parent staged.<br />
703         /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
704         /// </summary>
705         /// <param name="index">The property index of the visual.</param>
706         /// <returns>Whether visual is enabled or not.</returns>
707         /// <since_tizen> 3 </since_tizen>
708         protected bool IsVisualEnabled(int index)
709         {
710             return viewWrapperImpl.IsVisualEnabled(index);
711         }
712
713         /// <summary>
714         /// Creates a transition effect on the control.
715         /// </summary>
716         /// <param name="transitionData">The transition data describing the effect to create.</param>
717         /// <returns>A handle to an animation defined with the given effect, or an empty handle if no properties match.</returns>
718         /// <since_tizen> 3 </since_tizen>
719         protected Animation CreateTransition(TransitionData transitionData)
720         {
721             return viewWrapperImpl.CreateTransition(transitionData);
722         }
723
724         /// <summary>
725         /// Emits the KeyInputFocusGained signal if true, else, emits the KeyInputFocusLost signal.<br />
726         /// Should be called last by the control after it acts on the input focus change.<br />
727         /// </summary>
728         /// <param name="focusGained">True if gained, false if lost.</param>
729         /// <since_tizen> 3 </since_tizen>
730         protected void EmitFocusSignal(bool focusGained)
731         {
732             viewWrapperImpl.EmitFocusSignal(focusGained);
733         }
734
735
736         private void OnControlChildAdd(View child)
737         {
738         }
739
740         private void OnControlChildRemove(View child)
741         {
742         }
743
744         private void Initialize()
745         {
746             // Registering CustomView virtual functions to viewWrapperImpl delegates.
747             viewWrapperImpl.OnStageConnection = new ViewWrapperImpl.OnStageConnectionDelegate(OnStageConnection);
748             viewWrapperImpl.OnStageDisconnection = new ViewWrapperImpl.OnStageDisconnectionDelegate(OnStageDisconnection);
749             viewWrapperImpl.OnChildAdd = new ViewWrapperImpl.OnChildAddDelegate(OnChildAdd);
750             viewWrapperImpl.OnChildRemove = new ViewWrapperImpl.OnChildRemoveDelegate(OnChildRemove);
751             viewWrapperImpl.OnPropertySet = new ViewWrapperImpl.OnPropertySetDelegate(OnPropertySet);
752             viewWrapperImpl.OnSizeSet = new ViewWrapperImpl.OnSizeSetDelegate(OnSizeSet);
753             viewWrapperImpl.OnSizeAnimation = new ViewWrapperImpl.OnSizeAnimationDelegate(OnSizeAnimation);
754             viewWrapperImpl.OnTouch = new ViewWrapperImpl.OnTouchDelegate(OnTouch);
755             viewWrapperImpl.OnHover = new ViewWrapperImpl.OnHoverDelegate(OnHover);
756             viewWrapperImpl.OnKey = new ViewWrapperImpl.OnKeyDelegate(OnKey);
757             viewWrapperImpl.OnWheel = new ViewWrapperImpl.OnWheelDelegate(OnWheel);
758             viewWrapperImpl.OnRelayout = new ViewWrapperImpl.OnRelayoutDelegate(OnRelayout);
759             viewWrapperImpl.OnSetResizePolicy = new ViewWrapperImpl.OnSetResizePolicyDelegate(OnSetResizePolicy);
760             viewWrapperImpl.GetNaturalSize = new ViewWrapperImpl.GetNaturalSizeDelegate(GetNaturalSize);
761             viewWrapperImpl.CalculateChildSize = new ViewWrapperImpl.CalculateChildSizeDelegate(CalculateChildSize);
762             viewWrapperImpl.GetHeightForWidth = new ViewWrapperImpl.GetHeightForWidthDelegate(GetHeightForWidth);
763             viewWrapperImpl.GetWidthForHeight = new ViewWrapperImpl.GetWidthForHeightDelegate(GetWidthForHeight);
764             viewWrapperImpl.RelayoutDependentOnChildrenDimension = new ViewWrapperImpl.RelayoutDependentOnChildrenDimensionDelegate(RelayoutDependentOnChildren);
765             viewWrapperImpl.RelayoutDependentOnChildren = new ViewWrapperImpl.RelayoutDependentOnChildrenDelegate(RelayoutDependentOnChildren);
766             viewWrapperImpl.OnCalculateRelayoutSize = new ViewWrapperImpl.OnCalculateRelayoutSizeDelegate(OnCalculateRelayoutSize);
767             viewWrapperImpl.OnLayoutNegotiated = new ViewWrapperImpl.OnLayoutNegotiatedDelegate(OnLayoutNegotiated);
768             viewWrapperImpl.OnControlChildAdd = new ViewWrapperImpl.OnControlChildAddDelegate(OnControlChildAdd);
769             viewWrapperImpl.OnControlChildRemove = new ViewWrapperImpl.OnControlChildRemoveDelegate(OnControlChildRemove);
770             viewWrapperImpl.OnStyleChange = new ViewWrapperImpl.OnStyleChangeDelegate(OnStyleChange);
771             viewWrapperImpl.OnAccessibilityActivated = new ViewWrapperImpl.OnAccessibilityActivatedDelegate(OnAccessibilityActivated);
772             viewWrapperImpl.OnAccessibilityPan = new ViewWrapperImpl.OnAccessibilityPanDelegate(OnAccessibilityPan);
773             viewWrapperImpl.OnAccessibilityTouch = new ViewWrapperImpl.OnAccessibilityTouchDelegate(OnAccessibilityTouch);
774             viewWrapperImpl.OnAccessibilityValueChange = new ViewWrapperImpl.OnAccessibilityValueChangeDelegate(OnAccessibilityValueChange);
775             viewWrapperImpl.OnAccessibilityZoom = new ViewWrapperImpl.OnAccessibilityZoomDelegate(OnAccessibilityZoom);
776             viewWrapperImpl.OnFocusGained = new ViewWrapperImpl.OnFocusGainedDelegate(OnFocusGained);
777             viewWrapperImpl.OnFocusLost = new ViewWrapperImpl.OnFocusLostDelegate(OnFocusLost);
778             viewWrapperImpl.GetNextFocusableView = new ViewWrapperImpl.GetNextFocusableViewDelegate(GetNextFocusableView);
779             viewWrapperImpl.OnFocusChangeCommitted = new ViewWrapperImpl.OnFocusChangeCommittedDelegate(OnFocusChangeCommitted);
780             viewWrapperImpl.OnKeyboardEnter = new ViewWrapperImpl.OnKeyboardEnterDelegate(OnKeyboardEnter);
781             viewWrapperImpl.OnPinch = new ViewWrapperImpl.OnPinchDelegate(OnPinch);
782             viewWrapperImpl.OnPan = new ViewWrapperImpl.OnPanDelegate(OnPan);
783             viewWrapperImpl.OnTap = new ViewWrapperImpl.OnTapDelegate(OnTap);
784             viewWrapperImpl.OnLongPress = new ViewWrapperImpl.OnLongPressDelegate(OnLongPress);
785
786             // Make sure CustomView is initialized.
787             OnInitialize();
788
789             // Set the StyleName the name of the View
790             // We have to do this because the StyleManager on Native side can't workout it out
791             // This will also ensure that the style of views/visuals initialized above are applied by the style manager.
792             SetStyleName(this.GetType().Name);
793         }
794     }
795 }