summaryrefslogtreecommitdiff
path: root/ElmSharp/ElmSharp/GenGridItem.cs
blob: 66b451f20ae1467911d746d98294f2ddbd4314d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;
using System.ComponentModel;

namespace ElmSharp
{
    /// <summary>
    /// It inherits <see cref="GenItem"/>.
    /// A instance to the gengrid item added.
    /// It contains Update() method to update a gengrid item which is given.
    /// </summary>
    public class GenGridItem : GenItem
    {
        internal GenGridItem(object data, GenItemClass itemClass) : base(data, itemClass)
        {
        }

        /// <summary>
        /// Gets or sets whether a given gengrid item is selected.
        /// If one gengrid item is selected, any other previously selected items get unselected in favor of this new one.
        /// </summary>
        /// <remarks>
        /// If true, it is selected.
        /// If false, it is unselected.
        /// </remarks>
        public override bool IsSelected
        {
            get
            {
                return Interop.Elementary.elm_gengrid_item_selected_get(Handle);
            }
            set
            {
                Interop.Elementary.elm_gengrid_item_selected_set(Handle, value);
            }
        }

        /// <summary>
        /// Gets or sets the type of mouse pointer/cursor decoration to be shown, when the mouse pointer is over the given gengrid widget item.
        /// <remarks>
        /// The cursor's changing area is restricted to the item's area, and not the whole widget's. Note that that item cursors have precedence over widget cursors, so that a mouse over item will always show cursor type.
        /// </remarks>>
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override string Cursor
        {
            get
            {
                return Interop.Elementary.elm_gengrid_item_cursor_get(Handle);
            }
            set
            {
                if (!string.IsNullOrEmpty(value))
                {
                    Interop.Elementary.elm_gengrid_item_cursor_set(Handle, value);
                }
                else
                {
                    Interop.Elementary.elm_gengrid_item_cursor_unset(Handle);
                }
            }
        }

        /// <summary>
        /// Gets or sets custom cursor for gengrid item.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override string CursorStyle
        {
            get
            {
                return Interop.Elementary.elm_gengrid_item_cursor_style_get(Handle);
            }
            set
            {
                Interop.Elementary.elm_gengrid_item_cursor_style_set(Handle, value);
            }
        }

        /// <summary>
        /// Gets or sets whether to rely on the rendering engine.
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override bool IsUseEngineCursor
        {
            get
            {
                return Interop.Elementary.elm_gengrid_item_cursor_engine_only_get(Handle);
            }
            set
            {
                Interop.Elementary.elm_gengrid_item_cursor_engine_only_set(Handle, value);
            }
        }

        /// <summary>
        /// Gets or sets the style of given gengrid item's tooltip.
        /// </summary>
        public override string TooltipStyle
        {
            get
            {
                return Interop.Elementary.elm_gengrid_item_tooltip_style_get(Handle);
            }
            set
            {
                Interop.Elementary.elm_gengrid_item_tooltip_style_set(Handle, value);
            }
        }

        public override GenItemSelectionMode SelectionMode
        {
            get
            {
                return (GenItemSelectionMode)Interop.Elementary.elm_gengrid_item_select_mode_get(Handle);
            }
            set
            {
                Interop.Elementary.elm_gengrid_item_select_mode_set(Handle, (Interop.Elementary.Elm_Object_Select_Mode)value);
            }
        }

        /// <summary>
        /// Gets or sets gengrid item's row position, relative to the whole gengrid's grid area.
        /// </summary>
        public int Row
        {
            get
            {
                int row, column;
                Interop.Elementary.elm_gengrid_item_pos_get(Handle, out row, out column);
                return row;
            }
        }

        /// <summary>
        /// Gets or sets gengrid item's column position, relative to the whole gengrid's grid area.
        /// </summary>
        public int Column
        {
            get
            {
                int row, column;
                Interop.Elementary.elm_gengrid_item_pos_get(Handle, out row, out column);
                return column;
            }
        }

        public override void SetTooltipText(string tooltip)
        {
            Interop.Elementary.elm_gengrid_item_tooltip_text_set(Handle, tooltip);
        }

        public override void UnsetTooltip()
        {
            Interop.Elementary.elm_gengrid_item_tooltip_unset(Handle);
        }

        /// <summary>
        /// Updates the content of a given gengrid item.
        /// This updates an item by calling all the genitem class functions again to get the content, text, and states.
        /// Use this when the original item data has changed and you want the changes to reflect.
        /// </summary>
        /// <remarks>
        /// <see cref="GenGrid.UpdateRealizedItems"/> to update the contents of all the realized items.
        /// </remarks>
        public override void Update()
        {
            Interop.Elementary.elm_gengrid_item_update(Handle);
        }

        protected override void UpdateTooltipDelegate()
        {
            Interop.Elementary.elm_gengrid_item_tooltip_content_cb_set(Handle,
                TooltipContentDelegate != null ? _tooltipCb : null,
                IntPtr.Zero,
                null);
        }
    }
}