Merge branch 'master' into svn_merge
[framework/uifw/elementary.git] / src / lib / elm_dialoguegroup.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3 #include <Ecore.h>
4
5 /**
6  * @defgroup DialogueGroup DialogueGroup 
7  * @ingroup Elementary
8  *
9  * Using dialoguegroup, you can make a dialogue group.
10  */
11
12 struct _Dialogue_Item
13 {
14    Evas_Object *obj;
15    Evas_Object *bg_layout;
16    Evas_Object *content;
17    Elm_Dialoguegroup_Item_Style style;
18    const char *location;
19    Eina_Bool press;
20    Eina_Bool disabled;
21    //   Eina_Bool line_show;
22 };
23
24
25 typedef struct _Widget_Data Widget_Data;
26 struct _Widget_Data
27 {
28    Evas_Object *box;
29    Evas_Object *title_layout;
30    const char *title;
31    unsigned int num;
32    Eina_List *items;
33 };
34
35 static const char*widtype = NULL;
36
37 static void _del_hook(Evas_Object *obj);
38 static void _theme_hook(Evas_Object *obj);
39 static void _sizing_eval(Evas_Object *obj);
40
41 static void _remove_all(Evas_Object *obj);
42 static void _set_item_theme(Dialogue_Item *item, const char *location);
43 static void _change_item_bg(Dialogue_Item *item, const char *location);
44 static Dialogue_Item* _create_item(Evas_Object *obj, Evas_Object *subobj, Elm_Dialoguegroup_Item_Style style, const char *location);
45
46
47 static void
48 _del_hook(Evas_Object *obj)
49 {
50    Widget_Data *wd = elm_widget_data_get(obj);
51    
52    if (!wd) return;
53    if (wd->title) eina_stringshare_del(wd->title);
54    
55    _remove_all(obj);
56    
57    if (wd->box){
58       evas_object_del(wd->box);
59       wd->box = NULL;
60    }
61    
62    free(wd);
63 }
64
65
66 static void
67 _theme_hook(Evas_Object *obj)
68 {
69    Widget_Data *wd = elm_widget_data_get(obj);
70    Eina_List *l;
71    Dialogue_Item *item; 
72    
73    if (!wd) return;     
74    if (wd->title) {
75       elm_layout_theme_set(wd->title_layout, "dialoguegroup", "title", elm_widget_style_get(obj));
76       edje_object_part_text_set(elm_layout_edje_get(wd->title_layout), "text", wd->title);
77    }
78    EINA_LIST_FOREACH(wd->items, l, item) 
79      _change_item_bg( item, item->location );   
80    _sizing_eval(obj);
81 }
82
83 static void
84 _sizing_eval(Evas_Object *obj)
85 {
86    Widget_Data *wd = elm_widget_data_get(obj);
87    Evas_Coord minw, minh, maxw, maxh;
88    
89    if (!wd) return;
90    evas_object_size_hint_min_get(wd->box, &minw, &minh);
91    evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
92    evas_object_size_hint_min_set(obj, minw, minh);
93    evas_object_size_hint_max_set(obj, maxw, maxh);
94 }
95
96 static void 
97 _remove_all(Evas_Object *obj)
98 {
99    Widget_Data *wd = elm_widget_data_get(obj);
100    Dialogue_Item *item; 
101    
102    if (!wd) return;
103    
104    wd->num = 0;
105    
106    if (wd->items) {
107       EINA_LIST_FREE(wd->items, item) {
108          if (item->content){
109             evas_object_del(item->content);
110             item->content = NULL;
111          }
112          if (item->bg_layout){
113             evas_object_del(item->bg_layout);
114             item->bg_layout = NULL;
115          }
116          if (item->location)
117            eina_stringshare_del(item->location);
118          free(item);
119       }
120    }
121 }
122
123 static void 
124 _set_item_theme(Dialogue_Item *item, const char *location)
125 {
126    if (!item) return;
127    char buf[30];
128    
129    if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_DEFAULT) 
130      snprintf(buf, sizeof(buf), "bg_%s", location);
131    else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDITFIELD) 
132      snprintf(buf, sizeof(buf), "editfield_%s", location);
133    else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDITFIELD_WITH_TITLE) 
134      snprintf(buf, sizeof(buf), "editfield_with_title_%s", location);
135    else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDIT_TITLE) 
136      snprintf(buf, sizeof(buf), "edit_title_%s", location);
137    else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_HIDDEN) 
138      snprintf(buf, sizeof(buf), "hidden_%s", location);
139    else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_DATAVIEW) 
140      snprintf(buf, sizeof(buf), "dataview_%s", location);
141    else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_NO_BG) 
142      snprintf(buf, sizeof(buf), "no_bg_%s", location);
143    else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_SUB) 
144      snprintf(buf, sizeof(buf), "sub_%s", location);
145    else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDIT)
146      snprintf(buf, sizeof(buf), "bg_edit_%s", location);
147    else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDIT_MERGE)
148      snprintf(buf, sizeof(buf), "bg_edit_merge_%s", location);
149    elm_layout_theme_set(item->bg_layout, "dialoguegroup", buf, elm_widget_style_get(item->obj));
150 }
151
152 /*
153    static void _set_line_show(Dialogue_Item *item, Dialogue_Item *after)
154    {
155    if(!item || !after) return;
156
157    if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_DEFAULT) {
158    if (after->style == ELM_DIALOGUEGROUP_ITEM_STYLE_DEFAULT) {
159    item->line_show = EINA_TRUE;
160    edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,line,show", "elm"); 
161    }
162    else if (after->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDITFIELD) {
163    item->line_show = EINA_FALSE;
164    edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,line,hide", "elm"); 
165    }    
166    }
167    else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDITFIELD) 
168    item->line_show = EINA_TRUE; 
169    }
170 */
171
172 static void 
173 _change_item_bg(Dialogue_Item *item, const char *location)
174 {
175    if (!item) return;
176    
177    eina_stringshare_replace(&item->location, location);
178    _set_item_theme(item, location);
179    elm_layout_content_set(item->bg_layout, "swallow", item->content);
180    if ((item->press == EINA_TRUE) && (item->disabled == EINA_FALSE))
181      edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,press,on", "elm");
182    else
183      edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,press,off", "elm");   
184    if (item->disabled == EINA_TRUE)
185      edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,disabled", "elm");
186    else
187      edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,enabled", "elm");
188    
189    if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_SUB)
190      edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "flip_item", "");
191
192    /*   if(item->line_show == EINA_FALSE)
193     edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,line,hide", "elm");*/
194    
195 }
196
197 static Dialogue_Item* 
198 _create_item(Evas_Object *obj, Evas_Object *subobj, Elm_Dialoguegroup_Item_Style style, const char *location)
199 {
200    Widget_Data *wd = elm_widget_data_get(obj);
201    Dialogue_Item *item;
202    
203    if (!wd) return NULL;
204    
205    item = ELM_NEW(Dialogue_Item);
206    item->obj = obj;
207    item->content = subobj;
208    item->press = EINA_TRUE;
209    item->disabled = EINA_FALSE;
210    item->style = style;
211    //   item->line_show = EINA_TRUE;
212    eina_stringshare_replace(&item->location, location);
213    
214    item->bg_layout = elm_layout_add(wd->box);
215    _set_item_theme(item, location);
216    evas_object_size_hint_weight_set(item->bg_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
217    evas_object_size_hint_align_set(item->bg_layout, EVAS_HINT_FILL, 0.0);
218    evas_object_show(item->bg_layout);   
219    
220    elm_layout_content_set(item->bg_layout, "swallow", item->content);
221    
222    return item;
223 }
224
225 static void 
226 _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
227 {
228    _sizing_eval(data);
229 }
230
231 /**
232  * Add a new dialoguegroup to the parent.
233  *
234  * @param parent The parent object
235  * @return The new object or NULL if it cannot be created
236  *
237  * @ingroup DialogueGroup
238  */
239 EAPI Evas_Object *
240 elm_dialoguegroup_add(Evas_Object *parent)
241 {
242    Evas_Object *obj = NULL;
243    Widget_Data *wd = NULL;
244    Evas *e = NULL;
245    
246    e = evas_object_evas_get(parent);
247    if (e == NULL) return NULL;
248    wd = ELM_NEW(Widget_Data);
249    obj = elm_widget_add(e);
250    ELM_SET_WIDTYPE(widtype, "dialoguegroup");
251    elm_widget_type_set(obj, "dialoguegroup");
252    elm_widget_sub_object_add(parent, obj);
253    elm_widget_data_set(obj, wd);
254    elm_widget_del_hook_set(obj, _del_hook);
255    elm_widget_theme_hook_set(obj, _theme_hook);
256    elm_widget_can_focus_set(obj, EINA_FALSE);
257    
258    wd->num = 0;
259    
260    wd->box = elm_box_add(obj);
261    evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
262    evas_object_show(wd->box);
263    elm_widget_resize_object_set(obj, wd->box);
264    
265    _sizing_eval(obj);
266    return obj;
267 }
268
269 /**
270  * Append an item to the dialogue group.
271  *
272  * @param obj dialoguegroup object 
273  * @param subobj item
274  * @param style sytle of the item
275  * @return Dialogue_Item pointer, just made by this function
276  * 
277  * @ingroup DialogueGroup
278  */
279 EAPI Dialogue_Item *
280 elm_dialoguegroup_append(Evas_Object *obj, Evas_Object *subobj, Elm_Dialoguegroup_Item_Style style)
281 {
282    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
283    Widget_Data *wd = elm_widget_data_get(obj);
284    Dialogue_Item *item = NULL, *new_item = NULL;        
285    
286    if (!wd || !subobj) return NULL;
287    
288    if (!wd->items) 
289      new_item = _create_item(obj, subobj, style, "default");
290    else {
291       if (wd->num == 1) {       
292          item = eina_list_data_get(wd->items);
293          _change_item_bg(item, "top");          
294       }         
295       else {
296          item = eina_list_data_get( eina_list_last(wd->items) );
297          _change_item_bg(item, "middle");               
298       }
299       new_item = _create_item(obj, subobj, style, "bottom");
300       //                _set_line_show(item, new_item);
301    }
302    elm_box_pack_end(wd->box, new_item->bg_layout);
303    if (style == ELM_DIALOGUEGROUP_ITEM_STYLE_SUB)
304      edje_object_signal_emit(elm_layout_edje_get(new_item->bg_layout), "flip_item", "");
305    wd->items = eina_list_append(wd->items, new_item);                   
306    wd->num++;
307    _sizing_eval(obj);
308    return new_item;
309 }
310
311
312 /**
313  * Prepend an item to the dialogue group.
314  *
315  * @param obj dialoguegroup object 
316  * @param subobj item
317  * @param style sytle of the item
318  * @return Dialogue_Item pointer, just made by this function
319  *
320  * @ingroup DialogueGroup
321  */
322 EAPI Dialogue_Item *
323 elm_dialoguegroup_prepend(Evas_Object *obj, Evas_Object *subobj, Elm_Dialoguegroup_Item_Style style)
324 {
325    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
326    Widget_Data *wd = elm_widget_data_get(obj);
327    Dialogue_Item *item = NULL, *new_item = NULL;
328    
329    if (!wd || !subobj) return NULL;
330    
331    if (!wd->items)
332      new_item = _create_item(obj, subobj, style, "default");    
333    else {
334       if (wd->num == 1) {       
335          item = eina_list_data_get(wd->items);
336          _change_item_bg(item, "bottom");
337       }         
338       else {
339          item = eina_list_data_get(wd->items);
340          _change_item_bg(item, "middle");               
341       }
342       new_item = _create_item(obj, subobj, style, "top");
343       //                _set_line_show(new_item, item);
344    }
345    if (wd->title_layout)
346      elm_box_pack_after(wd->box, new_item->bg_layout, wd->title_layout);        
347    else                 
348      elm_box_pack_start(wd->box, new_item->bg_layout);          
349    if (style == ELM_DIALOGUEGROUP_ITEM_STYLE_SUB) 
350      edje_object_signal_emit(elm_layout_edje_get(new_item->bg_layout), "flip_item", "");
351    wd->items = eina_list_prepend(wd->items, new_item);          
352    wd->num++;
353    _sizing_eval(obj);
354    return new_item;
355 }
356
357 /**
358  * Insert an item to the dialogue group just after the specified item.
359  *
360  * @param obj dialoguegroup object 
361  * @param subobj item
362  * @param after specified item existing in the dialogue group
363  * @param style sytle of the item
364  * @return Dialogue_Item pointer, just made by this function
365  *
366  * @ingroup DialogueGroup
367  */
368 EAPI Dialogue_Item * 
369 elm_dialoguegroup_insert_after(Evas_Object *obj, Evas_Object *subobj, Dialogue_Item *after, Elm_Dialoguegroup_Item_Style style)
370 {
371    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
372    Widget_Data *wd = elm_widget_data_get(obj);
373    Dialogue_Item *after_item = NULL, *item = NULL;
374    Eina_List *l;
375    
376    if (!wd || !subobj || !after || !wd->items) return NULL;
377    
378    EINA_LIST_FOREACH(wd->items, l, after_item) {
379       if (after == after_item) {
380          if ( !strcmp(after_item->location, "default") ) {
381             _change_item_bg(after_item, "top");
382             item = _create_item(obj, subobj, style, "bottom");
383          }                      
384          else if ( !strcmp(after_item->location, "top") || !strcmp(after_item->location, "middle") )    
385            item = _create_item(obj, subobj, style, "middle");           
386          else if ( !strcmp(after_item->location, "bottom") ) {
387             _change_item_bg(after_item, "middle");
388             item = _create_item(obj, subobj, style, "bottom");          
389          }
390          if (!item)
391             return NULL;
392          elm_box_pack_after(wd->box, item->bg_layout, after_item->bg_layout);
393          if (style == ELM_DIALOGUEGROUP_ITEM_STYLE_SUB) 
394            edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "flip_item", "");
395          wd->items = eina_list_append_relative(wd->items, item, after_item);
396          //     _set_line_show(after, item);
397       }         
398    }
399    
400    wd->num++;
401    _sizing_eval(obj);
402    return item;
403 }
404
405 /**
406  * Insert an item to the dialogue group just before the specified item.
407  *
408  * @param obj dialoguegroup object 
409  * @param subobj item
410  * @param before specified item existing in the dialogue group
411  * @param style sytle of the item
412  * @return Dialogue_Item pointer, just made by this function
413  *
414  * @ingroup DialogueGroup
415  */
416 EAPI Dialogue_Item *
417 elm_dialoguegroup_insert_before(Evas_Object *obj, Evas_Object *subobj, Dialogue_Item *before, Elm_Dialoguegroup_Item_Style style)
418 {
419    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
420    Widget_Data *wd = elm_widget_data_get(obj);
421    Dialogue_Item *before_item = NULL, *item = NULL;
422    Eina_List *l;
423    Eina_List *prev;
424    
425    if (!wd || !subobj || !before || !wd->items) return NULL;
426    
427    EINA_LIST_FOREACH(wd->items, l, before_item) {
428       if (before == before_item) {
429          if ( !strcmp(before_item->location, "default") ) {
430             _change_item_bg(before_item, "bottom");
431             item = _create_item(obj, subobj, style, "top");
432          }
433          
434          else if ( !strcmp(before_item->location, "top") ) {
435             _change_item_bg(before_item, "middle");
436             item = _create_item(obj, subobj, style, "top");                     
437          }
438          
439          else if ( !strcmp(before_item->location, "middle") || !strcmp(before_item->location, "bottom") ) {
440             item = _create_item(obj, subobj, style, "middle");
441             prev = eina_list_prev(l);
442             //  _set_line_show(prev->data, item);
443          }
444          if (!item)
445             return NULL;
446          elm_box_pack_before(wd->box, item->bg_layout, before_item->bg_layout);
447          if (style == ELM_DIALOGUEGROUP_ITEM_STYLE_SUB) 
448            edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "flip_item", "");
449          wd->items = eina_list_prepend_relative(wd->items, item, before_item);
450       }         
451    }
452    
453    wd->num++;
454    _sizing_eval(obj);   
455    return item;
456 }
457
458 /**
459  * Remove an item from the dialogue group.
460  *
461  * @param obj dialoguegroup object 
462  * @param subobj item
463  *
464  * @ingroup DialogueGroup
465  */
466 EAPI void
467 elm_dialoguegroup_remove(Dialogue_Item *item)
468 {
469    if (!item) return;
470    ELM_CHECK_WIDTYPE(item->obj, widtype) ;
471    Dialogue_Item *current_item;
472    Widget_Data *wd = elm_widget_data_get(item->obj);
473    Eina_List *l;
474    
475    if (!wd || !wd->items || !item) return ;
476    
477    EINA_LIST_FOREACH(wd->items, l, current_item) {
478       if (current_item == item) {
479          if (current_item->content){
480             evas_object_del(current_item->content);
481             current_item->content = NULL;
482          }
483          if (current_item->bg_layout){
484             evas_object_del(current_item->bg_layout);
485             current_item->bg_layout = NULL;
486          }
487          elm_box_unpack(wd->box, current_item->bg_layout);                      
488          wd->items = eina_list_remove(wd->items, current_item);
489       }
490    }
491    
492    wd->num--;
493    
494    if (wd->num == 0) return;
495    
496    if (wd->num == 1) {
497       current_item = eina_list_data_get(wd->items);
498       _change_item_bg(current_item, "default");
499    }
500    
501    else {               
502       current_item = eina_list_data_get(wd->items);
503       _change_item_bg(current_item, "top");
504       current_item = eina_list_data_get( eina_list_last(wd->items) );
505       _change_item_bg(current_item, "bottom");          
506    }
507    
508    _sizing_eval(item->obj);  
509 }
510
511 /**
512  * Remove all items from the dialogue group.
513  *
514  * @param obj dialoguegroup object 
515  *
516  * @ingroup DialogueGroup
517  */
518 EAPI void
519 elm_dialoguegroup_remove_all(Evas_Object *obj)
520 {
521    ELM_CHECK_WIDTYPE(obj, widtype);
522    _remove_all(obj);    
523    _sizing_eval(obj);   
524 }
525
526
527 /**
528  * Set the title text of the  dialogue group.
529  *
530  * @param obj dialoguegroup object 
531  * @param title title text, if NULL title space will be disappeared 
532  * 
533  * @ingroup DialogueGroup
534  */
535 EAPI void 
536 elm_dialoguegroup_title_set(Evas_Object *obj, const char *title)
537 {
538    ELM_CHECK_WIDTYPE(obj, widtype);
539    Widget_Data *wd = elm_widget_data_get(obj);
540    
541    if (!wd) return ;
542    eina_stringshare_replace(&wd->title, title);
543    if (!title) {
544       wd->title = NULL;         
545       elm_box_unpack(wd->box, wd->title_layout);                
546    }    
547    if (!wd->title_layout) {
548       wd->title_layout = elm_layout_add(wd->box);
549       elm_layout_theme_set(wd->title_layout, "dialoguegroup", "title", elm_widget_style_get(obj));
550       evas_object_size_hint_weight_set(wd->title_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
551       evas_object_size_hint_align_set(wd->title_layout, EVAS_HINT_FILL, 0.0);
552       evas_object_show(wd->title_layout);       
553       edje_object_part_text_set(elm_layout_edje_get(wd->title_layout), "text", title);
554       elm_box_pack_start(wd->box, wd->title_layout);
555    }
556    edje_object_part_text_set(elm_layout_edje_get(wd->title_layout), "text", title);
557 }
558
559 /**
560  * Get the title text of the dialogue group
561  *
562  * @param obj The dialoguegroup object
563  * @return The text title string in UTF-8
564  *
565  * @ingroup DialogueGroup
566  */
567 EAPI const char *
568 elm_dialoguegroup_title_get(Evas_Object *obj)
569 {
570    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
571    Widget_Data *wd = elm_widget_data_get(obj);
572    if (!wd) return NULL;
573    return wd->title;
574 }
575
576 /**
577  * Set whether the press effect will be shown or not
578  *
579  * @param obj The dialoguegroup object
580  * @param item Dialogue_Item pointer
581  * @param press If set as 1, press effect will be shown 
582  *
583  * @ingroup DialogueGroup 
584  */
585 EAPI void 
586 elm_dialoguegroup_press_effect_set(Dialogue_Item *item, Eina_Bool press)
587 {
588    if (!item) return;
589    ELM_CHECK_WIDTYPE(item->obj, widtype) ;
590    
591    item->press = press;
592    if ((press == EINA_TRUE) && (item->disabled == EINA_FALSE))
593      edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,press,on", "elm");
594    else
595      edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,press,off", "elm");       
596 }
597
598 /**
599  * Get the press effect state
600  *
601  * @param obj The dialoguegroup object
602  * @param item Dialogue_Item pointer
603  * @return 1 if press effect on, 0 if press effect off 
604  *
605  * @ingroup DialogueGroup 
606  */
607 EAPI Eina_Bool
608 elm_dialoguegroup_press_effect_get(Dialogue_Item *item)
609 {
610    if (!item) return EINA_FALSE;
611    ELM_CHECK_WIDTYPE(item->obj, widtype) EINA_FALSE;
612    
613    return item->press;
614 }
615
616 /**
617  * Get the conetent object from the specified dialogue item
618  *
619  * @param obj The dialoguegroup object
620  * @param item Dialogue_Item pointer
621  * @return content object 
622  *
623  * @ingroup DialogueGroup 
624  */
625 EAPI Evas_Object *
626 elm_dialoguegroup_item_content_get(Dialogue_Item *item)
627 {
628    if (!item) return NULL;
629    ELM_CHECK_WIDTYPE(item->obj, widtype) EINA_FALSE;
630    
631    return item->content;
632 }
633
634 /**
635  * Set the style of the item.
636  *
637  * @param item dialoguegroup item
638  * @param style sytle of the item
639  * 
640  * @ingroup DialogueGroup
641  */
642 EAPI void 
643 elm_dialoguegroup_item_style_set(Dialogue_Item *item, Elm_Dialoguegroup_Item_Style style)
644 {
645    if (!item) return;
646    ELM_CHECK_WIDTYPE(item->obj, widtype);
647    Widget_Data *wd = elm_widget_data_get(item->obj);
648    
649    item->style = style;
650    _change_item_bg(item, item->location);
651    
652    if (!wd) return ;
653 }
654
655 /**
656  * Get the style of the item.
657  *
658  * @param item dialoguegroup item
659  * @return dialoguegroup item style
660  * 
661  * @ingroup DialogueGroup
662  */
663
664 EAPI Elm_Dialoguegroup_Item_Style
665 elm_dialoguegroup_item_style_get(Dialogue_Item *item)
666 {
667    if (!item) return ELM_DIALOGUEGROUP_ITEM_STYLE_LAST;
668    ELM_CHECK_WIDTYPE(item->obj, widtype) ELM_DIALOGUEGROUP_ITEM_STYLE_LAST;
669    Widget_Data *wd = elm_widget_data_get(item->obj);
670    
671    if (!wd) return ELM_DIALOGUEGROUP_ITEM_STYLE_LAST;
672    
673    return item->style;
674 }
675
676 /**
677  * Set item state as disable or not.
678  *
679  * @param item dialoguegroup item.
680  * @param disabled if EINA_TRUE disabled, else abled. 
681  * 
682  * @ingroup DialogueGroup
683  */
684 EAPI void 
685 elm_dialoguegroup_item_disabled_set(Dialogue_Item *item, Eina_Bool disabled)
686 {
687    if (!item) return;
688    ELM_CHECK_WIDTYPE(item->obj, widtype);
689    
690    item->disabled = disabled;
691    
692    if (disabled == EINA_TRUE)
693      {
694         edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,disabled", "elm");
695         edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,press,off", "elm");    
696      }
697    else
698      {
699         edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,enabled", "elm");
700         if (item->press == EINA_TRUE)
701           edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,press,on", "elm");
702      }
703 }
704
705 /**
706  * Get item state whether disabled or not.
707  *
708  * @param item dialoguegroup item.
709  * @return if EINA_TRUE, then disabled else abled.
710  * 
711  * @ingroup DialogueGroup
712  */
713
714 EAPI Eina_Bool
715 elm_dialoguegroup_item_disabled_get(Dialogue_Item *item)
716 {
717    if (!item) return EINA_FALSE;
718    ELM_CHECK_WIDTYPE(item->obj, widtype) EINA_FALSE;
719    
720    return item->disabled;
721 }
722
723 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
724