[efl-upgrade]
[framework/uifw/elementary.git] / src / lib / elm_dialoguegroup.c
index 062e3b8..606b8da 100644 (file)
@@ -14,8 +14,10 @@ struct _Dialogue_Item
        Evas_Object *parent;
        Evas_Object *bg_layout;
        Evas_Object *content;
-       const char *style;
+       Elm_Dialoguegroup_Item_Style style;
+       const char *location;
        Eina_Bool press;
+//     Eina_Bool line_show;
 };
 
 
@@ -39,8 +41,9 @@ static void _sizing_eval(Evas_Object *obj);
 static void _disable_hook(Evas_Object *obj);
 
 static void _remove_all(Evas_Object *obj);
-static void _change_item_bg(Dialogue_Item *item, const char *style);
-static Dialogue_Item* _create_item(Evas_Object *obj, Evas_Object *subobj, const char *style);
+static void _set_item_theme(Dialogue_Item *item, const char *location);
+static void _change_item_bg(Dialogue_Item *item, const char *location);
+static Dialogue_Item* _create_item(Evas_Object *obj, Evas_Object *subobj, Elm_Dialoguegroup_Item_Style style, const char *location);
 
        
 static void
@@ -71,11 +74,11 @@ _theme_hook(Evas_Object *obj)
        
        if (!wd) return;        
        if (wd->title) {
-               elm_layout_theme_set(wd->title_layout, "dialoguegroup", "base", "title");
+               elm_layout_theme_set(wd->title_layout, "dialoguegroup", "title", elm_widget_style_get(obj));
                edje_object_part_text_set(elm_layout_edje_get(wd->title_layout), "text", wd->title);
        }
        EINA_LIST_FOREACH(wd->items, l, item) 
-               _change_item_bg( item, item->style );   
+               _change_item_bg( item, item->location );        
        _sizing_eval(obj);
 }
 
@@ -117,27 +120,69 @@ static void _remove_all(Evas_Object *obj)
                                evas_object_del(item->bg_layout);
                                item->bg_layout = NULL;
                        }
-                       if (item->style)
-                               eina_stringshare_del(item->style);
+                       if (item->location)
+                               eina_stringshare_del(item->location);
                        free(item);
                }
        }
 }
 
-static void _change_item_bg(Dialogue_Item *item, const char *style)
+static void _set_item_theme(Dialogue_Item *item, const char *location)
+{
+       if (!item) return;
+       char buf[30];
+
+       if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_DEFAULT) 
+               snprintf(buf, sizeof(buf), "bg_%s", location);
+       else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDITFIELD) 
+               snprintf(buf, sizeof(buf), "editfield_%s", location);
+       else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDITFIELD_WITH_TITLE) 
+               snprintf(buf, sizeof(buf), "editfield_with_title_%s", location);
+       else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDIT_TITLE) 
+               snprintf(buf, sizeof(buf), "edit_title_%s", location);
+       else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_HIDDEN) 
+               snprintf(buf, sizeof(buf), "hidden_%s", location);
+       elm_layout_theme_set(item->bg_layout, "dialoguegroup", buf, elm_widget_style_get(item->parent));
+}
+
+/*
+static void _set_line_show(Dialogue_Item *item, Dialogue_Item *after)
+{
+       if(!item || !after) return;
+
+       if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_DEFAULT) {
+               if (after->style == ELM_DIALOGUEGROUP_ITEM_STYLE_DEFAULT) {
+                       item->line_show = EINA_TRUE;
+                       edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,line,show", "elm");    
+               }
+               else if (after->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDITFIELD) {
+                       item->line_show = EINA_FALSE;
+                       edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,line,hide", "elm");    
+               }       
+       }
+       else if (item->style == ELM_DIALOGUEGROUP_ITEM_STYLE_EDITFIELD) 
+               item->line_show = EINA_TRUE;    
+}
+*/
+
+static void _change_item_bg(Dialogue_Item *item, const char *location)
 {
        if (!item) return;
        
-       eina_stringshare_replace(&item->style, style);
-       elm_layout_theme_set(item->bg_layout, "dialoguegroup", "bg", style);
+       eina_stringshare_replace(&item->location, location);
+       _set_item_theme(item, location);
        elm_layout_content_set(item->bg_layout, "swallow", item->content);
        if(item->press == EINA_TRUE)
                edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,press,on", "elm");
        else
-               edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,press,off", "elm");    
+               edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,press,off", "elm");
+
+/*     if(item->line_show == EINA_FALSE)
+               edje_object_signal_emit(elm_layout_edje_get(item->bg_layout), "elm,state,line,hide", "elm");*/
+                       
 }
 
-static Dialogue_Item* _create_item(Evas_Object *obj, Evas_Object *subobj, const char *style)
+static Dialogue_Item* _create_item(Evas_Object *obj, Evas_Object *subobj, Elm_Dialoguegroup_Item_Style style, const char *location)
 {
        Widget_Data *wd = elm_widget_data_get(obj);
        Dialogue_Item *item;
@@ -148,10 +193,12 @@ static Dialogue_Item* _create_item(Evas_Object *obj, Evas_Object *subobj, const
        item->parent = obj;
        item->content = subobj;
        item->press = EINA_TRUE;
-       eina_stringshare_replace(&item->style, style);
+       item->style = style;
+//     item->line_show = EINA_TRUE;
+       eina_stringshare_replace(&item->location, location);
        
-       item->bg_layout = elm_layout_add(wd->parent);
-       elm_layout_theme_set(item->bg_layout, "dialoguegroup", "bg", style );
+       item->bg_layout = elm_layout_add(wd->box);
+       _set_item_theme(item, location);
        evas_object_size_hint_weight_set(item->bg_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(item->bg_layout, EVAS_HINT_FILL, 0.0);
        evas_object_show(item->bg_layout);      
@@ -193,7 +240,7 @@ EAPI Evas_Object *elm_dialoguegroup_add(Evas_Object *parent)
        wd->parent = parent;
        wd->num = 0;
        
-       wd->box = elm_box_add(parent);
+       wd->box = elm_box_add(obj);
        evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
        evas_object_show(wd->box);
        elm_widget_resize_object_set(obj, wd->box);
@@ -212,20 +259,16 @@ EAPI Evas_Object *elm_dialoguegroup_add(Evas_Object *parent)
  * @ingroup DialogueGroup
  */
 EAPI Dialogue_Item *
-elm_dialoguegroup_append(Evas_Object *obj, Evas_Object *subobj)
+elm_dialoguegroup_append(Evas_Object *obj, Evas_Object *subobj, Elm_Dialoguegroup_Item_Style style)
 {
        ELM_CHECK_WIDTYPE(obj, widtype) NULL;
        Widget_Data *wd = elm_widget_data_get(obj);
-       Dialogue_Item *item;
+       Dialogue_Item *item = NULL, *new_item = NULL;   
        
        if (!wd || !subobj) return NULL;
        
-       if (!wd->items) {
-               item = _create_item(obj, subobj, "default");    
-               elm_box_pack_end(wd->box, item->bg_layout);
-               wd->items = eina_list_append(wd->items, item);  
-       }
-
+       if (!wd->items) 
+               new_item = _create_item(obj, subobj, style, "default");
        else {
                if (wd->num == 1) {     
                        item = eina_list_data_get(wd->items);
@@ -235,14 +278,14 @@ elm_dialoguegroup_append(Evas_Object *obj, Evas_Object *subobj)
                        item = eina_list_data_get( eina_list_last(wd->items) );
                        _change_item_bg(item, "middle");                
                }
-               item = _create_item(obj, subobj, "bottom");
-               elm_box_pack_end(wd->box, item->bg_layout);
-               wd->items = eina_list_append(wd->items, item);          
+               new_item = _create_item(obj, subobj, style, "bottom");
+//             _set_line_show(item, new_item);
        }
-
+       elm_box_pack_end(wd->box, new_item->bg_layout);
+       wd->items = eina_list_append(wd->items, new_item);                      
        wd->num++;
        _sizing_eval(obj);
-       return item;
+       return new_item;
 }
 
 
@@ -256,23 +299,16 @@ elm_dialoguegroup_append(Evas_Object *obj, Evas_Object *subobj)
  * @ingroup DialogueGroup
  */
 EAPI Dialogue_Item *
-elm_dialoguegroup_prepend(Evas_Object *obj, Evas_Object *subobj)
+elm_dialoguegroup_prepend(Evas_Object *obj, Evas_Object *subobj, Elm_Dialoguegroup_Item_Style style)
 {
        ELM_CHECK_WIDTYPE(obj, widtype) NULL;
        Widget_Data *wd = elm_widget_data_get(obj);
-       Dialogue_Item *item;
+       Dialogue_Item *item = NULL, *new_item = NULL;
        
        if (!wd || !subobj) return NULL;
        
-       if (!wd->items) {
-               item = _create_item(obj, subobj, "default");    
-               if(wd->title_layout)
-                       elm_box_pack_after(wd->box, item->bg_layout, wd->title_layout); 
-               else                    
-                       elm_box_pack_start(wd->box, item->bg_layout);           
-               wd->items = eina_list_prepend(wd->items, item); 
-       }
-
+       if (!wd->items)
+               new_item = _create_item(obj, subobj, style, "default"); 
        else {
                if (wd->num == 1) {     
                        item = eina_list_data_get(wd->items);
@@ -282,17 +318,17 @@ elm_dialoguegroup_prepend(Evas_Object *obj, Evas_Object *subobj)
                        item = eina_list_data_get(wd->items);
                        _change_item_bg(item, "middle");                
                }
-               item = _create_item(obj, subobj, "top");
-               if(wd->title_layout)
-                       elm_box_pack_after(wd->box, item->bg_layout, wd->title_layout); 
-               else                    
-                       elm_box_pack_start(wd->box, item->bg_layout);           
-               wd->items = eina_list_prepend(wd->items, item);         
+               new_item = _create_item(obj, subobj, style, "top");
+//             _set_line_show(new_item, item);
        }
-
+       if(wd->title_layout)
+               elm_box_pack_after(wd->box, new_item->bg_layout, wd->title_layout);     
+       else                    
+               elm_box_pack_start(wd->box, new_item->bg_layout);               
+       wd->items = eina_list_prepend(wd->items, new_item);             
        wd->num++;
        _sizing_eval(obj);
-       return item;
+       return new_item;
 }
 
 /**
@@ -306,30 +342,31 @@ elm_dialoguegroup_prepend(Evas_Object *obj, Evas_Object *subobj)
  * @ingroup DialogueGroup
  */
 EAPI Dialogue_Item * 
-elm_dialoguegroup_insert_after(Evas_Object *obj, Evas_Object *subobj, Dialogue_Item *after)
+elm_dialoguegroup_insert_after(Evas_Object *obj, Evas_Object *subobj, Dialogue_Item *after, Elm_Dialoguegroup_Item_Style style)
 {
        ELM_CHECK_WIDTYPE(obj, widtype) NULL;
        Widget_Data *wd = elm_widget_data_get(obj);
-       Dialogue_Item *after_item, *item;
+       Dialogue_Item *after_item = NULL, *item = NULL;
        Eina_List *l;
 
        if (!wd || !subobj || !after || !wd->items) return NULL;
 
        EINA_LIST_FOREACH(wd->items, l, after_item) {
                if(after == after_item) {
-                       if( !strcmp(item->style, "default") ) {
+                       if( !strcmp(after_item->location, "default") ) {
                                _change_item_bg(after_item, "top");
-                               item = _create_item(obj, subobj, "bottom");
+                               item = _create_item(obj, subobj, style, "bottom");
                        }                       
-                       else if( !strcmp(item->style, "top") || !strcmp(item->style, "middle") )        
-                               item = _create_item(obj, subobj, "middle");             
-                       else if( !strcmp(item->style, "bottom") ) {
+                       else if( !strcmp(after_item->location, "top") || !strcmp(after_item->location, "middle") )      
+                               item = _create_item(obj, subobj, style, "middle");              
+                       else if( !strcmp(after_item->location, "bottom") ) {
                                _change_item_bg(after_item, "middle");
-                               item = _create_item(obj, subobj, "bottom");             
+                               item = _create_item(obj, subobj, style, "bottom");              
                        }
 
                        elm_box_pack_after(wd->box, item->bg_layout, after_item->bg_layout);
                        wd->items = eina_list_append_relative(wd->items, item, after_item);
+               //      _set_line_show(after, item);
                }               
        }
                
@@ -349,30 +386,33 @@ elm_dialoguegroup_insert_after(Evas_Object *obj, Evas_Object *subobj, Dialogue_I
  * @ingroup DialogueGroup
  */
 EAPI Dialogue_Item *
-elm_dialoguegroup_insert_before(Evas_Object *obj, Evas_Object *subobj, Dialogue_Item *before)
+elm_dialoguegroup_insert_before(Evas_Object *obj, Evas_Object *subobj, Dialogue_Item *before, Elm_Dialoguegroup_Item_Style style)
 {
        ELM_CHECK_WIDTYPE(obj, widtype) NULL;
        Widget_Data *wd = elm_widget_data_get(obj);
-       Dialogue_Item *before_item, *item;
+       Dialogue_Item *before_item = NULL, *item = NULL;
        Eina_List *l;
+       Eina_List *prev;
        
        if (!wd || !subobj || !before || !wd->items) return NULL;
 
        EINA_LIST_FOREACH(wd->items, l, before_item) {
                if(before == before_item) {
-                       if( !strcmp(item->style, "default") ) {
+                       if( !strcmp(before_item->location, "default") ) {
                                _change_item_bg(before_item, "bottom");
-                               item = _create_item(obj, subobj, "top");
+                               item = _create_item(obj, subobj, style, "top");
                        }
                                
-                       else if( !strcmp(item->style, "top") ) {
+                       else if( !strcmp(before_item->location, "top") ) {
                                _change_item_bg(before_item, "middle");
-                               item = _create_item(obj, subobj, "top");                        
+                               item = _create_item(obj, subobj, style, "top");                 
                        }
 
-                       else if( !strcmp(item->style, "middle") || !strcmp(item->style, "bottom") )             
-                               item = _create_item(obj, subobj, "middle");
-
+                       else if( !strcmp(before_item->location, "middle") || !strcmp(before_item->location, "bottom") ) {
+                               item = _create_item(obj, subobj, style, "middle");
+                               prev = eina_list_prev(l);
+                       //      _set_line_show(prev->data, item);
+                       }
                        elm_box_pack_before(wd->box, item->bg_layout, before_item->bg_layout);
                        wd->items = eina_list_prepend_relative(wd->items, item, before_item);
                }               
@@ -472,9 +512,8 @@ elm_dialoguegroup_title_set(Evas_Object *obj, const char *title)
                elm_box_unpack(wd->box, wd->title_layout);              
        }
        if (!wd->title_layout) {
-               wd->title_layout = elm_layout_add(wd->parent);
-               elm_widget_sub_object_add(obj, wd->title_layout);
-               elm_layout_theme_set(wd->title_layout, "dialoguegroup", "base", "title");
+               wd->title_layout = elm_layout_add(wd->box);
+               elm_layout_theme_set(wd->title_layout, "dialoguegroup", "title", elm_widget_style_get(obj));
                evas_object_size_hint_weight_set(wd->title_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
                evas_object_size_hint_align_set(wd->title_layout, EVAS_HINT_FILL, 0.0);
                evas_object_show(wd->title_layout);     
@@ -540,4 +579,20 @@ elm_dialoguegroup_press_effect_get(Dialogue_Item *item)
    return item->press;
 }
 
-
+/**
+ * Get the conetent object from the specified dialogue item
+ *
+ * @param obj The dialoguegroup object
+ * @param item Dialogue_Item pointer
+ * @return content object 
+ *
+ * @ingroup DialogueGroup 
+ */
+EAPI Evas_Object *
+elm_dialoguegroup_item_content_get(Dialogue_Item *item)
+{
+   ELM_CHECK_WIDTYPE(item->parent, widtype) EINA_FALSE;
+   if(!item) return EINA_FALSE;
+   
+   return item->content;
+}