2 * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #ifdef SUPPORTS_EMOTICONS
25 #include <Elementary.h>
26 #include <app_preference.h>
28 #include <sclfeedback.h>
30 #include "ise-emoticon-mode.h"
33 #include "candidate-factory.h"
36 #define LOG_TAG "ISE_DEFAULT"
39 #define EVAS_CANDIDATE_LAYER 32000
42 #define ISE_HEIGHT_PORT 398
43 #define ISE_HEIGHT_LAND 398
45 #define ISE_HEIGHT_PORT 240
46 #define ISE_HEIGHT_LAND 240
48 #define ISE_HEIGHT_PORT 442
49 #define ISE_HEIGHT_LAND 318
52 #define EMOTICON_DIR LAYOUTDIR"/emoticons/"
53 #define EMOTICON_EDJ_FILE_PATH RESDIR"/edje/layout_keypad.edj"
54 #define CUSTOM_GENGRID_EDJ_FILE_PATH RESDIR"/edje/customised_gengrid.edj"
56 #define EMOTICON_EDJ_GROUP_PORT_CANDIDATE_ON "emoticon.main.portrait.candidate.on"
57 #define EMOTICON_EDJ_GROUP_LAND_CANDIDATE_ON "emoticon.main.landscape.candidate.on"
59 #define EMOTICON_EDJ_GROUP_PORT_CANDIDATE_OFF "emoticon.main.portrait.candidate.off"
60 #define EMOTICON_EDJ_GROUP_LAND_CANDIDATE_OFF "emoticon.main.landscape.candidate.off"
62 #define EMOTICON_GENGRID_ITEM_STYLE_PORT "ise/customized_default_style_port"
63 #define EMOTICON_GENGRID_ITEM_STYLE_LAND "ise/customized_default_style_land"
65 #define EMOTICON_GENGRID_ITEM_STYLE_PORT2 "ise/customized_default_style_port2"
66 #define EMOTICON_GENGRID_ITEM_STYLE_LAND2 "ise/customized_default_style_land2"
68 #define EMOTICON_GENGRID_ITEM_STYLE_WEARABLE "ise/customized_default_style_wearable"
73 #define EMOTICON_ICON_WIDTH_PORT 40
74 #define EMOTICON_ICON_HEIGHT_PORT 40
76 #define EMOTICON_ICON_GAP_WIDTH_PORT 24
77 #define EMOTICON_ICON_GAP_HEIGHT_PORT 3
79 #define EMOTICON_ICON_WIDTH_PORT 27
80 #define EMOTICON_ICON_HEIGHT_PORT 27
82 #define EMOTICON_ICON_GAP_WIDTH_PORT 10
83 #define EMOTICON_ICON_GAP_HEIGHT_PORT 2
86 #define EMOTICON_WIDTH_PORT (EMOTICON_ICON_WIDTH_PORT + EMOTICON_ICON_GAP_WIDTH_PORT)
87 #define EMOTICON_HEIGHT_PORT (EMOTICON_ICON_HEIGHT_PORT + EMOTICON_ICON_GAP_HEIGHT_PORT)
89 #define EMOTICON_ICON_WIDTH_LAND 27
90 #define EMOTICON_ICON_HEIGHT_LAND 27
93 #define EMOTICON_ICON_GAP_WIDTH_LAND 16
94 #define EMOTICON_ICON_GAP_HEIGHT_LAND 16
96 #define EMOTICON_ICON_GAP_WIDTH_LAND 4
97 #define EMOTICON_ICON_GAP_HEIGHT_LAND 0
100 #define EMOTICON_LAYOUT_LEFT_MARGIN 88
102 #define EMOTICON_WIDTH_LAND (EMOTICON_ICON_WIDTH_LAND + EMOTICON_ICON_GAP_WIDTH_LAND)
103 #define EMOTICON_HEIGHT_LAND (EMOTICON_ICON_HEIGHT_LAND + EMOTICON_ICON_GAP_HEIGHT_LAND)
105 #define MIN_RECENT_EMOTICON_NEEDED_IN_PORT 22 // (7*3 + 1)
106 #define MIN_RECENT_EMOTICON_NEEDED_IN_LAND 27 // (13*2 + 1)
108 #define MAX_SIZE_AMONG_FIRST_3_EMOTICON_GROUPS (EMOTICON_GROUP_1_NUM > EMOTICON_GROUP_2_NUM ? (EMOTICON_GROUP_1_NUM > EMOTICON_GROUP_3_NUM ? EMOTICON_GROUP_1_NUM : EMOTICON_GROUP_3_NUM) : (EMOTICON_GROUP_2_NUM > EMOTICON_GROUP_3_NUM ? EMOTICON_GROUP_2_NUM : EMOTICON_GROUP_3_NUM))
109 #define MAX_SIZE_AMONG_EMOTICON_GROUPS (EMOTICON_GROUP_4_NUM > EMOTICON_GROUP_5_NUM ? (EMOTICON_GROUP_4_NUM > MAX_SIZE_AMONG_FIRST_3_EMOTICON_GROUPS ? EMOTICON_GROUP_4_NUM : MAX_SIZE_AMONG_FIRST_3_EMOTICON_GROUPS) : (EMOTICON_GROUP_5_NUM > MAX_SIZE_AMONG_FIRST_3_EMOTICON_GROUPS ? EMOTICON_GROUP_5_NUM : MAX_SIZE_AMONG_FIRST_3_EMOTICON_GROUPS))
111 static bool is_emoticon_mode = false;
112 emoticon_group_t current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
113 std::vector <int> emoticon_list_recent;
115 extern int * emoticon_list[];
118 static unsigned short int emoticon_group_items[MAX_EMOTICON_GROUP] =
120 EMOTICON_GROUP_RECENTLY_USED_NUM,
121 EMOTICON_GROUP_1_NUM,
122 EMOTICON_GROUP_2_NUM,
126 static unsigned short int emoticon_group_items[MAX_EMOTICON_GROUP] =
128 EMOTICON_GROUP_RECENTLY_USED_NUM,
129 EMOTICON_GROUP_1_NUM,
130 EMOTICON_GROUP_2_NUM,
131 EMOTICON_GROUP_3_NUM,
132 EMOTICON_GROUP_4_NUM,
136 const char *emoticon_group_icons_press[MAX_EMOTICON_GROUP] =
138 "emotion/icon_recent_press.png",
139 "emotion/icon_emotion_press.png",
140 "emotion/icon_crown_press.png",
141 "emotion/icon_dog_press.png",
142 "emotion/icon_house_press.png",
143 "emotion/icon_star_press.png"
147 struct emoticon_item_t
149 Elm_Object_Item *item;
152 Eina_Unicode keyevent;
155 static emoticon_item_t emoticon_items[MAX_SIZE_AMONG_EMOTICON_GROUPS] = {{0, }, };
157 // Static variable declarations
158 static Evas_Object *layout = NULL;
159 static Evas_Object *gengrid = NULL;
160 static Elm_Theme *theme = NULL;
161 static Elm_Gengrid_Item_Class *gic = NULL;
163 // Static Function declarations
164 static void __ise_emoticon_create_gengrid(unsigned short int screen_degree);
165 static void __ise_emoticon_append_items_to_gengrid(emoticon_group_t emoticon_group);
166 static void __ise_emoticon_create_item_class(unsigned short int screen_degree);
167 #if SUPPORTS_EMOTICONS_BY_IMAGE
168 static Evas_Object * grid_content_get(void *data, Evas_Object *obj, const char *part);
169 static void grid_content_del(void *data, Evas_Object *obj);
171 static char * grid_text_get(void *data, Evas_Object *obj, const char *part);
173 static void _item_selected(void *data, Evas_Object *obj, void *event_info);
174 static Eina_Bool _focus_done(void *data);
175 static void _multi_down(void *data, Evas *e, Evas_Object *o, void *event_info);
176 static void _multi_up(void *data, Evas *e, Evas_Object *o, void *event_info);
178 static bool get_landscape_device(int degree)
182 bool landscape_device = false;
184 CSCLUI *ui = get_ui();
185 if (!ui) return false;
187 ui->get_screen_resolution(&width, &height);
189 if (degree == 0 || degree == 180) {
191 landscape_device = true;
195 landscape_device = true;
198 return landscape_device;
201 void ise_read_recent_emoticon_list_from_scim(void)
204 std::string string_value;
205 read_ise_config_string(ISE_CONFIG_RECENT_EMOTICONS_LIST, string_value);
207 if (string_value.length() > 0) {
208 LOGD("read recent emoticon:%s\n", string_value.c_str());
209 std::stringstream ss(string_value);
210 std::istream_iterator<std::string> begin(ss);
211 std::istream_iterator<std::string> end;
212 std::vector<std::string> vstrings(begin, end);
214 emoticon_list_recent.clear();
215 std::vector<std::string>::iterator it;
216 for (it = vstrings.begin(); it != vstrings.end(); it++) {
217 emoticon_list_recent.push_back(atoi((*it).c_str()));
222 void ise_write_recent_emoticon_list_to_scim(void)
224 std::string string_value;
225 for (std::vector<int>::iterator it = emoticon_list_recent.begin();
226 it != emoticon_list_recent.end(); std::advance(it, 1)) {
228 snprintf (buf, sizeof(buf), "%d", *it);
229 string_value += std::string(buf);
232 if (string_value.length() > 0) {
233 preference_set_string(ISE_CONFIG_RECENT_EMOTICONS_LIST, string_value.c_str());
234 LOGD("write recent emoticon:%s\n", string_value.c_str());
238 void ise_show_emoticon_layout(emoticon_group_t emoticon_group, const int screen_degree, const bool is_candidate_on, void *main_window)
240 CSCLUI *ui = get_ui();
243 CONFIG_VALUES *config_values = get_config_values();
244 if (!config_values) return;
249 ise_init_emoticon_list();
250 ise_set_private_key_for_emoticon_mode(emoticon_group);
252 if (emoticon_group == EMOTICON_GROUP_RECENTLY_USED) {
253 //ise_read_recent_emoticon_list_from_scim();
254 if (emoticon_list_recent.size() == 0) {
255 //PRINTFUNC(DLOG_ERROR,"Cannot display recently used emoticons group. No recently used emoticons available");
260 ise_destroy_emoticon_layout();
262 layout = elm_layout_add((Evas_Object *)main_window);
263 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
264 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
267 Candidate *candidate = get_candidate();
268 if (candidate && candidate->get_visible())
269 y = candidate->get_height();
271 read_ise_config_values();
272 if (config_values->floating_mode)
273 evas_object_move(layout, 0, y + FLOATING_TITLE_BAR_HEIGHT);
275 evas_object_move(layout, 0, y);
277 bool landscape_device = get_landscape_device(screen_degree);
279 if (is_candidate_on) {
280 if (screen_degree == 0 || screen_degree == 180) {
281 elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH,
283 EMOTICON_EDJ_GROUP_LAND_CANDIDATE_ON :
284 EMOTICON_EDJ_GROUP_PORT_CANDIDATE_ON);
287 elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH,
289 EMOTICON_EDJ_GROUP_PORT_CANDIDATE_ON :
290 EMOTICON_EDJ_GROUP_LAND_CANDIDATE_ON);
295 ui->get_screen_resolution(&width, &height);
296 LOGD("screen width:%d, height:%d\n", width, height);
297 if (screen_degree == 0 || screen_degree == 180) {
298 elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH,
300 EMOTICON_EDJ_GROUP_LAND_CANDIDATE_OFF :
301 EMOTICON_EDJ_GROUP_PORT_CANDIDATE_OFF);
303 if (config_values->floating_mode)
304 evas_object_resize(layout, width * FLOATING_SCALE_RATE, ui->get_scaled_y(ISE_HEIGHT_PORT) - ELM_SCALE_SIZE(EMOTICON_HEIGHT_PORT));
306 evas_object_resize(layout, width, ui->get_scaled_y(landscape_device ? ISE_HEIGHT_LAND : ISE_HEIGHT_PORT));
308 elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH,
310 EMOTICON_EDJ_GROUP_PORT_CANDIDATE_OFF :
311 EMOTICON_EDJ_GROUP_LAND_CANDIDATE_OFF);
313 if (config_values->floating_mode)
314 evas_object_resize(layout, width * FLOATING_SCALE_RATE, ui->get_scaled_y(ISE_HEIGHT_LAND) * FLOATING_SCALE_RATE);
316 evas_object_resize(layout, width, ui->get_scaled_y(landscape_device ? ISE_HEIGHT_PORT : ISE_HEIGHT_LAND));
320 if (config_values->floating_mode) {
321 evas_object_resize(layout, 260 * FLOATING_SCALE_RATE, 240 * FLOATING_SCALE_RATE);
322 evas_object_move(layout, 10, y + FLOATING_TITLE_BAR_HEIGHT);
324 evas_object_resize(layout, 260, 240);
325 evas_object_move(layout, 10, y);
328 if (screen_degree == 0 || screen_degree == 180) {
329 if (landscape_device) {
330 evas_object_resize(layout, width - ui->get_scaled_y(EMOTICON_LAYOUT_LEFT_MARGIN*2), ui->get_scaled_y(ISE_HEIGHT_LAND));
331 evas_object_move(layout, ui->get_scaled_y(EMOTICON_LAYOUT_LEFT_MARGIN), y);
334 if (config_values->floating_mode) {
335 evas_object_resize(layout, (width - ui->get_scaled_y(EMOTICON_LAYOUT_LEFT_MARGIN*2)) * FLOATING_SCALE_RATE, (ui->get_scaled_y(ISE_HEIGHT_LAND)) * FLOATING_SCALE_RATE);
336 evas_object_move(layout, ui->get_scaled_y(EMOTICON_LAYOUT_LEFT_MARGIN), y + FLOATING_TITLE_BAR_HEIGHT);
338 evas_object_resize(layout, width - ui->get_scaled_y(EMOTICON_LAYOUT_LEFT_MARGIN*2), ui->get_scaled_y(landscape_device ? ISE_HEIGHT_PORT : ISE_HEIGHT_LAND));
339 evas_object_move(layout, ui->get_scaled_y(EMOTICON_LAYOUT_LEFT_MARGIN), y);
345 theme = elm_theme_new();
346 elm_theme_ref_set(theme, NULL); // refer to default theme
347 elm_theme_extension_add(theme, CUSTOM_GENGRID_EDJ_FILE_PATH);
349 __ise_emoticon_create_gengrid((unsigned short)screen_degree);
350 __ise_emoticon_create_item_class((unsigned short)screen_degree);
351 __ise_emoticon_append_items_to_gengrid(emoticon_group);
353 elm_object_part_content_set(layout, "emoticon.swallow.gengrid", gengrid);
354 //elm_win_resize_object_add(main_window, layout);
356 evas_object_show(gengrid);
357 evas_object_layer_set(layout, EVAS_CANDIDATE_LAYER-1);
358 evas_object_show(layout);
360 is_emoticon_mode = true;
361 current_emoticon_group = emoticon_group;
364 void ise_destroy_emoticon_layout(void)
366 /* According to UI FW team, when the a parent is deleted, all its child content will
367 * also be deleted. So no need to delete gengrid explicitly. Just setting the gendrid
368 * pointer to NULL should suffice here.
370 * We can first delete all the child elements and then we delete the parent.
371 * This approach is currently used below
375 elm_gengrid_clear(gengrid);
376 evas_object_del(gengrid);
381 evas_object_del(layout);
386 elm_theme_free(theme);
391 void ise_change_emoticon_mode(emoticon_group_t emoticon_group)
393 if (emoticon_group == EMOTICON_GROUP_RECENTLY_USED) {
394 //ise_read_recent_emoticon_list_from_scim();
395 if (emoticon_list_recent.size() == 0) {
396 //PRINTFUNC(DLOG_ERROR,"Cannot display recently used emoticons group. No recently used emoticons available");
402 elm_gengrid_clear(gengrid);
405 __ise_emoticon_append_items_to_gengrid(emoticon_group);
406 current_emoticon_group = emoticon_group;
409 static Eina_Bool _focus_done(void *data)
411 Elm_Object_Item *item = (Elm_Object_Item *)data;
413 elm_object_item_signal_emit(item, "mouse,up,1", "reorder_bg");
415 return ECORE_CALLBACK_CANCEL;
418 static void _multi_down(void *data, Evas *e, Evas_Object *o, void *event_info)
420 Evas_Event_Multi_Down *ev = (Evas_Event_Multi_Down*)event_info;
422 // PRINTFUNC(DLOG_DEBUG,"MULTI: down @ %4i %4i | dev: %i\n", ev->canvas.x, ev->canvas.y, ev->device);
423 if (ev->device >= IND_NUM)
426 Elm_Object_Item *item;
427 item = elm_gengrid_at_xy_item_get(o, ev->canvas.x, ev->canvas.y, NULL, NULL);
429 elm_object_item_signal_emit(item, "mouse,down,1", "reorder_bg");
431 ecore_timer_add(0.5, _focus_done, item);
434 static void _multi_up(void *data, Evas *e, Evas_Object *o, void *event_info)
436 Evas_Event_Multi_Up *ev = (Evas_Event_Multi_Up*)event_info;
437 // PRINTFUNC(DLOG_DEBUG,"MULTI: up @ %4i %4i | dev: %i\n", ev->canvas.x, ev->canvas.y, ev->device);
438 if (ev->device >= IND_NUM)
441 Elm_Object_Item *item = NULL;
442 item = elm_gengrid_at_xy_item_get(o, ev->canvas.x, ev->canvas.y, NULL, NULL);
444 elm_object_item_signal_emit(item, "mouse,up,1", "reorder_bg");
446 elm_gengrid_item_selected_set(item, EINA_TRUE);
450 static const char *get_item_style_for_degree(int screen_degree)
452 bool landscape_device = get_landscape_device(screen_degree);
454 if (screen_degree == 0 || screen_degree == 180) {
455 if (landscape_device)
456 return EMOTICON_GENGRID_ITEM_STYLE_LAND2;
458 return EMOTICON_GENGRID_ITEM_STYLE_PORT2;
461 if (landscape_device)
462 return EMOTICON_GENGRID_ITEM_STYLE_PORT2;
464 return EMOTICON_GENGRID_ITEM_STYLE_LAND2;
469 static void __ise_emoticon_create_gengrid(unsigned short int screen_degree)
471 gengrid = elm_gengrid_add(layout);
472 elm_object_theme_set(gengrid, theme);
473 //elm_object_style_set(gengrid,"no_effect");
474 elm_gengrid_align_set(gengrid, 0.5, 0);
476 evas_object_size_hint_weight_set(gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
477 evas_object_size_hint_align_set(gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL);
479 bool landscape_device = get_landscape_device(screen_degree);
481 if (screen_degree == 0 || screen_degree == 180) {
482 elm_gengrid_item_size_set(gengrid,
483 ELM_SCALE_SIZE(landscape_device ? EMOTICON_WIDTH_LAND : EMOTICON_WIDTH_PORT),
484 ELM_SCALE_SIZE(landscape_device ? EMOTICON_HEIGHT_LAND : EMOTICON_HEIGHT_PORT));
487 elm_gengrid_item_size_set(gengrid,
488 ELM_SCALE_SIZE(landscape_device ? EMOTICON_WIDTH_PORT : EMOTICON_WIDTH_LAND),
489 ELM_SCALE_SIZE(landscape_device ? EMOTICON_HEIGHT_PORT: EMOTICON_HEIGHT_LAND));
492 elm_gengrid_highlight_mode_set(gengrid, EINA_TRUE);
493 elm_gengrid_select_mode_set(gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS);
494 // elm_gengrid_cache_mode_set(gengrid, EINA_TRUE);
495 elm_gengrid_multi_select_set(gengrid, EINA_TRUE);
497 evas_object_event_callback_add(gengrid, EVAS_CALLBACK_MULTI_DOWN, _multi_down, NULL);
498 evas_object_event_callback_add(gengrid, EVAS_CALLBACK_MULTI_UP, _multi_up, NULL);
501 #if SUPPORTS_EMOTICONS_BY_IMAGE
502 static void __ise_emoticon_append_items_to_gengrid(emoticon_group_t emoticon_group)
506 std::string file_path = "";
508 if (emoticon_group == EMOTICON_GROUP_RECENTLY_USED) {
509 items = emoticon_list_recent.size();
511 for (int i = 0; i < items; i++) {
512 snprintf(img_name, 10, "%x", emoticon_list_recent[i]);
513 emoticon_items[i].code = emoticon_list_recent[i];
514 emoticon_items[i].keyevent = emoticon_list_recent[i];
515 emoticon_items[i].path = (std::string)EMOTICON_DIR + (std::string)"u" + (std::string)img_name + (std::string)".png";
516 emoticon_items[i].item = elm_gengrid_item_append(gengrid, gic, &(emoticon_items[i]), _item_selected, &(emoticon_items[i]));
519 if (emoticon_group != EMOTICON_GROUP_DESTROY) {
520 items = emoticon_group_items[emoticon_group];
522 for (int i = 0; i < items; i++) {
523 snprintf(img_name, 10, "%x", emoticon_list[emoticon_group-1][i]);
524 file_path = (std::string)EMOTICON_DIR + (std::string)"u" + (std::string)img_name + (std::string)".png";
525 if (ise_util_does_file_exists(file_path)) {
526 emoticon_items[i].code = emoticon_list[emoticon_group-1][i];
527 emoticon_items[i].keyevent = emoticon_list[emoticon_group-1][i];
528 emoticon_items[i].path = file_path;
529 emoticon_items[i].item = elm_gengrid_item_append(gengrid, gic, &(emoticon_items[i]), _item_selected, &(emoticon_items[i]));
530 // PRINTFUNC(SECURE_DEBUG,"file_path = %s\n",file_path.c_str());
534 Elm_Object_Item * it = elm_gengrid_first_item_get(gengrid);
535 elm_gengrid_item_show(it, ELM_GENGRID_ITEM_SCROLLTO_NONE);
538 static void __ise_emoticon_create_item_class(unsigned short int screen_degree)
541 gic = elm_gengrid_item_class_new();
543 gic->item_style = get_item_style_for_degree(screen_degree);
545 gic->func.text_get = NULL;
546 gic->func.content_get = grid_content_get;
547 gic->func.state_get = NULL;
548 gic->func.del = grid_content_del;
551 static Evas_Object * grid_content_get(void *data, Evas_Object *obj, const char *part)
553 emoticon_item_t *ti = (emoticon_item_t *)data;
557 if (!strcmp(part, "elm.swallow.icon")) {
558 if (ti->path.c_str()) {
559 Eina_Bool is_image_file_set = false;
560 Evas_Object *icon = elm_image_add(obj);
561 is_image_file_set = elm_image_file_set(icon, ti->path.c_str(), NULL);
562 if (!is_image_file_set) {
563 //PRINTFUNC(SECURE_ERROR,"image \"%s\" not set",ti->path.c_str());
565 elm_image_aspect_fixed_set(icon, EINA_FALSE);
566 elm_image_preload_disabled_set(icon, EINA_FALSE);
567 evas_object_show(icon);
569 evas_object_data_set(icon, "code", (void *)ti->code);
577 static void grid_content_del(void *data, Evas_Object *obj)
579 emoticon_item_t *ti = (emoticon_item_t *)data;
583 Evas_Object *icon = elm_object_item_part_content_get(ti->item, "elm.swallow.icon");
585 evas_object_data_del(icon, "code");
589 #else //SUPPORTS_EMOTICONS_BY_IMAGE
590 static void __ise_emoticon_append_items_to_gengrid(emoticon_group_t emoticon_group)
594 std::string file_path = "";
596 if (emoticon_group == EMOTICON_GROUP_RECENTLY_USED) {
597 items = emoticon_list_recent.size();
599 for (int i = 0; i < items; i++) {
600 snprintf(img_name, 10, "%x", emoticon_list_recent[i]);
601 emoticon_items[i].keyevent = emoticon_list_recent[i];
602 emoticon_items[i].path = (std::string)img_name;
603 emoticon_items[i].item = elm_gengrid_item_append(gengrid, gic, &(emoticon_items[i]), _item_selected, &(emoticon_items[i]));
606 if (emoticon_group != EMOTICON_GROUP_DESTROY) {
607 items = emoticon_group_items[emoticon_group];
609 for (int i = 0; i < items; i++) {
610 snprintf(img_name, 10, "%x", emoticon_list[emoticon_group-1][i]);
611 file_path = (std::string)img_name;
612 emoticon_items[i].keyevent = emoticon_list[emoticon_group-1][i];
613 emoticon_items[i].path = file_path;
614 emoticon_items[i].item = elm_gengrid_item_append(gengrid, gic, &(emoticon_items[i]), _item_selected, &(emoticon_items[i]));
617 Elm_Object_Item * it = elm_gengrid_first_item_get(gengrid);
618 elm_gengrid_item_show(it, ELM_GENGRID_ITEM_SCROLLTO_NONE);
621 static void __ise_emoticon_create_item_class(unsigned short int screen_degree)
624 gic = elm_gengrid_item_class_new();
628 gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_WEARABLE;
630 gic->item_style = get_item_style_for_degree(screen_degree);
632 gic->func.text_get = grid_text_get;
633 gic->func.content_get = NULL;
634 gic->func.state_get = NULL;
635 gic->func.del = NULL;
639 static char * grid_text_get(void *data, Evas_Object *obj, const char *part)
641 emoticon_item_t *ti = (emoticon_item_t *)data;
646 if (!strcmp(part, "elm.text")) {
647 if (ti && !(ti->path.empty())) {
648 const Eina_Unicode unicode_event[2] = {ti->keyevent, 0};
649 utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
656 #endif //SUPPORTS_EMOTICONS_BY_IMAGE
658 static void _item_selected(void *data, Evas_Object *obj, void *event_info)
660 emoticon_item_t *ti = (emoticon_item_t *)data;
664 std::vector<int>::iterator it;
666 CONFIG_VALUES *config_values = get_config_values();
667 static CSCLUtils *utils = CSCLUtils::get_instance();
668 if (utils && config_values) {
669 if (config_values->sound_on)
670 utils->play_sound(DEFAULT_SOUND_STYLE);
671 if (config_values->vibration_on)
672 utils->play_vibration(DEFAULT_VIBRATION_STYLE, DEFAULT_VIBRATION_DURATION);
676 elm_gengrid_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
677 if (ti && ti->keyevent) {
678 const Eina_Unicode unicode_event[2] = {ti->keyevent, 0};
679 // PRINTFUNC(DLOG_DEBUG,"unicode_event is %x",unicode_event);
680 utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
683 ise_send_string((sclchar *)utf_8);
687 if (current_emoticon_group != EMOTICON_GROUP_RECENTLY_USED) {
688 if (emoticon_list_recent.size() < EMOTICON_GROUP_RECENTLY_USED_NUM) {
689 it = find(emoticon_list_recent.begin(), emoticon_list_recent.end(), ti->keyevent);
690 if (it == emoticon_list_recent.end()) { // Item not found
691 emoticon_list_recent.insert(emoticon_list_recent.begin(), ti->keyevent);
693 emoticon_list_recent.erase(it);
694 emoticon_list_recent.insert(emoticon_list_recent.begin(), ti->keyevent);
697 it = find(emoticon_list_recent.begin(), emoticon_list_recent.end(), ti->keyevent);
698 if (it != emoticon_list_recent.end())
699 emoticon_list_recent.erase(it);
701 emoticon_list_recent.erase(emoticon_list_recent.end() - 1);
703 emoticon_list_recent.insert(emoticon_list_recent.begin(), ti->keyevent);
705 ise_write_recent_emoticon_list_to_scim();
707 if (is_recently_used_emoticon_mode_disabled)
708 ise_disable_recently_used_emoticon_key(false);
713 //PRINTFUNC(DLOG_DEBUG,"_item_selected() ends");
716 bool is_emoticon_show(void)
718 return is_emoticon_mode;
721 void ise_set_private_key_for_emoticon_mode(const emoticon_group_t emoticon_group)
723 CSCLUI *ui = get_ui();
725 const char *group_name = NULL;
726 for (int id = EMOTICON_GROUP_RECENTLY_USED; id < MAX_EMOTICON_GROUP; id++) {
727 group_name = ise_get_emoticon_group_name(id);
729 ui->unset_private_key(group_name);
732 group_name = ise_get_emoticon_group_name(emoticon_group);
735 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
736 const_cast<sclchar*>(emoticon_group_icons_press[emoticon_group]), const_cast<sclchar*>(""), const_cast<sclchar*>("")};
738 ui->set_private_key(group_name, const_cast<sclchar*>(""), imagelabel, NULL, 0, const_cast<sclchar*>(group_name), TRUE);