EAPI Eina_Bool e_icon_file_get(const Evas_Object *obj, const char **file, const char **group) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(EINA_FALSE); if ((!file) && (!group)) return EINA_FALSE; if (file) *file = NULL; if (group) *group = NULL; if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; #ifdef USE_ICON_CACHE if (sd->file) { if (file) *file = sd->file; return EINA_TRUE; } #endif if (sd->edje) { edje_object_file_get(sd->obj, file, group); return file || group; } evas_object_image_file_get(sd->obj, file, group); return file || group; }
/** * Gets a range of the text of the editable object, from position @a start to * position @a end * * @param editable an editable object * @param start the start position of the text range to get * @param end the end position of the text range to get * @return Returns the range of text. The returned string will have to be freed */ EAPI char * e_editable_text_range_get(Evas_Object *editable, int start, int end) { E_Editable_Smart_Data *sd; char *range; int start_id = 0, end_id = 0, i; if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERR(NULL); if ((!editable) || (!(sd = evas_object_smart_data_get(editable)))) return NULL; start = E_CLAMP(start, 0, sd->unicode_length); end = E_CLAMP(end, 0, sd->unicode_length); if (end <= start) return NULL; for (i = 0; i < end; i++) { end_id = evas_string_char_next_get(sd->text, end_id, NULL); if (i < start) start_id = end_id; } if (end_id <= start_id) return NULL; range = malloc((end_id - start_id + 1) * sizeof(char)); strncpy(range, &sd->text[start_id], end_id - start_id); range[end_id - start_id] = '\0'; return range; }
EAPI void e_icon_object_set(Evas_Object *obj, Evas_Object *o) { E_Smart_Data *sd; const char *str; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(); if (!(sd = evas_object_smart_data_get(obj))) return; str = evas_object_type_get(o); if ((!str) || strcmp(str, "image")) CRI(EINA_COLOR_RED"******************\ntrying to set an image object of type '%s'! this is not what you want!\n******************\n"EINA_COLOR_RESET, str); if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; /* smart code here */ if (sd->obj) evas_object_del(sd->obj); sd->loading = 0; sd->obj = o; evas_object_smart_member_add(sd->obj, obj); if (evas_object_visible_get(obj)) evas_object_show(sd->obj); _e_icon_smart_reconfigure(sd); }
EAPI Eina_Bool e_icon_file_edje_set(Evas_Object *obj, const char *file, const char *part) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; /* smart code here */ if (sd->obj) evas_object_del(sd->obj); sd->loading = 0; if (sd->fdo) { eina_stringshare_del(sd->fdo); sd->fdo = NULL; } if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_TRUE; sd->obj = edje_object_add(evas_object_evas_get(obj)); edje_object_file_set(sd->obj, file, part); if (edje_object_load_error_get(sd->obj) != EDJE_LOAD_ERROR_NONE) return EINA_FALSE; if (evas_object_visible_get(obj)) evas_object_show(sd->obj); evas_object_smart_member_add(sd->obj, obj); _e_icon_smart_reconfigure(sd); return EINA_TRUE; }
EAPI void e_icon_edje_object_set(Evas_Object *obj, Evas_Object *edje) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(); if (!(sd = evas_object_smart_data_get(obj))) return; /* smart code here */ if (sd->obj) evas_object_del(sd->obj); sd->loading = 0; if (sd->fdo) { eina_stringshare_del(sd->fdo); sd->fdo = NULL; } if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_TRUE; sd->obj = edje; if (evas_object_visible_get(obj)) evas_object_show(sd->obj); evas_object_smart_member_add(sd->obj, obj); _e_icon_smart_reconfigure(sd); }
/** * Deletes the text of the editable object, between position "start" and * position "end" * * @param editable the editable object in which the text should be deleted * @param start the position of the first char to delete * @param end the position of the last char to delete * @return Returns 1 if the text has been modified, 0 otherwise */ EAPI int e_editable_delete(Evas_Object *editable, int start, int end) { E_Editable_Smart_Data *sd; int unicode_length; if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERR(0); if ((!editable) || (!(sd = evas_object_smart_data_get(editable)))) return 0; unicode_length = _e_editable_text_delete(editable, start, end); if (unicode_length <= 0) return 0; if (sd->cursor_pos > end) e_editable_cursor_pos_set(editable, sd->cursor_pos - unicode_length); else if (sd->cursor_pos > start) e_editable_cursor_pos_set(editable, start); if (sd->selection_pos > end) e_editable_selection_pos_set(editable, sd->selection_pos - unicode_length); else if (sd->selection_pos > start) e_editable_selection_pos_set(editable, start); _e_editable_text_position_update(editable, -1); return 1; }
EAPI Eina_Bool e_icon_scale_up_get(const Evas_Object *obj) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; return sd->scale_up; }
EAPI int e_icon_scale_size_get(const Evas_Object *obj) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); if (!(sd = evas_object_smart_data_get(obj))) return 0; return sd->size; }
EAPI Eina_Bool e_icon_alpha_get(const Evas_Object *obj) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; if (sd->edje) return EINA_FALSE; return evas_object_image_alpha_get(sd->obj); }
/** * Gets the editable object used by the entry object. It will allow you to have * better control on the text, the cursor or the selection of the entry with * the e_editable_*() functions. * * @param entry an entry object * @return Returns the editable object used by the entry object */ EAPI Evas_Object * e_entry_editable_object_get(Evas_Object *entry) { E_Entry_Smart_Data *sd; if (evas_object_smart_smart_get(entry) != _e_entry_smart) SMARTERR(NULL); if ((!entry) || (!(sd = evas_object_smart_data_get(entry)))) return NULL; return sd->editable_object; }
/** * Gets the unicode length of the text of the editable object. The unicode * length is not always the length returned by strlen() since a UTF-8 char can * take several bytes * * @param editable an editable object * @return Returns the unicode length of the text of the editable object */ EAPI int e_editable_text_length_get(Evas_Object *editable) { E_Editable_Smart_Data *sd; if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERR(0); if ((!editable) || (!(sd = evas_object_smart_data_get(editable)))) return 0; return sd->unicode_length; }
/** * Gets the position of the selection bound of the editable object * * @param editable an editable object * @return Returns the position of the selection bound of the editable object */ EAPI int e_editable_selection_pos_get(Evas_Object *editable) { E_Editable_Smart_Data *sd; if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERR(0); if ((!editable) || (!(sd = evas_object_smart_data_get(editable)))) return 0; return sd->selection_pos; }
/** * Gets the entire text of the editable object * * @param editable an editable object * @return Returns the entire text of the editable object */ EAPI const char * e_editable_text_get(Evas_Object *editable) { E_Editable_Smart_Data *sd; if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERR(NULL); if ((!editable) || (!(sd = evas_object_smart_data_get(editable)))) return NULL; return sd->text; }
/** * Gets whether or not the editable is in password mode * * @param editable an editable object * @return Returns 1 if the editable object is in the password mode, 0 otherwise */ EAPI int e_editable_password_get(Evas_Object *editable) { E_Editable_Smart_Data *sd; if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERR(0); if ((!editable) || (!(sd = evas_object_smart_data_get(editable)))) return 0; return sd->password_mode; }
EAPI int e_table_freeze(Evas_Object *obj) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); sd = evas_object_smart_data_get(obj); sd->frozen++; return sd->frozen; }
EAPI int e_table_thaw(Evas_Object *obj) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); sd = evas_object_smart_data_get(obj); sd->frozen--; if (sd->frozen <= 0) _e_table_smart_reconfigure(sd); return sd->frozen; }
EAPI void * e_icon_data_get(const Evas_Object *obj, int *w, int *h) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(NULL); if (!(sd = evas_object_smart_data_get(obj))) return NULL; if (sd->edje) return NULL; evas_object_image_size_get(sd->obj, w, h); return evas_object_image_data_get(sd->obj, 0); }
/** * Gets the cursor position at the coords ( @a x, @a y ). It's used to know * where to place the cursor or the selection bound on mouse evevents. * * @param editable an editable object * @param x the x coord, relative to the editable object * @param y the y coord, relative to the editable object * @return Returns the position where to place the cursor according to the * given coords */ EAPI int e_editable_pos_get_from_coords(Evas_Object *editable, Evas_Coord x, Evas_Coord y) { E_Editable_Smart_Data *sd; const Evas_Object *text_obj; Evas_Coord ox, oy; Evas_Coord tx, ty, tw, th; Evas_Coord cx, cw; Evas_Coord canvas_x, canvas_y; int index, pos, i, j; const char *text; if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERR(0); if ((!editable) || (!(sd = evas_object_smart_data_get(editable)))) return 0; if (!(text_obj = edje_object_part_object_get(sd->text_object, "e.text.text"))) return 0; evas_object_geometry_get(editable, &ox, &oy, NULL, NULL); evas_object_geometry_get(text_obj, &tx, &ty, &tw, &th); canvas_x = ox + x; canvas_y = oy + y; if ((canvas_y < ty) || (canvas_x < tx)) pos = 0; else if ((canvas_y > (ty + th)) || (canvas_x > (tx + tw))) pos = sd->unicode_length; else { index = evas_object_text_char_coords_get(text_obj, canvas_x - tx, canvas_y - ty, &cx, NULL, &cw, NULL); text = evas_object_text_text_get(text_obj); if ((index >= 0) && (text)) { if ((canvas_x - tx) > (cx + (cw / 2))) index++; i = 0; j = -1; pos = 0; while ((i < index) && (j != i)) { pos++; j = i; i = evas_string_char_next_get(text, i, NULL); } if (pos > sd->unicode_length) pos = sd->unicode_length; } else pos = 0; } return pos; }
EAPI Eina_Bool e_icon_fdo_icon_set(Evas_Object *obj, const char *icon) { E_Smart_Data *sd; const char *path; int len; if (!icon) return EINA_FALSE; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); if (icon[0] == '/') return e_icon_file_set(obj, icon); if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; eina_stringshare_replace(&sd->fdo, icon); if (!sd->fdo) return EINA_FALSE; path = efreet_icon_path_find(e_config->icon_theme, sd->fdo, sd->size); if (!path) return EINA_FALSE; len = strlen(icon); if ((len > 4) && (!strcasecmp(icon + len - 4, ".edj"))) return e_icon_file_edje_set(obj, path, "icon"); /* smart code here */ _e_icon_obj_prepare(obj, sd); sd->loading = 0; if (sd->size != 0) evas_object_image_load_size_set(sd->obj, sd->size, sd->size); if (sd->preload) evas_object_hide(sd->obj); evas_object_image_file_set(sd->obj, path, NULL); if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE) return EINA_FALSE; if (sd->preload) { sd->loading = 1; evas_object_image_preload(sd->obj, 0); } else if (evas_object_visible_get(obj)) evas_object_show(sd->obj); _e_icon_smart_reconfigure(sd); return EINA_TRUE; }
EAPI Eina_Bool e_icon_file_key_set(Evas_Object *obj, const char *file, const char *key) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; /* smart code here */ sd->loading = 0; if (sd->fdo) { eina_stringshare_del(sd->fdo); sd->fdo = NULL; } if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; _e_icon_obj_prepare(obj, sd); if (sd->size != 0) evas_object_image_load_size_set(sd->obj, sd->size, sd->size); if (sd->preload) evas_object_hide(sd->obj); evas_object_image_file_set(sd->obj, file, key); if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE) return EINA_FALSE; if (!_handle_anim(sd)) { if (sd->preload) { sd->loading = 1; evas_object_image_preload(sd->obj, 0); } else if (evas_object_visible_get(obj)) evas_object_show(sd->obj); } _e_icon_smart_reconfigure(sd); return EINA_TRUE; }
/** * Inserts some text at the given position in the editable object * * @param editable the editable object in which the text should be inserted * @param pos the position where to insert the text * @param text the text to insert * @return Returns 1 if the text has been modified, 0 otherwise */ EAPI int e_editable_insert(Evas_Object *editable, int pos, const char *text) { E_Editable_Smart_Data *sd; int unicode_length; if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERR(0); if ((!editable) || (!(sd = evas_object_smart_data_get(editable)))) return 0; unicode_length = _e_editable_text_insert(editable, pos, text); if (unicode_length <= 0) return 0; if (sd->cursor_pos >= pos) e_editable_cursor_pos_set(editable, sd->cursor_pos + unicode_length); if (sd->selection_pos >= pos) e_editable_selection_pos_set(editable, sd->selection_pos + unicode_length); _e_editable_text_position_update(editable, -1); return 1; }
EAPI Eina_Bool e_icon_file_set(Evas_Object *obj, const char *file) { E_Smart_Data *sd; int len; if (!file) return EINA_FALSE; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0); if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; len = strlen(file); if ((len > 4) && (!strcasecmp(file + len - 4, ".edj"))) return e_icon_file_edje_set(obj, file, "icon"); /* smart code here */ _e_icon_obj_prepare(obj, sd); /* FIXME: 64x64 - unhappy about this. use icon size */ sd->loading = 0; if (sd->fdo) { eina_stringshare_del(sd->fdo); sd->fdo = NULL; } if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = EINA_FALSE; if (sd->size != 0) evas_object_image_load_size_set(sd->obj, sd->size, sd->size); if (sd->preload) evas_object_hide(sd->obj); #ifdef USE_ICON_CACHE if (_e_icon_cache_find(obj, file)) { _e_icon_smart_reconfigure(sd); return EINA_TRUE; } #endif evas_object_image_file_set(sd->obj, file, NULL); if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE) return EINA_FALSE; if (!_handle_anim(sd)) { if (sd->preload) { sd->loading = 1; evas_object_image_preload(sd->obj, EINA_FALSE); } else if (evas_object_visible_get(obj)) { evas_object_show(sd->obj); #ifdef USE_ICON_CACHE _e_icon_cache_icon_loaded(sd->ci); #endif } } #ifdef USE_ICON_CACHE else { evas_object_event_callback_del_full(sd->obj, EVAS_CALLBACK_DEL, _e_icon_obj_del, obj); _cache->load_queue = eina_list_remove(_cache->load_queue, sd->ci); eina_stringshare_del(sd->ci->id); E_FREE(sd->ci); sd->ci = NULL; } #endif _e_icon_smart_reconfigure(sd); return EINA_TRUE; }