#include "elm_priv.h"
#define MAX_STR 256
-#define MIN_W_ENTRY 20
+#define MIN_W_ENTRY 160
typedef enum _Multibuttonentry_Pos
{
MULTIBUTTONENTRY_POS_END,
MULTIBUTTONENTRY_POS_BEFORE,
MULTIBUTTONENTRY_POS_AFTER,
- MULTIBUTTONENTRY_POS_NUM
} Multibuttonentry_Pos;
typedef enum _Multibuttonentry_Button_State
{
MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
- MULTIBUTTONENTRY_BUTTON_STATE_NUM
} Multibuttonentry_Button_State;
+
typedef enum _MultiButtonEntry_Closed_Button_Type
{
MULTIBUTTONENTRY_CLOSED_IMAGE,
MULTIBUTTONENTRY_VIEW_NONE,
MULTIBUTTONENTRY_VIEW_GUIDETEXT,
MULTIBUTTONENTRY_VIEW_ENTRY,
- MULTIBUTTONENTRY_VIEW_CONTRACTED
+ MULTIBUTTONENTRY_VIEW_SHRINK
} Multibuttonentry_View_State;
+typedef struct _Widget_Data Widget_Data;
+typedef struct _Multibuttonentry_Item Elm_Multibuttonentry_Item;
+
struct _Multibuttonentry_Item
{
- Evas_Object *multibuttonentry;
+ ELM_WIDGET_ITEM;
Evas_Object *button;
- void *data;
Evas_Coord vw, rw; // vw: visual width, real width
Eina_Bool visible: 1;
+ Evas_Smart_Cb func;
};
-typedef struct _Widget_Data Widget_Data;
+typedef struct _Elm_Multibuttonentry_Item_Filter
+ {
+ Elm_Multibuttonentry_Item_Filter_Cb callback_func;
+ void *data;
+ } Elm_Multibuttonentry_Item_Filter;
+
struct _Widget_Data
{
Evas_Object *base;
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;
int n_str;
Multibuttonentry_View_State view_state;
Evas_Coord w_box, h_box;
- int contracted;
+ int shrink;
Eina_Bool focused: 1;
Eina_Bool last_btn_select: 1;
- Eina_Bool view_mode;
- Elm_Multibuttonentry_Item_Verify_Callback add_callback;
+ Elm_Multibuttonentry_Item_Filter_Cb add_callback;
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 void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
static void _event_init(Evas_Object *obj);
-static void _contracted_state_set(Evas_Object *obj, int contracted);
+static void _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink);
static void _view_update(Evas_Object *obj);
static void _set_label(Evas_Object *obj, const char *str);
static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
static void _del_button_item(Elm_Multibuttonentry_Item *item);
static void _select_button(Evas_Object *obj, Evas_Object *btn);
-static Elm_Multibuttonentry_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos,
- const Elm_Multibuttonentry_Item *reference, void *data);
-static void _add_button(Evas_Object *obj, char *str);
+static Elm_Object_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data);
static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
+static void _item_text_set_hook(Elm_Object_Item *it,
+ const char *part,
+ const char *label);
+static const char *_item_text_get_hook(const Elm_Object_Item *it,
+ const char *part);
+
+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;
-
- if (wd->entry) evas_object_del (wd->entry);
- if (wd->label) evas_object_del (wd->label);
- if (wd->guidetext) evas_object_del (wd->guidetext);
- if (wd->end) evas_object_del (wd->end);
+ wd->selected_it = NULL;
+
+ if (wd->labeltxt) eina_stringshare_del(wd->labeltxt);
+ if (wd->guidetexttxt) eina_stringshare_del(wd->guidetexttxt);
+ if (wd->entry) evas_object_del(wd->entry);
+ if (wd->label) evas_object_del(wd->label);
+ if (wd->guidetext) evas_object_del(wd->guidetext);
+ if (wd->end) evas_object_del(wd->end);
if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
}
if (!wd) return;
_elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
- if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
+ if (wd->box) edje_object_part_swallow(wd->base, "box.swallow", wd->box);
edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
EINA_LIST_FOREACH(wd->items, l, item)
{
if (item->button)
- _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
+ _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get(obj));
edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
}
if (!wd) return;
- Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(wd->entry);
-
if (elm_widget_focus_get(obj))
{
- if ((imf_context) && (wd->current))
+ if ((wd->selected_it))
{
- ecore_imf_context_input_panel_show(imf_context);
+ elm_entry_input_panel_show(wd->entry);
}
- else if ((imf_context) && ((!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);
- ecore_imf_context_input_panel_show(imf_context);
+ 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
{
wd->focused = EINA_FALSE;
_view_update(obj);
- if (imf_context) ecore_imf_context_input_panel_hide(imf_context);
- evas_object_smart_callback_call(obj, "unfocused", NULL);
+
+ elm_entry_input_panel_hide(wd->entry);
+ evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
}
}
wd->focused = EINA_TRUE;
_view_update(data);
- Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(wd->entry);
+ elm_entry_input_panel_show(wd->entry);
+ elm_object_focus_set(wd->entry, EINA_TRUE);
- if (imf_context) ecore_imf_context_input_panel_show(imf_context);
- 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;
if (!wd) return;
elm_box_unpack(wd->box, wd->guidetext);
elm_box_unpack(wd->box, wd->entry);
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) return;
+ 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))
else
{
evas_object_hide(wd->guidetext);
- if (!wd->view_mode)
- {
- elm_box_pack_end(wd->box, wd->entry);
- evas_object_show(wd->entry);
- }
+ 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;
}
}
static void
-_contracted_state_set(Evas_Object *obj, int contracted)
+_shrink_mode_set(Evas_Object *obj, Eina_Bool shrink)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *l;
evas_object_hide(wd->entry);
else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
evas_object_hide(wd->guidetext);
- else if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
+ else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
{
evas_object_hide(wd->rect_for_end);
evas_object_hide(wd->end);
wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
}
- if (contracted == 1)
+ if (shrink == EINA_TRUE)
{
- Evas_Coord w=0, w_tmp=0;
+ Evas_Coord w = 0, w_tmp = 0;
Evas_Coord box_inner_item_width_padding = 0;
elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
elm_box_pack_end(wd->box, wd->end);
evas_object_show(wd->end);
- wd->view_state = MULTIBUTTONENTRY_VIEW_CONTRACTED;
- evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)1);
+ wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
+ evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED, (void *)1);
break;
}
}
wd->rect_for_end = evas_object_rectangle_add(e);
evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
}
- evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get());
+ evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * _elm_config->scale);
elm_box_pack_end(wd->box, wd->rect_for_end);
evas_object_show(wd->rect_for_end);
elm_box_pack_end(wd->box, wd->end);
evas_object_show(wd->end);
- wd->view_state = MULTIBUTTONENTRY_VIEW_CONTRACTED;
- evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)0);
+ wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
+ 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, "contracted,state,changed", (void *)wd->contracted);
+ evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED,
+ (void *)(long)wd->shrink);
}
- if (wd->view_state != MULTIBUTTONENTRY_VIEW_CONTRACTED)
+ if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
{
_set_vis_guidetext(obj);
}
evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
}
- // update buttons in contracted mode
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
- _contracted_state_set(obj, 1);
+ // update buttons in shrink mode
+ if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
+ _shrink_mode_set(obj, EINA_TRUE);
// update guidetext
_set_vis_guidetext(obj);
}
static void
-_set_label(Evas_Object *obj, const char* str)
+_set_label(Evas_Object *obj, const char *str)
{
Widget_Data *wd = elm_widget_data_get(obj);
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);
}
static void
-_set_guidetext(Evas_Object *obj, const char* str)
+_set_guidetext(Evas_Object *obj, const char *str)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd || !str) return;
- if (!wd->guidetext)
+
+ eina_stringshare_replace(&wd->guidetexttxt, str);
+ if (wd->guidetext == NULL)
+ wd->guidetext = edje_object_add(evas_object_evas_get(obj));
+
+ if (wd->guidetext)
{
- if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
- _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
+ _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry",
+ "guidetext", elm_widget_style_get(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);
+ evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ edje_object_part_text_escaped_set(wd->guidetext, "elm.text", str);
+ _view_update(obj);
}
-
- if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
- _view_update(obj);
}
static void
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;
}
}
Widget_Data *wd = elm_widget_data_get(data);
Elm_Multibuttonentry_Item *item = NULL;
- if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) return;
+ if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
_select_button(data, obj);
- if ((wd->current) && ((item = eina_list_data_get(wd->current)) != NULL))
- evas_object_smart_callback_call(data, "item,clicked", item);
+ if (wd->selected_it)
+ if ((item = (Elm_Multibuttonentry_Item *)wd->selected_it) != NULL)
+ {
+ evas_object_smart_callback_call(data, SIG_ITEM_CLICKED, item);
+ _select_button(data, item->button);
+ }
}
static void
if (!item) return;
Widget_Data *wd;
- Evas_Object *obj = item->multibuttonentry;
+ Evas_Object *obj = WIDGET(item);
wd = elm_widget_data_get(obj);
if (!wd) return;
EINA_LIST_FOREACH(wd->items, l, _item)
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);
- free(_item);
- if (wd->current == l)
- wd->current = NULL;
+ if (wd->selected_it == (Elm_Object_Item *)_item)
+ wd->selected_it = NULL;
break;
}
}
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
- _contracted_state_set(obj, 1);
+ if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
+ _shrink_mode_set(obj, EINA_TRUE);
if (!eina_list_count(wd->items))
_set_vis_guidetext(obj);
_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;
+ Evas_Coord w_text, h_btn, padding_outer = 0;
Evas_Coord w_btn = 0, button_max_width = 0;
const char *size_str;
- const char *ellipsis = "<ellipsis=1.0>";
size_str = edje_object_data_get(btn, "button_max_size");
if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
- const char *button_text = edje_object_part_text_get(btn, "elm.btn.text");
-
// decide the size of button
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, "left.padding", NULL, NULL, &padding_outer, NULL);
- edje_object_part_geometry_get(btn, "left.inner.padding", NULL, NULL, &padding_inner, NULL);
- w_btn = w_text + 2*padding_outer + 2*padding_inner;
+ edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
+ w_btn = w_text + (2 * padding_outer);
rw = w_btn;
if (button_max_width < w_btn)
- {
- vw = button_max_width;
- edje_object_part_text_set(btn, "elm.btn.text", ellipsis);
- edje_object_part_text_append(btn, "elm.btn.text", button_text);
- }
+ vw = button_max_width;
else
vw = w_btn;
if (vieww) *vieww = vw;
}
-static Elm_Multibuttonentry_Item*
-_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
+static Eina_Bool
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ _del_button_item((Elm_Multibuttonentry_Item *)it);
+ return EINA_TRUE;
+}
+
+static Elm_Object_Item*
+_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data)
{
Elm_Multibuttonentry_Item *item;
+ Elm_Multibuttonentry_Item_Filter *item_filter;
+ Elm_Multibuttonentry_Item *reference = (Elm_Multibuttonentry_Item *)ref;
+ Eina_List *l;
Evas_Object *btn;
- Evas_Coord width, height;
+ Evas_Coord width = -1, height = -1;
char *str_utf8 = NULL;
-
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd || !wd->box || !wd->entry) return NULL;
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ if (!str) return NULL;
- if ((wd->add_callback) && !wd->add_callback(obj, str, data, wd->add_callback_data)) return NULL;
-
- //entry is cleared when text is made to button
- elm_entry_entry_set(wd->entry, "");
-
- // initialize entry size to be called entry's EVAS_CALLBACK_RESIZE even entry size's doesn't changed
- evas_object_resize(wd->entry, 0, 0);
-
+ EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
+ {
+ if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
+ return NULL;
+ }
// add button
btn = edje_object_add(evas_object_evas_get(obj));
str_utf8 = elm_entry_markup_to_utf8(str);
+ //entry is cleared when text is made to button
+ 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);
evas_object_show(btn);
// append item list
- item = ELM_NEW(Elm_Multibuttonentry_Item);
+ item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
if (item)
{
+ elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
+ elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
+ elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
+ elm_widget_item_data_set(item, data);
Evas_Coord rw, vw;
_resize_button(btn, &rw, &vw);
- item->multibuttonentry = obj;
item->button = btn;
- item->data = data;
item->rw = rw;
item->vw = vw;
item->visible = EINA_TRUE;
+ if (func)
+ {
+ item->func = func;
+ }
+
switch (pos)
{
- case MULTIBUTTONENTRY_POS_START:
- wd->items = eina_list_prepend(wd->items, item);
- if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
- {
- elm_widget_sub_object_add(obj, btn);
- _contracted_state_set(obj, 1);
- }
- 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_CONTRACTED)
- {
- 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)
- if (!wd->view_mode) 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_CONTRACTED)
- {
- elm_widget_sub_object_add(obj, btn);
- evas_object_hide(btn);
- _contracted_state_set(obj, 1);
- }
- 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)
- if (!wd->view_mode) 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_CONTRACTED)
- {
- elm_widget_sub_object_add(obj, btn);
- _contracted_state_set(obj, 1);
- }
- 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)
- if (!wd->view_mode) 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);
- return item;
+ return (Elm_Object_Item *)item;
}
-static void
-_add_button(Evas_Object *obj, char *str)
+static Elm_Multibuttonentry_Item_Filter*
+_filter_new(Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
+ Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
+ if (!item_filter) return NULL;
- // add button
- _add_button_item(obj, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
+ item_filter->callback_func= func;
+ item_filter->data = data;
+
+ return item_filter;
+}
+
+static void
+_filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
+{
+ free(item_filter);
}
static void
Widget_Data *wd = elm_widget_data_get(data);
Elm_Multibuttonentry_Item *item = NULL;
- static char str[MAX_STR];
-
if (!wd || !wd->base || !wd->box) return;
- strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
- str[MAX_STR - 1] = 0;
-
Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
if (wd->last_btn_select)
{
- if ((wd->current) && ( (strcmp (ev->keyname, "BackSpace") == 0) || (strcmp (ev->keyname, "BackSpace (") == 0)))
+ 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(wd->entry);
+ elm_widget_item_free(item);
+ elm_object_focus_set(wd->entry, EINA_TRUE);
}
}
- else if ((((!wd->current) && (wd->n_str == 0) && (strcmp (ev->keyname, "BackSpace") == 0))
- || (strcmp (ev->keyname, "BackSpace (") == 0)))
+ else if (((!wd->selected_it && (wd->n_str == 0) &&
+ (strcmp(ev->keyname, "BackSpace") == 0)) ||
+ (strcmp(ev->keyname, "Delete") == 0)))
{
item = eina_list_data_get(eina_list_last(wd->items));
if (item)
if (!wd) return;
- if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "BackSpace (") == 0 )))
+ if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
wd->last_btn_select = EINA_FALSE;
}
{
Widget_Data *wd = elm_widget_data_get(data);
Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
- static char str[MAX_STR];
+ const char *str;
if (!wd || !wd->base || !wd->box) return;
- strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
- str[MAX_STR - 1] = 0;
+ str = elm_object_text_get(wd->entry);
- if ( (strcmp (str, "") != 0) && (strcmp (ev->keyname, "KP_Enter") == 0 || strcmp (ev->keyname, "Return") == 0 ))
+ if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
{
- _add_button(data, str);
+ _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
wd->n_str = 0;
- return;
}
}
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_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Widget_Data *wd = elm_widget_data_get(data);
- if (!wd) return;
-
- static char str[MAX_STR];
+ const char *str;
- strncpy(str,elm_entry_entry_get(wd->entry), MAX_STR);
- str[MAX_STR -1] = 0;
+ if (!wd) return;
+ str = elm_object_text_get(wd->entry);
if (strlen(str))
- _add_button(data, str);
+ _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
}
static void
_entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Widget_Data *wd = elm_widget_data_get(data);
- if (!wd) return;
+ const char *str;
- static char str[MAX_STR];
-
- strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
- str[MAX_STR -1] = 0;
+ if (!wd) return;
- wd->n_str = strlen(str);
+ str = elm_object_text_get(wd->entry);
+ wd->n_str = strlen(str);
}
static void
if (!wd->box)
{
- wd->box = elm_box_add (obj);
+ wd->box = elm_box_add(obj);
if (!wd->box) return;
elm_widget_sub_object_add(obj, wd->box);
elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
if (!wd->entry)
{
- if (! (wd->entry = elm_entry_add (obj))) return;
+ 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_entry_entry_set(wd->entry, "");
+ elm_object_text_set(wd->entry, "");
elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
- if (wd->box) elm_box_pack_end (wd->box, wd->entry);
+ if (wd->box) elm_box_pack_end(wd->box, wd->entry);
evas_object_show(wd->entry);
wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
}
if (!wd->end)
{
- const char *end_type = edje_object_data_get(wd->base, "closed_button_type");
+ const char *end_type;
+
+ end_type = edje_object_data_get(wd->base, "closed_button_type");
if (!end_type || !strcmp(end_type, "label"))
{
- if (! (wd->end = elm_label_add (obj))) return;
+ wd->end = elm_label_add(obj);
+ if (!wd->end) return;
elm_object_style_set(wd->end, "extended/multibuttonentry_default");
wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
}
else
{
const char *size_str;
- if (!(wd->end = edje_object_add(evas_object_evas_get(obj)))) return;
+ wd->end = edje_object_add(evas_object_evas_get(obj));
+ if (!wd->end) return;
_elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
Evas_Coord button_min_width = 0;
Evas_Coord button_min_height = 0;
size_str = edje_object_data_get(wd->end, "closed_button_width");
- if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
+ if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
size_str = edje_object_data_get(wd->end, "closed_button_height");
- if(size_str) button_min_height = (Evas_Coord)atoi(size_str);
+ 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_scale_get(), button_min_height * elm_scale_get());
+ 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);
}
}
static void
_calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
{
- Evas_Coord minw, minh, maxw, maxh, mnw, mnh, ww;
+ Evas_Coord minw, minh, mnw, mnh, ww;
Evas_Coord w, cw = 0, cmaxh = 0;
const Eina_List *l;
Evas_Object_Box_Option *opt;
/* FIXME: need to calc max */
minw = 0;
minh = 0;
- maxw = -1;
- maxh = -1;
evas_object_geometry_get(box, NULL, NULL, &w, NULL);
evas_object_size_hint_min_get(box, &minw, NULL);
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
Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
const Eina_List *l;
Evas_Object_Box_Option *opt;
- int index = 0;
+ int local_index = 0;
double wx;
evas_object_geometry_get(box, NULL, NULL, &w, NULL);
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 ((cw + ww) > w)
{
- if (index > obj_index) return cmaxh;
+ if (local_index > obj_index) return cmaxh;
cw = 0;
cmaxh = 0;
}
cw += ww;
if (cmaxh < mnh) cmaxh = mnh;
- index++;
+ local_index++;
}
return cmaxh;
Evas_Coord x, y, w, h, xx, yy;
const Eina_List *l;
Evas_Object *obj;
- Evas_Coord minw, minh, wdif, hdif;
- int count = 0;
+ Evas_Coord minw, minh;
double ax, ay;
Evas_Object_Box_Option *opt;
evas_object_size_hint_min_get(o, &minw, &minh);
evas_object_size_hint_align_get(o, &ax, &ay);
- count = eina_list_count(priv->children);
if (w < minw)
{
x = x + ((w - minw) * (1.0 - ax));
h = minh;
}
- wdif = w - minw;
- hdif = h - minh;
xx = x;
yy = y;
{
Evas_Coord mnw, mnh, mxw, mxh;
double wx, wy;
- int fw, fh, xw, xh;
+ int fw, fh;
obj = opt->obj;
evas_object_size_hint_align_get(obj, &ax, &ay);
evas_object_size_hint_min_get(obj, &mnw, &mnh);
evas_object_size_hint_max_get(obj, &mxw, &mxh);
fw = fh = 0;
- xw = xh = 0;
if (ax == -1.0) {fw = 1; ax = 0.5;}
if (ay == -1.0) {fh = 1; ay = 0.5;}
- if (wx > 0.0) xw = 1;
- if (wy > 0.0) xh = 1;
Evas_Coord ww, hh, ow, oh;
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
}
}
+static void
+_item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
+{
+ Elm_Multibuttonentry_Item *item;
+ if (part && strcmp(part, "default")) return;
+ if (!label) return;
+ item = (Elm_Multibuttonentry_Item *)it;
+ edje_object_part_text_escaped_set(item->button, "elm.btn.text", label);
+ _resize_button(item->button, &item->rw, &item->vw);
+}
+
+static const char *
+_item_text_get_hook(const Elm_Object_Item *it, const char *part)
+{
+ Elm_Multibuttonentry_Item *item;
+ if (part && strcmp(part, "default")) return NULL;
+ item = (Elm_Multibuttonentry_Item *)it;
+ return edje_object_part_text_get(item->button, "elm.btn.text");
+}
+
+static void
+_text_set_hook(Evas_Object *obj, const char *part, const char *label)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ if (!part || !strcmp(part, "default"))
+ {
+ if (label) _set_label(obj, label);
+ else _set_label(obj, "");
+ }
+ else if (!strcmp(part, "guide"))
+ {
+ if (label) _set_guidetext(obj, label);
+ else _set_guidetext(obj, "");
+ }
+}
+
+static const char *
+_text_get_hook(const Evas_Object *obj, const char *part)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+
+ if (!part || !strcmp(part, "default"))
+ {
+ return wd->labeltxt;
+ }
+ else if (!strcmp(part, "guide"))
+ {
+ return wd->guidetexttxt;
+ }
+ return NULL;
+}
+
EAPI Evas_Object *
elm_multibuttonentry_add(Evas_Object *parent)
{
elm_widget_event_hook_set(obj, _event_hook);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
+ elm_widget_text_set_hook_set(obj, _text_set_hook);
+ elm_widget_text_get_hook_set(obj, _text_get_hook);
wd->base = edje_object_add(e);
_elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
wd->focused = EINA_FALSE;
wd->last_btn_select = EINA_TRUE;
wd->n_str = 0;
- wd->rect_for_end= NULL;
+ wd->rect_for_end = NULL;
wd->add_callback = NULL;
wd->add_callback_data = NULL;
+ evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
_view_init(obj);
_event_init(obj);
return wd->entry;
}
-EAPI const char *
-elm_multibuttonentry_label_get(const Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
-
- if (!wd) return NULL;
- if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
- return NULL;
-}
-
-EAPI void
-elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
-
- if (!wd) return;
- if (label)
- _set_label(obj, label);
- else
- _set_label(obj, "");
-}
-
-EAPI const char *
-elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
-
- if (!wd) return NULL;
- if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
- return NULL;
-}
-
-EAPI void
-elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
-
- if (!wd) return;
- if (guidetext)
- _set_guidetext(obj, guidetext);
- else
- _set_guidetext(obj, "");
-}
-
-EAPI int
-elm_multibuttonentry_contracted_state_get(const Evas_Object *obj)
+EAPI Eina_Bool
+elm_multibuttonentry_expanded_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) -1;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return -1;
- return wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED ? 1 : 0;
+ return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
}
EAPI void
-elm_multibuttonentry_contracted_state_set(Evas_Object *obj, int contracted)
+elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd || !wd->box ||
- ((wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) ? 1 : 0) == contracted) return;
- _contracted_state_set(obj, contracted);
-}
+ ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
-EAPI Elm_Multibuttonentry_Item *
-elm_multibuttonentry_item_add_start(Evas_Object *obj, const char *label, void *data)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- Elm_Multibuttonentry_Item *item;
+ if (expanded)
+ _shrink_mode_set(obj, EINA_FALSE);
+ else
+ _shrink_mode_set(obj, EINA_TRUE);
- if (!wd || !label) return NULL;
- item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
- return item;
}
-EAPI Elm_Multibuttonentry_Item *
-elm_multibuttonentry_item_add_end(Evas_Object *obj, const char *label, void *data)
+EAPI Elm_Object_Item *
+elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- Elm_Multibuttonentry_Item *item;
-
- if (!wd || !label) return NULL;
- item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
- return item;
+ return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, func, data);
}
-EAPI Elm_Multibuttonentry_Item *
-elm_multibuttonentry_item_add_before(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *before, void *data)
+EAPI Elm_Object_Item *
+elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- Elm_Multibuttonentry_Item *item;
-
- if (!wd || !label) return NULL;
- item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, data);
- return item;
+ return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, func, data);
}
-EAPI Elm_Multibuttonentry_Item *
-elm_multibuttonentry_item_add_after(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *after, void *data)
+EAPI Elm_Object_Item *
+elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data)
{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- Elm_Multibuttonentry_Item *item;
+ return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, func, data);
+}
- if (!wd || !label) return NULL;
- item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, data);
- return item;
+EAPI Elm_Object_Item *
+elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data)
+{
+ return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, func, data);
}
EAPI const Eina_List *
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
-
if (!wd) return NULL;
return wd->items;
}
-EAPI Elm_Multibuttonentry_Item *
-elm_multibuttonentry_item_first_get(const Evas_Object *obj)
+EAPI Elm_Object_Item *
+elm_multibuttonentry_first_item_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
-
- if (!wd || !wd->items) return NULL;
+ if (!wd) return NULL;
return eina_list_data_get(wd->items);
}
-EAPI Elm_Multibuttonentry_Item *
-elm_multibuttonentry_item_last_get(const Evas_Object *obj)
+EAPI Elm_Object_Item *
+elm_multibuttonentry_last_item_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
-
- if (!wd || !wd->items) return NULL;
+ if (!wd) return NULL;
return eina_list_data_get(eina_list_last(wd->items));
}
-EAPI Elm_Multibuttonentry_Item *
-elm_multibuttonentry_item_selected_get(const Evas_Object *obj)
+EAPI Elm_Object_Item *
+elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
-
- if (!wd || !wd->current) return NULL;
- return eina_list_data_get(wd->current);
+ if (!wd) return NULL;
+ return wd->selected_it;
}
EAPI void
-elm_multibuttonentry_item_selected_set(Elm_Multibuttonentry_Item *item)
+elm_multibuttonentry_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
{
- Widget_Data *wd;
- Eina_List *l;
- Elm_Multibuttonentry_Item *_item;
-
- if (!item) return;
- ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
- wd = elm_widget_data_get(item->multibuttonentry);
- if (!wd) return;
-
- EINA_LIST_FOREACH(wd->items, l, _item)
- {
- if (_item == item)
- _select_button(item->multibuttonentry, item->button);
- }
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+ Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *)it;
+ if (selected) _select_button(WIDGET(item), item->button);
+ else _select_button(WIDGET(item), NULL);
}
-EAPI void
-elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
+EAPI Eina_Bool
+elm_multibuttonentry_item_selected_get(const Elm_Object_Item *it)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
-
- _select_button(obj, NULL);
+ //TODO : To be implemented.
+ if (!it) return EINA_FALSE;
+ return EINA_TRUE;
}
EAPI void
-elm_multibuttonentry_items_del(Evas_Object *obj)
+elm_multibuttonentry_clear(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype);
+ Elm_Multibuttonentry_Item *item;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->items)
{
- Elm_Multibuttonentry_Item *item;
EINA_LIST_FREE(wd->items, item)
{
elm_box_unpack(wd->box, item->button);
}
wd->items = NULL;
}
- wd->current = NULL;
+ wd->selected_it = NULL;
_view_update(obj);
}
-EAPI void
-elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item)
-{
- if (!item) return;
- _del_button_item(item);
-}
-
-EAPI const char *
-elm_multibuttonentry_item_label_get(const Elm_Multibuttonentry_Item *item)
+EAPI Elm_Object_Item *
+elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
Widget_Data *wd;
Eina_List *l;
Elm_Multibuttonentry_Item *_item;
- if (!item) return NULL;
- ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
- wd = elm_widget_data_get(item->multibuttonentry);
- if (!wd || !wd->items) return NULL;
+
+ wd = elm_widget_data_get(WIDGET(it));
+ if (!wd) return NULL;
EINA_LIST_FOREACH(wd->items, l, _item)
{
- if (_item == item)
- return edje_object_part_text_get(_item->button, "elm.btn.text");
+ if (_item == (Elm_Multibuttonentry_Item *)it)
+ {
+ l = eina_list_prev(l);
+ if (!l) return NULL;
+ return eina_list_data_get(l);
+ }
}
-
return NULL;
}
-EAPI void
-elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str)
+EAPI Elm_Object_Item *
+elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
Widget_Data *wd;
Eina_List *l;
Elm_Multibuttonentry_Item *_item;
- if (!item || !str) return;
- ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
- wd = elm_widget_data_get(item->multibuttonentry);
- if (!wd || !wd->items) return;
+ wd = elm_widget_data_get(WIDGET(it));
+ if (!wd) return NULL;
EINA_LIST_FOREACH(wd->items, l, _item)
- if (_item == item)
- {
- edje_object_part_text_set(_item->button, "elm.btn.text", str);
- _resize_button(_item->button, &_item->rw, &_item->vw);
- break;
- }
+ {
+ if (_item == (Elm_Multibuttonentry_Item *)it)
+ {
+ l = eina_list_next(l);
+ if (!l) return NULL;
+ return eina_list_data_get(l);
+ }
+ }
+ return NULL;
}
-EAPI Elm_Multibuttonentry_Item *
-elm_multibuttonentry_item_prev(Elm_Multibuttonentry_Item *item)
+EINA_DEPRECATED EAPI void *
+elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
{
- Widget_Data *wd;
- Eina_List *l;
- Elm_Multibuttonentry_Item *_item;
- if (!item) return NULL;
- ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
- wd = elm_widget_data_get(item->multibuttonentry);
- if (!wd || !wd->items) return NULL;
+ return elm_widget_item_data_get(it);
+}
- EINA_LIST_FOREACH(wd->items, l, _item)
- if (_item == item)
- {
- l = eina_list_prev(l);
- if (!l) return NULL;
- return eina_list_data_get(l);
- }
- return NULL;
+EINA_DEPRECATED EAPI void
+elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
+{
+ return elm_widget_item_data_set(it, data);
}
-EAPI Elm_Multibuttonentry_Item *
-elm_multibuttonentry_item_next(Elm_Multibuttonentry_Item *item)
+EAPI void
+elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
{
- Widget_Data *wd;
+ Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
+ Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
Eina_List *l;
- Elm_Multibuttonentry_Item *_item;
- if (!item) return NULL;
- ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
- wd = elm_widget_data_get(item->multibuttonentry);
- if (!wd || !wd->items) return NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
- EINA_LIST_FOREACH(wd->items, l, _item)
- if (_item == item)
- {
- l = eina_list_next(l);
- if (!l) return NULL;
- return eina_list_data_get(l);
- }
- return NULL;
-}
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ EINA_SAFETY_ON_NULL_RETURN(func);
-EAPI void *
-elm_multibuttonentry_item_data_get(const Elm_Multibuttonentry_Item *item)
-{
- if (!item) return NULL;
- return item->data;
-}
+ new_item_filter= _filter_new(func, data);
+ if (!new_item_filter) return;
-EAPI void
-elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data)
-{
- if (!item) return;
- item->data = data;
+ EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
+ {
+ if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
+ {
+ printf("Already Registered this item filter!!!!\n");
+ return;
+ }
+ }
+ wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
}
EAPI void
-elm_multibuttonentry_item_verify_callback_set(Evas_Object *obj, Elm_Multibuttonentry_Item_Verify_Callback func, void *data)
+elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
+ Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
+ Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
+ Eina_List *l;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- wd->add_callback = func;
- wd->add_callback_data = data;
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ EINA_SAFETY_ON_NULL_RETURN(func);
+
+ new_item_filter = _filter_new(func, data);
+ if (!new_item_filter) return;
+
+ EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
+ {
+ if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
+ {
+ printf("Already Registered this item filter!!!!\n");
+ return;
+ }
+ }
+ wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
}
EAPI void
-elm_multibuttonentry_view_mode(Evas_Object *obj, Eina_Bool view_mode)
+elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- wd->view_mode = view_mode;
+ Widget_Data *wd;
+ Eina_List *l;
+ Elm_Multibuttonentry_Item_Filter *item_filter;
+
+ wd = elm_widget_data_get(obj);
+
+ EINA_SAFETY_ON_NULL_RETURN(func);
- if (view_mode)
+ EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
{
- elm_box_unpack(wd->box, wd->entry);
- evas_object_hide(wd->entry);
+ if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
+ {
+ wd->filter_list = eina_list_remove_list(wd->filter_list, l);
+ _filter_free(item_filter);
+ return;
+ }
}
- else
- _view_update(obj);
}