[NUI] Fix comments according to document review
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / CustomView.cs
1 /*
2  * Copyright (c) 2021 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;
18 using System.ComponentModel;
19 using Tizen.NUI.Binding;
20
21 namespace Tizen.NUI.BaseComponents
22 {
23     /// <summary>
24     /// CustomView provides some common functionality required by all views.
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public class CustomView : ViewWrapper
28     {
29         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
30         [EditorBrowsable(EditorBrowsableState.Never)]
31         public static readonly BindableProperty FocusNavigationSupportProperty = BindableProperty.Create(nameof(FocusNavigationSupport), typeof(bool), typeof(CustomView), false, propertyChanged: (bindable, oldValue, newValue) =>
32         {
33             var customView = (CustomView)bindable;
34             if (newValue != null)
35             {
36                 customView.SetKeyboardNavigationSupport((bool)newValue);
37             }
38         },
39         defaultValueCreator: (bindable) =>
40         {
41             var customView = (CustomView)bindable;
42             return customView.IsKeyboardNavigationSupported();
43         });
44
45         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
46         [EditorBrowsable(EditorBrowsableState.Never)]
47         public static readonly BindableProperty FocusGroupProperty = BindableProperty.Create(nameof(FocusGroup), typeof(bool), typeof(CustomView), false, propertyChanged: (bindable, oldValue, newValue) =>
48         {
49             var customView = (CustomView)bindable;
50             if (newValue != null)
51             {
52                 customView.SetAsKeyboardFocusGroup((bool)newValue);
53             }
54         },
55         defaultValueCreator: (bindable) =>
56         {
57             var customView = (CustomView)bindable;
58             return customView.IsKeyboardFocusGroup();
59         });
60
61         /// <summary>
62         /// Create an instance of customView.
63         /// </summary>
64         /// <param name="typeName">typename</param>
65         /// <param name="behaviour">CustomView Behaviour</param>
66         /// <param name="viewStyle">CustomView ViewStyle</param>
67         [EditorBrowsable(EditorBrowsableState.Never)]
68         public CustomView(string typeName, CustomViewBehaviour behaviour, ViewStyle viewStyle) : this(typeName, behaviour)
69         {
70             InitializeStyle(viewStyle);
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 CustomView has been initialized.<br />
142         /// After OnInitialize, the view will apply the style if it exists in the theme or it was given from constructor.<br />
143         /// Derived classes should do any second phase initialization by overriding this method.<br />
144         /// </summary>
145         /// <since_tizen> 3 </since_tizen>
146         public virtual void OnInitialize()
147         {
148             SetAccessibilityConstructor(Role.Unknown);
149             AppendAccessibilityAttribute("class", this.GetType().Name);
150         }
151
152         /// <summary>
153         /// Called after the view has been connected to the stage.<br />
154         /// When a view is connected, it will be directly or indirectly parented to the root view.<br />
155         /// The root view is provided automatically by Tizen.NUI.Stage, and is always considered to be connected.<br />
156         /// When the parent of a set of views is connected to the stage, then all of the children will receive this callback.<br />
157         /// </summary>
158         /// <param name="depth">The depth in the hierarchy for the view.</param>
159         /// <since_tizen> 3 </since_tizen>
160         [Obsolete("This has been deprecated since API8 and will be removed in API10. Use OnSceneConnection instead.")]
161         public virtual void OnStageConnection(int depth)
162         {
163         }
164
165         /// <summary>
166         /// Called after the view has been disconnected from the stage.<br />
167         /// If a view is disconnected, it either has no parent, or is parented to a disconnected view.<br />
168         /// 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 />
169         /// </summary>
170         /// <since_tizen> 3 </since_tizen>
171         [Obsolete("This has been deprecated since API8 and will be removed in API10. Use OnSceneDisconnection instead.")]
172         public virtual void OnStageDisconnection()
173         {
174         }
175
176         /// <summary>
177         /// Called after the view has been connected to the scene.<br />
178         /// When a view is connected, it will be directly or indirectly parented to the root view.<br />
179         /// The root view is provided automatically by Tizen.NUI.Window, and is always considered to be connected.<br />
180         /// When the parent of a set of views is connected to the scene, then all of the children will receive this callback.<br />
181         /// </summary>
182         /// <param name="depth">The depth in the hierarchy for the view.</param>
183         /// <since_tizen> 8 </since_tizen>
184         public virtual void OnSceneConnection(int depth)
185         {
186         }
187
188         /// <summary>
189         /// Called after the view has been disconnected from the scene.<br />
190         /// If a view is disconnected, it either has no parent, or is parented to a disconnected view.<br />
191         /// When the parent of a set of views is disconnected to the scene, then all of the children will receive this callback, starting with the leaf views.<br />
192         /// </summary>
193         /// <since_tizen> 8 </since_tizen>
194         public virtual void OnSceneDisconnection()
195         {
196         }
197
198         /// <summary>
199         /// Called after a child has been added to the owning view.
200         /// </summary>
201         /// <param name="view">The child which has been added.</param>
202         /// <since_tizen> 3 </since_tizen>
203         public virtual void OnChildAdd(View view)
204         {
205         }
206
207         /// <summary>
208         /// Called after the owning view has attempted to remove a child( regardless of whether it succeeded or not ).
209         /// </summary>
210         /// <param name="view">The child being removed.</param>
211         /// <since_tizen> 3 </since_tizen>
212         public virtual void OnChildRemove(View view)
213         {
214         }
215
216         /// <summary>
217         /// Called when the owning view property is set.
218         /// </summary>
219         /// <param name="index">The property index that was set.</param>
220         /// <param name="propertyValue">The value to set.</param>
221         /// <since_tizen> 3 </since_tizen>
222         public virtual void OnPropertySet(int index, Tizen.NUI.PropertyValue propertyValue)
223         {
224         }
225
226         /// <summary>
227         /// Called when the owning view's size is set, for example, using View.SetSize().
228         /// </summary>
229         /// <param name="targetSize">The target size.</param>
230         /// <since_tizen> 3 </since_tizen>
231         public virtual void OnSizeSet(Vector3 targetSize)
232         {
233         }
234
235         /// <summary>
236         /// Called when the owning view's size is animated, for example, using Animation::AnimateTo( Property ( view, View::Property::SIZE ), ... ).
237         /// </summary>
238         /// <param name="animation">The object which is animating the owning view.</param>
239         /// <param name="targetSize">The target size.</param>
240         /// <since_tizen> 3 </since_tizen>
241         public virtual void OnSizeAnimation(Animation animation, Vector3 targetSize)
242         {
243         }
244
245         /// <summary>
246         /// Called after a touch event is received by the owning view.<br />
247         /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
248         /// </summary>
249         /// <param name="touch">The touch event.</param>
250         /// <returns>True if the event should be consumed.</returns>
251         /// <since_tizen> 3 </since_tizen>
252         public virtual bool OnTouch(Touch touch)
253         {
254             return false; // Do not consume
255         }
256
257         /// <summary>
258         /// Called after a hover event is received by the owning view.<br />
259         /// CustomViewBehaviour.REQUIRES_HOVER_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
260         /// </summary>
261         /// <param name="hover">The hover event.</param>
262         /// <returns>True if the hover event should be consumed.</returns>
263         /// <since_tizen> 3 </since_tizen>
264         public virtual bool OnHover(Hover hover)
265         {
266             return false; // Do not consume
267         }
268
269         /// <summary>
270         /// Called after a key event is received by the view that has had its focus set.
271         /// </summary>
272         /// <param name="key">The key event.</param>
273         /// <returns>True if the key event should be consumed.</returns>
274         /// <since_tizen> 3 </since_tizen>
275         public virtual bool OnKey(Key key)
276         {
277             return false; // Do not consume
278         }
279
280         /// <summary>
281         /// Called after a wheel event is received by the owning view.<br />
282         /// CustomViewBehaviour.REQUIRES_WHEEL_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
283         /// </summary>
284         /// <param name="wheel">The wheel event.</param>
285         /// <returns>True if the wheel event should be consumed.</returns>
286         /// <since_tizen> 3 </since_tizen>
287         public virtual bool OnWheel(Wheel wheel)
288         {
289             return false; // Do not consume
290         }
291
292         /// <summary>
293         /// Called after the size negotiation has been finished for this control.<br />
294         /// The control is expected to assign this given size to itself or its children.<br />
295         /// 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 />
296         /// As this function is called from inside the size negotiation algorithm, you cannot call RequestRelayout (the call would just be ignored).<br />
297         /// </summary>
298         /// <param name="size">The allocated size.</param>
299         /// <param name="container">The control should add views to this container that it is not able to allocate a size for.</param>
300         /// <since_tizen> 3 </since_tizen>
301         public virtual void OnRelayout(Vector2 size, RelayoutContainer container)
302         {
303         }
304
305         /// <summary>
306         /// Notification for deriving classes.
307         /// </summary>
308         /// <param name="policy">The policy being set.</param>
309         /// <param name="dimension">The policy is being set for.</param>
310         /// <since_tizen> 3 </since_tizen>
311         public virtual void OnSetResizePolicy(ResizePolicyType policy, DimensionType dimension)
312         {
313         }
314
315         /// <summary>
316         /// Returns the natural size of the view.
317         /// </summary>
318         /// <returns>The view's natural size</returns>
319         /// <since_tizen> 3 </since_tizen>
320         [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
321         public new virtual Size2D GetNaturalSize()
322         {
323             return (Size2D)GetValue(Size2DProperty);
324         }
325
326         /// <summary>
327         /// Calculates the size for a child.
328         /// </summary>
329         /// <param name="child">The child view to calculate the size for.</param>
330         /// <param name="dimension">The dimension to calculate the size, for example, the width or the height.</param>
331         /// <returns>Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found.</returns>
332         /// <since_tizen> 3 </since_tizen>
333         public virtual float CalculateChildSize(View child, DimensionType dimension)
334         {
335             return viewWrapperImpl.CalculateChildSizeBase(child, dimension);
336         }
337
338         /// <summary>
339         /// This method is called during size negotiation when a height is required for a given width.<br />
340         /// Derived classes should override this if they wish to customize the height returned.<br />
341         /// </summary>
342         /// <param name="width">Width to use</param>
343         /// <returns>The height based on the width</returns>
344         /// <since_tizen> 3 </since_tizen>
345         [Obsolete("This has been deprecated in API9 and will be removed in API11. Use HeightForWidth property instead.")]
346         public new virtual float GetHeightForWidth(float width)
347         {
348             return viewWrapperImpl.GetHeightForWidthBase(width);
349         }
350
351         /// <summary>
352         /// This method is called during size negotiation when a width is required for a given height.<br />
353         /// Derived classes should override this if they wish to customize the width returned.<br />
354         /// </summary>
355         /// <param name="height">Height to use</param>
356         /// <returns>The width based on the width</returns>
357         /// <since_tizen> 3 </since_tizen>
358         [Obsolete("This has been deprecated since API9 and will be removed in API11. Use WidthForHeight property instead.")]
359         public new virtual float GetWidthForHeight(float height)
360         {
361             return viewWrapperImpl.GetWidthForHeightBase(height);
362         }
363
364         /// <summary>
365         /// Determines if this view is dependent on it's children for relayout.
366         /// </summary>
367         /// <param name="dimension">The dimension(s) to check for.</param>
368         /// <returns>Return if the view is dependent on it's children.</returns>
369         /// <since_tizen> 3 </since_tizen>
370         public virtual bool RelayoutDependentOnChildren(DimensionType dimension)
371         {
372             return viewWrapperImpl.RelayoutDependentOnChildrenBase(dimension);
373         }
374
375         /// <summary>
376         /// Determines if this view is dependent on it's children for relayout from the base class.
377         /// </summary>
378         /// <returns>Return true if the view is dependent on it's children.</returns>
379         /// <since_tizen> 3 </since_tizen>
380         public virtual bool RelayoutDependentOnChildren()
381         {
382             return viewWrapperImpl.RelayoutDependentOnChildrenBase();
383         }
384
385         /// <summary>
386         /// The virtual method to notify deriving classes that relayout dependencies have been
387         /// met and the size for this object is about to be calculated for the given dimension.
388         /// </summary>
389         /// <param name="dimension">The dimension that is about to be calculated.</param>
390         /// <since_tizen> 3 </since_tizen>
391         public virtual void OnCalculateRelayoutSize(DimensionType dimension)
392         {
393         }
394
395         /// <summary>
396         /// The virtual method to notify deriving classes that the size for a dimension has just been negotiated.
397         /// </summary>
398         /// <param name="size">The new size for the given dimension.</param>
399         /// <param name="dimension">The dimension that was just negotiated.</param>
400         /// <since_tizen> 3 </since_tizen>
401         public virtual void OnLayoutNegotiated(float size, DimensionType dimension)
402         {
403         }
404
405         /// <summary>
406         /// This method should be overridden by deriving classes requiring notifications when the style changes.
407         /// </summary>
408         /// <param name="styleManager">The StyleManager object.</param>
409         /// <param name="change">Information denoting what has changed.</param>
410         /// <since_tizen> 3 </since_tizen>
411         [Obsolete("Deprecated in API9, Will be removed in API11.")]
412         public virtual void OnStyleChange(StyleManager styleManager, StyleChangeType change)
413         {
414         }
415
416         /// <summary>
417         /// 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.
418         /// </summary>
419         /// <since_tizen> 3 </since_tizen>
420         public virtual void OnFocusGained()
421         {
422         }
423
424         /// <summary>
425         /// 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.
426         /// </summary>
427         /// <since_tizen> 3 </since_tizen>
428         public virtual void OnFocusLost()
429         {
430         }
431
432         /// <summary>
433         /// Gets the next keyboard focusable view in this control towards the given direction.<br />
434         /// A control needs to override this function in order to support two dimensional keyboard navigation.<br />
435         /// </summary>
436         /// <param name="currentFocusedView">The current focused view.</param>
437         /// <param name="direction">The direction to move the focus towards.</param>
438         /// <param name="loopEnabled">Whether the focus movement should be looped within the control.</param>
439         /// <returns>The next keyboard focusable view in this control or null if no view can be focused.</returns>
440         /// <since_tizen> 3 </since_tizen>
441         public virtual View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
442         {
443             return null;
444         }
445
446         /// <summary>
447         /// Informs this control that its chosen focusable view will be focused.<br />
448         /// This allows the application to preform any actions it wishes before the focus is actually moved to the chosen view.<br />
449         /// </summary>
450         /// <param name="commitedFocusableView">The commited focused view.</param>
451         /// <since_tizen> 3 </since_tizen>
452         public virtual void OnFocusChangeCommitted(View commitedFocusableView)
453         {
454         }
455
456         /// <summary>
457         /// This method is called when the control has enter pressed on it.<br />
458         /// Derived classes should override this to perform custom actions.<br />
459         /// </summary>
460         /// <returns>True if this control supported this action.</returns>
461         /// <since_tizen> 3 </since_tizen>
462         public virtual bool OnKeyboardEnter()
463         {
464             return false;
465         }
466
467         /// <summary>
468         /// Called whenever a pan gesture is detected on this control.<br />
469         /// This should be overridden by deriving classes when pan detection is enabled.<br />
470         /// There is no default behavior with panning.<br />
471         /// Pan detection should be enabled via EnableGestureDetection().<br />
472         /// </summary>
473         /// <param name="pan">The pan gesture.</param>
474         /// <since_tizen> 3 </since_tizen>
475         public virtual void OnPan(PanGesture pan)
476         {
477         }
478
479         /// <summary>
480         /// Called whenever a tap gesture is detected on this control.<br />
481         /// This should be overridden by deriving classes when tap detection is enabled.<br />
482         /// There is no default behavior with a tap.<br />
483         /// Tap detection should be enabled via EnableGestureDetection().<br />
484         /// </summary>
485         /// <param name="tap">The tap gesture.</param>
486         /// <since_tizen> 3 </since_tizen>
487         public virtual void OnTap(TapGesture tap)
488         {
489         }
490
491         [EditorBrowsable(EditorBrowsableState.Never)]
492         protected override bool AccessibilityDoAction(string name)
493         {
494             if (name == AccessibilityActivateAction)
495             {
496                 if (ActivateSignal?.Empty() == false)
497                 {
498                     ActivateSignal?.Emit();
499                     return true;
500                 }
501                 else
502                 {
503                     return OnAccessibilityActivated();
504                 }
505             }
506             else if (name == AccessibilityReadingSkippedAction)
507             {
508                 if (ReadingSkippedSignal?.Empty() == false)
509                 {
510                     ReadingSkippedSignal?.Emit();
511                     return true;
512                 }
513                 else
514                 {
515                     return OnAccessibilityReadingSkipped();
516                 }
517             }
518             else if (name == AccessibilityReadingCancelledAction)
519             {
520                 if (ReadingCancelledSignal?.Empty() == false)
521                 {
522                     ReadingCancelledSignal?.Emit();
523                     return true;
524                 }
525                 else
526                 {
527                     return OnAccessibilityReadingCancelled();
528                 }
529             }
530             else if (name == AccessibilityReadingStoppedAction)
531             {
532                 if (ReadingStoppedSignal?.Empty() == false)
533                 {
534                     ReadingStoppedSignal?.Emit();
535                     return true;
536                 }
537                 else
538                 {
539                     return OnAccessibilityReadingStopped();
540                 }
541             }
542             else if (name == AccessibilityReadingPausedAction)
543             {
544                 if (ReadingPausedSignal?.Empty() == false)
545                 {
546                     ReadingPausedSignal?.Emit();
547                     return true;
548                 }
549                 else
550                 {
551                     return OnAccessibilityReadingPaused();
552                 }
553             }
554             else if (name == AccessibilityReadingResumedAction)
555             {
556                 if (ReadingResumedSignal?.Empty() == false)
557                 {
558                     ReadingResumedSignal?.Emit();
559                     return true;
560                 }
561                 else
562                 {
563                     return OnAccessibilityReadingResumed();
564                 }
565             }
566             else
567             {
568                 return false;
569             }
570         }
571
572         /// <summary>
573         /// This method is called when the control accessibility is activated.<br />
574         /// Derived classes should override this to perform custom accessibility activation.<br />
575         /// </summary>
576         /// <returns>True if this control can perform accessibility activation.</returns>
577         internal virtual bool OnAccessibilityActivated()
578         {
579             return false;
580         }
581
582         /// <summary>
583         /// This method is called when reading is skipped.
584         /// </summary>
585         /// <returns>True if information was served.</returns>
586         internal virtual bool OnAccessibilityReadingSkipped()
587         {
588             return false;
589         }
590
591         /// <summary>
592         /// This method is called when reading is cancelled.
593         /// </summary>
594         /// <returns>True if information was served.</returns>
595         internal virtual bool OnAccessibilityReadingCancelled()
596         {
597             return false;
598         }
599         /// <summary>
600         /// This method is called when reading is stopped.
601         /// </summary>
602         /// <returns>True if information was served.</returns>
603         internal virtual bool OnAccessibilityReadingStopped()
604         {
605             return false;
606         }
607         /// <summary>
608         /// This method is called when reading was paused.
609         /// </summary>
610         /// <returns>True if information was served.</returns>
611         internal virtual bool OnAccessibilityReadingPaused()
612         {
613             return false;
614         }
615         /// <summary>
616         /// This method is called when reading is resumed.
617         /// </summary>
618         /// <returns>True if information was served.</returns>
619         internal virtual bool OnAccessibilityReadingResumed()
620         {
621             return false;
622         }
623
624         /// <summary>
625         /// This method should be overridden by deriving classes when they wish to respond the accessibility.
626         /// </summary>
627         /// <param name="gestures">The pan gesture.</param>
628         /// <returns>True if the pan gesture has been consumed by this control.</returns>
629         internal virtual bool OnAccessibilityPan(PanGesture gestures)
630         {
631             return false;
632         }
633
634         /// <summary>
635         /// 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).
636         /// </summary>
637         /// <param name="isIncrease">Whether the value should be increased or decreased.</param>
638         /// <returns>True if the value changed action has been consumed by this control.</returns>
639         internal virtual bool OnAccessibilityValueChange(bool isIncrease)
640         {
641             return false;
642         }
643
644         /// <summary>
645         /// This method should be overridden by deriving classes when they wish to respond the accessibility zoom action.
646         /// </summary>
647         /// <returns>True if the zoom action has been consumed by this control.</returns>
648         internal virtual bool OnAccessibilityZoom()
649         {
650             return false;
651         }
652
653         /// <summary>
654         /// Allows deriving classes to disable any of the gesture detectors.<br />
655         /// Like EnableGestureDetection, this can also be called using bitwise or one at a time.<br />
656         /// </summary>
657         /// <param name="type">The gesture type(s) to disable.</param>
658         internal void DisableGestureDetection(Gesture.GestureType type)
659         {
660             viewWrapperImpl.DisableGestureDetection(type);
661         }
662
663         internal void SetKeyboardNavigationSupport(bool isSupported)
664         {
665             viewWrapperImpl.SetKeyboardNavigationSupport(isSupported);
666         }
667
668         /// <summary>
669         /// Gets whether this control supports two-dimensional keyboard navigation.
670         /// </summary>
671         /// <returns>True if this control supports two-dimensional keyboard navigation.</returns>
672         internal bool IsKeyboardNavigationSupported()
673         {
674             return viewWrapperImpl.IsKeyboardNavigationSupported();
675         }
676
677         /// <summary>
678         /// Sets whether this control is a focus group for keyboard navigation.
679         /// (i.e., the scope of keyboard focus movement can be limitied to its child views). The control is not a focus group by default.
680         /// </summary>
681         /// <param name="isFocusGroup">Whether this control is set as a focus group for keyboard navigation.</param>
682         internal void SetAsKeyboardFocusGroup(bool isFocusGroup)
683         {
684             viewWrapperImpl.SetAsFocusGroup(isFocusGroup);
685         }
686
687         /// <summary>
688         /// Gets whether this control is a focus group for keyboard navigation.
689         /// </summary>
690         internal bool IsKeyboardFocusGroup()
691         {
692             return viewWrapperImpl.IsFocusGroup();
693         }
694
695         /// <summary>
696         /// Called whenever a pinch gesture is detected on this control.<br />
697         /// 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 />
698         /// If overridden, then the default behavior will not occur.<br />
699         /// Pinch detection should be enabled via EnableGestureDetection().<br />
700         /// </summary>
701         /// <param name="pinch">The pinch tap gesture.</param>
702         internal virtual void OnPinch(PinchGesture pinch)
703         {
704         }
705
706         /// <summary>
707         /// Called whenever a long press gesture is detected on this control.<br />
708         /// This should be overridden by deriving classes when long press detection is enabled.<br />
709         /// There is no default behavior associated with a long press.<br />
710         /// Long press detection should be enabled via EnableGestureDetection().<br />
711         /// </summary>
712         /// <param name="longPress">The long press gesture.</param>
713         internal virtual void OnLongPress(LongPressGesture longPress)
714         {
715         }
716
717         /// <summary>
718         /// Requests a relayout, which means performing a size negotiation on this view, its parent, and children (and potentially whole scene).<br />
719         /// This method can also be called from a derived class every time it needs a different size.<br />
720         /// At the end of event processing, the relayout process starts and all controls which requested relayout will have their sizes (re)negotiated.<br />
721         /// 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 />
722         /// </summary>
723         /// <since_tizen> 3 </since_tizen>
724         protected void RelayoutRequest()
725         {
726             viewWrapperImpl.RelayoutRequest();
727         }
728
729         /// <summary>
730         /// Provides the view implementation of GetHeightForWidth.
731         /// </summary>
732         /// <param name="width">The width to use.</param>
733         /// <returns>The height based on the width.</returns>
734         /// <since_tizen> 3 </since_tizen>
735         protected float GetHeightForWidthBase(float width)
736         {
737             return viewWrapperImpl.GetHeightForWidthBase(width);
738         }
739
740         /// <summary>
741         /// Provides the view implementation of GetWidthForHeight.
742         /// </summary>
743         /// <param name="height">The height to use.</param>
744         /// <returns>The width based on the height.</returns>
745         /// <since_tizen> 3 </since_tizen>
746         protected float GetWidthForHeightBase(float height)
747         {
748             return viewWrapperImpl.GetWidthForHeightBase(height);
749         }
750
751         /// <summary>
752         /// Calculates the size for a child using the base view object.
753         /// </summary>
754         /// <param name="child">The child view to calculate the size for.</param>
755         /// <param name="dimension">The dimension to calculate the size, for example, the width or the height.</param>
756         /// <returns>Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found.</returns>
757         /// <since_tizen> 3 </since_tizen>
758         protected float CalculateChildSizeBase(View child, DimensionType dimension)
759         {
760             return viewWrapperImpl.CalculateChildSizeBase(child, dimension);
761         }
762
763         /// <summary>
764         /// Determines if this view is dependent on it's children for relayout from the base class.
765         /// </summary>
766         /// <param name="dimension">The dimension(s) to check for.</param>
767         /// <returns>Return if the view is dependent on it's children.</returns>
768         /// <since_tizen> 3 </since_tizen>
769         protected bool RelayoutDependentOnChildrenBase(DimensionType dimension)
770         {
771             return viewWrapperImpl.RelayoutDependentOnChildrenBase(dimension);
772         }
773
774         /// <summary>
775         /// Determines if this view is dependent on it's children for relayout from the base class.
776         /// </summary>
777         /// <returns>Return if the view is dependent on it's children.</returns>
778         /// <since_tizen> 3 </since_tizen>
779         protected bool RelayoutDependentOnChildrenBase()
780         {
781             return viewWrapperImpl.RelayoutDependentOnChildrenBase();
782         }
783
784         /// <summary>
785         /// Registers a visual by property index, linking a view to visual when required.<br />
786         /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br />
787         /// No parenting is done during registration, this should be done by a derived class.<br />
788         /// </summary>
789         /// <param name="index">The property index of the visual used to reference visual.</param>
790         /// <param name="visual">The visual to register.</param>
791         /// <since_tizen> 3 </since_tizen>
792         protected void RegisterVisual(int index, VisualBase visual)
793         {
794             viewWrapperImpl.RegisterVisual(index, visual);
795         }
796
797         /// <summary>
798         /// Registers a visual by the property index, linking a view to visual when required.<br />
799         /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br />
800         /// If enabled is false, then the visual is not set on the stage until enabled by the derived class.<br />
801         /// </summary>
802         /// <param name="index">The property index of the visual used to reference visual.</param>
803         /// <param name="visual">The visual to register.</param>
804         /// <param name="enabled">False if derived class wants to control when the visual is set on the stage.</param>
805         /// <since_tizen> 3 </since_tizen>
806         protected void RegisterVisual(int index, VisualBase visual, bool enabled)
807         {
808             viewWrapperImpl.RegisterVisual(index, visual, enabled);
809         }
810
811         /// <summary>
812         /// Erases the entry matching the given index from the list of registered visuals.
813         /// </summary>
814         /// <param name="index">The property index of the visual used to reference visual.</param>
815         /// <since_tizen> 3 </since_tizen>
816         protected void UnregisterVisual(int index)
817         {
818             viewWrapperImpl.UnregisterVisual(index);
819         }
820
821         /// <summary>
822         /// Retrieves the visual associated with the given property index.<br />
823         /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
824         /// </summary>
825         /// <param name="index">The property index of the visual used to reference visual.</param>
826         /// <returns>The registered visual if exists, otherwise an empty handle.</returns>
827         /// <since_tizen> 3 </since_tizen>
828         protected VisualBase GetVisual(int index)
829         {
830             return viewWrapperImpl.GetVisual(index);
831         }
832
833         /// <summary>
834         /// Sets the given visual to be displayed or not when parent staged.<br />
835         /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
836         /// </summary>
837         /// <param name="index">The property index of the visual, used to reference visual.</param>
838         /// <param name="enable">Flag set to enabled or disabled.</param>
839         /// <since_tizen> 3 </since_tizen>
840         protected void EnableVisual(int index, bool enable)
841         {
842             viewWrapperImpl.EnableVisual(index, enable);
843         }
844
845         /// <summary>
846         /// Queries if the given visual is to be displayed when parent staged.<br />
847         /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
848         /// </summary>
849         /// <param name="index">The property index of the visual.</param>
850         /// <returns>Whether visual is enabled or not.</returns>
851         /// <since_tizen> 3 </since_tizen>
852         protected bool IsVisualEnabled(int index)
853         {
854             return viewWrapperImpl.IsVisualEnabled(index);
855         }
856
857         /// <summary>
858         /// Creates a transition effect on the control.
859         /// </summary>
860         /// <param name="transitionData">The transition data describing the effect to create.</param>
861         /// <returns>A handle to an animation defined with the given effect, or an empty handle if no properties match.</returns>
862         /// <since_tizen> 3 </since_tizen>
863         protected Animation CreateTransition(TransitionData transitionData)
864         {
865             return viewWrapperImpl.CreateTransition(transitionData);
866         }
867
868         /// <summary>
869         /// Emits the KeyInputFocusGained signal if true, else, emits the KeyInputFocusLost signal.<br />
870         /// Should be called last by the control after it acts on the input focus change.<br />
871         /// </summary>
872         /// <param name="focusGained">True if gained, false if lost.</param>
873         /// <since_tizen> 3 </since_tizen>
874         protected void EmitFocusSignal(bool focusGained)
875         {
876             viewWrapperImpl.EmitFocusSignal(focusGained);
877         }
878
879         private void Initialize()
880         {
881             // Registering CustomView virtual functions to viewWrapperImpl delegates.
882             viewWrapperImpl.OnSceneConnection = new ViewWrapperImpl.OnSceneConnectionDelegate(OnSceneConnection);
883             viewWrapperImpl.OnSceneDisconnection = new ViewWrapperImpl.OnSceneDisconnectionDelegate(OnSceneDisconnection);
884             viewWrapperImpl.OnStageConnection = new ViewWrapperImpl.OnSceneConnectionDelegate(OnStageConnection);
885             viewWrapperImpl.OnStageDisconnection = new ViewWrapperImpl.OnSceneDisconnectionDelegate(OnStageDisconnection);
886             viewWrapperImpl.OnChildAdd = new ViewWrapperImpl.OnChildAddDelegate(OnChildAdd);
887             viewWrapperImpl.OnChildRemove = new ViewWrapperImpl.OnChildRemoveDelegate(OnChildRemove);
888             viewWrapperImpl.OnPropertySet = new ViewWrapperImpl.OnPropertySetDelegate(OnPropertySet);
889             viewWrapperImpl.OnSizeSet = new ViewWrapperImpl.OnSizeSetDelegate(OnSizeSet);
890             viewWrapperImpl.OnSizeAnimation = new ViewWrapperImpl.OnSizeAnimationDelegate(OnSizeAnimation);
891             viewWrapperImpl.OnTouch = new ViewWrapperImpl.OnTouchDelegate(OnTouch);
892             viewWrapperImpl.OnHover = new ViewWrapperImpl.OnHoverDelegate(OnHover);
893             viewWrapperImpl.OnKey = new ViewWrapperImpl.OnKeyDelegate(OnKey);
894             viewWrapperImpl.OnWheel = new ViewWrapperImpl.OnWheelDelegate(OnWheel);
895             viewWrapperImpl.OnRelayout = new ViewWrapperImpl.OnRelayoutDelegate(OnRelayout);
896             viewWrapperImpl.OnSetResizePolicy = new ViewWrapperImpl.OnSetResizePolicyDelegate(OnSetResizePolicy);
897             viewWrapperImpl.GetNaturalSize = new ViewWrapperImpl.GetNaturalSizeDelegate(GetNaturalSize);
898             viewWrapperImpl.CalculateChildSize = new ViewWrapperImpl.CalculateChildSizeDelegate(CalculateChildSize);
899             viewWrapperImpl.GetHeightForWidth = new ViewWrapperImpl.GetHeightForWidthDelegate(GetHeightForWidth);
900             viewWrapperImpl.GetWidthForHeight = new ViewWrapperImpl.GetWidthForHeightDelegate(GetWidthForHeight);
901             viewWrapperImpl.RelayoutDependentOnChildrenDimension = new ViewWrapperImpl.RelayoutDependentOnChildrenDimensionDelegate(RelayoutDependentOnChildren);
902             viewWrapperImpl.RelayoutDependentOnChildren = new ViewWrapperImpl.RelayoutDependentOnChildrenDelegate(RelayoutDependentOnChildren);
903             viewWrapperImpl.OnCalculateRelayoutSize = new ViewWrapperImpl.OnCalculateRelayoutSizeDelegate(OnCalculateRelayoutSize);
904             viewWrapperImpl.OnLayoutNegotiated = new ViewWrapperImpl.OnLayoutNegotiatedDelegate(OnLayoutNegotiated);
905             viewWrapperImpl.OnStyleChange = new ViewWrapperImpl.OnStyleChangeDelegate(OnStyleChange);
906             viewWrapperImpl.OnAccessibilityActivated = new ViewWrapperImpl.OnAccessibilityActivatedDelegate(OnAccessibilityActivated);
907             viewWrapperImpl.OnAccessibilityPan = new ViewWrapperImpl.OnAccessibilityPanDelegate(OnAccessibilityPan);
908             viewWrapperImpl.OnAccessibilityValueChange = new ViewWrapperImpl.OnAccessibilityValueChangeDelegate(OnAccessibilityValueChange);
909             viewWrapperImpl.OnAccessibilityZoom = new ViewWrapperImpl.OnAccessibilityZoomDelegate(OnAccessibilityZoom);
910             viewWrapperImpl.OnFocusGained = new ViewWrapperImpl.OnFocusGainedDelegate(OnFocusGained);
911             viewWrapperImpl.OnFocusLost = new ViewWrapperImpl.OnFocusLostDelegate(OnFocusLost);
912             viewWrapperImpl.GetNextFocusableView = new ViewWrapperImpl.GetNextFocusableViewDelegate(GetNextFocusableView);
913             viewWrapperImpl.OnFocusChangeCommitted = new ViewWrapperImpl.OnFocusChangeCommittedDelegate(OnFocusChangeCommitted);
914             viewWrapperImpl.OnKeyboardEnter = new ViewWrapperImpl.OnKeyboardEnterDelegate(OnKeyboardEnter);
915             viewWrapperImpl.OnPinch = new ViewWrapperImpl.OnPinchDelegate(OnPinch);
916             viewWrapperImpl.OnPan = new ViewWrapperImpl.OnPanDelegate(OnPan);
917             viewWrapperImpl.OnTap = new ViewWrapperImpl.OnTapDelegate(OnTap);
918             viewWrapperImpl.OnLongPress = new ViewWrapperImpl.OnLongPressDelegate(OnLongPress);
919
920             // Set the StyleName the name of the View
921             // We have to do this because the StyleManager on Native side can't workout it out
922             // This will also ensure that the style of views/visuals initialized above are applied by the style manager.
923             SetStyleName(this.GetType().Name);
924
925             OnInitialize();
926         }
927     }
928 }