Release 4.0.0-preview1-00051
[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     public enum IconLookupOrder
25     {
26         /// <summary>
27         /// Icon look up order: freedesktop, theme
28         /// </summary>
29         FreeDesktopFirst = 0,
30         /// <summary>
31         /// Icon look up order: theme, freedesktop
32         /// </summary>
33         ThemeFirst,
34         /// <summary>
35         /// Icon look up order: freedesktop
36         /// </summary>
37         FreeDesktopOnly,
38         /// <summary>
39         /// Icon look up order: theme
40         /// </summary>
41         ThemeOnly
42     }
43
44     /// <summary>
45     /// The Icon is a widget that displays standard icon images ("delete", "edit", "arrows", etc.)
46     /// or images coming from a custom file (PNG, JPG, EDJE, etc.), on icon context.
47     /// Inherits Image
48     /// </summary>
49     public class Icon : Image
50     {
51         /// <summary>
52         /// Creates and initializes a new instance of Icon class.
53         /// </summary>
54         /// <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>
55         public Icon(EvasObject parent) : base(parent)
56         {
57         }
58
59         /// <summary>
60         /// Sets or gets the standard icon name of a given Icon widget.
61         /// </summary>
62         public string StandardIconName
63         {
64             get
65             {
66                 return Interop.Elementary.elm_icon_standard_get(RealHandle);
67             }
68             set
69             {
70                 Interop.Elementary.elm_icon_standard_set(RealHandle, value);
71             }
72         }
73
74         /// <summary>
75         /// Sets or gets the icon lookup order of a given Icon widget.
76         /// </summary>
77         public IconLookupOrder IconLookupOrder
78         {
79             get
80             {
81                 return (IconLookupOrder)Interop.Elementary.elm_icon_order_lookup_get(RealHandle);
82             }
83             set
84             {
85                 Interop.Elementary.elm_icon_order_lookup_set(RealHandle, (int)value);
86             }
87         }
88
89         /// <summary>
90         /// Sets the file that is used, but uses a generated thumbnail.
91         /// </summary>
92         /// <param name="file">The path to the file that is used as an icon image</param>
93         /// <param name="group">The group that the icon belongs to</param>
94         public void SetThumb(string file, string group)
95         {
96             Interop.Elementary.elm_icon_thumb_set(RealHandle, file, group);
97         }
98
99         /// <summary>
100         /// Adds a new icon object to the parent.
101         /// </summary>
102         /// <param name="parent">EvasObject</param>
103         /// <returns>The new object, otherwise NULL if it cannot be created</returns>
104         protected override IntPtr CreateHandle(EvasObject parent)
105         {
106             IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
107             Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
108
109             RealHandle = Interop.Elementary.elm_icon_add(handle);
110             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
111
112             return handle;
113         }
114     }
115 }