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