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