From: raster Date: Tue, 31 May 2011 05:24:58 +0000 (+0000) Subject: fix disk selector to handle intl trext properly. was bad to begin with. X-Git-Tag: REL_F_I9500_20120323_1~17^2~2658 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da2eaf28fe6ed8027819aca1548c6abdd7d9008e;p=framework%2Fuifw%2Felementary.git fix disk selector to handle intl trext properly. was bad to begin with. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@59831 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/bin/test_diskselector.c b/src/bin/test_diskselector.c index 1bcc7a0..5bd46e5 100644 --- a/src/bin/test_diskselector.c +++ b/src/bin/test_diskselector.c @@ -133,6 +133,25 @@ test_diskselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even evas_object_show(disk); evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL); + disk = elm_diskselector_add(win); + ic = elm_icon_add(win); + snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); + elm_icon_file_set(ic, buf, NULL); + elm_icon_scale_set(ic, 1, 1); + elm_diskselector_item_append(disk, "머리스타일", ic, NULL, NULL); + elm_diskselector_item_append(disk, "プロが伝授する", NULL, NULL, NULL); + elm_diskselector_item_append(disk, "生上访要求政府", NULL, NULL, NULL); + elm_diskselector_item_append(disk, "English", NULL, NULL, NULL); + elm_diskselector_item_append(disk, "والشريعة", NULL, NULL, NULL); + elm_diskselector_item_append(disk, "עִבְרִית", NULL, NULL, NULL); + elm_diskselector_item_append(disk, "Grüßen", NULL, NULL, NULL); + elm_diskselector_round_set(disk, EINA_TRUE); + evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(bx, disk); + evas_object_show(disk); + evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL); + // displayed item number setting example disk = elm_diskselector_add(win); elm_diskselector_display_item_num_set(disk, 5); diff --git a/src/lib/elm_diskselector.c b/src/lib/elm_diskselector.c index b9f88cb..4940a5c 100644 --- a/src/lib/elm_diskselector.c +++ b/src/lib/elm_diskselector.c @@ -414,20 +414,32 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty } static int +_count_letter(const char *str) +{ + int pos = 0; + int code = 0, chnum; + + for (chnum = 0; ; chnum++) + { + pos = evas_string_char_next_get(str, pos, &code); + if (code == 0) break; + } + return chnum; +} + +static int _check_letter(const char *str, int length) { - int code = str[length]; - - if (code == '\0') - return length; // null string - else if (((code >= 65) && (code <= 90)) || ((code >= 97) && (code <= 122))) - return length; // alphabet - else if ((48 <= code) && (code < 58)) - return length; // number - else if (((33 <= code) && (code < 47)) || ((58 <= code) && (code < 64)) - || ((91 <= code) && (code < 96)) || ((123 <= code) && (code < 126))) - return length; // special letter - return length - 1; + int pos = 0; + int code = 0, chnum; + + for (chnum = 0; ; chnum++) + { + if (chnum == length) break; + pos = evas_string_char_next_get(str, pos, &code); + if (code == 0) break; + } + return pos; } static Eina_Bool @@ -459,7 +471,9 @@ _check_string(void *data) if ((x + w <= ox) || (x >= ox + ow)) continue; - len = eina_stringshare_strlen(it->label); + len = _count_letter(it->label); +// // FIXME: len should be # of ut8f letters. ie count using utf8 string walk, not stringshare len +// len = eina_stringshare_strlen(it->label); if (x <= ox + 5) edje_object_signal_emit(it->base.view, "elm,state,left_side", @@ -477,6 +491,7 @@ _check_string(void *data) "elm"); } + // if len is les that the limit len, skip anyway if (len <= wd->len_side) continue; @@ -489,7 +504,9 @@ _check_string(void *data) length = len - (int)(diff * steps / (ow / 3)); length = MAX(length, wd->len_side); + // limit string len to "length" ut8f chars length = _check_letter(it->label, length); + // cut it off at byte mark returned form _check_letter strncpy(buf, it->label, length); buf[length] = '\0'; edje_object_part_text_set(it->base.view, "elm.text", buf);