+++ /dev/null
-//Compile with:
-//gcc -o check_example_02 check_example_02.c -g `pkg-config --cflags --libs elementary` && ./check_example_02
-
-#include <Elementary.h>
-
-Evas_Object *cb, *cb1, *cb2, *cb3;
-
-static void
-_print(void *data, Evas_Object *obj, void *event_info)
-{
- if (!elm_check_three_state_mode_get(cb))
- {
- printf("check0 %smarked\n", *((Eina_Bool*)data) ? "" : "un");
- }
- else
- {
- printf("check0 elm_check_state_get() value is %d (%s)\n", elm_check_state_get(cb), *((Eina_Bool*)data) ? "EINA_TRUE" : "EINA_FALSE");
- }
-}
-
-static void
-_print1(void *data, Evas_Object *obj, void *event_info)
-{
- Check_State st = elm_check_state_get(cb1);
- if (st == _CHECK_STATE_CHECKED)
- printf("check1 elm_check_state_get() value is %d (%s)\n", st, "_CHECK_STATE_CHECKED");
- else if (st == _CHECK_STATE_INDETERMINATE)
- printf("check1 elm_check_state_get() value is %d (%s)\n", st, "_CHECK_STATE_INDETERMINATE");
- else
- printf("check1 elm_check_state_get() value is %d (%s)\n", st, "_CHECK_STATE_UNCHECKED");
-}
-
-static void
-_print2(void *data, Evas_Object *obj, void *event_info)
-{
- printf("Currently three state mode is: %s\n", elm_check_three_state_mode_get(cb) ? "On" : "Off");
- elm_check_three_state_mode_set(cb, elm_check_state_get(cb2));
- elm_check_three_state_mode_set(cb1, elm_check_state_get(cb2));
- printf("Three state mode is changed to: %s\n", elm_check_three_state_mode_get(cb) ? "On" : "Off");
-}
-
-static void
-_print3(void *data, Evas_Object *obj, void *event_info)
-{
- elm_object_disabled_set(cb, elm_check_state_get(cb3));
- elm_object_disabled_set(cb1, elm_check_state_get(cb3));
- printf("Checkbox disable mode is : %s\n", elm_check_state_get(cb3) ? "Enabled" : "Disabled");
-}
-
-EAPI_MAIN int
-elm_main(int argc, char **argv)
-{
- Evas_Object *win, *icon;
- Eina_Bool value, *value2, *value3;
- Check_State *value1;
-
- elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
-
- win = elm_win_util_standard_add("check", "Check");
- elm_win_autodel_set(win, EINA_TRUE);
-
- cb = elm_check_add(win);
- elm_object_text_set(cb, "check0 using bool");
- elm_check_state_pointer_set(cb, &value);
- elm_check_state_set(cb, EINA_FALSE);
- evas_object_smart_callback_add(cb, "changed", _print, &value);
- evas_object_move(cb, 10, 10);
- evas_object_resize(cb, 250, 30);
- evas_object_show(cb);
-
- cb1 = elm_check_add(win);
- elm_object_text_set(cb1, "check1 using enum");
- elm_check_state_pointer_set(cb1, (Check_State *)&value1);
- elm_check_state_set(cb1, (Check_State)_CHECK_STATE_CHECKED);
- evas_object_smart_callback_add(cb1, "changed", _print1, &value1);
- evas_object_move(cb1, 10, 50);
- evas_object_resize(cb1, 250, 30);
- evas_object_show(cb1);
-
- icon = evas_object_rectangle_add(evas_object_evas_get(win));
- evas_object_color_set(icon, 0, 255, 0, 255);
- evas_object_resize(icon, 20, 20);
- evas_object_show(icon);
-
- cb2 = elm_check_add(win);
- elm_object_text_set(cb2, "Enable three state mode in above checkboxes");
- elm_check_state_pointer_set(cb2, (Check_State *)&value2);
- elm_check_state_set(cb2, (Check_State)_CHECK_STATE_UNCHECKED);
- evas_object_smart_callback_add(cb2, "changed", _print2, &value2);
- elm_object_part_content_set(cb2, "icon", icon);
- evas_object_move(cb2, 10, 90);
- evas_object_resize(cb2, 250, 30);
- evas_object_show(cb2);
-
- cb3 = elm_check_add(win);
- elm_object_text_set(cb3, "Enable/Disable checkboxes");
- elm_check_state_pointer_set(cb3, (Check_State *)&value3);
- elm_check_state_set(cb3, (Check_State)_CHECK_STATE_UNCHECKED);
- evas_object_smart_callback_add(cb3, "changed", _print3, &value3);
- evas_object_move(cb3, 10, 130);
- evas_object_resize(cb3, 250, 30);
- evas_object_show(cb3);
-
- evas_object_resize(win, 200, 190);
- evas_object_show(win);
-
- elm_run();
-
- return 0;
-}
-ELM_MAIN()
{
ELM_CHECK_DATA_GET(obj, sd);
- if (!sd->three_state_mode)
- {
- sd->state = !sd->state;
- }
- else
- {
- if (sd->state == _CHECK_STATE_UNCHECKED)
- sd->state = _CHECK_STATE_CHECKED;
- else if (sd->state == _CHECK_STATE_CHECKED)
- sd->state = _CHECK_STATE_INDETERMINATE;
- else
- sd->state = _CHECK_STATE_UNCHECKED;
- }
-
+ sd->state = !sd->state;
if (sd->statep) *sd->statep = sd->state;
-
- if (!sd->three_state_mode)
+ if (sd->state)
{
- if (sd->state)
- {
- elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
- if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
- _elm_access_say(E_("State: On"));
- }
- else
- {
- elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
- if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
- _elm_access_say(E_("State: Off"));
- }
+ elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
+ if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
+ _elm_access_say(E_("State: On"));
}
else
{
- if (sd->state == _CHECK_STATE_CHECKED)
- {
- elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
- if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
- _elm_access_say(E_("State: On"));
- }
- else if (sd->state == _CHECK_STATE_UNCHECKED)
- {
- elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
- if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
- _elm_access_say(E_("State: Off"));
- }
- else
- {
- elm_layout_signal_emit(obj, "elm,state,check,indeterminate", "elm");
- if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
- _elm_access_say(E_("State: Indeterminate"));
- }
+ elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
+ if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
+ _elm_access_say(E_("State: Off"));
}
evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
eo_do_super(obj, ELM_CHECK_CLASS, states = elm_interface_atspi_accessible_state_set_get());
- if (elm_check_state_get(obj) == _CHECK_STATE_CHECKED)
- STATE_TYPE_SET(states, ELM_ATSPI_STATE_CHECKED);
- else if (elm_check_state_get(obj) == _CHECK_STATE_INDETERMINATE)
- STATE_TYPE_SET(states, ELM_ATSPI_STATE_INDETERMINATE);
+ if (elm_check_state_get(obj))
+ STATE_TYPE_SET(states, ELM_ATSPI_STATE_CHECKED);
return states;
}
eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
if (!int_ret) return EINA_FALSE;
- if (sd->state == _CHECK_STATE_UNCHECKED) elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
- else if (sd->state == _CHECK_STATE_CHECKED) elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
- else elm_layout_signal_emit(obj, "elm,state,check,indeterminate", "elm");
+ if (!sd->state) elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
+ else elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
edje_object_message_signal_process(wd->resize_obj);
_access_state_cb(void *data, Evas_Object *obj)
{
Elm_Check_Data *sd = eo_data_scope_get(data, MY_CLASS);
- const char *on_text, *off_text, *indeterminate_text;
+ const char *on_text, *off_text;
if (elm_widget_disabled_get(obj))
return strdup(E_("State: Disabled"));
- if (sd->state == _CHECK_STATE_CHECKED)
+ if (sd->state)
{
on_text = elm_layout_text_get(data, "on");
else
return strdup(E_("State: On"));
}
- else if (sd->state == _CHECK_STATE_UNCHECKED)
- {
- off_text = elm_layout_text_get(data, "off");
- if (off_text)
- {
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s: %s", E_("State"), off_text);
- return strdup(buf);
- }
- return strdup(E_("State: Off"));
- }
- else
+ off_text = elm_layout_text_get(data, "off");
+
+ if (off_text)
{
- indeterminate_text = elm_layout_text_get(data, "indeterminate");
+ char buf[1024];
- if (indeterminate_text)
- {
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s: %s", E_("State"), indeterminate_text);
- return strdup(buf);
- }
- return strdup(E_("State: indeterminate"));
+ snprintf(buf, sizeof(buf), "%s: %s", E_("State"), off_text);
+ return strdup(buf);
}
+ return strdup(E_("State: Off"));
}
static void
ELM_CHECK_DATA_GET(obj, sd);
- sd->state = _CHECK_STATE_UNCHECKED;
+ sd->state = EINA_FALSE;
if (sd->statep) *sd->statep = sd->state;
elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
ELM_CHECK_DATA_GET(obj, sd);
- sd->state = _CHECK_STATE_CHECKED;
+ sd->state = EINA_TRUE;
if (sd->statep) *sd->statep = sd->state;
elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
if (_elm_config->atspi_mode)
- elm_interface_atspi_accessible_state_changed_signal_emit(data,
- ELM_ATSPI_STATE_CHECKED,
- sd->state);
-}
-
-static void
-_on_check_indeterminate(void *data,
- Evas_Object *o EINA_UNUSED,
- const char *emission EINA_UNUSED,
- const char *source EINA_UNUSED)
-{
- Evas_Object *obj = data;
-
- ELM_CHECK_DATA_GET(obj, sd);
-
- sd->state = _CHECK_STATE_INDETERMINATE;
- if (sd->statep) *sd->statep = sd->state;
- elm_layout_signal_emit(obj, "elm,state,check,indeterminate", "elm");
- evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
-
- if (_elm_config->atspi_mode)
- elm_interface_atspi_accessible_state_changed_signal_emit(data,
- ELM_ATSPI_STATE_CHECKED,
- sd->state);
+ elm_interface_atspi_accessible_state_changed_signal_emit(data,
+ ELM_ATSPI_STATE_CHECKED,
+ sd->state);
}
static void
(wd->resize_obj, "elm,action,check,off", "*",
_on_check_off, obj);
edje_object_signal_callback_add
- (wd->resize_obj, "elm,action,check,indeterminate", "*",
- _on_check_indeterminate, obj);
- edje_object_signal_callback_add
(wd->resize_obj, "elm,action,check,toggle", "*",
_on_check_toggle, obj);
}
EOLIAN static void
-_elm_check_state_set(Eo *obj, Elm_Check_Data *sd, Check_State state)
+_elm_check_state_set(Eo *obj, Elm_Check_Data *sd, Eina_Bool state)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
{
sd->state = state;
if (sd->statep) *sd->statep = sd->state;
- if (sd->state == _CHECK_STATE_UNCHECKED)
- elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
- else if ((sd->state == _CHECK_STATE_CHECKED) || (!sd->three_state_mode))
+ if (sd->state)
elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
else
- elm_layout_signal_emit(obj, "elm,state,check,indeterminate", "elm");
+ elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
}
edje_object_message_signal_process(wd->resize_obj);
}
-EOLIAN static Check_State
+EOLIAN static Eina_Bool
_elm_check_state_get(Eo *obj EINA_UNUSED, Elm_Check_Data *sd)
{
return sd->state;
}
EOLIAN static void
-_elm_check_state_pointer_set(Eo *obj, Elm_Check_Data *sd, Check_State *statep)
+_elm_check_state_pointer_set(Eo *obj, Elm_Check_Data *sd, Eina_Bool *statep)
{
if (statep)
{
if (*sd->statep != sd->state)
{
sd->state = *sd->statep;
- if (sd->state == _CHECK_STATE_CHECKED)
+ if (sd->state)
elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
- else if (sd->state == _CHECK_STATE_UNCHECKED)
- elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
else
- elm_layout_signal_emit(obj, "elm,state,check,indeterminate", "elm");
+ elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
}
}
else
sd->statep = NULL;
}
-EOLIAN static void
-_elm_check_three_state_mode_set(Eo *obj, Elm_Check_Data *sd, Eina_Bool is_enabled)
-{
- ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
-
- if (is_enabled != sd->three_state_mode)
- {
- sd->three_state_mode = is_enabled;
- if ((!sd->three_state_mode) && (sd->state == _CHECK_STATE_INDETERMINATE))
- elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
- }
-
- edje_object_message_signal_process(wd->resize_obj);
-}
-
-EOLIAN static Eina_Bool
-_elm_check_three_state_mode_get(Eo *obj EINA_UNUSED, Elm_Check_Data *sd)
-{
- return sd->three_state_mode;
-}
-
EOLIAN static Eina_Bool
_elm_check_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED)
{