static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
+static void _on_focus_hook(void *data, Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
-static void _clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
-static void _changed(void *data, Evas_Object *obj, const char *emission, const char *source);
-static void _cancel_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
+static void _clicked(void *data, Evas_Object *obj, void *event_info);
+static void _changed(void *data, Evas_Object *obj, void *event_info);
+static void _cancel_clicked(void *data, Evas_Object *obj, void *event_info);
static void _del_hook(Evas_Object *obj)
{
static void _theme_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
+ char buf[4096];
+
if (!wd) return;
_elm_theme_object_set(obj, wd->base, "searchbar", "base", elm_widget_style_get(obj));
if (wd->cancel_btn)
edje_object_part_swallow(wd->base, "button_cancel", wd->cancel_btn);
+ snprintf(buf, sizeof(buf), "searchbar/%s", elm_widget_style_get(obj));
+ elm_object_style_set(wd->eb, buf);
+
+ snprintf(buf, sizeof(buf), "searchbar/%s", elm_widget_style_get(obj));
+ elm_object_style_set(wd->cancel_btn, buf);
+
edje_object_scale_set(wd->cancel_btn, elm_widget_scale_get(obj) * _elm_config->scale);
_sizing_eval(obj);
}
+static void
+_on_focus_hook(void *data, Evas_Object *obj)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd || !wd->base)
+ return;
+ if (elm_widget_focus_get(obj))
+ {
+ if (wd->cancel_btn_show_mode)
+ {
+ if (wd->cancel_btn_ani_flag) edje_object_signal_emit(wd->base, "CANCELIN", "PROG");
+ else edje_object_signal_emit(wd->base, "CANCELSHOW", "PROG");
+ }
+ }
+}
+
static void _sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
evas_object_size_hint_max_set(obj, maxw, maxh);
}
-static void _clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
+static void _clicked(void *data, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
- elm_entry_cursor_end_set(elm_editfield_entry_get(wd->eb));
-
if (wd->cancel_btn_show_mode)
- {
- if (wd->cancel_btn_ani_flag)
- edje_object_signal_emit(wd->base, "CANCELIN", "PROG");
- else
- edje_object_signal_emit(wd->base, "CANCELSHOW", "PROG");
- }
+ {
+ if (wd->cancel_btn_ani_flag) edje_object_signal_emit(wd->base, "CANCELIN", "PROG");
+ else edje_object_signal_emit(wd->base, "CANCELSHOW", "PROG");
+ }
evas_object_smart_callback_call(data, "clicked", NULL);
}
-static void _changed(void *data, Evas_Object *obj, const char *emission, const char *source)
+static void _changed(void *data, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
// evas_object_smart_callback_call(data, "changed", NULL);
}
-static void _cancel_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
+static void _cancel_clicked(void *data, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
if (wd->cancel_btn_show_mode)
- {
- if (wd->cancel_btn_ani_flag)
- edje_object_signal_emit(wd->base, "CANCELOUT", "PROG");
- else
- edje_object_signal_emit(wd->base, "CANCELHIDE", "PROG");
- }
+ {
+ if (wd->cancel_btn_ani_flag) edje_object_signal_emit(wd->base, "CANCELOUT", "PROG");
+ else edje_object_signal_emit(wd->base, "CANCELHIDE", "PROG");
+ }
const char* text;
text = elm_entry_entry_get(elm_editfield_entry_get(wd->eb));
- if (text != NULL && strlen(text) > 0)
- elm_entry_entry_set(elm_editfield_entry_get(wd->eb), NULL);
+ if (text != NULL && strlen(text) > 0) elm_entry_entry_set(elm_editfield_entry_get(wd->eb), NULL);
evas_object_smart_callback_call(data, "cancel,clicked", NULL);
}
static void
-_searchicon_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
+_basebg_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
+
if (!wd) return;
- if (!strcmp(source, "search_icon"))
- evas_object_smart_callback_call(data, "searchsymbol,clicked", NULL);
- else if (!strcmp(source, "base_bg"))
- _clicked(data, obj, emission, source);
+ if (!strcmp(source, "base_bg"))
+ _clicked(data, obj, NULL);
+}
+
+static void
+_searchsymbol_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+
+ if (!wd) return;
+ evas_object_smart_callback_call(data, "searchsymbol,clicked", NULL);
}
/**
Evas_Object *obj;
Evas *e;
Widget_Data *wd;
+ char buf[4096];
wd = ELM_NEW(Widget_Data);
e = evas_object_evas_get(parent);
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
+ elm_widget_on_focus_hook_set( obj, _on_focus_hook, NULL );
elm_widget_can_focus_set(obj, 1 );
wd->base = edje_object_add(e);
if (wd->base == NULL) return NULL;
- _elm_theme_object_set(obj, wd->base, "searchbar", "base", "default_with_bg");
+ _elm_theme_object_set(obj, wd->base, "searchbar", "base", "default");
// evas_object_size_hint_weight_set(wd->base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
// evas_object_size_hint_align_set(wd->base, EVAS_HINT_FILL, EVAS_HINT_FILL);
// Add Entry
wd->eb = elm_editfield_add(parent);
- elm_object_style_set(wd->eb, "searchbar_with_bg");
+ snprintf(buf, sizeof(buf), "searchbar/%s", elm_widget_style_get(obj));
+ elm_object_style_set(wd->eb, buf);
+
edje_object_part_swallow(wd->base, "search_textfield", wd->eb);
// elm_editfield_guide_text_set(wd->eb, "Search");
elm_editfield_entry_single_line_set(wd->eb, EINA_TRUE);
elm_editfield_eraser_set(wd->eb, EINA_TRUE);
evas_object_smart_callback_add(wd->eb, "clicked", _clicked, obj);
evas_object_smart_callback_add(elm_editfield_entry_get(wd->eb), "changed", _changed, obj);
- edje_object_signal_callback_add(wd->base, "mouse,up,1", "*", _searchicon_clicked, obj);
+ edje_object_signal_callback_add(wd->base, "mouse,up,1", "*", _basebg_clicked, obj);
+ edje_object_signal_callback_add(wd->base, "elm,action,click", "", _searchsymbol_clicked, obj);
elm_widget_sub_object_add(obj, wd->eb);
// Add Button
wd->cancel_btn = elm_button_add(parent);
edje_object_part_swallow(wd->base, "button_cancel", wd->cancel_btn);
- elm_object_style_set(wd->cancel_btn, "custom/darkblue");
+
+ snprintf(buf, sizeof(buf), "searchbar/%s", elm_widget_style_get(obj));
+ elm_object_style_set(wd->cancel_btn, buf);
+
elm_button_label_set(wd->cancel_btn, "Cancel");
evas_object_smart_callback_add(wd->cancel_btn, "clicked", _cancel_clicked, obj);
elm_widget_sub_object_add(obj, wd->cancel_btn);
EAPI void elm_searchbar_text_set(Evas_Object *obj, const char *entry)
{
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
+ if (!wd) return;
elm_entry_entry_set(elm_editfield_entry_get(wd->eb), entry);
}
else wd->cancel_btn_show_mode = visible;
if (!visible)
- {
- if (wd->cancel_btn_show_mode && wd->cancel_btn_ani_flag)
- edje_object_signal_emit(wd->base, "CANCELOUT", "PROG");
- else
- edje_object_signal_emit(wd->base, "CANCELHIDE", "PROG");
-
- _sizing_eval(obj);
- }
+ {
+ if (wd->cancel_btn_ani_flag)
+ edje_object_signal_emit(wd->base, "CANCELOUT", "PROG");
+ else
+ edje_object_signal_emit(wd->base, "CANCELHIDE", "PROG");
+ }
+ _sizing_eval(obj);
}
/**
- * clear searchbar content
+ * clear searchbar status
*
* @param obj The searchbar object
* @return void
if (!wd) return;
if (wd->cancel_btn_show_mode)
- {
- if (wd->cancel_btn_ani_flag)
- edje_object_signal_emit(wd->base, "CANCELOUT", "PROG");
- else
- edje_object_signal_emit(wd->base, "CANCELHIDE", "PROG");
- }
-
- elm_entry_entry_set(elm_editfield_entry_get(wd->eb), NULL);
+ {
+ if (wd->cancel_btn_ani_flag)
+ edje_object_signal_emit(wd->base, "CANCELOUT", "PROG");
+ else
+ edje_object_signal_emit(wd->base, "CANCELHIDE", "PROG");
+ }
+// elm_entry_entry_set(elm_editfield_entry_get(wd->eb), NULL);
}
/**
- * set the searchbar background mode(with bg rect) set
+ * set the searchbar boundary rect mode(with bg rect) set
*
* @param obj The searchbar object
- * @param boundary The flag of background mode or not
+ * @param boundary The present flag of boundary rect or not
* @return void
*
* @ingroup Searchbar
else wd->boundary_mode = boundary;
if (wd->boundary_mode)
- {
- _elm_theme_object_set(obj, wd->base, "searchbar", "base", "default_with_bd");
- elm_object_style_set(wd->eb, "searchbar_with_bd");
-
- }
+ {
+ edje_object_signal_emit(wd->base, "BDSHOW", "PROG");
+ }
else
- {
- _elm_theme_object_set(obj, wd->base, "searchbar", "base", "default");
- elm_object_style_set(wd->eb, "searchbar");
- }
-
+ {
+ edje_object_signal_emit(wd->base, "BDHIDE", "PROG");
+ }
_sizing_eval(obj);
}