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