[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Icon.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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 using System;
18
19 namespace ElmSharp
20 {
21     /// <summary>
22     /// Enumeration for the icon lookup order. Should look for icons in the theme, FDO paths, or both.
23     /// </summary>
24     /// <since_tizen> preview </since_tizen>
25     public enum IconLookupOrder
26     {
27         /// <summary>
28         /// Icon look up order: freedesktop, theme.
29         /// </summary>
30         FreeDesktopFirst = 0,
31         /// <summary>
32         /// Icon look up order: theme, freedesktop.
33         /// </summary>
34         ThemeFirst,
35         /// <summary>
36         /// Icon look up order: freedesktop.
37         /// </summary>
38         FreeDesktopOnly,
39         /// <summary>
40         /// Icon look up order: theme.
41         /// </summary>
42         ThemeOnly
43     }
44
45     /// <summary>
46     /// The Icon is a widget that displays the standard icon images ("delete", "edit", "arrows", etc.)
47     /// or images coming from a custom file (PNG, JPG, EDJE, etc.), on the icon context.
48     /// Inherits Image.
49     /// </summary>
50     /// <since_tizen> preview </since_tizen>
51     public class Icon : Image
52     {
53         /// <summary>
54         /// Creates and initializes a new instance of the Icon class.
55         /// </summary>
56         /// <param name="parent">The parent is a given container, which will be attached by Icon as a child. It's <see cref="EvasObject"/> type.</param>
57         /// <since_tizen> preview </since_tizen>
58         public Icon(EvasObject parent) : base(parent)
59         {
60         }
61
62         /// <summary>
63         /// Sets or gets the standard icon name of a given Icon widget.
64         /// </summary>
65         /// <since_tizen> preview </since_tizen>
66         public string StandardIconName
67         {
68             get
69             {
70                 return Interop.Elementary.elm_icon_standard_get(RealHandle);
71             }
72             set
73             {
74                 Interop.Elementary.elm_icon_standard_set(RealHandle, value);
75             }
76         }
77
78         /// <summary>
79         /// Sets or gets the icon lookup order of a given Icon widget.
80         /// </summary>
81         /// <since_tizen> preview </since_tizen>
82         public IconLookupOrder IconLookupOrder
83         {
84             get
85             {
86                 return (IconLookupOrder)Interop.Elementary.elm_icon_order_lookup_get(RealHandle);
87             }
88             set
89             {
90                 Interop.Elementary.elm_icon_order_lookup_set(RealHandle, (int)value);
91             }
92         }
93
94         /// <summary>
95         /// Sets the file that is used, but uses a generated thumbnail.
96         /// </summary>
97         /// <param name="file">The path to the file that is used as an icon image.</param>
98         /// <param name="group">The group that the icon belongs to.</param>
99         /// <since_tizen> preview </since_tizen>
100         public void SetThumb(string file, string group)
101         {
102             Interop.Elementary.elm_icon_thumb_set(RealHandle, file, group);
103         }
104
105         /// <summary>
106         /// Adds a new icon object to the parent.
107         /// </summary>
108         /// <param name="parent">EvasObject</param>
109         /// <returns>The new object, otherwise null if it cannot be created.</returns>
110         /// <since_tizen> preview </since_tizen>
111         protected override IntPtr CreateHandle(EvasObject parent)
112         {
113             IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
114             Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
115
116             RealHandle = Interop.Elementary.elm_icon_add(handle);
117             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
118
119             return handle;
120         }
121     }
122 }