Release 4.0.0-preview1-00267
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / GenItem.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 select mode of GenItem.
23     /// </summary>
24     public enum GenItemSelectionMode
25     {
26         /// <summary>
27         /// Default select mode.
28         /// </summary>
29         Default,
30
31         /// <summary>
32         /// Always select mode.
33         /// </summary>
34         Always,
35
36         /// <summary>
37         /// No select mode.
38         /// </summary>
39         None,
40
41         /// <summary>
42         /// No select mode with no finger size rule.
43         /// </summary>
44         DisplayOnly
45     }
46
47     /// <summary>
48     /// It inherits <see cref="ItemObject"/>.
49     /// A base class for <see cref="GenGridItem"/> and <see cref="GenListItem"/>.
50     /// It contains genitem class and data to display data.
51     /// </summary>
52     public abstract class GenItem : ItemObject
53     {
54         internal Interop.Elementary.Elm_Tooltip_Item_Content_Cb _tooltipCb;
55         GetTooltipContentDelegate _tooltipContentDelegate = null;
56
57         /// <summary>
58         /// The delegate returning the tooltip contents.
59         /// </summary>
60         public delegate EvasObject GetTooltipContentDelegate();
61
62         internal GenItem(object data, GenItemClass itemClass) : base(IntPtr.Zero)
63         {
64             Data = data;
65             ItemClass = itemClass;
66             _tooltipCb = (d, obj, tooltip, item) => { return TooltipContentDelegate(); };
67         }
68
69         /// <summary>
70         /// Gets the item class that defines how to display data. It returns <see cref="GenItemClass"/> type.
71         /// </summary>
72         public GenItemClass ItemClass { get; protected set; }
73
74         /// <summary>
75         /// Sets or gets tooltip content delegate.
76         /// </summary>
77         public GetTooltipContentDelegate TooltipContentDelegate
78         {
79             get
80             {
81                 return _tooltipContentDelegate;
82             }
83             set
84             {
85                 _tooltipContentDelegate = value;
86                 UpdateTooltipDelegate();
87             }
88         }
89
90         /// <summary>
91         /// It's a abstract property.
92         /// </summary>
93         public abstract GenItemSelectionMode SelectionMode { get; set; }
94
95         /// <summary>
96         /// Sets or gets the cursor to be shown when mouse is over the gengrid item
97         /// </summary>
98         public abstract string Cursor { get; set; }
99
100         /// <summary>
101         /// Sets or gets the style for this item cursor.
102         /// </summary>
103         public abstract string CursorStyle { get; set; }
104
105         /// <summary>
106         /// Sets or gets the cursor engine only usage for this item cursor.
107         /// </summary>
108         public abstract bool IsUseEngineCursor { get; set; }
109
110         /// <summary>
111         /// Gets item data that is added through calling <see cref="GenGrid.Append(GenItemClass, object)"/>, <see cref="GenGrid.Prepend(GenItemClass, object)"/> or <see cref="GenGrid.InsertBefore(GenItemClass, object, GenGridItem)"/> methods.
112         /// </summary>
113         public object Data { get; protected set; }
114
115         /// <summary>
116         /// It's a abstract property. It's implemented by <see cref="GenGridItem.IsSelected"/> and <see cref="GenListItem.IsSelected"/>.
117         /// </summary>
118         public abstract bool IsSelected { get; set; }
119
120         /// <summary>
121         /// It's a abstract property. It's implemented by <see cref="GenGridItem.TooltipStyle"/> and <see cref="GenListItem.TooltipStyle"/>.
122         /// </summary>
123         public abstract string TooltipStyle { get; set; }
124
125         /// <summary>
126         /// Set tooltip text.
127         /// </summary>
128         /// <param name="tooltip">The text to set.</param>
129         public abstract void SetTooltipText(string tooltip);
130
131         /// <summary>
132         /// Unset tooltip.
133         /// </summary>
134         public abstract void UnsetTooltip();
135
136         /// <summary>
137         /// It's a abstract method. It's implemented by <see cref="GenGridItem.Update"/> and <see cref="GenListItem.Update"/>.
138         /// </summary>
139         public abstract void Update();
140
141         /// <summary>
142         /// The override method for delete item class and item data. It's called when the item is deleting.
143         /// </summary>
144         protected override void OnInvalidate()
145         {
146             ItemClass?.SendItemDeleted(Data);
147             Data = null;
148             ItemClass = null;
149         }
150
151         /// <summary>
152         /// Abstract method for updating tooltip content.
153         /// </summary>
154         protected abstract void UpdateTooltipDelegate();
155     }
156 }