[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             AccessibilityRole = 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 GetUserSize2D();
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             using var key = new Key();
465
466             key.State = Key.StateType.Down;
467             key.KeyPressedName = "Return";
468
469             // Touch Down
470             OnKey(key);
471
472             // Touch Up
473             key.State = Key.StateType.Up;
474             return OnKey(key);
475         }
476
477         /// <summary>
478         /// Called whenever a pan gesture is detected on this control.<br />
479         /// This should be overridden by deriving classes when pan detection is enabled.<br />
480         /// There is no default behavior with panning.<br />
481         /// Pan detection should be enabled via EnableGestureDetection().<br />
482         /// </summary>
483         /// <param name="pan">The pan gesture.</param>
484         /// <since_tizen> 3 </since_tizen>
485         public virtual void OnPan(PanGesture pan)
486         {
487         }
488
489         /// <summary>
490         /// Called whenever a tap gesture is detected on this control.<br />
491         /// This should be overridden by deriving classes when tap detection is enabled.<br />
492         /// There is no default behavior with a tap.<br />
493         /// Tap detection should be enabled via EnableGestureDetection().<br />
494         /// </summary>
495         /// <param name="tap">The tap gesture.</param>
496         /// <since_tizen> 3 </since_tizen>
497         public virtual void OnTap(TapGesture tap)
498         {
499         }
500
501         [EditorBrowsable(EditorBrowsableState.Never)]
502         protected override bool AccessibilityDoAction(string name)
503         {
504             if (name == AccessibilityActivateAction)
505             {
506                 if (ActivateSignal?.Empty() == false)
507                 {
508                     ActivateSignal?.Emit();
509                     return true;
510                 }
511                 else
512                 {
513                     return OnAccessibilityActivated();
514                 }
515             }
516             else if (name == AccessibilityReadingSkippedAction)
517             {
518                 if (ReadingSkippedSignal?.Empty() == false)
519                 {
520                     ReadingSkippedSignal?.Emit();
521                     return true;
522                 }
523                 else
524                 {
525                     return OnAccessibilityReadingSkipped();
526                 }
527             }
528             else if (name == AccessibilityReadingCancelledAction)
529             {
530                 if (ReadingCancelledSignal?.Empty() == false)
531                 {
532                     ReadingCancelledSignal?.Emit();
533                     return true;
534                 }
535                 else
536                 {
537                     return OnAccessibilityReadingCancelled();
538                 }
539             }
540             else if (name == AccessibilityReadingStoppedAction)
541             {
542                 if (ReadingStoppedSignal?.Empty() == false)
543                 {
544                     ReadingStoppedSignal?.Emit();
545                     return true;
546                 }
547                 else
548                 {
549                     return OnAccessibilityReadingStopped();
550                 }
551             }
552             else if (name == AccessibilityReadingPausedAction)
553             {
554                 if (ReadingPausedSignal?.Empty() == false)
555                 {
556                     ReadingPausedSignal?.Emit();
557                     return true;
558                 }
559                 else
560                 {
561                     return OnAccessibilityReadingPaused();
562                 }
563             }
564             else if (name == AccessibilityReadingResumedAction)
565             {
566                 if (ReadingResumedSignal?.Empty() == false)
567                 {
568                     ReadingResumedSignal?.Emit();
569                     return true;
570                 }
571                 else
572                 {
573                     return OnAccessibilityReadingResumed();
574                 }
575             }
576             else
577             {
578                 return false;
579             }
580         }
581
582         /// <summary>
583         /// This method is called when the control accessibility is activated.<br />
584         /// Derived classes should override this to perform custom accessibility activation.<br />
585         /// </summary>
586         /// <returns>True if this control can perform accessibility activation.</returns>
587         internal virtual bool OnAccessibilityActivated()
588         {
589             return OnKeyboardEnter();
590         }
591
592         /// <summary>
593         /// This method is called when reading is skipped.
594         /// </summary>
595         /// <returns>True if information was served.</returns>
596         internal virtual bool OnAccessibilityReadingSkipped()
597         {
598             return false;
599         }
600
601         /// <summary>
602         /// This method is called when reading is cancelled.
603         /// </summary>
604         /// <returns>True if information was served.</returns>
605         internal virtual bool OnAccessibilityReadingCancelled()
606         {
607             return false;
608         }
609         /// <summary>
610         /// This method is called when reading is stopped.
611         /// </summary>
612         /// <returns>True if information was served.</returns>
613         internal virtual bool OnAccessibilityReadingStopped()
614         {
615             return false;
616         }
617         /// <summary>
618         /// This method is called when reading was paused.
619         /// </summary>
620         /// <returns>True if information was served.</returns>
621         internal virtual bool OnAccessibilityReadingPaused()
622         {
623             return false;
624         }
625         /// <summary>
626         /// This method is called when reading is resumed.
627         /// </summary>
628         /// <returns>True if information was served.</returns>
629         internal virtual bool OnAccessibilityReadingResumed()
630         {
631             return false;
632         }
633
634         /// <summary>
635         /// This method should be overridden by deriving classes when they wish to respond the accessibility.
636         /// </summary>
637         /// <param name="gestures">The pan gesture.</param>
638         /// <returns>True if the pan gesture has been consumed by this control.</returns>
639         internal virtual bool OnAccessibilityPan(PanGesture gestures)
640         {
641             return false;
642         }
643
644         /// <summary>
645         /// 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).
646         /// </summary>
647         /// <param name="isIncrease">Whether the value should be increased or decreased.</param>
648         /// <returns>True if the value changed action has been consumed by this control.</returns>
649         internal virtual bool OnAccessibilityValueChange(bool isIncrease)
650         {
651             return false;
652         }
653
654         /// <summary>
655         /// This method should be overridden by deriving classes when they wish to respond the accessibility zoom action.
656         /// </summary>
657         /// <returns>True if the zoom action has been consumed by this control.</returns>
658         internal virtual bool OnAccessibilityZoom()
659         {
660             return false;
661         }
662
663         /// <summary>
664         /// Allows deriving classes to disable any of the gesture detectors.<br />
665         /// Like EnableGestureDetection, this can also be called using bitwise or one at a time.<br />
666         /// </summary>
667         /// <param name="type">The gesture type(s) to disable.</param>
668         internal void DisableGestureDetection(Gesture.GestureType type)
669         {
670             viewWrapperImpl.DisableGestureDetection(type);
671         }
672
673         internal void SetKeyboardNavigationSupport(bool isSupported)
674         {
675             viewWrapperImpl.SetKeyboardNavigationSupport(isSupported);
676         }
677
678         /// <summary>
679         /// Gets whether this control supports two-dimensional keyboard navigation.
680         /// </summary>
681         /// <returns>True if this control supports two-dimensional keyboard navigation.</returns>
682         internal bool IsKeyboardNavigationSupported()
683         {
684             return viewWrapperImpl.IsKeyboardNavigationSupported();
685         }
686
687         /// <summary>
688         /// Sets whether this control is a focus group for keyboard navigation.
689         /// (i.e., the scope of keyboard focus movement can be limitied to its child views). The control is not a focus group by default.
690         /// </summary>
691         /// <param name="isFocusGroup">Whether this control is set as a focus group for keyboard navigation.</param>
692         internal void SetAsKeyboardFocusGroup(bool isFocusGroup)
693         {
694             viewWrapperImpl.SetAsFocusGroup(isFocusGroup);
695         }
696
697         /// <summary>
698         /// Gets whether this control is a focus group for keyboard navigation.
699         /// </summary>
700         internal bool IsKeyboardFocusGroup()
701         {
702             return viewWrapperImpl.IsFocusGroup();
703         }
704
705         /// <summary>
706         /// Called whenever a pinch gesture is detected on this control.<br />
707         /// 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 />
708         /// If overridden, then the default behavior will not occur.<br />
709         /// Pinch detection should be enabled via EnableGestureDetection().<br />
710         /// </summary>
711         /// <param name="pinch">The pinch tap gesture.</param>
712         internal virtual void OnPinch(PinchGesture pinch)
713         {
714         }
715
716         /// <summary>
717         /// Called whenever a long press gesture is detected on this control.<br />
718         /// This should be overridden by deriving classes when long press detection is enabled.<br />
719         /// There is no default behavior associated with a long press.<br />
720         /// Long press detection should be enabled via EnableGestureDetection().<br />
721         /// </summary>
722         /// <param name="longPress">The long press gesture.</param>
723         internal virtual void OnLongPress(LongPressGesture longPress)
724         {
725         }
726
727         /// <summary>
728         /// Requests a relayout, which means performing a size negotiation on this view, its parent, and children (and potentially whole scene).<br />
729         /// This method can also be called from a derived class every time it needs a different size.<br />
730         /// At the end of event processing, the relayout process starts and all controls which requested relayout will have their sizes (re)negotiated.<br />
731         /// 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 />
732         /// </summary>
733         /// <since_tizen> 3 </since_tizen>
734         protected void RelayoutRequest()
735         {
736             viewWrapperImpl.RelayoutRequest();
737         }
738
739         /// <summary>
740         /// Provides the view implementation of GetHeightForWidth.
741         /// </summary>
742         /// <param name="width">The width to use.</param>
743         /// <returns>The height based on the width.</returns>
744         /// <since_tizen> 3 </since_tizen>
745         protected float GetHeightForWidthBase(float width)
746         {
747             return viewWrapperImpl.GetHeightForWidthBase(width);
748         }
749
750         /// <summary>
751         /// Provides the view implementation of GetWidthForHeight.
752         /// </summary>
753         /// <param name="height">The height to use.</param>
754         /// <returns>The width based on the height.</returns>
755         /// <since_tizen> 3 </since_tizen>
756         protected float GetWidthForHeightBase(float height)
757         {
758             return viewWrapperImpl.GetWidthForHeightBase(height);
759         }
760
761         /// <summary>
762         /// Calculates the size for a child using the base view object.
763         /// </summary>
764         /// <param name="child">The child view to calculate the size for.</param>
765         /// <param name="dimension">The dimension to calculate the size, for example, the width or the height.</param>
766         /// <returns>Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found.</returns>
767         /// <since_tizen> 3 </since_tizen>
768         protected float CalculateChildSizeBase(View child, DimensionType dimension)
769         {
770             return viewWrapperImpl.CalculateChildSizeBase(child, dimension);
771         }
772
773         /// <summary>
774         /// Determines if this view is dependent on it's children for relayout from the base class.
775         /// </summary>
776         /// <param name="dimension">The dimension(s) to check for.</param>
777         /// <returns>Return if the view is dependent on it's children.</returns>
778         /// <since_tizen> 3 </since_tizen>
779         protected bool RelayoutDependentOnChildrenBase(DimensionType dimension)
780         {
781             return viewWrapperImpl.RelayoutDependentOnChildrenBase(dimension);
782         }
783
784         /// <summary>
785         /// Determines if this view is dependent on it's children for relayout from the base class.
786         /// </summary>
787         /// <returns>Return if the view is dependent on it's children.</returns>
788         /// <since_tizen> 3 </since_tizen>
789         protected bool RelayoutDependentOnChildrenBase()
790         {
791             return viewWrapperImpl.RelayoutDependentOnChildrenBase();
792         }
793
794         /// <summary>
795         /// Registers a visual by property index, linking a view to visual when required.<br />
796         /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br />
797         /// No parenting is done during registration, this should be done by a derived class.<br />
798         /// </summary>
799         /// <param name="index">The property index of the visual used to reference visual.</param>
800         /// <param name="visual">The visual to register.</param>
801         /// <since_tizen> 3 </since_tizen>
802         protected void RegisterVisual(int index, VisualBase visual)
803         {
804             viewWrapperImpl.RegisterVisual(index, visual);
805         }
806
807         /// <summary>
808         /// Registers a visual by the property index, linking a view to visual when required.<br />
809         /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br />
810         /// If enabled is false, then the visual is not set on the stage until enabled by the derived class.<br />
811         /// </summary>
812         /// <param name="index">The property index of the visual used to reference visual.</param>
813         /// <param name="visual">The visual to register.</param>
814         /// <param name="enabled">False if derived class wants to control when the visual is set on the stage.</param>
815         /// <since_tizen> 3 </since_tizen>
816         protected void RegisterVisual(int index, VisualBase visual, bool enabled)
817         {
818             viewWrapperImpl.RegisterVisual(index, visual, enabled);
819         }
820
821         /// <summary>
822         /// Erases the entry matching the given index from the list of registered visuals.
823         /// </summary>
824         /// <param name="index">The property index of the visual used to reference visual.</param>
825         /// <since_tizen> 3 </since_tizen>
826         protected void UnregisterVisual(int index)
827         {
828             viewWrapperImpl.UnregisterVisual(index);
829         }
830
831         /// <summary>
832         /// Retrieves the visual associated with the given property index.<br />
833         /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
834         /// </summary>
835         /// <param name="index">The property index of the visual used to reference visual.</param>
836         /// <returns>The registered visual if exists, otherwise an empty handle.</returns>
837         /// <since_tizen> 3 </since_tizen>
838         protected VisualBase GetVisual(int index)
839         {
840             return viewWrapperImpl.GetVisual(index);
841         }
842
843         /// <summary>
844         /// Sets the given visual to be displayed or not when parent staged.<br />
845         /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
846         /// </summary>
847         /// <param name="index">The property index of the visual, used to reference visual.</param>
848         /// <param name="enable">Flag set to enabled or disabled.</param>
849         /// <since_tizen> 3 </since_tizen>
850         protected void EnableVisual(int index, bool enable)
851         {
852             viewWrapperImpl.EnableVisual(index, enable);
853         }
854
855         /// <summary>
856         /// Queries if the given visual is to be displayed when parent staged.<br />
857         /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
858         /// </summary>
859         /// <param name="index">The property index of the visual.</param>
860         /// <returns>Whether visual is enabled or not.</returns>
861         /// <since_tizen> 3 </since_tizen>
862         protected bool IsVisualEnabled(int index)
863         {
864             return viewWrapperImpl.IsVisualEnabled(index);
865         }
866
867         /// <summary>
868         /// Creates a transition effect on the control.
869         /// </summary>
870         /// <param name="transitionData">The transition data describing the effect to create.</param>
871         /// <returns>A handle to an animation defined with the given effect, or an empty handle if no properties match.</returns>
872         /// <since_tizen> 3 </since_tizen>
873         protected Animation CreateTransition(TransitionData transitionData)
874         {
875             return viewWrapperImpl.CreateTransition(transitionData);
876         }
877
878         /// <summary>
879         /// Emits the KeyInputFocusGained signal if true, else, emits the KeyInputFocusLost signal.<br />
880         /// Should be called last by the control after it acts on the input focus change.<br />
881         /// </summary>
882         /// <param name="focusGained">True if gained, false if lost.</param>
883         /// <since_tizen> 3 </since_tizen>
884         protected void EmitFocusSignal(bool focusGained)
885         {
886             viewWrapperImpl.EmitFocusSignal(focusGained);
887         }
888
889         private void Initialize()
890         {
891             // Registering CustomView virtual functions to viewWrapperImpl delegates.
892             viewWrapperImpl.OnSceneConnection = new ViewWrapperImpl.OnSceneConnectionDelegate(OnSceneConnection);
893             viewWrapperImpl.OnSceneDisconnection = new ViewWrapperImpl.OnSceneDisconnectionDelegate(OnSceneDisconnection);
894             viewWrapperImpl.OnStageConnection = new ViewWrapperImpl.OnSceneConnectionDelegate(OnStageConnection);
895             viewWrapperImpl.OnStageDisconnection = new ViewWrapperImpl.OnSceneDisconnectionDelegate(OnStageDisconnection);
896             viewWrapperImpl.OnChildAdd = new ViewWrapperImpl.OnChildAddDelegate(OnChildAdd);
897             viewWrapperImpl.OnChildRemove = new ViewWrapperImpl.OnChildRemoveDelegate(OnChildRemove);
898             viewWrapperImpl.OnPropertySet = new ViewWrapperImpl.OnPropertySetDelegate(OnPropertySet);
899             viewWrapperImpl.OnSizeSet = new ViewWrapperImpl.OnSizeSetDelegate(OnSizeSet);
900             viewWrapperImpl.OnSizeAnimation = new ViewWrapperImpl.OnSizeAnimationDelegate(OnSizeAnimation);
901             viewWrapperImpl.OnTouch = new ViewWrapperImpl.OnTouchDelegate(OnTouch);
902             viewWrapperImpl.OnHover = new ViewWrapperImpl.OnHoverDelegate(OnHover);
903             viewWrapperImpl.OnKey = new ViewWrapperImpl.OnKeyDelegate(OnKey);
904             viewWrapperImpl.OnWheel = new ViewWrapperImpl.OnWheelDelegate(OnWheel);
905             viewWrapperImpl.OnRelayout = new ViewWrapperImpl.OnRelayoutDelegate(OnRelayout);
906             viewWrapperImpl.OnSetResizePolicy = new ViewWrapperImpl.OnSetResizePolicyDelegate(OnSetResizePolicy);
907             viewWrapperImpl.GetNaturalSize = new ViewWrapperImpl.GetNaturalSizeDelegate(GetNaturalSize);
908             viewWrapperImpl.CalculateChildSize = new ViewWrapperImpl.CalculateChildSizeDelegate(CalculateChildSize);
909             viewWrapperImpl.GetHeightForWidth = new ViewWrapperImpl.GetHeightForWidthDelegate(GetHeightForWidth);
910             viewWrapperImpl.GetWidthForHeight = new ViewWrapperImpl.GetWidthForHeightDelegate(GetWidthForHeight);
911             viewWrapperImpl.RelayoutDependentOnChildrenDimension = new ViewWrapperImpl.RelayoutDependentOnChildrenDimensionDelegate(RelayoutDependentOnChildren);
912             viewWrapperImpl.RelayoutDependentOnChildren = new ViewWrapperImpl.RelayoutDependentOnChildrenDelegate(RelayoutDependentOnChildren);
913             viewWrapperImpl.OnCalculateRelayoutSize = new ViewWrapperImpl.OnCalculateRelayoutSizeDelegate(OnCalculateRelayoutSize);
914             viewWrapperImpl.OnLayoutNegotiated = new ViewWrapperImpl.OnLayoutNegotiatedDelegate(OnLayoutNegotiated);
915             viewWrapperImpl.OnStyleChange = new ViewWrapperImpl.OnStyleChangeDelegate(OnStyleChange);
916             viewWrapperImpl.OnAccessibilityActivated = new ViewWrapperImpl.OnAccessibilityActivatedDelegate(OnAccessibilityActivated);
917             viewWrapperImpl.OnAccessibilityPan = new ViewWrapperImpl.OnAccessibilityPanDelegate(OnAccessibilityPan);
918             viewWrapperImpl.OnAccessibilityValueChange = new ViewWrapperImpl.OnAccessibilityValueChangeDelegate(OnAccessibilityValueChange);
919             viewWrapperImpl.OnAccessibilityZoom = new ViewWrapperImpl.OnAccessibilityZoomDelegate(OnAccessibilityZoom);
920             viewWrapperImpl.OnFocusGained = new ViewWrapperImpl.OnFocusGainedDelegate(OnFocusGained);
921             viewWrapperImpl.OnFocusLost = new ViewWrapperImpl.OnFocusLostDelegate(OnFocusLost);
922             viewWrapperImpl.GetNextFocusableView = new ViewWrapperImpl.GetNextFocusableViewDelegate(GetNextFocusableView);
923             viewWrapperImpl.OnFocusChangeCommitted = new ViewWrapperImpl.OnFocusChangeCommittedDelegate(OnFocusChangeCommitted);
924             viewWrapperImpl.OnKeyboardEnter = new ViewWrapperImpl.OnKeyboardEnterDelegate(OnKeyboardEnter);
925             viewWrapperImpl.OnPinch = new ViewWrapperImpl.OnPinchDelegate(OnPinch);
926             viewWrapperImpl.OnPan = new ViewWrapperImpl.OnPanDelegate(OnPan);
927             viewWrapperImpl.OnTap = new ViewWrapperImpl.OnTapDelegate(OnTap);
928             viewWrapperImpl.OnLongPress = new ViewWrapperImpl.OnLongPressDelegate(OnLongPress);
929
930             // Set the StyleName the name of the View
931             // We have to do this because the StyleManager on Native side can't workout it out
932             // This will also ensure that the style of views/visuals initialized above are applied by the style manager.
933             SetStyleName(this.GetType().Name);
934
935             OnInitialize();
936         }
937     }
938 }