summaryrefslogtreecommitdiff
path: root/src/lib/elementary/elm_toolbar_item.eo
blob: aff0fa362a6484ae5ad0797bb45ea03c0541c84a (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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
enum Elm.Toolbar.Item.Scrollto_Type
{
   [[Defines where to position the item in the toolbar.]]
   legacy: elm_toolbar_item_scrollto;

   none = 0, [[no scrollto]]
   in = (1 << 0), [[to the nearest viewport]]
   first = (1 << 1), [[to the first of viewport]]
   middle = (1 << 2), [[to the middle of viewport]]
   last = (1 << 3) [[to the last of viewport]]
}

struct Elm.Toolbar.Item.State
{
   [[
     State of a Elm_Toolbar_Item.
     Can be created with elm_toolbar_item_state_add() and removed with elm_toolbar_item_state_del().
   ]]
   label: const(char)*;
   icon_str: const(char)*;
   icon: Evas.Object *;
   func: Evas_Smart_Cb ;
   data: const(void)*;
}

class Elm.Toolbar.Item(Elm.Widget.Item)
{
      legacy_prefix: elm_toolbar_item;
      eo_prefix: elm_obj_toolbar_item;
      methods {
           @property prev {
                get {
                     [[Get the item before $item in toolbar.

                       Note: If it is the first item, $null will be returned.
                     ]]
                }
                values {
                     item: Elm.Widget.Item *; [[The item before $item, or $null
                                                if none or on failure.]]
                }
           }
           @property next {
                get {
                     [[Get the item after $item in toolbar.

                       Note: If it is the last item, $null will be returned.
                     ]]
                }
                values {
                     item: Elm.Widget.Item *; [[The item after $item, or $null
                                                if none or on failure.]]
                }
           }
           @property priority {
                get {
                     [[Get the priority of a toolbar item.]]
                }
                set {
                     [[Set the priority of a toolbar item.

                       This is used only when the toolbar shrink mode is set
                       to #ELM_TOOLBAR_SHRINK_MENU or #ELM_TOOLBAR_SHRINK_HIDE.
                       When space is less than required, items with low priority
                       will be removed from the toolbar and added to a
                       dynamically-created menu, while items with higher
                       priority will remain on the toolbar, with the same
                       order they were added.
                     ]]
                }
                values {
                     priority: int; [[The $item priority. The default is zero
                                      for set and 0 is returned on failure.]]
                }
           }
           @property selected {
                get {
                     [[Get whether the $item is selected or not.]]
                }
                set {
                     [[Set the selected state of an item.

                       This sets the selected state of the given item $it.
                       $true for selected, $false for not selected.

                       If a new item is selected the previously selected will
                       be unselected. Previously selected item can be get with
                       function @Elm.Toolbar.selected_item.get.

                       Selected items will be highlighted.
                     ]]
                }
                values {
                     selected: bool; [[The selected state.]]
                }
           }
           @property icon {
                get {
                     [[Get the string used to set the icon of $item.]]
                }
                set {
                     [[Set the icon associated with $item.

                       Toolbar will load icon image from fdo or current theme.
                       This behavior can be set by
                       elm_toolbar_icon_order_lookup_set function.
                       If an absolute path is provided it will load it direct
                       from a file.

                       Note: This function does not accept relative icon path.
                     ]]
                }
                values {
                     icon: const(char)*; [[A string with icon name or the
                                           absolute path of an image file.]]
                }
           }
           @property object {
                get {
                     [[Get the real Evas(Edje) object created to implement the
                       view of a given toolbar $item.
                     ]]
                }
                values {
                     obj: Evas.Object *; [[The base Edje object associated with $it.]]
                }
           }
           @property icon_object {
                get {
                     [[Get the icon object of $item.

                       See also @.icon.set, @.icon_file_set, @.icon_memfile_set.
                     ]]
                }
                values {
                     obj: Evas.Object *; [[The icon object.]]
                }
           }
           @property separator {
                get {
                     [[Get a value whether item is a separator or not.]]
                }
                set {
                     [[Set or unset item as a separator.

                       Items aren't set as separator by default.

                       If set as separator it will display separator theme, so
                       won't display icons or label.
                     ]]
                }
                values {
                     separator: bool;
                }
           }
           @property menu {
                get {
                     [[Get toolbar item's menu.

                       If $item wasn't set as menu item with @.menu_set,
                       this function will set it.
                     ]]
                }
                values {
                     menu: Evas.Object *; [[Item's menu object or $null on failure.]]
                }
           }
           @property state {
                get {
                     [[Get the current state of $it.]]
                }
                set {
                     [[Set $state as the current state of $it.

                       If $state is $NULL, it won't select any state and the
                       default item's icon and label will be used. It's the
                       behavior as \@ref elm_toolbar_item_state_unset.
                     ]]
                     return: bool;
                }
                values {
                     state: Elm.Toolbar.Item.State * @nullable;
                }
           }
           /*      init { FIXME
                   params {
                   Evas_Smart_Cb func;
                   const(void)* data;
                   }
                   }*/
           icon_memfile_set {
                [[Set the icon associated with $item to an image in a binary buffer.

                  Note: The icon image set by this function can be changed by
                  @.icon.set.
                ]]
                params {
                     @in img: const (void) *; [[The binary data that will be used as an image.]]
                     @in size: size; [[The size of binary data $img.]]
                     @in format: const (char) *; [[Optional format of $img to pass to the image loader.]]
                     @in key: const (char) *; [[Optional key of $img to pass to the image loader (eg. if $img is an edje file).]]
                }
                return: bool;
           }
           icon_file_set {
                [[Set the icon associated with $item to an image in a binary buffer.

                  Note: The icon image set by this function can be changed by
                  elm_toolbar_item_icon_set().
                ]]
                params {
                     @in file: const (char) *; [[The file that contains the image.]]
                     @in key: const (char) *; [[Optional key of $img to pass to the image loader (eg. if $img is an edje file).]]
                }
                return: bool;
           }
           state_add {
                [[Add a new state to $item.

                  Toolbar will load icon image from fdo or current theme.
                  This behavior can be set by elm_toolbar_icon_order_lookup_set
                  function. If an absolute path is provided it will load it
                  direct from a file.

                  States created with this function can be removed with
                  @.state_del.
                ]]
                params {
                     @in icon: const (char) *; [[A string with icon name or the absolute path of an image file.]]
                     @in label: const (char) *; [[The label of the new state.]]
                     @in func: Evas_Smart_Cb @optional; [[The function to call when the item is clicked when this state is selected.]]
                     @in data: const (void) * @optional; [[The data to associate with the state.]]
                }
                return: Elm.Toolbar.Item.State *; [[The toolbar item state, or $null upon failure.]]
           }
           state_del {
                [[Delete a previously added state to $item.]]
                params {
                     @in state: Elm.Toolbar.Item.State *; [[The state to be deleted.]]
                }
                return: bool; [[$true on success or $false on failure.]]
           }
           state_next {
                [[Get the state after selected state in toolbar's $item.

                  If last state is selected, this function will return first
                  state.
                ]]
                return: Elm.Toolbar.Item.State *; [[The state after current state, or $null on failure.]]
           }
           state_prev {
                [[Get the state before selected state in toolbar's $item.

                  If first state is selected, this function will return last
                  state.
                ]]
                return: Elm.Toolbar.Item.State *; [[The state before current state, or $null on failure.]]
           }
           show {
                [[Show a specific item, when the toolbar can be scrolled.

                  @since 1.8
                ]]
                params {
                     @in scrollto: Elm.Toolbar.Item.Scrollto_Type; [[The position the item should appear at.]]
                }
           }
           bring_in {
                [[Show a specific item with scroll animation, when the toolbar
                  can be scrolled.

                  @since 1.8
                ]]
                params {
                     @in scrollto: Elm.Toolbar.Item.Scrollto_Type; [[The position the item should appear at.]]
                }
           }
           menu_set {
                [[Set whether the toolbar item opens a menu.

                  A toolbar item can be set to be a menu, using this function.

                  Once it is set to be a menu, it can be manipulated through the
                  menu-like function @Elm.Toolbar.menu_parent.set and the
                  other elm_menu functions, using the Evas_Object $menu returned
                  by @.menu.get.

                  So, items to be displayed in this item's menu should be added
                  with \@ref elm_menu_item_add.
                ]]
                /* FIXME-doc
                 The following code exemplifies the most basic usage:
                 @code
                 tb = elm_toolbar_add(win)
                 item = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL);
                 elm_toolbar_item_menu_set(item, true);
                 elm_toolbar_menu_parent_set(tb, win);
                 menu = elm_toolbar_item_menu_get(item);
                 elm_menu_item_add(menu, NULL, "edit-cut", "Cut", NULL, NULL);
                 menu_item = elm_menu_item_add(menu, NULL, "edit-copy", "Copy", NULL,
                 NULL);
                 @endcode
                */
                params {
                     @in menu: bool; [[If $true, $item will opens a menu when selected.]]
                }
           }
      }
      implements {
           Eo.Base.constructor;
           Eo.Base.destructor;
           Elm.Widget.Item.disable;
           Elm.Widget.Item.focus.set;
           Elm.Widget.Item.focus.get;
           Elm.Widget.Item.signal_emit;
           Elm.Widget.Item.part_text.get;
           Elm.Widget.Item.part_text.set;
           Elm.Widget.Item.part_content.get;
           Elm.Widget.Item.part_content.set;
           Elm.Widget.Item.part_content_unset;
           Elm.Interface.Atspi_Accessible.name.get;
           Elm.Interface.Atspi_Accessible.state_set.get;
      }
}