2 * Copyright (c) 2018 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 ElmSharp.Accessible;
24 /// Enumeration for the focus direction.
26 /// <since_tizen> preview </since_tizen>
27 [Obsolete("This has been deprecated in API12")]
28 public enum FocusDirection
31 /// Previous direction.
62 /// The Widget is an abstract class and the parent of other widgets.
63 /// Inherits from <see cref="EvasObject"/>.
65 /// <since_tizen> preview </since_tizen>
66 [Obsolete("This has been deprecated in API12")]
67 public abstract class Widget : AccessibleObject
69 Dictionary<string, EvasObject> _partContents = new Dictionary<string, EvasObject>();
72 SmartEvent _unfocused;
74 internal Color _backgroundColor = Color.Default;
75 internal int _opacity = Color.Default.A;
78 /// Creates and initializes a new instance of the Widget class.
80 /// <since_tizen> preview </since_tizen>
81 [Obsolete("This has been deprecated in API12")]
87 /// Creates and initializes a new instance of the Widget class.
89 /// <param name="parent">The parent of the new Widget instance.</param>
90 /// <since_tizen> preview </since_tizen>
91 [Obsolete("This has been deprecated in API12")]
92 protected Widget(EvasObject parent) : base(parent)
97 /// Updates the part contents.
99 /// <param name="content">The content which is put into the part.</param>
100 /// <param name="part">The updated part.</param>
101 /// <since_tizen> preview </since_tizen>
102 [Obsolete("This has been deprecated in API12")]
103 protected void UpdatePartContents(EvasObject content, string part = "__default__")
105 _partContents[part] = content;
109 /// Focused will be triggered when the widget is focused.
111 /// <since_tizen> preview </since_tizen>
112 [Obsolete("This has been deprecated in API12")]
113 public event EventHandler Focused;
116 /// Unfocused will be triggered when the widget is unfocused.
118 /// <since_tizen> preview </since_tizen>
119 [Obsolete("This has been deprecated in API12")]
120 public event EventHandler Unfocused;
123 /// Sets or gets the state of the widget, which might be enabled or disabled.
125 /// <since_tizen> preview </since_tizen>
126 [Obsolete("This has been deprecated in API12")]
127 public virtual bool IsEnabled
131 return !Interop.Elementary.elm_object_disabled_get(RealHandle);
135 Interop.Elementary.elm_object_disabled_set(RealHandle, !value);
140 /// Sets or gets the style of the widget.
142 /// <since_tizen> preview </since_tizen>
143 [Obsolete("This has been deprecated in API12")]
148 return Interop.Elementary.elm_object_style_get(RealHandle);
152 Interop.Elementary.elm_object_style_set(RealHandle, value);
157 /// Gets whether this widget is focused.
159 /// <since_tizen> preview </since_tizen>
160 [Obsolete("This has been deprecated in API12")]
161 public bool IsFocused
165 return Interop.Elementary.elm_object_focus_get(RealHandle);
170 /// Gets whether a widget is focusable or not.
172 /// <remarks>Widgets which are meant to be interacted with by input events, are created able to be focused by default.</remarks>
173 /// <since_tizen> preview </since_tizen>
174 [Obsolete("This has been deprecated in API12")]
175 public bool IsFocusAllowed
179 return Interop.Elementary.elm_object_focus_allow_get(RealHandle);
184 /// Sets or gets the text of the widget.
186 /// <remarks>It could be overridden by special child class.</remarks>
187 /// <since_tizen> preview </since_tizen>
188 [Obsolete("This has been deprecated in API12")]
189 public virtual string Text
193 return Interop.Elementary.elm_object_part_text_get(RealHandle);
197 Interop.Elementary.elm_object_part_text_set(RealHandle, IntPtr.Zero, value);
202 /// Sets or gets the background color of the widget.
204 /// <remarks>It could be overridden by special child class.</remarks>
205 /// <since_tizen> preview </since_tizen>
206 [Obsolete("This has been deprecated in API12")]
207 public virtual Color BackgroundColor
211 if (!_backgroundColor.IsDefault)
213 _backgroundColor = GetPartColor("bg");
215 return _backgroundColor;
221 Console.WriteLine("Widget instance doesn't support to set BackgroundColor to Color.Default.");
225 SetPartColor("bg", value);
226 _backgroundColor = value;
232 /// Sets or gets the opacity of the widget.
234 /// <remarks>It could be overridden by special child class.</remarks>
235 /// <since_tizen> preview </since_tizen>
236 [Obsolete("This has been deprecated in API12")]
237 public virtual int Opacity
241 if (_opacity != Color.Default.A)
243 _opacity = GetPartOpacity("opacity");
249 SetPartOpacity("opacity", value);
255 /// Sets or gets whether a widget and its children are focusable or not.
257 /// <since_tizen> preview </since_tizen>
258 [Obsolete("This has been deprecated in API12")]
259 public bool AllowTreeFocus
263 return Interop.Elementary.elm_object_tree_focus_allow_get(RealHandle);
267 Interop.Elementary.elm_object_tree_focus_allow_set(RealHandle, value);
272 /// Sets or gets the widget's mirrored mode.
274 /// <since_tizen> preview </since_tizen>
275 [Obsolete("This has been deprecated in API12")]
276 public bool IsMirroredMode
280 return Interop.Elementary.elm_object_mirrored_get(RealHandle);
284 Interop.Elementary.elm_object_mirrored_set(RealHandle, value);
289 /// Sets or gets the widget's mirrored mode setting.
290 /// When widget is set to automatic mode(true), it follows the system mirrored mode.
292 /// <since_tizen> preview </since_tizen>
293 [Obsolete("This has been deprecated in API12")]
294 public bool IsAutoMirroredMode
298 return Interop.Elementary.elm_object_mirrored_automatic_get(RealHandle);
302 Interop.Elementary.elm_object_mirrored_automatic_set(RealHandle, value);
307 /// Sets the widget to be focused or not.
309 /// <param name="isFocus">Whether be focused.</param>
310 /// <since_tizen> preview </since_tizen>
311 [Obsolete("This has been deprecated in API12")]
312 public void SetFocus(bool isFocus)
316 Interop.Elementary.elm_object_focus_set(RealHandle, isFocus);
320 Interop.Elementary.elm_object_focused_clear(RealHandle);
325 /// Sets the ability for a widget to be focused.
327 /// <param name="isAllowFocus">true if the object can be focused, false if not(and on errors).</param>
328 /// <since_tizen> preview </since_tizen>
329 [Obsolete("This has been deprecated in API12")]
330 public void AllowFocus(bool isAllowFocus)
332 Interop.Elementary.elm_object_focus_allow_set(RealHandle, isAllowFocus);
336 /// Gives focus to the next widget in the widget tree.
338 /// <param name="direction">Direction to move the focus.</param>
339 /// <since_tizen> preview </since_tizen>
340 [Obsolete("This has been deprecated in API12")]
341 public void FocusNext(FocusDirection direction)
343 Interop.Elementary.elm_object_focus_next(RealHandle, (int)direction);
347 /// Sets the next widget with specific focus direction.
349 /// <param name="next">Focus next widget.</param>
350 /// <param name="direction">Focus direction.</param>
351 /// <since_tizen> preview </since_tizen>
352 [Obsolete("This has been deprecated in API12")]
353 public void SetNextFocusObject(EvasObject next, FocusDirection direction)
355 Interop.Elementary.elm_object_focus_next_object_set(RealHandle, next?.RealHandle ?? IntPtr.Zero, (int)direction);
359 /// Sets content to the particular part of the widget, and the preserve old content will be deleted.
361 /// <param name="part">The name of the particular part.</param>
362 /// <param name="content">The content.</param>
363 /// <seealso cref="SetPartContent(string, EvasObject, bool)"/>
364 /// <since_tizen> preview </since_tizen>
365 [Obsolete("This has been deprecated in API12")]
366 public virtual bool SetPartContent(string part, EvasObject content)
368 return SetPartContent(part, content, false);
372 /// Sets content to the particular part of the widget.
374 /// <param name="part">The name of the particular part.</param>
375 /// <param name="content">The content.</param>
376 /// <param name="preserveOldContent">true, preserve old content will be unset and not be deleted. false, preserve old content will be deleted.</param>
377 /// <seealso cref="SetPartContent(string, EvasObject)"/>
378 /// <since_tizen> preview </since_tizen>
379 [Obsolete("This has been deprecated in API12")]
380 public virtual bool SetPartContent(string part, EvasObject content, bool preserveOldContent)
382 if (preserveOldContent)
384 Interop.Elementary.elm_object_part_content_unset(RealHandle, part);
386 Interop.Elementary.elm_object_part_content_set(RealHandle, part, content);
387 UpdatePartContents(content, part);
392 /// Sets content to the widget, and the preserve old content will be deleted.
394 /// <param name="content">The content.</param>
395 /// <seealso cref="SetContent(EvasObject, bool)"/>
396 /// <since_tizen> preview </since_tizen>
397 [Obsolete("This has been deprecated in API12")]
398 public void SetContent(EvasObject content)
400 SetContent(content, false);
404 /// Sets content to the widget.
406 /// <param name="content">The content.</param>
407 /// <param name="preserveOldContent">true, preserve old content will be unset and not be deleted. false, preserve old content will be deleted.</param>
408 /// <seealso cref="SetContent(EvasObject)"/>
409 /// <since_tizen> preview </since_tizen>
410 [Obsolete("This has been deprecated in API12")]
411 public void SetContent(EvasObject content, bool preserveOldContent)
413 if (preserveOldContent)
415 Interop.Elementary.elm_object_content_unset(RealHandle);
418 Interop.Elementary.elm_object_content_set(RealHandle, content);
419 UpdatePartContents(content);
423 /// Sets text to the particular part of the widget.
425 /// <param name="part">The name of the particular part.</param>
426 /// <param name="text">The text.</param>
427 /// <since_tizen> preview </since_tizen>
428 [Obsolete("This has been deprecated in API12")]
429 public virtual bool SetPartText(string part, string text)
431 Interop.Elementary.elm_object_part_text_set(RealHandle, part, text);
436 /// Gets text of a particular part of the widget.
438 /// <param name="part">The name of the particular part.</param>
439 /// <returns>Text of the particular part of the widget.</returns>
440 /// <since_tizen> preview </since_tizen>
441 [Obsolete("This has been deprecated in API12")]
442 public virtual string GetPartText(string part)
444 return Interop.Elementary.elm_object_part_text_get(RealHandle, part);
448 /// Sets color of a particular part of the widget.
450 /// <param name="part">The name of the particular part.</param>
451 /// <param name="color">The color to be set to the widget.</param>
452 /// <remarks>This method is a virtual method, it could be overridden by special child class.</remarks>
453 /// <since_tizen> preview </since_tizen>
454 [Obsolete("This has been deprecated in API12")]
455 public virtual void SetPartColor(string part, Color color)
457 Interop.Elementary.elm_object_color_class_color_set(RealHandle, part, color.R * color.A / 255,
458 color.G * color.A / 255,
459 color.B * color.A / 255,
464 /// Gets color of the particular part of the widget.
466 /// <param name="part">The name of the particular part.</param>
467 /// <returns>The color of the particular part.</returns>
468 /// <remarks>This method is a virtual method, it could be overridden by special child class.</remarks>
469 /// <since_tizen> preview </since_tizen>
470 [Obsolete("This has been deprecated in API12")]
471 public virtual Color GetPartColor(string part)
474 Interop.Elementary.elm_object_color_class_color_get(RealHandle, part, out r, out g, out b, out a);
475 return new Color((int)(r / (a / 255.0)), (int)(g / (a / 255.0)), (int)(b / (a / 255.0)), a);
479 /// Sets opacity of the particular part of the widget.
481 /// <param name="part">The name of the particular part.</param>
482 /// <param name="opacity">The opacity of the particular part.</param>
483 /// <since_tizen> preview </since_tizen>
484 [Obsolete("This has been deprecated in API12")]
485 public void SetPartOpacity(string part, int opacity)
487 Interop.Elementary.elm_object_color_class_color_set(Handle, part, 255, 255, 255, opacity);
491 /// Gets opacity of the particular part of the widget.
493 /// <param name="part">The name of the particular part.</param>
494 /// <returns>Opacity value of the particular part.</returns>
495 /// <since_tizen> preview </since_tizen>
496 [Obsolete("This has been deprecated in API12")]
497 public int GetPartOpacity(string part)
500 Interop.Elementary.elm_object_color_class_color_get(Handle, part, out r, out g, out b, out a);
505 /// Sends a signal to the edje object of the widget.
507 /// <param name="emission">The signal's name.</param>
508 /// <param name="source">The signal's source.</param>
509 /// <since_tizen> preview </since_tizen>
510 [Obsolete("This has been deprecated in API12")]
511 public void SignalEmit(string emission, string source)
513 Interop.Elementary.elm_object_signal_emit(Handle, emission, source);
517 /// The callback of the Realized event.
519 /// <since_tizen> preview </since_tizen>
520 [Obsolete("This has been deprecated in API12")]
521 protected override void OnRealized()
524 _focused = new SmartEvent(this, "focused");
525 _focused.On += (s, e) => Focused?.Invoke(this, EventArgs.Empty);
527 _unfocused = new SmartEvent(this, "unfocused");
528 _unfocused.On += (s, e) => Unfocused?.Invoke(this, EventArgs.Empty);
531 internal IntPtr GetPartContent(string part)
533 return Interop.Elementary.elm_object_part_content_get(RealHandle, part);