/* Called when the spinner's editable-object is pressed by the mouse */ static void _etk_spinner_editable_mouse_down_cb(void *data, Evas *evas, Evas_Object *object, void *event_info) { Etk_Spinner *spinner; Etk_Event_Mouse_Down event; Evas_Coord ox, oy; int pos; if (!(spinner = ETK_SPINNER(data))) return; etk_event_mouse_down_wrap(ETK_WIDGET(spinner), event_info, &event); evas_object_geometry_get(spinner->editable_object, &ox, &oy, NULL, NULL); pos = etk_editable_pos_get_from_coords(spinner->editable_object, event.canvas.x - ox, event.canvas.y - oy); if (event.button == 1) { if (event.flags & ETK_MOUSE_DOUBLE_CLICK) etk_editable_select_all(spinner->editable_object); else { etk_editable_cursor_pos_set(spinner->editable_object, pos); if (!(event.modifiers & ETK_MODIFIER_SHIFT)) etk_editable_selection_pos_set(spinner->editable_object, pos); spinner->selection_dragging = ETK_TRUE; } } else if (event.button == 2) { etk_editable_cursor_pos_set(spinner->editable_object, pos); etk_editable_selection_pos_set(spinner->editable_object, pos); etk_selection_text_request(ETK_SELECTION_PRIMARY, ETK_WIDGET(spinner)); } }
/* Called when the selection/clipboard content is received */ static Etk_Bool _etk_spinner_selection_received_cb(Etk_Object *object, void *event, void *data) { Etk_Spinner *spinner; Evas_Object *editable; Etk_Selection_Event *ev = event; const char *text; if (!(spinner = ETK_SPINNER(object)) || !(editable = spinner->editable_object)) return ETK_TRUE; if (ev->type == ETK_SELECTION_TEXT && (text = ev->data.text) && *text && (strlen(text) != 1 || text[0] >= 0x20)) { int cursor_pos, selection_pos; int start_pos, end_pos; Etk_Bool selecting; cursor_pos = etk_editable_cursor_pos_get(editable); selection_pos = etk_editable_selection_pos_get(editable); start_pos = ETK_MIN(cursor_pos, selection_pos); end_pos = ETK_MAX(cursor_pos, selection_pos); selecting = (start_pos != end_pos); if (selecting) etk_editable_delete(editable, start_pos, end_pos); etk_editable_insert(editable, start_pos, text); } return ETK_TRUE; }
/* Called when the spinner gets disabled */ static Etk_Bool _etk_spinner_disabled_cb(Etk_Object *object, void *data) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(object))) return ETK_TRUE; etk_editable_disabled_set(spinner->editable_object, ETK_TRUE); return ETK_TRUE; }
/* Resizes the spinner to the allocated size */ static void _etk_spinner_size_allocate(Etk_Widget *widget, Etk_Geometry geometry) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(widget))) return; evas_object_move(spinner->editable_object, geometry.x, geometry.y); evas_object_resize(spinner->editable_object, geometry.w, geometry.h); }
/* Called when the spinner is focused */ static Etk_Bool _etk_spinner_focused_cb(Etk_Object *object, void *data) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(object)) || !spinner->editable_object) return ETK_TRUE; etk_editable_cursor_show(spinner->editable_object); etk_editable_selection_show(spinner->editable_object); return ETK_TRUE; }
/* Called when the spinner is unrealized */ static Etk_Bool _etk_spinner_unrealized_cb(Etk_Object *object, void *data) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(object))) return ETK_TRUE; evas_object_del(spinner->editable_object); spinner->editable_object = NULL; return ETK_TRUE; }
/* Called when one of the arrows is released: it stops incrementing or decrementing the value */ static void _etk_spinner_step_stop_cb(void *data, Evas_Object *obj, const char *emission, const char *source) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(data))) return; if (spinner->step_timer) { ecore_timer_del(spinner->step_timer); spinner->step_timer = NULL; } }
/* Called when the spinner is realized */ static Etk_Bool _etk_spinner_realized_cb(Etk_Object *object, void *data) { Etk_Spinner *spinner; Evas_Object *theme_object; Evas *evas; if (!(spinner = ETK_SPINNER(object)) || !(evas = etk_widget_toplevel_evas_get(ETK_WIDGET(spinner)))) return ETK_TRUE; if (!(theme_object = ETK_WIDGET(spinner)->theme_object)) return ETK_TRUE; /* Create the editable object */ spinner->editable_object = etk_editable_add(evas); evas_object_show(spinner->editable_object); etk_widget_member_object_add(ETK_WIDGET(spinner), spinner->editable_object); etk_editable_theme_set(spinner->editable_object, etk_widget_theme_file_get(ETK_WIDGET(spinner)), etk_widget_theme_group_get(ETK_WIDGET(spinner))); etk_editable_align_set(spinner->editable_object, 1.0); if (!etk_widget_is_focused(ETK_WIDGET(spinner))) { etk_editable_cursor_hide(spinner->editable_object); etk_editable_selection_hide(spinner->editable_object); } if (etk_widget_disabled_get(ETK_WIDGET(spinner))) etk_editable_disabled_set(spinner->editable_object, ETK_TRUE); evas_object_event_callback_add(spinner->editable_object, EVAS_CALLBACK_MOUSE_IN, _etk_spinner_editable_mouse_in_cb, spinner); evas_object_event_callback_add(spinner->editable_object, EVAS_CALLBACK_MOUSE_OUT, _etk_spinner_editable_mouse_out_cb, spinner); evas_object_event_callback_add(spinner->editable_object, EVAS_CALLBACK_MOUSE_DOWN, _etk_spinner_editable_mouse_down_cb, spinner); evas_object_event_callback_add(spinner->editable_object, EVAS_CALLBACK_MOUSE_UP, _etk_spinner_editable_mouse_up_cb, spinner); evas_object_event_callback_add(spinner->editable_object, EVAS_CALLBACK_MOUSE_MOVE, _etk_spinner_editable_mouse_move_cb, spinner); /* Connect the "decrement"/"increment" edje signals to callbacks */ edje_object_signal_callback_add(theme_object, "etk,action,decrement,start", "", _etk_spinner_step_start_cb, spinner); edje_object_signal_callback_add(theme_object, "etk,action,increment,start", "", _etk_spinner_step_start_cb, spinner); edje_object_signal_callback_add(theme_object, "etk,action,decrement,stop", "", _etk_spinner_step_stop_cb, spinner); edje_object_signal_callback_add(theme_object, "etk,action,increment,stop", "", _etk_spinner_step_stop_cb, spinner); /* Update the text of the editable object */ _etk_spinner_update_text_from_value(spinner); return ETK_TRUE; }
/* A timer used to increment the value */ static int _etk_spinner_step_increment_timer_cb(void *data) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(data))) return 1; _etk_spinner_update_value_from_text(spinner); ecore_timer_interval_set(spinner->step_timer, (spinner->successive_steps == 0) ? FIRST_DELAY : REPEAT_DELAY); _etk_spinner_spin(spinner, ETK_RANGE(spinner)->step_increment); return 1; }
/* Called when the spinner's editable-object is released by the mouse */ static void _etk_spinner_editable_mouse_up_cb(void *data, Evas *evas, Evas_Object *object, void *event_info) { Etk_Spinner *spinner; Etk_Event_Mouse_Up event; if (!(spinner = ETK_SPINNER(data))) return; etk_event_mouse_up_wrap(ETK_WIDGET(spinner), event_info, &event); if (event.button == 1) { spinner->selection_dragging = ETK_FALSE; _etk_spinner_selection_copy(spinner, ETK_SELECTION_PRIMARY, ETK_FALSE); } }
/* Called when the step-increment of the spinner is changed: * We correct the value if the "snap-to-ticks" setting is on */ static void _etk_spinner_step_increment_changed_cb(Etk_Object *object, const char *property_name, void *data) { Etk_Spinner *spinner; double value; if (!(spinner = ETK_SPINNER(object))) return; if (spinner->snap_to_ticks) { value = etk_range_value_get(ETK_RANGE(spinner)); value = _etk_spinner_value_snap(spinner, value); etk_range_value_set(ETK_RANGE(spinner), value); } }
/* Called when a key is released while the spinner is focused */ static Etk_Bool _etk_spinner_key_up_cb(Etk_Object *object, Etk_Event_Key_Up *event, void *data) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(object))) return ETK_TRUE; if (strcmp(event->keyname, "Prior") == 0 || strcmp(event->keyname, "Next") == 0 || strcmp(event->keyname, "Up") == 0 || strcmp(event->keyname, "Down") == 0) { spinner->successive_steps = 0; } return ETK_TRUE; }
/* Called when the spinner is unfocused */ static Etk_Bool _etk_spinner_unfocused_cb(Etk_Object *object, void *data) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(object)) || !spinner->editable_object) return ETK_TRUE; etk_editable_cursor_move_to_end(spinner->editable_object); etk_editable_selection_move_to_end(spinner->editable_object); etk_editable_cursor_hide(spinner->editable_object); etk_editable_selection_hide(spinner->editable_object); _etk_spinner_update_value_from_text(spinner); return ETK_TRUE; }
static void evolve_gui_property_spinner_value_changed_cb(Etk_Range *range, double value) { Etk_Spinner *spinner; Evolve_Property *prop; Evolve_Widget *widget; char value_str[64]; if (!(spinner = ETK_SPINNER(range))) return; prop = etk_object_data_get(ETK_OBJECT(spinner), "prop"); widget = etk_object_data_get(ETK_OBJECT(spinner), "widget"); snprintf(value_str, sizeof(value_str), "%f", value); evolve_widget_property_set(widget, prop->name, value_str, prop->type); }
/* Called when one of the arrows is pressed: it starts to increment or decrement the value */ static void _etk_spinner_step_start_cb(void *data, Evas_Object *obj, const char *emission, const char *source) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(data))) return; if (spinner->step_timer) { ecore_timer_del(spinner->step_timer); spinner->step_timer = NULL; } spinner->successive_steps = 0; if (strcmp(emission, "etk,action,decrement,start") == 0) spinner->step_timer = ecore_timer_add(0.0, _etk_spinner_step_decrement_timer_cb, spinner); else if (strcmp(emission, "etk,action,increment,start") == 0) spinner->step_timer = ecore_timer_add(0.0, _etk_spinner_step_increment_timer_cb, spinner); }
/* Default handler for the "value-changed" signal of a spinner */ static Etk_Bool _etk_spinner_value_changed_handler(Etk_Range *range, double value) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(range))) return ETK_TRUE; if (spinner->snap_to_ticks) { double new_value; new_value = _etk_spinner_value_snap(spinner, value); if (value != range->lower && value != range->upper && value != value) etk_range_value_set(ETK_RANGE(spinner), new_value); } _etk_spinner_update_text_from_value(spinner); return ETK_TRUE; }
/* Called when the mouse moves over the spinner's editable-object */ static void _etk_spinner_editable_mouse_move_cb(void *data, Evas *evas, Evas_Object *object, void *event_info) { Etk_Spinner *spinner; Etk_Event_Mouse_Move event; Evas_Coord ox, oy; int pos; if (!(spinner = ETK_SPINNER(data))) return; if (spinner->selection_dragging) { etk_event_mouse_move_wrap(ETK_WIDGET(spinner), event_info, &event); evas_object_geometry_get(spinner->editable_object, &ox, &oy, NULL, NULL); pos = etk_editable_pos_get_from_coords(spinner->editable_object, event.cur.canvas.x - ox, event.cur.canvas.y - oy); if (pos >= 0) etk_editable_cursor_pos_set(spinner->editable_object, pos); } }
/* Gets the value of the property whose id is "property_id" */ static void _etk_spinner_property_get(Etk_Object *object, int property_id, Etk_Property_Value *value) { Etk_Spinner *spinner; if (!(spinner = ETK_SPINNER(object)) || !value) return; switch (property_id) { case ETK_SPINNER_DIGITS_PROPERTY: etk_property_value_int_set(value, spinner->digits); break; case ETK_SPINNER_SNAP_TO_TICKS_PROPERTY: etk_property_value_bool_set(value, spinner->snap_to_ticks); break; case ETK_SPINNER_WRAP_PROPERTY: etk_property_value_bool_set(value, spinner->wrap); break; default: break; } }
void evolve_gui_general_table_populate(Evolve_Widget *widget) { Etk_Widget *label; Etk_Widget *entry; Etk_Type *type; Eina_List *l, *list = NULL; char *str; int i = 2; if (!widget || !widget->type || !(type = evolve_widget_type_to_etk(widget->type))) return; etk_type_property_list(type, &list); etk_table_resize(ETK_TABLE(_evolve_gui_gen_table), 0, 0); etk_table_resize(ETK_TABLE(_evolve_gui_gen_table), 2, eina_list_count(list) + 2); label = etk_label_new("Class:"); entry = etk_entry_new(); etk_entry_text_set(ETK_ENTRY(entry), type->name); etk_widget_disabled_set(entry, ETK_TRUE); etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), label, 0, 0, 0, 0); etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), entry, 1, 1, 0, 0); label = etk_label_new("Name:"); entry = etk_entry_new(); etk_entry_text_set(ETK_ENTRY(entry), widget->name); etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), label, 0, 0, 1, 1); etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), entry, 1, 1, 1, 1); for (l = list; l; l = l->next) { Evolve_Property *prop; Evolve_Property *eprop; Evolve_Property *p; Etk_String *value; Etk_Widget *vwidget; if (!(prop = l->data)) continue; str = evolve_util_string_humanize(prop->name); label = etk_label_new(str); free(str); eprop = evolve_widget_property_get(widget, prop->name); if (eprop && eprop->default_value) p = eprop; else p = prop; switch(prop->type) { case EVOLVE_PROPERTY_INT: value = etk_string_new_printf("%d", evolve_property_value_int_get(p->default_value)); vwidget = etk_spinner_new(0, 9999, evolve_property_value_int_get(p->default_value), 1, 10); etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL); etk_object_data_set_full(ETK_OBJECT(vwidget), "widget", widget, NULL); etk_signal_connect("value-changed", ETK_OBJECT(vwidget), ETK_CALLBACK(evolve_gui_property_spinner_value_changed_cb), NULL); break; case EVOLVE_PROPERTY_BOOL: value = etk_string_new_printf("%d", evolve_property_value_bool_get(p->default_value)); vwidget = etk_combobox_new_default(); { Etk_Combobox_Item *item; item = etk_combobox_item_append(ETK_COMBOBOX(vwidget), "True"); if (evolve_property_value_bool_get(p->default_value)) etk_combobox_active_item_set(ETK_COMBOBOX(vwidget), item); item = etk_combobox_item_append(ETK_COMBOBOX(vwidget), "False"); if (!evolve_property_value_bool_get(p->default_value)) etk_combobox_active_item_set(ETK_COMBOBOX(vwidget), item); } break; case EVOLVE_PROPERTY_CHAR: value = etk_string_new_printf("%c", evolve_property_value_char_get(p->default_value)); vwidget = etk_entry_new(); etk_entry_text_set(ETK_ENTRY(vwidget), etk_string_get(value)); etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL); etk_signal_connect("text-changed", ETK_OBJECT(vwidget), ETK_CALLBACK(evolve_gui_property_entry_text_changed_cb), widget); break; case EVOLVE_PROPERTY_FLOAT: value = etk_string_new_printf("%f", evolve_property_value_float_get(p->default_value)); vwidget = etk_spinner_new(0.0, 9999.0, evolve_property_value_float_get(p->default_value), 0.1, 1.0); etk_spinner_digits_set(ETK_SPINNER(vwidget), 1); etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL); etk_object_data_set_full(ETK_OBJECT(vwidget), "widget", widget, NULL); etk_signal_connect("value-changed", ETK_OBJECT(vwidget), ETK_CALLBACK(evolve_gui_property_spinner_value_changed_cb), NULL); break; case EVOLVE_PROPERTY_DOUBLE: value = etk_string_new_printf("%g", evolve_property_value_double_get(p->default_value)); vwidget = etk_spinner_new(0.0, 9999.0, evolve_property_value_double_get(p->default_value), 0.1, 1.0); etk_spinner_digits_set(ETK_SPINNER(vwidget), 1); etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL); etk_object_data_set_full(ETK_OBJECT(vwidget), "widget", widget, NULL); etk_signal_connect("value-changed", ETK_OBJECT(vwidget), ETK_CALLBACK(evolve_gui_property_spinner_value_changed_cb), NULL); break; case EVOLVE_PROPERTY_SHORT: value = etk_string_new_printf("%d", evolve_property_value_short_get(p->default_value)); vwidget = etk_spinner_new(0, 9999, evolve_property_value_short_get(p->default_value), 1, 10); etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL); etk_object_data_set_full(ETK_OBJECT(vwidget), "widget", widget, NULL); etk_signal_connect("value-changed", ETK_OBJECT(vwidget), ETK_CALLBACK(evolve_gui_property_spinner_value_changed_cb), NULL); break; case EVOLVE_PROPERTY_LONG: value = etk_string_new_printf("%li", evolve_property_value_long_get(p->default_value)); vwidget = etk_spinner_new(0, 9999, evolve_property_value_long_get(p->default_value), 1, 10); etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL); etk_object_data_set_full(ETK_OBJECT(vwidget), "widget", widget, NULL); etk_signal_connect("value-changed", ETK_OBJECT(vwidget), ETK_CALLBACK(evolve_gui_property_spinner_value_changed_cb), NULL); break; case EVOLVE_PROPERTY_POINTER: value = etk_string_new_printf("cant cast PROPERTY_POINTER"); vwidget = etk_entry_new(); etk_entry_text_set(ETK_ENTRY(vwidget), etk_string_get(value)); etk_widget_disabled_set(vwidget, ETK_TRUE); break; case EVOLVE_PROPERTY_STRING: value = etk_string_new_printf("%s", evolve_property_value_string_get(p->default_value)); vwidget = etk_entry_new(); etk_entry_text_set(ETK_ENTRY(vwidget), etk_string_get(value)); etk_entry_text_set(ETK_ENTRY(vwidget), etk_string_get(value)); etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL); etk_signal_connect("text-changed", ETK_OBJECT(vwidget), ETK_CALLBACK(evolve_gui_property_entry_text_changed_cb), widget); break; default: value = etk_string_new_printf("cant determine value"); vwidget = etk_entry_new(); etk_entry_text_set(ETK_ENTRY(vwidget), etk_string_get(value)); break; } if (p == prop) { int type; type = prop->type; evolve_widget_property_set(widget, prop->name, etk_string_get(value), type); eprop = evolve_widget_property_get(widget, prop->name); } etk_object_destroy(ETK_OBJECT(value)); etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), label, 0, 0, i, i); etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), vwidget, 1, 1, i, i); ++i; } etk_widget_show_all(_evolve_gui_gen_table); }
/* Called when the user presses a key */ static Etk_Bool _etk_spinner_key_down_cb(Etk_Object *object, Etk_Event_Key_Down *event, void *data) { Etk_Spinner *spinner; Etk_Range *range; Evas_Object *editable; int cursor_pos, selection_pos; int start_pos, end_pos; int climb_factor; Etk_Bool selecting; Etk_Bool changed = ETK_FALSE; Etk_Bool selection_changed = ETK_FALSE; Etk_Bool stop_signal = ETK_TRUE; if (!(spinner = ETK_SPINNER(object))) return ETK_TRUE; range = ETK_RANGE(spinner); editable = spinner->editable_object; cursor_pos = etk_editable_cursor_pos_get(editable); selection_pos = etk_editable_selection_pos_get(editable); start_pos = ETK_MIN(cursor_pos, selection_pos); end_pos = ETK_MAX(cursor_pos, selection_pos); selecting = (start_pos != end_pos); /* TODO: increment faster if the key has been pressed for a long time... */ climb_factor = 1; /* Move the cursor/selection to the left */ if (strcmp(event->keyname, "Left") == 0) { if (event->modifiers & ETK_MODIFIER_SHIFT) { etk_editable_cursor_move_left(editable); selection_changed = ETK_TRUE; } else if (selecting) { if (cursor_pos < selection_pos) etk_editable_selection_pos_set(editable, cursor_pos); else etk_editable_cursor_pos_set(editable, selection_pos); } else { etk_editable_cursor_move_left(editable); etk_editable_selection_pos_set(editable, etk_editable_cursor_pos_get(editable)); } } /* Move the cursor/selection to the right */ else if (strcmp(event->keyname, "Right") == 0) { if (event->modifiers & ETK_MODIFIER_SHIFT) { etk_editable_cursor_move_right(editable); selection_changed = ETK_TRUE; } else if (selecting) { if (cursor_pos > selection_pos) etk_editable_selection_pos_set(editable, cursor_pos); else etk_editable_cursor_pos_set(editable, selection_pos); } else { etk_editable_cursor_move_right(editable); etk_editable_selection_pos_set(editable, etk_editable_cursor_pos_get(editable)); } } /* Move the cursor/selection to the start of the spinner */ else if (strcmp(event->keyname, "Home") == 0) { etk_editable_cursor_move_to_start(editable); if (!(event->modifiers & ETK_MODIFIER_SHIFT)) etk_editable_selection_pos_set(editable, etk_editable_cursor_pos_get(editable)); else selection_changed = ETK_TRUE; } /* Move the cursor/selection to the end of the spinner */ else if (strcmp(event->keyname, "End") == 0) { etk_editable_cursor_move_to_end(editable); if (!(event->modifiers & ETK_MODIFIER_SHIFT)) etk_editable_selection_pos_set(editable, etk_editable_cursor_pos_get(editable)); else selection_changed = ETK_TRUE; } /* Delete the previous character */ else if (strcmp(event->keyname, "BackSpace") == 0) { if (selecting) changed = etk_editable_delete(editable, start_pos, end_pos); else changed = etk_editable_delete(editable, cursor_pos - 1, cursor_pos); } /* Delete the next character */ else if (strcmp(event->keyname, "Delete") == 0) { if (selecting) changed = etk_editable_delete(editable, start_pos, end_pos); else changed = etk_editable_delete(editable, cursor_pos, cursor_pos + 1); } /* Increment the value */ else if (strcmp(event->keyname, "Up") == 0) { _etk_spinner_spin(spinner, climb_factor * range->step_increment); } /* Decrement the value */ else if (strcmp(event->keyname, "Down") == 0) { _etk_spinner_spin(spinner, -(climb_factor * range->step_increment)); } /* Increment the value by the page-increment */ else if (strcmp(event->keyname, "Prior") == 0) { _etk_spinner_spin(spinner, climb_factor * range->page_increment); } /* Decrement the value by the page-increment */ else if (strcmp(event->keyname, "Next") == 0) { _etk_spinner_spin(spinner, -(climb_factor * range->page_increment)); } /* Validate the value entered in the spinner */ else if (strcmp(event->keyname, "Return") == 0 || strcmp(event->keyname, "KP_Enter") == 0) { _etk_spinner_update_value_from_text(spinner); } /* Ctrl + A,C,X,V */ else if (event->modifiers & ETK_MODIFIER_CTRL) { if (strcmp(event->keyname, "a") == 0) { etk_editable_select_all(editable); selection_changed = ETK_TRUE; } else if (strcmp(event->keyname, "x") == 0 || strcmp(event->keyname, "c") == 0) _etk_spinner_selection_copy(spinner, ETK_SELECTION_CLIPBOARD, (strcmp(event->keyname, "x") == 0)); else if (strcmp(event->keyname, "v") == 0) etk_selection_text_request(ETK_SELECTION_CLIPBOARD, ETK_WIDGET(spinner)); else stop_signal = ETK_FALSE; } /* Otherwise, we insert the corresponding character */ else if (event->string && *event->string && (strlen(event->string) != 1 || event->string[0] >= 0x20)) { if (selecting) changed |= etk_editable_delete(editable, start_pos, end_pos); changed |= etk_editable_insert(editable, start_pos, event->string); } else stop_signal = ETK_FALSE; if (selection_changed) _etk_spinner_selection_copy(spinner, ETK_SELECTION_PRIMARY, ETK_FALSE); return (!stop_signal); }
/*** Implementation ***/ Etk_Widget* state_frame_create(void) { Etk_Widget *vbox; Etk_Widget *hbox; Etk_Widget *label; Etk_Combobox_Item *ComboItem; //vbox vbox = etk_vbox_new(ETK_FALSE, 0); // etk_container_add(ETK_CONTAINER(UI_DescriptionFrame), vbox); //hbox hbox = etk_hbox_new(ETK_FALSE, 0); etk_box_append(ETK_BOX(vbox), hbox, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); label = etk_label_new("<b>Name</b>"); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); //StateEntry UI_StateEntry = etk_entry_new(); UI_StateEntryImage = etk_image_new_from_stock(ETK_STOCK_DIALOG_OK, ETK_STOCK_SMALL); etk_entry_image_set(ETK_ENTRY(UI_StateEntry), ETK_ENTRY_IMAGE_SECONDARY, ETK_IMAGE(UI_StateEntryImage)); etk_box_append(ETK_BOX(hbox), UI_StateEntry, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); //UI_StateIndexSpinner //~ UI_StateIndexSpinner = etk_spinner_new(0.0, 1.0, 0.0, 0.1, 1.0); //~ etk_spinner_digits_set(ETK_SPINNER(UI_StateIndexSpinner), 1); //~ etk_widget_size_request_set(UI_StateIndexSpinner,45, 20); //~ etk_box_append(ETK_BOX(hbox),UI_StateIndexSpinner, ETK_BOX_START, ETK_BOX_NONE, 0); //hbox hbox = etk_hbox_new(ETK_FALSE, 0); etk_box_append(ETK_BOX(vbox), hbox, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); label = etk_label_new("<b>Aspect</b>"); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); label = etk_label_new("min:"); etk_object_properties_set(ETK_OBJECT(label), "xalign", 1.0, NULL); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_NONE, 0); //UI_AspectMinSpinner UI_AspectMinSpinner = etk_spinner_new(0.0, 100.0, 0.0, 0.1, 1.0); etk_spinner_digits_set(ETK_SPINNER(UI_AspectMinSpinner), 1); etk_widget_size_request_set(UI_AspectMinSpinner,45, 20); etk_box_append(ETK_BOX(hbox), UI_AspectMinSpinner, ETK_BOX_START, ETK_BOX_NONE, 0); label = etk_label_new("max:"); etk_object_properties_set(ETK_OBJECT(label), "xalign", 1.0, NULL); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_NONE, 0); //UI_AspectMaxSpinner UI_AspectMaxSpinner = etk_spinner_new(0.0, 100.0, 0.0, 0.1, 1.0); etk_spinner_digits_set(ETK_SPINNER(UI_AspectMaxSpinner), 1); etk_widget_size_request_set(UI_AspectMaxSpinner, 45, 20); etk_box_append(ETK_BOX(hbox), UI_AspectMaxSpinner, ETK_BOX_START, ETK_BOX_NONE, 0); //UI_AspectCombo UI_AspectComboBox = etk_combobox_new(); etk_combobox_column_add(ETK_COMBOBOX(UI_AspectComboBox), ETK_COMBOBOX_LABEL, 30, ETK_COMBOBOX_NONE, 0.0); etk_combobox_build(ETK_COMBOBOX(UI_AspectComboBox)); etk_box_append(ETK_BOX(hbox), UI_AspectComboBox, ETK_BOX_START, ETK_BOX_NONE, 0); ComboItem = etk_combobox_item_append(ETK_COMBOBOX(UI_AspectComboBox), "None"); etk_combobox_item_data_set(ComboItem, (void*)EDJE_ASPECT_PREFER_NONE); ComboItem = etk_combobox_item_append(ETK_COMBOBOX(UI_AspectComboBox), "Vertical"); etk_combobox_item_data_set(ComboItem, (void*)EDJE_ASPECT_PREFER_VERTICAL); ComboItem = etk_combobox_item_append(ETK_COMBOBOX(UI_AspectComboBox), "Horizontal"); etk_combobox_item_data_set(ComboItem, (void*)EDJE_ASPECT_PREFER_HORIZONTAL); ComboItem = etk_combobox_item_append(ETK_COMBOBOX(UI_AspectComboBox), "Both"); etk_combobox_item_data_set(ComboItem, (void*)EDJE_ASPECT_PREFER_BOTH); //hbox hbox = etk_hbox_new(ETK_FALSE, 0); etk_box_append(ETK_BOX(vbox), hbox, ETK_BOX_START, ETK_BOX_NONE, 0); label = etk_label_new("<b>Size</b> min"); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_NONE, 0); //UI_StateMinWSpinner UI_StateMinWSpinner = etk_spinner_new(0, 2000, 0, 1, 10); etk_widget_size_request_set(UI_StateMinWSpinner, 45, 20); etk_box_append(ETK_BOX(hbox), UI_StateMinWSpinner, ETK_BOX_START, ETK_BOX_NONE, 0); label = etk_label_new("x"); etk_object_properties_set(ETK_OBJECT(label), "xalign", 0.5, NULL); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_NONE, 0); //UI_StateMinHSpinner UI_StateMinHSpinner = etk_spinner_new(0, 2000, 0, 1, 10); etk_widget_size_request_set(UI_StateMinHSpinner, 45, 20); etk_box_append(ETK_BOX(hbox), UI_StateMinHSpinner, ETK_BOX_START, ETK_BOX_NONE, 0); label = etk_label_new("max"); etk_object_properties_set(ETK_OBJECT(label), "xalign", 1.0, NULL); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); //UI_StateMaxWSpinner UI_StateMaxWSpinner = etk_spinner_new(0, 2000, 0, 1, 10); etk_widget_size_request_set(UI_StateMaxWSpinner, 45, 20); etk_box_append(ETK_BOX(hbox), UI_StateMaxWSpinner, ETK_BOX_START, ETK_BOX_NONE, 0); label = etk_label_new("x"); etk_object_properties_set(ETK_OBJECT(label), "xalign", 0.5, NULL); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_NONE, 0); //UI_StateMaxHspinner UI_StateMaxHSpinner = etk_spinner_new(0, 2000, 0, 1, 10); etk_widget_size_request_set(UI_StateMaxHSpinner, 45, 20); etk_box_append(ETK_BOX(hbox), UI_StateMaxHSpinner, ETK_BOX_START, ETK_BOX_NONE, 0); //hbox hbox = etk_hbox_new(ETK_FALSE, 0); etk_box_append(ETK_BOX(vbox), hbox, ETK_BOX_START, ETK_BOX_NONE, 0); //UI_StateAlignHSpinner label = etk_label_new("<b>Align</b> H"); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_NONE, 0); UI_StateAlignHSpinner = etk_spinner_new(0, 1, 0, 0.01, 0.1); etk_spinner_digits_set(ETK_SPINNER(UI_StateAlignHSpinner), 2); etk_widget_size_request_set(UI_StateAlignHSpinner, 45, 20); etk_box_append(ETK_BOX(hbox), UI_StateAlignHSpinner, ETK_BOX_START, ETK_BOX_NONE, 0); //UI_StateAlignVSpinner label = etk_label_new("V"); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_NONE, 0); UI_StateAlignVSpinner = etk_spinner_new(0, 1, 0, 0.01, 0.1); etk_spinner_digits_set(ETK_SPINNER(UI_StateAlignVSpinner), 2); etk_widget_size_request_set(UI_StateAlignVSpinner, 45, 20); etk_box_append(ETK_BOX(hbox), UI_StateAlignVSpinner, ETK_BOX_START, ETK_BOX_NONE, 0); //UI_StateVisibleCheck UI_StateVisibleCheck = etk_check_button_new_with_label("Visible"); etk_widget_padding_set(UI_StateVisibleCheck, 20, 0, 0, 0); etk_box_append(ETK_BOX(hbox), UI_StateVisibleCheck, ETK_BOX_START, ETK_BOX_NONE, 0); //hbox hbox = etk_hbox_new(ETK_FALSE, 0); etk_box_append(ETK_BOX(vbox), hbox, ETK_BOX_START, ETK_BOX_NONE, 0); //UI_StateCCEntry label = etk_label_new("Color Class"); etk_box_append(ETK_BOX(hbox), label, ETK_BOX_START, ETK_BOX_NONE, 0); UI_StateCCEntry = etk_entry_new(); etk_box_append(ETK_BOX(hbox), UI_StateCCEntry, ETK_BOX_START, ETK_BOX_NONE, 0); etk_signal_connect("key-down", ETK_OBJECT(UI_StateEntry), ETK_CALLBACK(_state_Entry_key_down_cb), NULL); etk_signal_connect("mouse-click", ETK_OBJECT(UI_StateEntryImage), ETK_CALLBACK(_state_EntryImage_clicked_cb), NULL); etk_signal_connect("text-changed", ETK_OBJECT(UI_StateEntry), ETK_CALLBACK(_group_NamesEntry_text_changed_cb), NULL); etk_signal_connect("value-changed", ETK_OBJECT(UI_AspectMinSpinner), ETK_CALLBACK(_state_AspectSpinner_value_changed_cb), NULL); etk_signal_connect("value-changed", ETK_OBJECT(UI_AspectMaxSpinner), ETK_CALLBACK(_state_AspectSpinner_value_changed_cb), NULL); etk_signal_connect("active-item-changed", ETK_OBJECT(UI_AspectComboBox), ETK_CALLBACK(_state_AspectComboBox_changed_cb), NULL); etk_signal_connect("value-changed", ETK_OBJECT(UI_StateMinWSpinner), ETK_CALLBACK(_state_MinMaxSpinner_value_changed_cb), NULL); etk_signal_connect("value-changed", ETK_OBJECT(UI_StateMinHSpinner), ETK_CALLBACK(_state_MinMaxSpinner_value_changed_cb), NULL); etk_signal_connect("value-changed", ETK_OBJECT(UI_StateMaxWSpinner), ETK_CALLBACK(_state_MinMaxSpinner_value_changed_cb), NULL); etk_signal_connect("value-changed", ETK_OBJECT(UI_StateMaxHSpinner), ETK_CALLBACK(_state_MinMaxSpinner_value_changed_cb), NULL); etk_signal_connect("value-changed", ETK_OBJECT(UI_StateAlignVSpinner), ETK_CALLBACK(_text_FontAlignSpinner_value_changed_cb), (void*)STATE_ALIGNV_SPINNER); etk_signal_connect("value-changed", ETK_OBJECT(UI_StateAlignHSpinner), ETK_CALLBACK(_text_FontAlignSpinner_value_changed_cb), (void*)STATE_ALIGNH_SPINNER); etk_signal_connect("toggled", ETK_OBJECT(UI_StateVisibleCheck), ETK_CALLBACK(_state_VisibleCheck_toggled_cb), NULL); etk_signal_connect("text-changed", ETK_OBJECT(UI_StateCCEntry), ETK_CALLBACK(_state_CCEntry_text_changed_cb), NULL); return vbox; }