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;
19 using System.Collections.Generic;
24 /// The EdjeObject is a class that the evas object exists in.
26 /// <since_tizen> preview </since_tizen>
27 public class EdjeObject
30 Dictionary<SignalData, Interop.Elementary.Edje_Signal_Cb> _signalDatas = new Dictionary<SignalData, Interop.Elementary.Edje_Signal_Cb>();
32 internal EdjeObject(IntPtr handle)
38 /// Checks whether an edje part exists in a given edje object's group definition.
39 /// This function returns if a given part exists in the edje group bound to object obj
41 /// <remarks>This call is useful, for example, when one could expect a given GUI element, depending on the theme applied to object.</remarks>
42 /// <param name="part">The part's name to check for existence in object's group.</param>
43 /// <returns>TRUE, if the edje part exists in the object's group, otherwise FALSE.</returns>
44 /// <since_tizen> preview </since_tizen>
45 public EdjeTextPartObject this[string part]
49 if (Interop.Elementary.edje_object_part_exists(_edjeHandle, part))
51 return new EdjeTextPartObject(_edjeHandle, part);
58 /// Sends or emits an edje signal to a given edje object.
60 /// <param name="emission">The signal's "emission" string</param>
61 /// <param name="source">The signal's "source" string</param>
62 /// <since_tizen> preview </since_tizen>
63 public void EmitSignal(string emission, string source)
65 Interop.Elementary.edje_object_signal_emit(_edjeHandle, emission, source);
69 /// Deletes the object Color class.
70 /// This function deletes any values at the object level for the specified object and Color class.
72 /// <remarks>Deleting the Color class defined in the theme file.</remarks>
73 /// <param name="part">The Color class to be deleted.</param>
74 /// <since_tizen> preview </since_tizen>
75 public void DeleteColorClass(string part)
77 Interop.Elementary.edje_object_color_class_del(_edjeHandle, part);
81 /// Sets the object Color class.
83 /// <param name="colorClass">The Color class name.</param>
84 /// <param name="red">The object red value.</param>
85 /// <param name="green">The object green value.</param>
86 /// <param name="blue">The object blue value.</param>
87 /// <param name="alpha">The object alpha value.</param>
88 /// <param name="outlineRed">The outline red value.</param>
89 /// <param name="outlineGreen">The outline green value.</param>
90 /// <param name="outlineBlue">The outline blue value.</param>
91 /// <param name="outlineAlpha">The outline alpha value.</param>
92 /// <param name="shadowRed">The shadow red value.</param>
93 /// <param name="shadowGreen">The shadow green value.</param>
94 /// <param name="shadowBlue">The shadow blue value.</param>
95 /// <param name="shadowAlpha">The shadow alpha value.</param>
96 /// <returns>True if succeeds, otherwise False.</returns>
97 /// <since_tizen> preview </since_tizen>
98 public bool SetColorClass(string colorClass, int red, int green, int blue, int alpha, int outlineRed, int outlineGreen, int outlineBlue, int outlineAlpha,
99 int shadowRed, int shadowGreen, int shadowBlue, int shadowAlpha)
101 return Interop.Elementary.edje_object_color_class_set(_edjeHandle, colorClass, red, green, blue, alpha, outlineRed, outlineGreen, outlineBlue, outlineAlpha,
102 shadowRed, shadowGreen, shadowBlue, shadowAlpha);
106 /// Gets the object Color class.
108 /// <param name="colorClass">The Color class name.</param>
109 /// <param name="red">The object red value.</param>
110 /// <param name="green">The object green value.</param>
111 /// <param name="blue">The object blue value.</param>
112 /// <param name="alpha">The object alpha value.</param>
113 /// <param name="outlineRed">The outline red value.</param>
114 /// <param name="outlineGreen">The outline green value.</param>
115 /// <param name="outlineBlue">The outline blue value.</param>
116 /// <param name="outlineAlpha">The outline alpha value.</param>
117 /// <param name="shadowRed">The shadow red value.</param>
118 /// <param name="shadowGreen">The shadow green value.</param>
119 /// <param name="shadowBlue">The shadow blue value.</param>
120 /// <param name="shadowAlpha">The shadow alpha value.</param>
121 /// <returns>True if succeeds, otherwise False.</returns>
122 /// <since_tizen> preview </since_tizen>
123 public bool GetColorClass(string colorClass, out int red, out int green, out int blue, out int alpha, out int outlineRed, out int outlineGreen, out int outlineBlue, out int outlineAlpha,
124 out int shadowRed, out int shadowGreen, out int shadowBlue, out int shadowAlpha)
126 return Interop.Elementary.edje_object_color_class_get(_edjeHandle, colorClass, out red, out green, out blue, out alpha, out outlineRed, out outlineGreen, out outlineBlue, out outlineAlpha,
127 out shadowRed, out shadowGreen, out shadowBlue, out shadowAlpha);
131 /// Sets the Edje text class.
133 /// <param name="textClass">The text class name.</param>
134 /// <param name="font">Font name.</param>
135 /// <param name="fontSize">Font size.</param>
136 /// <returns>True if succeeds, otherwise False.</returns>
137 /// <since_tizen> preview </since_tizen>
138 public bool SetTextClass(string textClass, string font, int fontSize)
140 return Interop.Elementary.edje_object_text_class_set(_edjeHandle, textClass, font, fontSize);
144 /// Gets the Edje text class.
146 /// <param name="textClass">The text class name.</param>
147 /// <param name="font">Font name.</param>
148 /// <param name="fontSize">Font size.</param>
149 /// <returns>True if succeeds, otherwise False.</returns>
150 /// <since_tizen> preview </since_tizen>
151 public bool GetTextClass(string textClass, out string font, out int fontSize)
153 return Interop.Elementary.edje_object_text_class_get(_edjeHandle, textClass, out font, out fontSize);
157 /// Adds Action for an arriving edje signal, emitted by a given Ejde object.
159 /// <param name="emission">The signal's "emission" string.</param>
160 /// <param name="source">The signal's "source" string.</param>
161 /// <param name="action">The action to be executed when the signal is emitted.</param>
162 /// <since_tizen> preview </since_tizen>
163 public void AddSignalAction(string emission, string source, Action<string, string> action)
165 if (emission != null && source != null && action != null)
167 var signalData = new SignalData(emission, source, action);
168 if (!_signalDatas.ContainsKey(signalData))
170 var signalCallback = new Interop.Elementary.Edje_Signal_Cb((d, o, e, s) =>
175 Interop.Elementary.edje_object_signal_callback_add(_edjeHandle, emission, source, signalCallback, IntPtr.Zero);
176 _signalDatas.Add(signalData, signalCallback);
182 /// Deletes a signal-triggered action from an object.
184 /// <param name="emission">The signal's "emission" string.</param>
185 /// <param name="source">The signal's "source" string.</param>
186 /// <param name="action">The action to be executed when the signal is emitted.</param>
187 /// <since_tizen> preview </since_tizen>
188 public void DeleteSignalAction(string emission, string source, Action<string, string> action)
190 if (emission != null && source != null && action != null)
192 var signalData = new SignalData(emission, source, action);
194 Interop.Elementary.Edje_Signal_Cb signalCallback = null;
195 _signalDatas.TryGetValue(signalData, out signalCallback);
197 if (signalCallback != null)
199 Interop.Elementary.edje_object_signal_callback_del(_edjeHandle, emission, source, signalCallback);
200 _signalDatas.Remove(signalData);
205 class SignalData : IEquatable<SignalData>
207 public string Emission { get; set; }
208 public string Source { get; set; }
210 public Action<string, string> Action { get; set; }
212 public SignalData(string emission, string source, Action<string, string> action)
219 public override bool Equals(object other)
221 return Equals(other as SignalData);
224 public bool Equals(SignalData other) {
229 return (Emission == other.Emission) && (Source == other.Source) && (Action == other.Action);
232 public override int GetHashCode()
234 int hashCode = Emission.GetHashCode();
235 hashCode ^= Source.GetHashCode();
236 hashCode ^= Action.GetHashCode();
243 /// The EdjeTextPartObject is a class dealing with parts of type text.
245 /// <since_tizen> preview </since_tizen>
246 public class EdjeTextPartObject
251 internal EdjeTextPartObject(IntPtr edjeHandle, string part)
253 _edjeHandle = edjeHandle;
258 /// Gets the name of the EdjeTextPartObject.
260 /// <since_tizen> preview </since_tizen>
261 public string Name { get { return _part; } }
264 /// Gets or sets the text for an object part.
266 /// <since_tizen> preview </since_tizen>
271 return Interop.Elementary.edje_object_part_text_get(_edjeHandle, _part);
275 Interop.Elementary.edje_object_part_text_set(_edjeHandle, _part, value);
280 /// Sets or gets the style of the object part.
282 /// <since_tizen> preview </since_tizen>
283 public string TextStyle
287 return Interop.Elementary.edje_object_part_text_style_user_peek(_edjeHandle, _part);
293 Interop.Elementary.edje_object_part_text_style_user_pop(_edjeHandle, _part);
297 Interop.Elementary.edje_object_part_text_style_user_push(_edjeHandle, _part, value);
303 /// Gets the geometry of a given edje part, in a given edje object's group definition, relative to the object's area.
305 /// <since_tizen> preview </since_tizen>
311 Interop.Elementary.edje_object_part_geometry_get(_edjeHandle, _part, out x, out y, out w, out h);
312 return new Rect(x, y, w, h);
317 /// Gets the native width and height.
319 /// <since_tizen> preview </since_tizen>
320 public Size TextBlockNativeSize
326 IntPtr part = Interop.Elementary.edje_object_part_object_get(_edjeHandle, _part);
327 Interop.Evas.evas_object_textblock_size_native_get(part, out w, out h);
328 return new Size(w, h);
333 /// Gets the formatted width and height.
335 /// <since_tizen> preview </since_tizen>
336 public Size TextBlockFormattedSize
342 IntPtr part = Interop.Elementary.edje_object_part_object_get(_edjeHandle, _part);
343 Interop.Evas.evas_object_textblock_size_formatted_get(part, out w, out h);
344 return new Size(w, h);