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