2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.ComponentModel;
19 using Tizen.NUI.Binding;
21 namespace Tizen.NUI.BaseComponents
24 /// CustomView provides some common functionality required by all views.
26 /// <since_tizen> 3 </since_tizen>
27 public class CustomView : ViewWrapper
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) =>
33 var customView = (CustomView)bindable;
36 customView.SetKeyboardNavigationSupport((bool)newValue);
39 defaultValueCreator: (bindable) =>
41 var customView = (CustomView)bindable;
42 return customView.IsKeyboardNavigationSupported();
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) =>
49 var customView = (CustomView)bindable;
52 customView.SetAsKeyboardFocusGroup((bool)newValue);
55 defaultValueCreator: (bindable) =>
57 var customView = (CustomView)bindable;
58 return customView.IsKeyboardFocusGroup();
62 /// Create an instance of customView.
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)
70 InitializeStyle(viewStyle);
74 /// Create an instance of customView.
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))
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 />
89 /// <since_tizen> 3 </since_tizen>
90 public bool FocusNavigationSupport
94 return (bool)GetValue(FocusNavigationSupportProperty);
98 SetValue(FocusNavigationSupportProperty, value);
103 /// Sets or gets whether this control is a focus group for keyboard navigation.
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
111 return (bool)GetValue(FocusGroupProperty);
115 SetValue(FocusGroupProperty, value);
120 /// Sets the background with a property map.
122 /// <param name="map">The background property map.</param>
123 /// <since_tizen> 3 </since_tizen>
124 public void SetBackground(Tizen.NUI.PropertyMap map)
126 viewWrapperImpl.SetBackground(map);
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 />
133 /// <param name="type">The gesture type(s) to enable.</param>
134 /// <since_tizen> 3 </since_tizen>
135 public void EnableGestureDetection(Gesture.GestureType type)
137 viewWrapperImpl.EnableGestureDetection(type);
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 />
145 /// <since_tizen> 3 </since_tizen>
146 public virtual void OnInitialize()
148 AccessibilityRole = Role.Unknown;
149 AppendAccessibilityAttribute("class", this.GetType().Name);
153 /// Called after the view has been connected to the stage.<br />
154 /// When a view is connected, it will be directly or indirectly parented to the root view.<br />
155 /// The root view is provided automatically by Tizen.NUI.Stage, and is always considered to be connected.<br />
156 /// When the parent of a set of views is connected to the stage, then all of the children will receive this callback.<br />
158 /// <param name="depth">The depth in the hierarchy for the view.</param>
159 /// <since_tizen> 3 </since_tizen>
160 [Obsolete("This has been deprecated since API8 and will be removed in API10. Use OnSceneConnection instead.")]
161 public virtual void OnStageConnection(int depth)
166 /// Called after the view has been disconnected from the stage.<br />
167 /// If a view is disconnected, it either has no parent, or is parented to a disconnected view.<br />
168 /// When the parent of a set of views is disconnected to the stage, then all of the children will receive this callback, starting with the leaf views.<br />
170 /// <since_tizen> 3 </since_tizen>
171 [Obsolete("This has been deprecated since API8 and will be removed in API10. Use OnSceneDisconnection instead.")]
172 public virtual void OnStageDisconnection()
177 /// Called after the view has been connected to the scene.<br />
178 /// When a view is connected, it will be directly or indirectly parented to the root view.<br />
179 /// The root view is provided automatically by Tizen.NUI.Window, and is always considered to be connected.<br />
180 /// When the parent of a set of views is connected to the scene, then all of the children will receive this callback.<br />
182 /// <param name="depth">The depth in the hierarchy for the view.</param>
183 /// <since_tizen> 8 </since_tizen>
184 public virtual void OnSceneConnection(int depth)
189 /// Called after the view has been disconnected from the scene.<br />
190 /// If a view is disconnected, it either has no parent, or is parented to a disconnected view.<br />
191 /// When the parent of a set of views is disconnected to the scene, then all of the children will receive this callback, starting with the leaf views.<br />
193 /// <since_tizen> 8 </since_tizen>
194 public virtual void OnSceneDisconnection()
199 /// Called after a child has been added to the owning view.
201 /// <param name="view">The child which has been added.</param>
202 /// <since_tizen> 3 </since_tizen>
203 public virtual void OnChildAdd(View view)
208 /// Called after the owning view has attempted to remove a child( regardless of whether it succeeded or not ).
210 /// <param name="view">The child being removed.</param>
211 /// <since_tizen> 3 </since_tizen>
212 public virtual void OnChildRemove(View view)
217 /// Called when the owning view property is set.
219 /// <param name="index">The property index that was set.</param>
220 /// <param name="propertyValue">The value to set.</param>
221 /// <since_tizen> 3 </since_tizen>
222 public virtual void OnPropertySet(int index, Tizen.NUI.PropertyValue propertyValue)
227 /// Called when the owning view's size is set, for example, using View.SetSize().
229 /// <param name="targetSize">The target size.</param>
230 /// <since_tizen> 3 </since_tizen>
231 public virtual void OnSizeSet(Vector3 targetSize)
236 /// Called when the owning view's size is animated, for example, using Animation::AnimateTo( Property ( view, View::Property::SIZE ), ... ).
238 /// <param name="animation">The object which is animating the owning view.</param>
239 /// <param name="targetSize">The target size.</param>
240 /// <since_tizen> 3 </since_tizen>
241 public virtual void OnSizeAnimation(Animation animation, Vector3 targetSize)
246 /// Called after a touch event is received by the owning view.<br />
247 /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
249 /// <param name="touch">The touch event.</param>
250 /// <returns>True if the event should be consumed.</returns>
251 /// <since_tizen> 3 </since_tizen>
252 public virtual bool OnTouch(Touch touch)
254 return false; // Do not consume
258 /// Called after a hover event is received by the owning view.<br />
259 /// CustomViewBehaviour.REQUIRES_HOVER_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
261 /// <param name="hover">The hover event.</param>
262 /// <returns>True if the hover event should be consumed.</returns>
263 /// <since_tizen> 3 </since_tizen>
264 public virtual bool OnHover(Hover hover)
266 return false; // Do not consume
270 /// Called after a key event is received by the view that has had its focus set.
272 /// <param name="key">The key event.</param>
273 /// <returns>True if the key event should be consumed.</returns>
274 /// <since_tizen> 3 </since_tizen>
275 public virtual bool OnKey(Key key)
277 return false; // Do not consume
281 /// Called after a wheel event is received by the owning view.<br />
282 /// CustomViewBehaviour.REQUIRES_WHEEL_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
284 /// <param name="wheel">The wheel event.</param>
285 /// <returns>True if the wheel event should be consumed.</returns>
286 /// <since_tizen> 3 </since_tizen>
287 public virtual bool OnWheel(Wheel wheel)
289 return false; // Do not consume
293 /// Called after the size negotiation has been finished for this control.<br />
294 /// The control is expected to assign this given size to itself or its children.<br />
295 /// Should be overridden by derived classes if they need to layout views differently after certain operations like add or remove views, resize, or after changing specific properties.<br />
296 /// As this function is called from inside the size negotiation algorithm, you cannot call RequestRelayout (the call would just be ignored).<br />
298 /// <param name="size">The allocated size.</param>
299 /// <param name="container">The control should add views to this container that it is not able to allocate a size for.</param>
300 /// <since_tizen> 3 </since_tizen>
301 public virtual void OnRelayout(Vector2 size, RelayoutContainer container)
306 /// Notification for deriving classes.
308 /// <param name="policy">The policy being set.</param>
309 /// <param name="dimension">The policy is being set for.</param>
310 /// <since_tizen> 3 </since_tizen>
311 public virtual void OnSetResizePolicy(ResizePolicyType policy, DimensionType dimension)
316 /// Returns the natural size of the view.
318 /// <returns>The view's natural size</returns>
319 /// <since_tizen> 3 </since_tizen>
320 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
321 public new virtual Size2D GetNaturalSize()
323 return GetUserSize2D();
327 /// Calculates the size for a child.
329 /// <param name="child">The child view to calculate the size for.</param>
330 /// <param name="dimension">The dimension to calculate the size, for example, the width or the height.</param>
331 /// <returns>Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found.</returns>
332 /// <since_tizen> 3 </since_tizen>
333 public virtual float CalculateChildSize(View child, DimensionType dimension)
335 return viewWrapperImpl.CalculateChildSizeBase(child, dimension);
339 /// This method is called during size negotiation when a height is required for a given width.<br />
340 /// Derived classes should override this if they wish to customize the height returned.<br />
342 /// <param name="width">Width to use</param>
343 /// <returns>The height based on the width</returns>
344 /// <since_tizen> 3 </since_tizen>
345 [Obsolete("This has been deprecated in API9 and will be removed in API11. Use HeightForWidth property instead.")]
346 public new virtual float GetHeightForWidth(float width)
348 return viewWrapperImpl.GetHeightForWidthBase(width);
352 /// This method is called during size negotiation when a width is required for a given height.<br />
353 /// Derived classes should override this if they wish to customize the width returned.<br />
355 /// <param name="height">Height to use</param>
356 /// <returns>The width based on the width</returns>
357 /// <since_tizen> 3 </since_tizen>
358 [Obsolete("This has been deprecated since API9 and will be removed in API11. Use WidthForHeight property instead.")]
359 public new virtual float GetWidthForHeight(float height)
361 return viewWrapperImpl.GetWidthForHeightBase(height);
365 /// Determines if this view is dependent on it's children for relayout.
367 /// <param name="dimension">The dimension(s) to check for.</param>
368 /// <returns>Return if the view is dependent on it's children.</returns>
369 /// <since_tizen> 3 </since_tizen>
370 public virtual bool RelayoutDependentOnChildren(DimensionType dimension)
372 return viewWrapperImpl.RelayoutDependentOnChildrenBase(dimension);
376 /// Determines if this view is dependent on it's children for relayout from the base class.
378 /// <returns>Return true if the view is dependent on it's children.</returns>
379 /// <since_tizen> 3 </since_tizen>
380 public virtual bool RelayoutDependentOnChildren()
382 return viewWrapperImpl.RelayoutDependentOnChildrenBase();
386 /// The virtual method to notify deriving classes that relayout dependencies have been
387 /// met and the size for this object is about to be calculated for the given dimension.
389 /// <param name="dimension">The dimension that is about to be calculated.</param>
390 /// <since_tizen> 3 </since_tizen>
391 public virtual void OnCalculateRelayoutSize(DimensionType dimension)
396 /// The virtual method to notify deriving classes that the size for a dimension has just been negotiated.
398 /// <param name="size">The new size for the given dimension.</param>
399 /// <param name="dimension">The dimension that was just negotiated.</param>
400 /// <since_tizen> 3 </since_tizen>
401 public virtual void OnLayoutNegotiated(float size, DimensionType dimension)
406 /// This method should be overridden by deriving classes requiring notifications when the style changes.
408 /// <param name="styleManager">The StyleManager object.</param>
409 /// <param name="change">Information denoting what has changed.</param>
410 /// <since_tizen> 3 </since_tizen>
411 [Obsolete("Deprecated in API9, Will be removed in API11.")]
412 public virtual void OnStyleChange(StyleManager styleManager, StyleChangeType change)
417 /// Called when the control gain key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is gained.
419 /// <since_tizen> 3 </since_tizen>
420 public virtual void OnFocusGained()
425 /// Called when the control loses key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is lost.
427 /// <since_tizen> 3 </since_tizen>
428 public virtual void OnFocusLost()
433 /// Gets the next keyboard focusable view in this control towards the given direction.<br />
434 /// A control needs to override this function in order to support two dimensional keyboard navigation.<br />
436 /// <param name="currentFocusedView">The current focused view.</param>
437 /// <param name="direction">The direction to move the focus towards.</param>
438 /// <param name="loopEnabled">Whether the focus movement should be looped within the control.</param>
439 /// <returns>The next keyboard focusable view in this control or null if no view can be focused.</returns>
440 /// <since_tizen> 3 </since_tizen>
441 public virtual View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
447 /// Informs this control that its chosen focusable view will be focused.<br />
448 /// This allows the application to preform any actions it wishes before the focus is actually moved to the chosen view.<br />
450 /// <param name="commitedFocusableView">The commited focused view.</param>
451 /// <since_tizen> 3 </since_tizen>
452 public virtual void OnFocusChangeCommitted(View commitedFocusableView)
457 /// This method is called when the control has enter pressed on it.<br />
458 /// Derived classes should override this to perform custom actions.<br />
460 /// <returns>True if this control supported this action.</returns>
461 /// <since_tizen> 3 </since_tizen>
462 public virtual bool OnKeyboardEnter()
464 using var key = new Key();
466 key.State = Key.StateType.Down;
467 key.KeyPressedName = "Return";
473 key.State = Key.StateType.Up;
478 /// Called whenever a pan gesture is detected on this control.<br />
479 /// This should be overridden by deriving classes when pan detection is enabled.<br />
480 /// There is no default behavior with panning.<br />
481 /// Pan detection should be enabled via EnableGestureDetection().<br />
483 /// <param name="pan">The pan gesture.</param>
484 /// <since_tizen> 3 </since_tizen>
485 public virtual void OnPan(PanGesture pan)
490 /// Called whenever a tap gesture is detected on this control.<br />
491 /// This should be overridden by deriving classes when tap detection is enabled.<br />
492 /// There is no default behavior with a tap.<br />
493 /// Tap detection should be enabled via EnableGestureDetection().<br />
495 /// <param name="tap">The tap gesture.</param>
496 /// <since_tizen> 3 </since_tizen>
497 public virtual void OnTap(TapGesture tap)
501 [EditorBrowsable(EditorBrowsableState.Never)]
502 protected override bool AccessibilityDoAction(string name)
504 if (name == AccessibilityActivateAction)
506 if (ActivateSignal?.Empty() == false)
508 ActivateSignal?.Emit();
513 return OnAccessibilityActivated();
516 else if (name == AccessibilityReadingSkippedAction)
518 if (ReadingSkippedSignal?.Empty() == false)
520 ReadingSkippedSignal?.Emit();
525 return OnAccessibilityReadingSkipped();
528 else if (name == AccessibilityReadingCancelledAction)
530 if (ReadingCancelledSignal?.Empty() == false)
532 ReadingCancelledSignal?.Emit();
537 return OnAccessibilityReadingCancelled();
540 else if (name == AccessibilityReadingStoppedAction)
542 if (ReadingStoppedSignal?.Empty() == false)
544 ReadingStoppedSignal?.Emit();
549 return OnAccessibilityReadingStopped();
552 else if (name == AccessibilityReadingPausedAction)
554 if (ReadingPausedSignal?.Empty() == false)
556 ReadingPausedSignal?.Emit();
561 return OnAccessibilityReadingPaused();
564 else if (name == AccessibilityReadingResumedAction)
566 if (ReadingResumedSignal?.Empty() == false)
568 ReadingResumedSignal?.Emit();
573 return OnAccessibilityReadingResumed();
583 /// This method is called when the control accessibility is activated.<br />
584 /// Derived classes should override this to perform custom accessibility activation.<br />
586 /// <returns>True if this control can perform accessibility activation.</returns>
587 internal virtual bool OnAccessibilityActivated()
589 return OnKeyboardEnter();
593 /// This method is called when reading is skipped.
595 /// <returns>True if information was served.</returns>
596 internal virtual bool OnAccessibilityReadingSkipped()
602 /// This method is called when reading is cancelled.
604 /// <returns>True if information was served.</returns>
605 internal virtual bool OnAccessibilityReadingCancelled()
610 /// This method is called when reading is stopped.
612 /// <returns>True if information was served.</returns>
613 internal virtual bool OnAccessibilityReadingStopped()
618 /// This method is called when reading was paused.
620 /// <returns>True if information was served.</returns>
621 internal virtual bool OnAccessibilityReadingPaused()
626 /// This method is called when reading is resumed.
628 /// <returns>True if information was served.</returns>
629 internal virtual bool OnAccessibilityReadingResumed()
635 /// This method should be overridden by deriving classes when they wish to respond the accessibility.
637 /// <param name="gestures">The pan gesture.</param>
638 /// <returns>True if the pan gesture has been consumed by this control.</returns>
639 internal virtual bool OnAccessibilityPan(PanGesture gestures)
645 /// This method should be overridden by deriving classes when they wish to respond the accessibility up and down action (i.e., value change of slider control).
647 /// <param name="isIncrease">Whether the value should be increased or decreased.</param>
648 /// <returns>True if the value changed action has been consumed by this control.</returns>
649 internal virtual bool OnAccessibilityValueChange(bool isIncrease)
655 /// This method should be overridden by deriving classes when they wish to respond the accessibility zoom action.
657 /// <returns>True if the zoom action has been consumed by this control.</returns>
658 internal virtual bool OnAccessibilityZoom()
664 /// Allows deriving classes to disable any of the gesture detectors.<br />
665 /// Like EnableGestureDetection, this can also be called using bitwise or one at a time.<br />
667 /// <param name="type">The gesture type(s) to disable.</param>
668 internal void DisableGestureDetection(Gesture.GestureType type)
670 viewWrapperImpl.DisableGestureDetection(type);
673 internal void SetKeyboardNavigationSupport(bool isSupported)
675 viewWrapperImpl.SetKeyboardNavigationSupport(isSupported);
679 /// Gets whether this control supports two-dimensional keyboard navigation.
681 /// <returns>True if this control supports two-dimensional keyboard navigation.</returns>
682 internal bool IsKeyboardNavigationSupported()
684 return viewWrapperImpl.IsKeyboardNavigationSupported();
688 /// Sets whether this control is a focus group for keyboard navigation.
689 /// (i.e., the scope of keyboard focus movement can be limitied to its child views). The control is not a focus group by default.
691 /// <param name="isFocusGroup">Whether this control is set as a focus group for keyboard navigation.</param>
692 internal void SetAsKeyboardFocusGroup(bool isFocusGroup)
694 viewWrapperImpl.SetAsFocusGroup(isFocusGroup);
698 /// Gets whether this control is a focus group for keyboard navigation.
700 internal bool IsKeyboardFocusGroup()
702 return viewWrapperImpl.IsFocusGroup();
706 /// Called whenever a pinch gesture is detected on this control.<br />
707 /// This can be overridden by deriving classes when pinch detection is enabled. The default behavior is to scale the control by the pinch scale.<br />
708 /// If overridden, then the default behavior will not occur.<br />
709 /// Pinch detection should be enabled via EnableGestureDetection().<br />
711 /// <param name="pinch">The pinch tap gesture.</param>
712 internal virtual void OnPinch(PinchGesture pinch)
717 /// Called whenever a long press gesture is detected on this control.<br />
718 /// This should be overridden by deriving classes when long press detection is enabled.<br />
719 /// There is no default behavior associated with a long press.<br />
720 /// Long press detection should be enabled via EnableGestureDetection().<br />
722 /// <param name="longPress">The long press gesture.</param>
723 internal virtual void OnLongPress(LongPressGesture longPress)
728 /// Requests a relayout, which means performing a size negotiation on this view, its parent, and children (and potentially whole scene).<br />
729 /// This method can also be called from a derived class every time it needs a different size.<br />
730 /// At the end of event processing, the relayout process starts and all controls which requested relayout will have their sizes (re)negotiated.<br />
731 /// It can be called multiple times; the size negotiation is still only performed once, i.e., there is no need to keep track of this in the calling side.<br />
733 /// <since_tizen> 3 </since_tizen>
734 protected void RelayoutRequest()
736 viewWrapperImpl.RelayoutRequest();
740 /// Provides the view implementation of GetHeightForWidth.
742 /// <param name="width">The width to use.</param>
743 /// <returns>The height based on the width.</returns>
744 /// <since_tizen> 3 </since_tizen>
745 protected float GetHeightForWidthBase(float width)
747 return viewWrapperImpl.GetHeightForWidthBase(width);
751 /// Provides the view implementation of GetWidthForHeight.
753 /// <param name="height">The height to use.</param>
754 /// <returns>The width based on the height.</returns>
755 /// <since_tizen> 3 </since_tizen>
756 protected float GetWidthForHeightBase(float height)
758 return viewWrapperImpl.GetWidthForHeightBase(height);
762 /// Calculates the size for a child using the base view object.
764 /// <param name="child">The child view to calculate the size for.</param>
765 /// <param name="dimension">The dimension to calculate the size, for example, the width or the height.</param>
766 /// <returns>Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found.</returns>
767 /// <since_tizen> 3 </since_tizen>
768 protected float CalculateChildSizeBase(View child, DimensionType dimension)
770 return viewWrapperImpl.CalculateChildSizeBase(child, dimension);
774 /// Determines if this view is dependent on it's children for relayout from the base class.
776 /// <param name="dimension">The dimension(s) to check for.</param>
777 /// <returns>Return if the view is dependent on it's children.</returns>
778 /// <since_tizen> 3 </since_tizen>
779 protected bool RelayoutDependentOnChildrenBase(DimensionType dimension)
781 return viewWrapperImpl.RelayoutDependentOnChildrenBase(dimension);
785 /// Determines if this view is dependent on it's children for relayout from the base class.
787 /// <returns>Return if the view is dependent on it's children.</returns>
788 /// <since_tizen> 3 </since_tizen>
789 protected bool RelayoutDependentOnChildrenBase()
791 return viewWrapperImpl.RelayoutDependentOnChildrenBase();
795 /// Registers a visual by property index, linking a view to visual when required.<br />
796 /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br />
797 /// No parenting is done during registration, this should be done by a derived class.<br />
799 /// <param name="index">The property index of the visual used to reference visual.</param>
800 /// <param name="visual">The visual to register.</param>
801 /// <since_tizen> 3 </since_tizen>
802 protected void RegisterVisual(int index, VisualBase visual)
804 viewWrapperImpl.RegisterVisual(index, visual);
808 /// Registers a visual by the property index, linking a view to visual when required.<br />
809 /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br />
810 /// If enabled is false, then the visual is not set on the stage until enabled by the derived class.<br />
812 /// <param name="index">The property index of the visual used to reference visual.</param>
813 /// <param name="visual">The visual to register.</param>
814 /// <param name="enabled">False if derived class wants to control when the visual is set on the stage.</param>
815 /// <since_tizen> 3 </since_tizen>
816 protected void RegisterVisual(int index, VisualBase visual, bool enabled)
818 viewWrapperImpl.RegisterVisual(index, visual, enabled);
822 /// Erases the entry matching the given index from the list of registered visuals.
824 /// <param name="index">The property index of the visual used to reference visual.</param>
825 /// <since_tizen> 3 </since_tizen>
826 protected void UnregisterVisual(int index)
828 viewWrapperImpl.UnregisterVisual(index);
832 /// Retrieves the visual associated with the given property index.<br />
833 /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
835 /// <param name="index">The property index of the visual used to reference visual.</param>
836 /// <returns>The registered visual if exists, otherwise an empty handle.</returns>
837 /// <since_tizen> 3 </since_tizen>
838 protected VisualBase GetVisual(int index)
840 return viewWrapperImpl.GetVisual(index);
844 /// Sets the given visual to be displayed or not when parent staged.<br />
845 /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
847 /// <param name="index">The property index of the visual, used to reference visual.</param>
848 /// <param name="enable">Flag set to enabled or disabled.</param>
849 /// <since_tizen> 3 </since_tizen>
850 protected void EnableVisual(int index, bool enable)
852 viewWrapperImpl.EnableVisual(index, enable);
856 /// Queries if the given visual is to be displayed when parent staged.<br />
857 /// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.<br />
859 /// <param name="index">The property index of the visual.</param>
860 /// <returns>Whether visual is enabled or not.</returns>
861 /// <since_tizen> 3 </since_tizen>
862 protected bool IsVisualEnabled(int index)
864 return viewWrapperImpl.IsVisualEnabled(index);
868 /// Creates a transition effect on the control.
870 /// <param name="transitionData">The transition data describing the effect to create.</param>
871 /// <returns>A handle to an animation defined with the given effect, or an empty handle if no properties match.</returns>
872 /// <since_tizen> 3 </since_tizen>
873 protected Animation CreateTransition(TransitionData transitionData)
875 return viewWrapperImpl.CreateTransition(transitionData);
879 /// Emits the KeyInputFocusGained signal if true, else, emits the KeyInputFocusLost signal.<br />
880 /// Should be called last by the control after it acts on the input focus change.<br />
882 /// <param name="focusGained">True if gained, false if lost.</param>
883 /// <since_tizen> 3 </since_tizen>
884 protected void EmitFocusSignal(bool focusGained)
886 viewWrapperImpl.EmitFocusSignal(focusGained);
889 private void Initialize()
891 // Registering CustomView virtual functions to viewWrapperImpl delegates.
892 viewWrapperImpl.OnSceneConnection = new ViewWrapperImpl.OnSceneConnectionDelegate(OnSceneConnection);
893 viewWrapperImpl.OnSceneDisconnection = new ViewWrapperImpl.OnSceneDisconnectionDelegate(OnSceneDisconnection);
894 viewWrapperImpl.OnStageConnection = new ViewWrapperImpl.OnSceneConnectionDelegate(OnStageConnection);
895 viewWrapperImpl.OnStageDisconnection = new ViewWrapperImpl.OnSceneDisconnectionDelegate(OnStageDisconnection);
896 viewWrapperImpl.OnChildAdd = new ViewWrapperImpl.OnChildAddDelegate(OnChildAdd);
897 viewWrapperImpl.OnChildRemove = new ViewWrapperImpl.OnChildRemoveDelegate(OnChildRemove);
898 viewWrapperImpl.OnPropertySet = new ViewWrapperImpl.OnPropertySetDelegate(OnPropertySet);
899 viewWrapperImpl.OnSizeSet = new ViewWrapperImpl.OnSizeSetDelegate(OnSizeSet);
900 viewWrapperImpl.OnSizeAnimation = new ViewWrapperImpl.OnSizeAnimationDelegate(OnSizeAnimation);
901 viewWrapperImpl.OnTouch = new ViewWrapperImpl.OnTouchDelegate(OnTouch);
902 viewWrapperImpl.OnHover = new ViewWrapperImpl.OnHoverDelegate(OnHover);
903 viewWrapperImpl.OnKey = new ViewWrapperImpl.OnKeyDelegate(OnKey);
904 viewWrapperImpl.OnWheel = new ViewWrapperImpl.OnWheelDelegate(OnWheel);
905 viewWrapperImpl.OnRelayout = new ViewWrapperImpl.OnRelayoutDelegate(OnRelayout);
906 viewWrapperImpl.OnSetResizePolicy = new ViewWrapperImpl.OnSetResizePolicyDelegate(OnSetResizePolicy);
907 viewWrapperImpl.GetNaturalSize = new ViewWrapperImpl.GetNaturalSizeDelegate(GetNaturalSize);
908 viewWrapperImpl.CalculateChildSize = new ViewWrapperImpl.CalculateChildSizeDelegate(CalculateChildSize);
909 viewWrapperImpl.GetHeightForWidth = new ViewWrapperImpl.GetHeightForWidthDelegate(GetHeightForWidth);
910 viewWrapperImpl.GetWidthForHeight = new ViewWrapperImpl.GetWidthForHeightDelegate(GetWidthForHeight);
911 viewWrapperImpl.RelayoutDependentOnChildrenDimension = new ViewWrapperImpl.RelayoutDependentOnChildrenDimensionDelegate(RelayoutDependentOnChildren);
912 viewWrapperImpl.RelayoutDependentOnChildren = new ViewWrapperImpl.RelayoutDependentOnChildrenDelegate(RelayoutDependentOnChildren);
913 viewWrapperImpl.OnCalculateRelayoutSize = new ViewWrapperImpl.OnCalculateRelayoutSizeDelegate(OnCalculateRelayoutSize);
914 viewWrapperImpl.OnLayoutNegotiated = new ViewWrapperImpl.OnLayoutNegotiatedDelegate(OnLayoutNegotiated);
915 viewWrapperImpl.OnStyleChange = new ViewWrapperImpl.OnStyleChangeDelegate(OnStyleChange);
916 viewWrapperImpl.OnAccessibilityActivated = new ViewWrapperImpl.OnAccessibilityActivatedDelegate(OnAccessibilityActivated);
917 viewWrapperImpl.OnAccessibilityPan = new ViewWrapperImpl.OnAccessibilityPanDelegate(OnAccessibilityPan);
918 viewWrapperImpl.OnAccessibilityValueChange = new ViewWrapperImpl.OnAccessibilityValueChangeDelegate(OnAccessibilityValueChange);
919 viewWrapperImpl.OnAccessibilityZoom = new ViewWrapperImpl.OnAccessibilityZoomDelegate(OnAccessibilityZoom);
920 viewWrapperImpl.OnFocusGained = new ViewWrapperImpl.OnFocusGainedDelegate(OnFocusGained);
921 viewWrapperImpl.OnFocusLost = new ViewWrapperImpl.OnFocusLostDelegate(OnFocusLost);
922 viewWrapperImpl.GetNextFocusableView = new ViewWrapperImpl.GetNextFocusableViewDelegate(GetNextFocusableView);
923 viewWrapperImpl.OnFocusChangeCommitted = new ViewWrapperImpl.OnFocusChangeCommittedDelegate(OnFocusChangeCommitted);
924 viewWrapperImpl.OnKeyboardEnter = new ViewWrapperImpl.OnKeyboardEnterDelegate(OnKeyboardEnter);
925 viewWrapperImpl.OnPinch = new ViewWrapperImpl.OnPinchDelegate(OnPinch);
926 viewWrapperImpl.OnPan = new ViewWrapperImpl.OnPanDelegate(OnPan);
927 viewWrapperImpl.OnTap = new ViewWrapperImpl.OnTapDelegate(OnTap);
928 viewWrapperImpl.OnLongPress = new ViewWrapperImpl.OnLongPressDelegate(OnLongPress);
930 // Set the StyleName the name of the View
931 // We have to do this because the StyleManager on Native side can't workout it out
932 // This will also ensure that the style of views/visuals initialized above are applied by the style manager.
933 SetStyleName(this.GetType().Name);