Release 4.0.0-preview1-00267
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / GenGridItem.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 using System.ComponentModel;
19
20 namespace ElmSharp
21 {
22     /// <summary>
23     /// It inherits <see cref="GenItem"/>.
24     /// A instance to the gengrid item added.
25     /// It contains Update() method to update a gengrid item which is given.
26     /// </summary>
27     public class GenGridItem : GenItem
28     {
29         internal GenGridItem(object data, GenItemClass itemClass) : base(data, itemClass)
30         {
31         }
32
33         /// <summary>
34         /// Gets or sets whether a given gengrid item is selected.
35         /// If one gengrid item is selected, any other previously selected items get unselected in favor of this new one.
36         /// </summary>
37         /// <remarks>
38         /// If true, it is selected.
39         /// If false, it is unselected.
40         /// </remarks>
41         public override bool IsSelected
42         {
43             get
44             {
45                 return Interop.Elementary.elm_gengrid_item_selected_get(Handle);
46             }
47             set
48             {
49                 Interop.Elementary.elm_gengrid_item_selected_set(Handle, value);
50             }
51         }
52
53         /// <summary>
54         /// Sets or gets the cursor to be shown when mouse is over the gengrid item.
55         /// </summary>
56         [EditorBrowsable(EditorBrowsableState.Never)]
57         public override string Cursor
58         {
59             get
60             {
61                 return Interop.Elementary.elm_gengrid_item_cursor_get(Handle);
62             }
63             set
64             {
65                 if (!string.IsNullOrEmpty(value))
66                 {
67                     Interop.Elementary.elm_gengrid_item_cursor_set(Handle, value);
68                 }
69                 else
70                 {
71                     Interop.Elementary.elm_gengrid_item_cursor_unset(Handle);
72                 }
73             }
74         }
75
76         /// <summary>
77         /// Sets or gets the style for this item cursor.
78         /// </summary>
79         [EditorBrowsable(EditorBrowsableState.Never)]
80         public override string CursorStyle
81         {
82             get
83             {
84                 return Interop.Elementary.elm_gengrid_item_cursor_style_get(Handle);
85             }
86             set
87             {
88                 Interop.Elementary.elm_gengrid_item_cursor_style_set(Handle, value);
89             }
90         }
91
92         /// <summary>
93         /// Sets or gets the cursor engine only usage for this item cursor.
94         /// </summary>
95         [EditorBrowsable(EditorBrowsableState.Never)]
96         public override bool IsUseEngineCursor
97         {
98             get
99             {
100                 return Interop.Elementary.elm_gengrid_item_cursor_engine_only_get(Handle);
101             }
102             set
103             {
104                 Interop.Elementary.elm_gengrid_item_cursor_engine_only_set(Handle, value);
105             }
106         }
107
108         /// <summary>
109         /// Sets or gets or sets the style of given gengrid item's tooltip.
110         /// </summary>
111         public override string TooltipStyle
112         {
113             get
114             {
115                 return Interop.Elementary.elm_gengrid_item_tooltip_style_get(Handle);
116             }
117             set
118             {
119                 Interop.Elementary.elm_gengrid_item_tooltip_style_set(Handle, value);
120             }
121         }
122
123         /// <summary>
124         /// Get the gengrid item's select mode.
125         /// </summary>
126         public override GenItemSelectionMode SelectionMode
127         {
128             get
129             {
130                 return (GenItemSelectionMode)Interop.Elementary.elm_gengrid_item_select_mode_get(Handle);
131             }
132             set
133             {
134                 Interop.Elementary.elm_gengrid_item_select_mode_set(Handle, (Interop.Elementary.Elm_Object_Select_Mode)value);
135             }
136         }
137
138         /// <summary>
139         /// Gets or sets gengrid item's row position, relative to the whole gengrid's grid area.
140         /// </summary>
141         public int Row
142         {
143             get
144             {
145                 int row, column;
146                 Interop.Elementary.elm_gengrid_item_pos_get(Handle, out row, out column);
147                 return row;
148             }
149         }
150
151         /// <summary>
152         /// Gets or sets gengrid item's column position, relative to the whole gengrid's grid area.
153         /// </summary>
154         public int Column
155         {
156             get
157             {
158                 int row, column;
159                 Interop.Elementary.elm_gengrid_item_pos_get(Handle, out row, out column);
160                 return column;
161             }
162         }
163
164         /// <summary>
165         /// Set the text to be shown in the gengrid item.
166         /// </summary>
167         /// <param name="tooltip">The text to set.</param>
168         public override void SetTooltipText(string tooltip)
169         {
170             Interop.Elementary.elm_gengrid_item_tooltip_text_set(Handle, tooltip);
171         }
172
173         /// <summary>
174         /// Unset tooltip from item.
175         /// </summary>
176         public override void UnsetTooltip()
177         {
178             Interop.Elementary.elm_gengrid_item_tooltip_unset(Handle);
179         }
180
181         /// <summary>
182         /// Updates the content of a given gengrid item.
183         /// This updates an item by calling all the genitem class functions again to get the content, text, and states.
184         /// Use this when the original item data has changed and you want the changes to reflect.
185         /// </summary>
186         /// <remarks>
187         /// <see cref="GenGrid.UpdateRealizedItems"/> to update the contents of all the realized items.
188         /// </remarks>
189         public override void Update()
190         {
191             Interop.Elementary.elm_gengrid_item_update(Handle);
192         }
193
194         /// <summary>
195         /// Set the content to be shown in the tooltip item.
196         /// </summary>
197         protected override void UpdateTooltipDelegate()
198         {
199             Interop.Elementary.elm_gengrid_item_tooltip_content_cb_set(Handle,
200                 TooltipContentDelegate != null ? _tooltipCb : null,
201                 IntPtr.Zero,
202                 null);
203         }
204     }
205 }