2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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.Collections.Generic;
19 using System.Diagnostics;
24 /// Enumeration for the Tooltip orientation.
26 /// <since_tizen> preview </since_tizen>
27 public enum TooltipOrientation
30 /// Default value. Tooltip moves with a mouse pointer.
35 /// Tooltip should appear to the top left of the parent.
40 /// Tooltip should appear to the left of the parent.
45 /// Tooltip should appear to the top right of the parent.
50 /// Tooltip should appear to the left of the parent.
55 /// Tooltip should appear to the center of the parent.
60 /// Tooltip should appear to the right of the parent.
65 /// Tooltip should appear to the bottom left of the parent.
70 /// Tooltip should appear to the bottom of the parent.
75 /// Tooltip should appear to the bottom right of the parent.
81 /// Enumeration for the aspect control.
83 /// <since_tizen> preview </since_tizen>
84 public enum AspectControl
87 /// Preference on the scaling unset.
92 /// Same effect as the unset preference on the scaling.
97 /// Use all horizontal container space to place an object using the given aspect.
102 /// Use all vertical container space to place an object using the given aspect.
107 /// Use all horizontal @b and vertical container spaces to place an object (never growing it out of those bounds), using the given aspect.
113 /// How the object should be rendered to output.
115 /// <since_tizen> 5 </since_tizen>
119 /// default op: d = d * (1 - sa) + s
124 /// d = d*(1 - sa) + s*da
159 /// d = d*s + d*(1 - sa) + s*(1 - da)
164 /// d = d*(1 - sa + s)
180 /// The EvasObject is a base class for other widget classes.
182 /// <since_tizen> preview </since_tizen>
183 public abstract class EvasObject
185 private IntPtr _realHandle = IntPtr.Zero;
186 private EvasCanvas _evasCanvas;
187 private string _automationId;
189 private event EventHandler _backButtonPressed;
191 private event EventHandler _moreButtonPressed;
193 private Interop.Eext.EextEventCallback _backButtonHandler;
194 private Interop.Eext.EextEventCallback _moreButtonHandler;
196 private static Dictionary<IntPtr, EvasObject> s_handleTable = new Dictionary<IntPtr, EvasObject>();
199 /// Sets or gets the handle for EvasObject.
201 /// <since_tizen> preview </since_tizen>
202 public IntPtr Handle { get; protected set; }
205 /// Gets the parent object for EvasObject.
207 /// <since_tizen> preview </since_tizen>
208 public EvasObject Parent { get; private set; }
211 /// Sets or gets the real handle for EvasObject.
213 /// <since_tizen> preview </since_tizen>
214 public IntPtr RealHandle
218 return _realHandle == IntPtr.Zero ? Handle : _realHandle;
223 Interop.Evas.evas_object_show(_realHandle);
227 EvasObjectEvent _deleted;
228 EvasObjectEvent<EvasKeyEventArgs> _keyup;
229 EvasObjectEvent<EvasKeyEventArgs> _keydown;
230 EvasObjectEvent _moved;
231 EvasObjectEvent _resized;
232 EvasObjectEvent _shown;
233 EvasObjectEvent _hidden;
234 EventHandler _renderPost;
235 Interop.Evas.EvasCallback _renderPostCallback = null;
236 Interop.Elementary.Elm_Tooltip_Content_Cb _tooltipContentCallback = null;
238 GetTooltipContentDelegate _tooltipContentDelegate = null;
240 readonly HashSet<IInvalidatable> _eventStore = new HashSet<IInvalidatable>();
243 /// Creates and initializes a new instance of the EvasObject class with the parent EvasObject class parameter.
245 /// <param name="parent">Parent EvasObject class.</param>
246 /// <since_tizen> preview </since_tizen>
247 protected EvasObject(EvasObject parent) : this()
249 Debug.Assert(parent == null || parent.IsRealized);
254 /// Creates and initializes a new instance of the EvasObject class.
256 /// <since_tizen> preview </since_tizen>
257 protected EvasObject()
259 _backButtonHandler = new Interop.Eext.EextEventCallback((d, o, i) => { _backButtonPressed?.Invoke(this, EventArgs.Empty); });
260 _moreButtonHandler = new Interop.Eext.EextEventCallback((d, o, i) => { _moreButtonPressed?.Invoke(this, EventArgs.Empty); });
264 _tooltipContentCallback = (d, o, t) =>
266 return _tooltipContentDelegate?.Invoke();
270 // C# Finalizer was called on GC thread
271 // So, We can't access to EFL object
272 // And When Finalizer was called, Field can be already released.
279 /// Deleted will be triggered when the widght is deleted.
281 /// <since_tizen> preview </since_tizen>
282 public event EventHandler Deleted;
285 /// KeyUp will be triggered when the key is loose.
287 /// <since_tizen> preview </since_tizen>
288 public event EventHandler<EvasKeyEventArgs> KeyUp
290 add { _keyup.On += value; }
291 remove { _keyup.On -= value; }
295 /// KeyDown will be triggered when the key is pressed down.
297 /// <since_tizen> preview </since_tizen>
298 public event EventHandler<EvasKeyEventArgs> KeyDown
300 add { _keydown.On += value; }
301 remove { _keydown.On -= value; }
305 /// BackButtonPressed will be triggered when the Back button is pressed.
307 /// <since_tizen> preview </since_tizen>
308 public event EventHandler BackButtonPressed
312 if (_backButtonPressed == null)
314 Interop.Eext.eext_object_event_callback_add(RealHandle, Interop.Eext.EextCallbackType.EEXT_CALLBACK_BACK, _backButtonHandler, IntPtr.Zero);
316 _backButtonPressed += value;
320 _backButtonPressed -= value;
321 if (_backButtonPressed == null)
323 Interop.Eext.eext_object_event_callback_del(RealHandle, Interop.Eext.EextCallbackType.EEXT_CALLBACK_BACK, _backButtonHandler);
329 /// MoreButtonPressed will be triggered when the More button is pressed.
331 /// <since_tizen> preview </since_tizen>
332 public event EventHandler MoreButtonPressed
336 if (_moreButtonPressed == null)
338 Interop.Eext.eext_object_event_callback_add(RealHandle, Interop.Eext.EextCallbackType.EEXT_CALLBACK_MORE, _moreButtonHandler, IntPtr.Zero);
340 _moreButtonPressed += value;
344 _moreButtonPressed -= value;
345 if (_moreButtonPressed == null)
347 Interop.Eext.eext_object_event_callback_del(RealHandle, Interop.Eext.EextCallbackType.EEXT_CALLBACK_MORE, _moreButtonHandler);
353 /// Moved will be triggered when the widght is moved.
355 /// <since_tizen> preview </since_tizen>
356 public event EventHandler Moved
358 add { _moved.On += value; }
359 remove { _moved.On -= value; }
363 /// Resized Event Handler of the current widget's size.
365 /// <since_tizen> preview </since_tizen>
366 public event EventHandler Resized
368 add { _resized.On += value; }
369 remove { _resized.On -= value; }
373 /// Shown will be triggered when the widget is shown.
375 /// <since_tizen> preview </since_tizen>
376 public event EventHandler Shown
378 add { _shown.On += value; }
379 remove { _shown.On -= value; }
383 /// Hidden will be triggered when the widget is hidden.
385 /// <since_tizen> preview </since_tizen>
386 public event EventHandler Hidden
388 add { _hidden.On += value; }
389 remove { _hidden.On -= value; }
393 /// RenderPost Event Handler of the current widget.
395 /// <since_tizen> preview </since_tizen>
396 public event EventHandler RenderPost
400 _renderPost += value;
401 if (_renderPostCallback == null)
403 _renderPostCallback = new Interop.Evas.EvasCallback((o, e, d) => _renderPost?.Invoke(this, EventArgs.Empty));
404 Interop.Evas.evas_event_callback_add(Interop.Evas.evas_object_evas_get(RealHandle), Interop.Evas.ObjectCallbackType.RenderPost, _renderPostCallback, IntPtr.Zero);
409 _renderPost -= value;
410 if (_renderPost == null)
412 Interop.Evas.evas_event_callback_del(Interop.Evas.evas_object_evas_get(RealHandle), Interop.Evas.ObjectCallbackType.RenderPost, _renderPostCallback);
413 _renderPostCallback = null;
419 /// Called when a widget's tooltip is activated and needs content.
421 /// <returns></returns>
422 /// <since_tizen> preview </since_tizen>
423 public delegate EvasObject GetTooltipContentDelegate();
426 /// Gets a widget's status of realized or not.
428 /// <since_tizen> preview </since_tizen>
429 public bool IsRealized { get { return Handle != IntPtr.Zero; } }
434 /// <since_tizen> preview </since_tizen>
435 public EvasCanvas EvasCanvas
439 if (_evasCanvas == null)
440 _evasCanvas = new EvasCanvas(Handle);
446 /// Sets of gets a value that allow the automation framework to find and interact with this object.
448 /// <since_tizen> preview </since_tizen>
449 public string AutomationId
453 return _automationId;
457 if (_automationId != null)
458 throw new InvalidOperationException("AutomationId may only be set one time.");
459 _automationId = value;
464 /// Gets the current class's Name.
466 /// <since_tizen> preview </since_tizen>
467 public string ClassName
471 return Interop.Eo.efl_class_name_get(Interop.Eo.efl_class_get(RealHandle));
476 /// Sets or gets the horizontal pointer hints for an object's weight.
478 /// <since_tizen> preview </since_tizen>
479 public double WeightX
483 return Interop.Evas.GetWeightX(Handle);
487 Interop.Evas.SetWeightX(Handle, value);
492 /// Sets or gets the vertical pointer hints for an object's weight.
494 /// <since_tizen> preview </since_tizen>
495 public double WeightY
499 return Interop.Evas.GetWeightY(Handle);
503 Interop.Evas.SetWeightY(Handle, value);
508 /// Sets or gets the horizontal alignment hint of an object's alignment.
510 /// <since_tizen> preview </since_tizen>
511 public virtual double AlignmentX
515 return Interop.Evas.GetAlignX(Handle);
519 Interop.Evas.SetAlignX(Handle, value);
524 /// Sets or gets the vertical alignment hint of an object's alignment.
526 /// <since_tizen> preview </since_tizen>
527 public virtual double AlignmentY
531 return Interop.Evas.GetAlignY(Handle);
535 Interop.Evas.SetAlignY(Handle, value);
540 /// Sets or gets the width hints for an object's minimum size.
542 /// <since_tizen> preview </since_tizen>
543 public int MinimumWidth
548 Interop.Evas.evas_object_size_hint_min_get(RealHandle, out w, out h);
553 int h = MinimumHeight;
554 Interop.Evas.evas_object_size_hint_min_set(RealHandle, value, h);
559 /// Sets or gets the height hints for an object's minimum size.
561 /// <since_tizen> preview </since_tizen>
562 public int MinimumHeight
567 Interop.Evas.evas_object_size_hint_min_get(RealHandle, out w, out h);
572 int w = MinimumWidth;
573 Interop.Evas.evas_object_size_hint_min_set(RealHandle, w, value);
578 /// Gets the visible state of the given Evas object.
580 /// <since_tizen> preview </since_tizen>
581 public bool IsVisible
585 return Interop.Evas.evas_object_visible_get(Handle);
590 /// Sets or gets the position and (rectangular) size of the given Evas object.
592 /// <since_tizen> preview </since_tizen>
598 Interop.Evas.evas_object_geometry_get(Handle, out x, out y, out w, out h);
599 Rect rect = new Rect(x, y, w, h);
604 Interop.Evas.evas_object_geometry_set(Handle, value.X, value.Y, value.Width, value.Height);
609 /// Sets or gets the general or main color of the given Evas object.
611 /// <since_tizen> preview </since_tizen>
612 public virtual Color Color
617 Interop.Evas.evas_object_color_get(RealHandle, out r, out g, out b, out a);
618 return Color.FromRgba(r, g, b, a);
622 Interop.Evas.SetPremultipliedColor(RealHandle, value.R, value.G, value.B, value.A);
627 /// Sets or gets the map enabled state.
629 /// <since_tizen> preview </since_tizen>
630 public bool IsMapEnabled
634 return Interop.Evas.evas_object_map_enable_get(Handle);
638 Interop.Evas.evas_object_map_enable_set(Handle, value);
643 /// Sets or gets the current object's transformation map.
645 /// <since_tizen> preview </since_tizen>
646 public EvasMap EvasMap
650 IntPtr evasMap = Interop.Evas.evas_object_map_get(Handle);
651 return new EvasMap(evasMap);
655 Interop.Evas.evas_object_map_set(Handle, value.Handle);
660 /// Sets or gets whether an object is to repeat events.
662 /// <since_tizen> preview </since_tizen>
663 public bool RepeatEvents
667 var result = Interop.Evas.evas_object_repeat_events_get(Handle);
668 Debug.Assert(Handle == RealHandle || result == Interop.Evas.evas_object_repeat_events_get(RealHandle));
673 if (Handle != RealHandle)
675 Interop.Evas.evas_object_repeat_events_set(RealHandle, value);
677 Interop.Evas.evas_object_repeat_events_set(Handle, value);
682 /// Sets or gets whether events on a smart object's member should get propagated up to its parent.
684 /// <since_tizen> preview </since_tizen>
685 public bool PropagateEvents
689 var result = Interop.Evas.evas_object_propagate_events_get(Handle);
690 Debug.Assert(Handle == RealHandle || result == Interop.Evas.evas_object_propagate_events_get(RealHandle));
695 if (Handle != RealHandle)
697 Interop.Evas.evas_object_propagate_events_set(RealHandle, value);
699 Interop.Evas.evas_object_propagate_events_set(Handle, value);
704 /// Sets or gets whether an object is set to pass (ignore) events.
706 /// <since_tizen> preview </since_tizen>
707 public bool PassEvents
711 var result = Interop.Evas.evas_object_pass_events_get(Handle);
712 Debug.Assert(Handle == RealHandle || result == Interop.Evas.evas_object_pass_events_get(RealHandle));
717 if (Handle != RealHandle)
719 Interop.Evas.evas_object_pass_events_set(RealHandle, value);
721 Interop.Evas.evas_object_pass_events_set(Handle, value);
726 /// Sets or gets the style for this object tooltip.
728 /// <since_tizen> preview </since_tizen>
729 public string TooltipStyle
733 return Interop.Elementary.elm_object_tooltip_style_get(RealHandle);
737 Interop.Elementary.elm_object_tooltip_style_set(RealHandle, value);
742 /// Sets or gets the orientation of tooltip.
744 /// <since_tizen> preview </since_tizen>
745 public TooltipOrientation TooltipOrientation
749 return (TooltipOrientation)Interop.Elementary.elm_object_tooltip_orient_get(RealHandle);
753 Interop.Elementary.elm_object_tooltip_orient_set(RealHandle, (int)value);
758 /// Sets or gets size restriction state of an object's tooltip.
760 /// <since_tizen> preview </since_tizen>
761 public bool TooltipWindowMode
765 return Interop.Elementary.elm_object_tooltip_window_mode_get(RealHandle);
769 Interop.Elementary.elm_object_tooltip_window_mode_set(RealHandle, value);
774 /// Sets the content to be shown in the tooltip object.
776 /// <since_tizen> preview </since_tizen>
777 public GetTooltipContentDelegate TooltipContentDelegate
781 return _tooltipContentDelegate;
785 _tooltipContentDelegate = value;
788 Interop.Elementary.elm_object_tooltip_content_cb_set(RealHandle, _tooltipContentCallback, IntPtr.Zero, null);
792 Interop.Elementary.elm_object_tooltip_content_cb_set(RealHandle, null, IntPtr.Zero, null);
798 /// Gets the movement freeze by 1.
799 /// This gets the movement freeze count by one.
801 /// <since_tizen> preview </since_tizen>
802 public int TooltipMoveFreezeCount
806 return Interop.Elementary.elm_object_tooltip_move_freeze_get(RealHandle);
811 /// Sets or gets whether an Evas object is to freeze (discard) events.
813 /// <since_tizen> preview </since_tizen>
814 public bool AllEventsFrozen
818 var result = Interop.Evas.evas_object_freeze_events_get(Handle);
819 Debug.Assert(Handle == RealHandle || result == Interop.Evas.evas_object_freeze_events_get(RealHandle));
824 if (Handle != RealHandle)
826 Interop.Evas.evas_object_freeze_events_set(RealHandle, value);
828 Interop.Evas.evas_object_freeze_events_set(Handle, value);
833 /// Sets or gets the layer of its canvas that the given object will be part of.
835 /// <since_tizen> preview </since_tizen>
836 public virtual int Layer
840 return Interop.Evas.evas_object_layer_get(Handle);
844 Interop.Evas.evas_object_layer_set(Handle, value);
849 /// Sets or gets the render operation to be used for rendering the Evas object.
851 /// <since_tizen> 5 </since_tizen>
852 public RenderOp RenderOperation
856 return (RenderOp)Interop.Evas.evas_object_render_op_get(RealHandle);
860 Interop.Evas.evas_object_render_op_set(RealHandle, (Interop.Evas.RenderOp)value);
866 /// Clips one object to another.
868 /// <param name="clip">The object to clip object by.</param>
869 /// <since_tizen> preview </since_tizen>
870 public void SetClip(EvasObject clip)
872 Interop.Evas.evas_object_clip_set(Handle, clip);
876 /// Sets the hints for an object's alignment.
878 /// <param name="x">The horizontal alignment hint as double value ranging from 0.0 to 1.0. The default alignment hint value is 0.5.</param>
879 /// <param name="y">The vertical alignment hint as double value ranging from 0.0 to 1.0. The default alignment hint value is 0.5.</param>
880 /// <since_tizen> preview </since_tizen>
881 public void SetAlignment(double x, double y)
883 Interop.Evas.evas_object_size_hint_align_set(Handle, x, y);
887 /// Sets the hints for an object's weight.
889 /// <param name="x">The non-negative double value to be used as horizontal weight hint.</param>
890 /// <param name="y">The non-negative double value to be used as vertical weight hint.</param>
891 /// <since_tizen> preview </since_tizen>
892 public void SetWeight(double x, double y)
894 Interop.Evas.evas_object_size_hint_weight_set(Handle, x, y);
898 /// Sets the text for an object's tooltip.
900 /// <param name="text">The text value to display inside the tooltip.</param>
901 /// <since_tizen> preview </since_tizen>
902 public void SetTooltipText(string text)
904 Interop.Elementary.elm_object_tooltip_text_set(RealHandle, text);
908 /// Unsets an object's tooltip.
910 /// <since_tizen> preview </since_tizen>
911 public void UnsetTooltip()
913 Interop.Elementary.elm_object_tooltip_unset(RealHandle);
917 /// This increments the tooltip movement freeze count by one.
918 /// If the count is more than 0, the tooltip position will be fixed.
920 /// <since_tizen> preview </since_tizen>
921 public void PushTooltipMoveFreeze()
923 Interop.Elementary.elm_object_tooltip_move_freeze_push(RealHandle);
927 /// This decrements the tooltip freeze count by one.
929 /// <since_tizen> preview </since_tizen>
930 public void PopTooltipMoveFreeze()
932 Interop.Elementary.elm_object_tooltip_move_freeze_pop(RealHandle);
936 /// Force hide the tooltip of the object.
938 /// <since_tizen> preview </since_tizen>
939 public void HideTooltip()
941 Interop.Elementary.elm_object_tooltip_hide(RealHandle);
945 /// Force show the tooltip of the object.
947 /// <since_tizen> preview </since_tizen>
948 public void ShowTooltip()
950 Interop.Elementary.elm_object_tooltip_show(RealHandle);
954 /// Makes the current object visible.
956 /// <since_tizen> preview </since_tizen>
959 Interop.Evas.evas_object_show(Handle);
963 /// Makes the current object invisible.
965 /// <since_tizen> preview </since_tizen>
968 Interop.Evas.evas_object_hide(Handle);
972 /// Changes the size of the current object.
974 /// <param name="w">The new width.</param>
975 /// <param name="h">The new height.</param>
976 /// <since_tizen> preview </since_tizen>
977 public void Resize(int w, int h)
979 Interop.Evas.evas_object_resize(Handle, w, h);
983 /// Moves the current object to the given location.
985 /// <param name="x">The X position to move the object.</param>
986 /// <param name="y">The Y position to move the object.</param>
987 /// <since_tizen> preview </since_tizen>
988 public void Move(int x, int y)
990 Interop.Evas.evas_object_move(Handle, x, y);
994 /// Lowers the object to the bottom of its layer.
996 /// <since_tizen> preview </since_tizen>
999 Interop.Evas.evas_object_lower(Handle);
1003 /// Define the IntPtr operator.
1005 /// <param name="obj">Parent object.</param>
1006 /// <since_tizen> preview </since_tizen>
1007 public static implicit operator IntPtr(EvasObject obj)
1015 /// Define cast to EvasObject operator from IntPtr
1017 /// <param name="handle">Native handle to EvasObject</param>
1018 /// <since_tizen> preview </since_tizen>
1019 public static explicit operator EvasObject(IntPtr handle) => EvasObject.s_handleTable.TryGetValue(handle, out EvasObject obj) ? obj : null;
1022 /// Requests the keyname key events to be directed to the current object.
1024 /// <param name="keyname">The key to request events for.</param>
1025 /// <param name="exclusive">Set TRUE to request that the obj is the only object receiving the keyname events, otherwise set to FALSE.</param>
1026 /// <returns>If the call succeeds then true, otherwise false.</returns>
1027 /// <since_tizen> preview </since_tizen>
1028 public bool KeyGrab(string keyname, bool exclusive)
1030 return Interop.Evas.evas_object_key_grab(Handle, keyname, 0, 0, exclusive);
1034 /// Removes the grab on the keyname key events.
1036 /// <param name="keyname">The key the grab is set for.</param>
1037 /// <since_tizen> preview </since_tizen>
1038 public void KeyUngrab(string keyname)
1040 Interop.Evas.evas_object_key_ungrab(Handle, keyname, 0, 0);
1044 /// Marks the smart object as changed.
1046 /// <since_tizen> preview </since_tizen>
1047 public void MarkChanged()
1049 Interop.Evas.evas_object_smart_changed(RealHandle);
1053 /// Calls the calculate smart function immediately.
1054 /// This will force immediate calculations needed for renderization of this object.
1056 /// <since_tizen> preview </since_tizen>
1057 public void Calculate()
1059 Interop.Evas.evas_object_smart_calculate(RealHandle);
1063 /// Sets the hints for an object's aspect ratio.
1065 /// <param name="aspect">The policy or type of aspect ratio to apply to an object.</param>
1066 /// <param name="w">The integer to be used as aspect width ratio term.</param>
1067 /// <param name="h">The integer to be used as aspect height ratio term.</param>
1068 /// <since_tizen> preview </since_tizen>
1069 public void SetSizeHintAspect(AspectControl aspect, int w, int h)
1071 Interop.Evas.evas_object_size_hint_aspect_set(Handle, (int)aspect, w, h);
1075 /// Gets the hints for an object's aspect ratio.
1077 /// <param name="aspect">The policy or type of aspect ratio to apply to an object.</param>
1078 /// <param name="w">The integer to be used as aspect width ratio term.</param>
1079 /// <param name="h">The integer to be used as aspect height ratio term.</param>
1080 /// <since_tizen> preview </since_tizen>
1081 public void GetSizeHintAspect(out AspectControl aspect, out int w, out int h)
1084 Interop.Evas.evas_object_size_hint_aspect_get(Handle, out aspectRatio, out w, out h);
1085 aspect = (AspectControl)aspectRatio;
1089 /// Stacks immediately below anchor.
1091 /// <param name="anchor">The object below which to stack.</param>
1092 /// <since_tizen> preview </since_tizen>
1093 public void StackBelow(EvasObject anchor)
1095 Interop.Evas.evas_object_stack_below(Handle, anchor);
1099 /// Stacks immediately above anchor.
1101 /// <param name="anchor">The object above which to stack.</param>
1102 /// <since_tizen> preview </since_tizen>
1103 public void StackAbove(EvasObject anchor)
1105 Interop.Evas.evas_object_stack_above(Handle, anchor);
1109 /// Raises to the top of its layer.
1111 /// <since_tizen> preview </since_tizen>
1112 public void RaiseTop()
1114 Interop.Evas.evas_object_raise(Handle);
1118 /// Gets the geometry of a line number.
1120 /// <param name="lineNumber">The line number.</param>
1121 /// <param name="x">x coordinate of the line.</param>
1122 /// <param name="y">y coordinate of the line.</param>
1123 /// <param name="w">w coordinate of the line.</param>
1124 /// <param name="h">h coordinate of the line.</param>
1125 /// <returns>True on success, or False on error.</returns>
1126 /// <since_tizen> preview </since_tizen>
1127 [Obsolete("GetTextBlockGeometryByLineNumber is obsolete as of version 5.0.0.14299 and is no longer supported.")]
1128 public bool GetTextBlockGeometryByLineNumber(int lineNumber, out int x, out int y, out int w, out int h)
1130 x = -1; y = -1; w = -1; h = -1;
1132 IntPtr _edjeHandle = Interop.Elementary.elm_layout_edje_get(RealHandle);
1133 if (_edjeHandle == IntPtr.Zero)
1138 IntPtr _textblock = Interop.Elementary.edje_object_part_object_get(_edjeHandle, "elm.text");
1139 if (_textblock == IntPtr.Zero)
1144 return Interop.Evas.evas_object_textblock_line_number_geometry_get(_textblock, lineNumber, out x, out y, out w, out h);
1147 internal IntPtr GetData(string key)
1149 return Interop.Evas.evas_object_data_get(RealHandle, key);
1152 internal void SetData(string key, IntPtr data)
1154 Interop.Evas.evas_object_data_set(RealHandle, key, data);
1157 internal IntPtr DeleteData(string key)
1159 return Interop.Evas.evas_object_data_del(RealHandle, key);
1163 /// The callback of the Invalidate Event.
1165 /// <since_tizen> preview </since_tizen>
1166 protected virtual void OnInvalidate()
1171 /// The callback of the Instantiated Event.
1173 /// <since_tizen> preview </since_tizen>
1174 protected virtual void OnInstantiated()
1179 /// The callback of the Realized Event.
1181 /// <since_tizen> preview </since_tizen>
1182 protected virtual void OnRealized()
1187 /// The callback of the Unrealize Event.
1189 /// <since_tizen> preview </since_tizen>
1190 protected virtual void OnUnrealize()
1195 /// Creates a widget handle.
1197 /// <param name="parent">Parent EvasObject.</param>
1198 /// <returns>Handle IntPtr.</returns>
1199 /// <since_tizen> preview </since_tizen>
1200 protected abstract IntPtr CreateHandle(EvasObject parent);
1203 /// For this object bind Parent object.Init handle and all kinds of EvasObjectEvent.
1205 /// <param name="parent">Parent object.</param>
1206 /// <since_tizen> preview </since_tizen>
1207 public void Realize(EvasObject parent)
1212 Handle = CreateHandle(parent);
1213 Debug.Assert(Handle != IntPtr.Zero);
1215 s_handleTable[Handle] = this;
1217 (parent as Window)?.AddChild(this);
1220 _deleted = new EvasObjectEvent(this, EvasObjectCallbackType.Del);
1221 _keydown = new EvasObjectEvent<EvasKeyEventArgs>(this, RealHandle, EvasObjectCallbackType.KeyDown, EvasKeyEventArgs.Create);
1222 _keyup = new EvasObjectEvent<EvasKeyEventArgs>(this, RealHandle, EvasObjectCallbackType.KeyUp, EvasKeyEventArgs.Create);
1223 _moved = new EvasObjectEvent(this, EvasObjectCallbackType.Move);
1224 _resized = new EvasObjectEvent(this, EvasObjectCallbackType.Resize);
1225 _shown = new EvasObjectEvent(this, EvasObjectCallbackType.Show);
1226 _hidden = new EvasObjectEvent(this, EvasObjectCallbackType.Hide);
1228 _deleted.On += (s, e) => MakeInvalidate();
1229 _shown.On += (s, e) => Elementary.SendEvasObjectRealized(this);
1234 /// Removes the current object relationship with others.
1236 /// <since_tizen> preview </since_tizen>
1237 public void Unrealize()
1241 if (_renderPostCallback != null)
1243 Interop.Evas.evas_event_callback_del(Interop.Evas.evas_object_evas_get(Handle), Interop.Evas.ObjectCallbackType.RenderPost, _renderPostCallback);
1244 _renderPostCallback = null;
1248 IntPtr toBeDeleted = Handle;
1249 Handle = IntPtr.Zero;
1253 (Parent as Window)?.RemoveChild(this);
1255 Interop.Evas.evas_object_del(toBeDeleted);
1256 Deleted?.Invoke(this, EventArgs.Empty);
1258 s_handleTable.Remove(toBeDeleted);
1262 private void MakeInvalidate()
1264 Deleted?.Invoke(this, EventArgs.Empty);
1266 IntPtr toBeDeleted = Handle;
1267 Handle = IntPtr.Zero;
1269 MakeInvalidateEvent();
1271 (Parent as Window)?.RemoveChild(this);
1275 s_handleTable.Remove(toBeDeleted);
1278 private void DisposeEvent()
1280 var events = new List<IInvalidatable>(_eventStore);
1281 foreach (var evt in events)
1285 _eventStore.Clear();
1288 private void MakeInvalidateEvent()
1290 foreach (var evt in _eventStore)
1292 evt.MakeInvalidate();
1294 _eventStore.Clear();
1297 internal void AddToEventLifeTracker(IInvalidatable item)
1299 _eventStore.Add(item);
1302 internal void RemoveFromEventLifeTracker(IInvalidatable item)
1304 _eventStore.Remove(item);