#include "elm_priv.h"
#define MAX_STR 256
-#define MIN_W_ENTRY 10
+#define MIN_W_ENTRY 160
typedef enum _Multibuttonentry_Pos
{
MultiButtonEntry_Closed_Button_Type end_type;
Eina_List *items;
- Eina_List *current;
Eina_List *filter_list;
+ Elm_Object_Item *selected_it; /* selected item */
const char *labeltxt, *guidetexttxt;
void *add_callback_data;
};
-static const char *widtype = NULL;
static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
static const char *_item_text_get_hook(const Elm_Object_Item *it,
const char *part);
- /* TODO
- * Code refactoring
- * use evas_object_smart_callback_descriptions_set for smart callbacks.
- */
+static const char *widtype = NULL;
+
+//widget signals
+static const char SIG_ITEM_SELECTED[] = "item,selected";
+static const char SIG_ITEM_ADDED[] = "item,added";
+static const char SIG_ITEM_DELETED[] = "item,deleted";
+static const char SIG_ITEM_CLICKED[] = "item,clicked";
+static const char SIG_CLICKED[] = "clicked";
+static const char SIG_FOCUSED[] = "focused";
+static const char SIG_UNFOCUSED[] = "unfocused";
+static const char SIG_EXPANDED[] = "expanded";
+static const char SIG_CONTRACTED[] = "contracted";
+static const char SIG_EXPAND_STATE_CHANGED[] = "expand,state,changed";
+
+static const Evas_Smart_Cb_Description _signals[] = {
+ {SIG_ITEM_SELECTED, ""},
+ {SIG_ITEM_ADDED, ""},
+ {SIG_ITEM_DELETED, ""},
+ {SIG_ITEM_CLICKED, ""},
+ {SIG_CLICKED, ""},
+ {SIG_FOCUSED, ""},
+ {SIG_UNFOCUSED, ""},
+ {SIG_EXPANDED, ""},
+ {SIG_CONTRACTED, ""},
+ {SIG_EXPAND_STATE_CHANGED, ""},
+ {NULL, NULL}
+};
static void
_del_hook(Evas_Object *obj)
}
wd->items = NULL;
}
- wd->current = NULL;
+ wd->selected_it = NULL;
if (wd->labeltxt) eina_stringshare_del(wd->labeltxt);
if (wd->guidetexttxt) eina_stringshare_del(wd->guidetexttxt);
if (elm_widget_focus_get(obj))
{
- if ((wd->current))
+ if ((wd->selected_it))
{
elm_entry_input_panel_show(wd->entry);
}
- else if (((!wd->current) || (!eina_list_count(wd->items))))
+ else if (((!wd->selected_it) || (!eina_list_count(wd->items))))
{
if (wd->entry) elm_entry_cursor_end_set(wd->entry);
_view_update(obj);
elm_entry_input_panel_show(wd->entry);
}
wd->focused = EINA_TRUE;
- evas_object_smart_callback_call(obj, "focused", NULL);
+ evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
}
else
{
_view_update(obj);
elm_entry_input_panel_hide(wd->entry);
- evas_object_smart_callback_call(obj, "unfocused", NULL);
+ evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
}
}
_view_update(data);
elm_entry_input_panel_show(wd->entry);
+ elm_object_focus_set(wd->entry, EINA_TRUE);
- evas_object_smart_callback_call(data, "clicked", NULL);
+ evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
}
static void
if (!wd) return;
evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
- if (wd->h_box < h) evas_object_smart_callback_call(data, "expanded", NULL);
- else if (wd->h_box > h) evas_object_smart_callback_call(data, "contracted", NULL);
+ if (wd->h_box < h) evas_object_smart_callback_call(data, SIG_EXPANDED, NULL);
+ else if (wd->h_box > h)
+ evas_object_smart_callback_call(data, SIG_CONTRACTED, NULL);
wd->w_box = w;
wd->h_box = h;
elm_box_unpack(wd->box, wd->entry);
if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
+ if (!wd->focused)
+ elm_object_focus_set(wd->entry, EINA_FALSE);
+
if (wd && (!eina_list_count(wd->items)) && wd->guidetext
&& (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
{
elm_box_pack_end(wd->box, wd->entry);
evas_object_show(wd->entry);
if (elm_widget_focus_get(obj) || wd->focused)
- if (!wd->current)
+ if (!wd->selected_it)
elm_object_focus_set(wd->entry, EINA_TRUE);
wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
}
evas_object_show(wd->end);
wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
- evas_object_smart_callback_call(obj, "expand,state,changed", (void *)1);
+ evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED, (void *)1);
break;
}
}
evas_object_show(wd->end);
wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
- evas_object_smart_callback_call(obj, "expand,state,changed", (void *)0);
+ evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED, (void *)0);
break;
}
}
}
wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
- evas_object_smart_callback_call(obj, "expand,state,changed", (void *)(long)wd->shrink);
+ evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED,
+ (void *)(long)wd->shrink);
}
if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
{
if (!wd || !str) return;
eina_stringshare_replace(&wd->labeltxt, str);
if (wd->label)
- {
- Evas_Coord width, height, sum_width = 0;
- evas_object_size_hint_min_set(wd->label, 0, 0);
- evas_object_resize(wd->label, 0, 0);
- edje_object_part_text_set(wd->label, "mbe.label", str);
-
- if (!strcmp(str, ""))
- {
- /* FIXME: not work yet */
- edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
- edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
- sum_width += width;
- }
- else
- {
- edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
- edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
-
- sum_width += width;
-
- edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
- sum_width += width;
-
- edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
- sum_width += width;
- }
- evas_object_size_hint_min_set(wd->label, sum_width, height);
- }
+ {
+ Evas_Coord width, height, sum_width = 0;
+ evas_object_size_hint_min_set(wd->label, 0, 0);
+ evas_object_resize(wd->label, 0, 0);
+ edje_object_part_text_escaped_set(wd->label, "mbe.label", str);
+
+ if (!strcmp(str, ""))
+ {
+ /* FIXME: not work yet */
+ edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
+ edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
+ sum_width += width;
+ }
+ else
+ {
+ edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
+ edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
+
+ sum_width += width;
+
+ edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
+ sum_width += width;
+
+ edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
+ sum_width += width;
+ }
+ evas_object_size_hint_min_set(wd->label, sum_width, height);
+ }
evas_object_show(wd->label);
_view_update(obj);
}
evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
EVAS_HINT_FILL);
- edje_object_part_text_set(wd->guidetext, "elm.text", str);
+ edje_object_part_text_escaped_set(wd->guidetext, "elm.text", str);
_view_update(obj);
}
}
Elm_Multibuttonentry_Item *item = NULL;
if (!wd) return;
- if (wd->current)
- item = eina_list_data_get(wd->current);
+ item = (Elm_Multibuttonentry_Item *)wd->selected_it;
if (item && item->button)
{
switch (state)
{
- case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
- edje_object_signal_emit(item->button, "default", "");
- wd->current = NULL;
- break;
- case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
- edje_object_signal_emit(item->button, "focused", "");
- evas_object_smart_callback_call(obj, "item,selected", item);
- break;
- default:
- edje_object_signal_emit(item->button, "default", "");
- wd->current = NULL;
- break;
+ case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
+ edje_object_signal_emit(item->button, "default", "");
+ wd->selected_it = NULL;
+ break;
+ case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
+ edje_object_signal_emit(item->button, "focused", "");
+ evas_object_smart_callback_call(obj, SIG_ITEM_SELECTED, item);
+ break;
+ default:
+ edje_object_signal_emit(item->button, "default", "");
+ wd->selected_it = NULL;
+ break;
}
}
}
{
if (item->button == btn)
{
- wd->current = l;
+ wd->selected_it = (Elm_Object_Item *)item;
break;
}
}
Elm_Multibuttonentry_Item *item = NULL;
if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
- _change_current_button(data, obj);
+ _select_button(data, obj);
- if (wd->current)
- if ((item = eina_list_data_get(wd->current)) != NULL)
+ if (wd->selected_it)
+ if ((item = (Elm_Multibuttonentry_Item *)wd->selected_it) != NULL)
{
- evas_object_smart_callback_call(data, "item,clicked", item);
+ evas_object_smart_callback_call(data, SIG_ITEM_CLICKED, item);
_select_button(data, item->button);
}
}
wd->items = eina_list_remove(wd->items, _item);
elm_box_unpack(wd->box, _item->button);
- evas_object_smart_callback_call(obj, "item,deleted", _item);
+ evas_object_smart_callback_call(obj, SIG_ITEM_DELETED, _item);
_del_button_obj(obj, _item->button);
- if (wd->current == l)
- wd->current = NULL;
+ if (wd->selected_it == (Elm_Object_Item *)_item)
+ wd->selected_it = NULL;
break;
}
}
_resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
{
Evas_Coord rw, vw;
- Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
+ Evas_Coord w_text, h_btn, padding_outer = 0;
Evas_Coord w_btn = 0, button_max_width = 0;
const char *size_str;
edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
- w_btn = w_text + 2*padding_outer + 2*padding_inner;
+ w_btn = w_text + (2 * padding_outer);
rw = w_btn;
elm_object_text_set(wd->entry, "");
_elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
- edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
+ edje_object_part_text_escaped_set(btn, "elm.btn.text", str_utf8);
edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
evas_object_size_hint_min_set(btn, width, height);
switch (pos)
{
- case MULTIBUTTONENTRY_POS_START:
- wd->items = eina_list_prepend(wd->items, item);
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
- {
- elm_widget_sub_object_add(obj, btn);
- _shrink_mode_set(obj, EINA_TRUE);
- }
- else
- {
- if (wd->label)
- elm_box_pack_after(wd->box, btn, wd->label);
- else
- elm_box_pack_start(wd->box, btn);
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
- _set_vis_guidetext(obj);
- }
- break;
- case MULTIBUTTONENTRY_POS_END:
+ case MULTIBUTTONENTRY_POS_START:
+ wd->items = eina_list_prepend(wd->items, item);
+ if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
+ {
+ elm_widget_sub_object_add(obj, btn);
+ _shrink_mode_set(obj, EINA_TRUE);
+ }
+ else
+ {
+ if (wd->label)
+ elm_box_pack_after(wd->box, btn, wd->label);
+ else
+ elm_box_pack_start(wd->box, btn);
+ if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
+ _set_vis_guidetext(obj);
+ }
+ break;
+ case MULTIBUTTONENTRY_POS_END:
+ wd->items = eina_list_append(wd->items, item);
+ if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
+ {
+ elm_widget_sub_object_add(obj, btn);
+ evas_object_hide(btn);
+ }
+ else
+ {
+ if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
+ _set_vis_guidetext(obj);
+ if (wd->entry)
+ elm_box_pack_before(wd->box, btn, wd->entry);
+ else
+ elm_box_pack_end(wd->box, btn);
+ }
+ break;
+ case MULTIBUTTONENTRY_POS_BEFORE:
+ if (reference)
+ wd->items = eina_list_prepend_relative(wd->items, item, reference);
+ else
+ wd->items = eina_list_append(wd->items, item);
+ if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
+ {
+ elm_widget_sub_object_add(obj, btn);
+ evas_object_hide(btn);
+ _shrink_mode_set(obj, EINA_TRUE);
+ }
+ else
+ {
+ if (reference)
+ elm_box_pack_before(wd->box, btn, reference->button);
+ else
+ {
+ if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
+ _set_vis_guidetext(obj);
+ if (wd->entry)
+ elm_box_pack_before(wd->box, btn, wd->entry);
+ else
+ elm_box_pack_end(wd->box, btn);
+ }
+ }
+ break;
+ case MULTIBUTTONENTRY_POS_AFTER:
+ if (reference)
+ wd->items = eina_list_append_relative(wd->items, item, reference);
+ else
wd->items = eina_list_append(wd->items, item);
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
- {
- elm_widget_sub_object_add(obj, btn);
- evas_object_hide(btn);
- }
- else
- {
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
- _set_vis_guidetext(obj);
- if (wd->entry)
- elm_box_pack_before(wd->box, btn, wd->entry);
- else
- elm_box_pack_end(wd->box, btn);
- }
- break;
- case MULTIBUTTONENTRY_POS_BEFORE:
- if (reference)
- wd->items = eina_list_prepend_relative(wd->items, item, reference);
- else
- wd->items = eina_list_append(wd->items, item);
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
- {
- elm_widget_sub_object_add(obj, btn);
- evas_object_hide(btn);
- _shrink_mode_set(obj, EINA_TRUE);
- }
- else
- {
- if (reference)
- elm_box_pack_before(wd->box, btn, reference->button);
- else
- {
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
- _set_vis_guidetext(obj);
- if (wd->entry)
- elm_box_pack_before(wd->box, btn, wd->entry);
- else
- elm_box_pack_end(wd->box, btn);
- }
- }
- break;
- case MULTIBUTTONENTRY_POS_AFTER:
- if (reference)
- wd->items = eina_list_append_relative(wd->items, item, reference);
- else
- wd->items = eina_list_append(wd->items, item);
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
- {
- elm_widget_sub_object_add(obj, btn);
- _shrink_mode_set(obj, EINA_TRUE);
- }
- else
- {
- if (reference)
- elm_box_pack_after(wd->box, btn, reference->button);
- else
- {
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
- _set_vis_guidetext(obj);
- if (wd->entry)
- elm_box_pack_before(wd->box, btn, wd->entry);
- else
- elm_box_pack_end(wd->box, btn);
- }
- }
- break;
- default:
- break;
+ if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
+ {
+ elm_widget_sub_object_add(obj, btn);
+ _shrink_mode_set(obj, EINA_TRUE);
+ }
+ else
+ {
+ if (reference)
+ elm_box_pack_after(wd->box, btn, reference->button);
+ else
+ {
+ if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
+ _set_vis_guidetext(obj);
+ if (wd->entry)
+ elm_box_pack_before(wd->box, btn, wd->entry);
+ else
+ elm_box_pack_end(wd->box, btn);
+ }
+ }
+ break;
+ default:
+ break;
}
}
- evas_object_smart_callback_call(obj, "item,added", item);
+ evas_object_smart_callback_call(obj, SIG_ITEM_ADDED, item);
free(str_utf8);
if (wd->last_btn_select)
{
- if (wd->current &&
+ if (wd->selected_it &&
((strcmp(ev->keyname, "BackSpace") == 0) ||
(strcmp(ev->keyname, "Delete") == 0)))
{
- item = eina_list_data_get(wd->current);
+ item = (Elm_Multibuttonentry_Item *)wd->selected_it;
if (item)
{
_del_button_item(item);
elm_object_focus_set(wd->entry, EINA_TRUE);
}
}
- else if (((!wd->current && (wd->n_str == 0) &&
+ else if (((!wd->selected_it && (wd->n_str == 0) &&
(strcmp(ev->keyname, "BackSpace") == 0)) ||
(strcmp(ev->keyname, "Delete") == 0)))
{
if (!wd) return;
- if (wd->current)
+ if (wd->selected_it)
{
- item = eina_list_data_get(wd->current);
+ item = (Elm_Multibuttonentry_Item *)wd->selected_it;
elm_object_focus_set(wd->entry, EINA_FALSE);
evas_object_focus_set(item->button, EINA_TRUE);
}
_entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Coord en_x, en_y, en_w, en_h;
- Evas_Coord bx_x, bx_y;
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
- evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
if (wd->focused)
- elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w,
- en_h, EINA_TRUE);
+ elm_widget_show_region_set(wd->entry, en_x, en_y, en_w, en_h, EINA_TRUE);
}
static void
{
wd->entry = elm_entry_add(obj);
if (!wd->entry) return;
+ elm_entry_scrollable_set(wd->entry, EINA_TRUE);
elm_entry_single_line_set(wd->entry, EINA_TRUE);
elm_object_text_set(wd->entry, "");
elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
- evas_object_size_hint_min_set(wd->end,
- button_min_width * _elm_config->scale,
+ evas_object_size_hint_min_set(wd->end,
+ button_min_width * _elm_config->scale,
button_min_height * _elm_config->scale);
elm_widget_sub_object_add(obj, wd->end);
}
if (wx)
{
+ if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
+ mnw = MIN_W_ENTRY;
+
if (mnw != -1 && (w - cw) >= mnw)
ww = w - cw;
else
if (wx)
{
+ if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
+ mnw = MIN_W_ENTRY;
+
if (mnw != -1 && (w - cw) >= mnw)
ww = w - cw;
else
if (wx)
{
+ if ((elm_widget_is(obj)) && (!(strcmp(elm_widget_type_get(obj), "entry"))) && (mnw == -1))
+ mnw = MIN_W_ENTRY;
+
if (mnw != -1 && (w - cw) >= mnw)
ww = w - cw;
else
if (part && strcmp(part, "default")) return;
if (!label) return;
item = (Elm_Multibuttonentry_Item *)it;
- edje_object_part_text_set(item->button, "elm.btn.text", label);
+ edje_object_part_text_escaped_set(item->button, "elm.btn.text", label);
_resize_button(item->button, &item->rw, &item->vw);
}
wd->add_callback = NULL;
wd->add_callback_data = NULL;
+ evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
_view_init(obj);
_event_init(obj);
if (!wd) return -1;
return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
-
}
EAPI void
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
- return eina_list_data_get(wd->current);
+ return wd->selected_it;
}
EAPI void
}
wd->items = NULL;
}
- wd->current = NULL;
+ wd->selected_it = NULL;
_view_update(obj);
}
return NULL;
}
-EAPI void *
+EINA_DEPRECATED EAPI void *
elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
{
return elm_widget_item_data_get(it);
}
-EAPI void
+EINA_DEPRECATED EAPI void
elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
{
return elm_widget_item_data_set(it, data);