Merge "[Bug] Fix N_SE-13906, N_SE-13353, N_SE-13514, N_SE-14415, N_SE-13999, N_SE...
[apps/core/preloaded/settings.git] / setting-common / src / setting-common-draw-widget.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 #include <setting-common-draw-widget.h>
22 #include <glib.h>
23 #include <utilX.h>
24 #include <Ecore_X.h>
25
26 /**
27  * Hide the input pannel
28  *
29  * @param[in] entry
30  */
31 void setting_hide_input_pannel_cb(Evas_Object *entry)
32 {
33         ret_if(entry == NULL);
34         Ecore_IMF_Context *imf_context = (Ecore_IMF_Context*)elm_entry_imf_context_get(entry);
35         if (imf_context) {
36                 ecore_imf_context_input_panel_hide(imf_context);
37         }
38
39         elm_object_focus_set(entry, EINA_FALSE);
40         Evas_Object *entry_container = elm_object_parent_widget_get(entry);
41         if (entry_container)
42         {
43                 if (elm_entry_is_empty(entry))
44                         elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
45                 elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
46         }
47 }
48
49 Evas_Object *setting_create_button(Evas_Object *parent, const char *btn_str,
50                                    const char *btn_style,
51                                    setting_call_back_func btn_click_cb,
52                                    void *cb_data)
53 {
54         retv_if(!parent || !btn_str, NULL);
55         if ('\0' == btn_str[0]) {//Empty rectangle
56                 return setting_create_blank_rect_customize(parent,
57                                                            SETTING_PADDING_WIDTH,
58                                                            SETTING_PADDING_WIDTH);
59         }
60
61         Evas_Object *button = elm_button_add(parent);
62         if (btn_style) {
63                 elm_object_style_set(button, btn_style);
64         }
65
66         if (0 != safeStrCmp(NAVI_BACK_BUTTON_STYLE, btn_style)) {//not '<-' button
67                 elm_object_text_set(button, btn_str);
68
69                 evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
70                 evas_object_size_hint_align_set(button,EVAS_HINT_FILL, 0.5);
71         }
72
73         if (btn_click_cb) {
74                 evas_object_smart_callback_add(button, "clicked",
75                                                btn_click_cb, cb_data);
76         }
77         evas_object_show(button);
78         return button;
79 }
80
81
82 /**
83  * To create slider object of a genlist item
84  *
85  *@return a slider container object
86  */
87 Evas_Object *setting_create_slider(Evas_Object *parent, Evas *evas,
88                                    const char *l_swallow_path,
89                                    const char *r_swallow_path, double value,
90                                    bool indicator, double slider_min, double slider_max,
91                                    setting_call_back_func slider_change_cb,
92                                    setting_call_back_func slider_start_change_cb,
93                                    setting_call_back_func slider_stop_change_cb,
94                                    void *cb_data)
95 {
96         Evas_Object *slider = elm_slider_add(parent);   /*  "elm/slider/horizontal/default" */
97         retv_if(slider == NULL, NULL);
98
99         if(indicator)
100         {
101                 elm_slider_indicator_format_set(slider, "%1.0f");
102         }
103         else
104         {
105                 /* for brightness slider */
106                 elm_slider_indicator_show_set(slider, EINA_FALSE);
107 #if DISABLED_CODE
108                 elm_object_style_set(slider, "ebook");
109 #endif
110         }
111
112         evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, 0.0);
113         evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
114
115         if (slider_change_cb)
116                 evas_object_smart_callback_add(slider, "changed", slider_change_cb, cb_data);
117
118         if (slider_stop_change_cb)
119                 evas_object_smart_callback_add(slider, "slider,drag,stop", slider_stop_change_cb, cb_data);
120
121         if(slider_start_change_cb)
122                 evas_object_smart_callback_add(slider, "slider,drag,start", slider_start_change_cb, cb_data);
123
124         Evas_Object *icon1 = elm_icon_add(slider);
125         elm_icon_file_set(icon1, l_swallow_path, NULL);
126         evas_object_size_hint_aspect_set(icon1, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
127
128         Evas_Object *icon2 = elm_icon_add(slider);
129         elm_icon_file_set(icon2, r_swallow_path, NULL);
130         evas_object_size_hint_aspect_set(icon2, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
131
132         elm_object_content_set(slider, icon1);
133         elm_object_part_content_set(slider, "end", icon2);
134
135         elm_slider_min_max_set(slider, slider_min, slider_max);
136         elm_slider_value_set(slider, value);
137         return slider;
138 }
139
140 /**
141  * The main implement body of create a certain size icon
142  */
143 void create_image_box_add_ex(void *data, Evas_Object *win_main, Evas *evas,
144                              char *img_path, int img_w, int img_h,
145                              Evas_Object_Event_Cb mouse_down_cb,
146                              Evas_Object_Event_Cb mouse_up_cb,
147                              Evas_Object **image_box, Evas_Object **img)
148 {
149         /* SETTING_TRACE_BEGIN; */
150         *image_box = elm_box_add(win_main);
151         retm_if(*image_box == NULL, "Cannot get box");
152         elm_box_horizontal_set(*image_box, 1);
153         evas_object_size_hint_align_set(*image_box, 0.0, EVAS_HINT_FILL);       /* */
154         evas_object_show(*image_box);
155
156         *img = evas_object_image_add(evas);
157         evas_object_size_hint_weight_set(*img, 0.0, EVAS_HINT_EXPAND);
158
159         int temp_h = img_h;
160         int temp_w = img_w;
161
162         evas_object_image_file_set(*img, img_path, NULL);
163         if (img_h <= 0 || temp_w <= 0)  //error handling. load the image as it's own size
164         {
165                 evas_object_image_size_get(*img, &temp_w, &temp_h);
166         }
167
168         evas_object_image_load_size_set(*img, temp_w, temp_h);
169         evas_object_image_fill_set(*img, 0, 0, temp_w, temp_h);
170
171         evas_object_size_hint_min_set(*img, temp_w, temp_h);
172         evas_object_show(*img);
173
174         evas_object_event_callback_add(*img, EVAS_CALLBACK_MOUSE_DOWN,
175                                        mouse_down_cb, data);
176         evas_object_event_callback_add(*img, EVAS_CALLBACK_MOUSE_UP,
177                                        mouse_up_cb, data);
178
179         elm_box_pack_end(*image_box, *img);
180 }
181
182 /**
183  * To create a size fixed icon
184  * @return a image container object
185  */
186
187 Evas_Object *create_image_box_add(void *data, Evas_Object *win_main,
188                                   Evas *evas, char *img_path, int img_w,
189                                   int img_h, Evas_Object_Event_Cb mouse_down_cb,
190                                   Evas_Object_Event_Cb mouse_up_cb)
191 {
192         /* SETTING_TRACE_BEGIN; */
193         Evas_Object *image_box = NULL;
194         Evas_Object *img = NULL;
195         create_image_box_add_ex(data, win_main, evas, img_path,
196                                 img_w * WIDGET_SCALE_FACTOR,
197                                 img_h * WIDGET_SCALE_FACTOR, mouse_down_cb,
198                                 mouse_up_cb, &image_box, &img);
199         return image_box;
200
201 }
202
203 /**
204 * To create a size specialized icon
205 *
206 * @return a image container object
207 */
208
209 Evas_Object *create_bgimage_box_add(void *data, Evas_Object *win_main, Evas *evas, char *img_path, int img_w, int img_h,        /* if img_w<0 or img_h <0, load the image as it's own size */
210                                     Evas_Object_Event_Cb mouse_down_cb,
211                                     Evas_Object_Event_Cb mouse_up_cb)
212 {
213         Evas_Object *image_box = NULL;
214         Evas_Object *img = NULL;
215         create_image_box_add_ex(data, win_main, evas, img_path, img_w, img_h,
216                                 mouse_down_cb, mouse_up_cb, &image_box, &img);
217         return image_box;
218 }
219
220 /**
221 * @ create a box container
222 *
223 * @param[in] win_main
224 *
225 * @return a box container
226 */
227 Evas_Object *setting_create_client_bx(Evas_Object *win_main)
228 {
229         Evas_Object *client_bx = NULL;
230
231         client_bx = elm_box_add(win_main);
232         retvm_if(client_bx == NULL, NULL, "Cannot create client box object");
233
234         elm_box_horizontal_set(client_bx, 0);
235         evas_object_size_hint_weight_set(client_bx, EVAS_HINT_EXPAND, 0.0);
236         evas_object_size_hint_align_set(client_bx, EVAS_HINT_FILL, 0.0);
237
238         return client_bx;
239 }
240
241
242 Evas_Object *setting_create_lable(Evas_Object *parent, const char *lable,
243                                   const char *style)
244 {
245         Evas_Object *label = elm_label_add(parent);
246         elm_object_style_set(label, style);
247         elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
248
249         const char *str = setting_customize_text(lable, 0, NULL, "left");
250         elm_object_text_set(label, str);
251         FREE(str);
252         evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
253         evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
254         evas_object_show(label);
255         return label;
256 }
257
258 #define DEMO_STEP 0.4
259 typedef struct _setting_gif_data{
260         Ecore_Timer *update_timer;
261         const char  **png_list;
262         int         cur_png_idx;
263 }setting_gif_data;
264
265 static void __gif_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
266 {
267         SETTING_TRACE_BEGIN;
268         ret_if(!data);
269         setting_gif_data *gif_data = data;
270         if (gif_data->update_timer) {//first delete the timer
271                 ecore_timer_del(gif_data->update_timer);
272                 gif_data->update_timer = NULL;
273         }
274         FREE(gif_data);//delete the date.
275         evas_object_data_set(obj, "gif_data", NULL);
276 }
277
278 Eina_Bool __gif_updater(void *data)
279 {
280         retv_if(!data, FALSE);
281         Evas_Object *gif =  data;
282         setting_gif_data *gif_data = evas_object_data_get(gif, "gif_data");
283         retv_if(!gif_data, FALSE);
284         SETTING_TRACE_BEGIN;
285
286         gif_data->cur_png_idx++;
287         if (NULL == gif_data->png_list[gif_data->cur_png_idx]) { //the last element of current array.
288                 gif_data->cur_png_idx = 0;
289         }
290         elm_image_file_set(gif, gif_data->png_list[gif_data->cur_png_idx], NULL);
291         int w = 0;
292         int h = 0;
293         elm_image_object_size_get(gif, &w, &h);
294         setting_resize_object(gif, w, h);
295
296         return TRUE;
297 }
298
299 Evas_Object *setting_create_image(Evas_Object *parent, const char *img_path)
300 {
301         Evas_Object *image = elm_image_add(parent);
302         //SETTING_TRACE("icon_path:%s", icon_path);
303         elm_image_file_set(image, img_path, NULL);
304         elm_image_resizable_set(image, EINA_TRUE, EINA_TRUE);
305
306         int w = 0;
307         int h = 0;
308         elm_image_object_size_get(image, &w, &h);
309         setting_resize_object(image, w, h);
310         evas_object_show(image);
311         return image;
312 }
313
314 /* @png_list is an array end with 'NULL'. like ,
315                 const char *png_list[] = {
316                         SETTING_ICON_PATH_CFG"motions/motion_overturn_01.png",
317                         SETTING_ICON_PATH_CFG"motions/motion_overturn_02.png",
318                         SETTING_ICON_PATH_CFG"motions/motion_overturn_03.png",
319                         SETTING_ICON_PATH_CFG"motions/motion_overturn_04.png",
320                         SETTING_ICON_PATH_CFG"motions/motion_overturn_05.png",
321                         NULL //must end with 'NULL'
322                 };
323 */
324 Evas_Object *setting_create_gif(Evas_Object *parent, const char **png_list)
325 {
326         retv_if(!png_list, NULL);
327         setting_gif_data *gif_data = calloc(1,sizeof(setting_gif_data));
328         setting_retvm_if(!gif_data, NULL, "calloc failed");
329         gif_data->cur_png_idx = 0;
330         gif_data->png_list = png_list;
331
332         SETTING_TRACE_BEGIN;
333
334         Evas_Object *gif = setting_create_image(parent, *png_list);//the first element
335         //bind object data
336         evas_object_data_set(gif, "gif_data", gif_data);
337         evas_object_event_callback_add(gif, EVAS_CALLBACK_DEL, __gif_del_cb, gif_data);
338
339         if (gif_data->update_timer) {
340                 ecore_timer_del(gif_data->update_timer);
341                 gif_data->update_timer = NULL;
342         }
343         gif_data->update_timer = ecore_timer_add(DEMO_STEP, (Ecore_Task_Cb)__gif_updater, gif);
344
345         return gif;
346 }
347
348 /**
349 * Set the vconf value via its binded check object.
350 * @return 0: sucess, other: failed
351 */
352
353 int setting_reset_slp_key_by_status(Evas_Object *obj,
354                                     setting_bool_slp_list key)
355 {
356         SETTING_TRACE_BEGIN;
357         int err, ret;
358
359         int status = 0;
360         status = elm_check_state_get(obj);
361         if (status) {
362                 ret =
363                     setting_set_bool_slp_key(key, SETTING_ON_OFF_BTN_ON, &err);
364         } else {
365                 ret =
366                     setting_set_bool_slp_key(key, SETTING_ON_OFF_BTN_OFF, &err);
367         }
368         return ret;
369 }
370
371 /**
372 * Alternate the check object status and its binded vcof value via original vcofn value
373 */
374 int setting_draw_onoff_status(Evas_Object *obj, setting_bool_slp_list key)
375 {
376         int value;
377         int err;
378         int ret;
379
380         setting_get_bool_slp_key(key, &value, &err);
381
382         elm_check_state_set(obj, !value);
383         ret = setting_set_bool_slp_key(key, !value, &err);
384         return ret;
385 }
386
387 /**
388 * Set the status of check object via its binded vconf value.
389 * @return  0: sucess, other: failed
390 */
391 int setting_check_onoff_status(Evas_Object *obj, setting_bool_slp_list key)
392 {
393         int value = 0;
394         int err = 0;
395         int ret = 0;
396
397         ret = setting_get_bool_slp_key(key, &value, &err);
398         elm_check_state_set(obj, value);
399         return ret;
400 }
401
402 /**
403 * Set the status of radio group object via its binded vconf value.
404 * @return  0: sucess, other: failed
405 */
406 int setting_update_chk_status(Evas_Object *chk, setting_int_slp_list type)
407 {
408         SETTING_TRACE_BEGIN;
409         /* error check */
410         if (chk == NULL) {
411                 return SETTING_GENERAL_ERR_NULL_DATA_PARAMETER;
412         }
413
414         SETTING_TRACE_BEGIN;
415
416         int ret = SETTING_RETURN_FAIL;
417         int value;
418         int err;
419
420         /* value set */
421         ret = setting_get_int_slp_key(type, &value, &err);
422         SETTING_TRACE("binded: %d, checked: %d, err: %d", type, value, err);
423
424         elm_radio_value_set(chk, value);
425
426         return ret;
427 }
428
429 /**
430 * Create a size specilized rectangle object
431 * @return a size specilized rectangle object
432 */
433 Evas_Object *setting_create_blank_rect_customize(Evas_Object *layout, int w,
434                                                  int h)
435 {
436         Evas_Object *rect;
437
438         rect = evas_object_rectangle_add(evas_object_evas_get(layout));
439         evas_object_size_hint_min_set(rect, w, h);
440         evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, 0);
441         evas_object_color_set(rect, 0, 0, 0, 0);
442
443         return rect;
444 }
445
446 /**
447 * Create a size fixed rectangle object
448 *
449 * @param[in] layout
450 *
451 * @return a size fixed rectangle object
452 */
453 Evas_Object *setting_create_blank_rect(Evas_Object *layout)
454 {
455         return setting_create_blank_rect_customize(layout,
456                                                    SETTING_PADDING_WIDTH, 80);
457 }
458
459 /**
460 * The API to Create an editfiled object
461 * @return an editfiled object
462 */
463 Evas_Object *                   /* multi-line is default, use elm_editfield_entry_single_line_set(ef, EINA_TRUE) to set single-line */
464 setting_create_editfiled(Evas_Object *win_main, char *title, char *def_str)
465 {
466         Evas_Object *layout = NULL;
467         Evas_Object *entry = NULL;
468         layout = elm_layout_add(win_main);
469
470         if(title)
471         {
472                 elm_layout_theme_set(layout, "layout", "editfield", "title");
473                 elm_object_part_text_set(layout, "elm.text", title);
474         }
475         else
476         {
477                 elm_layout_theme_set(layout, "layout", "editfield", "default");
478         }
479         entry = elm_entry_add(win_main);
480         elm_object_part_content_set(layout, "elm.swallow.content", entry);
481         //elm_entry_context_menu_disabled_set(entry, TRUE);
482         //elm_entry_magnifier_disabled_set(entry, TRUE);
483         elm_entry_prediction_allow_set(entry, FALSE);
484
485         if (def_str && safeStrLen(def_str) > 0) {
486                 elm_entry_entry_set(entry, def_str);
487         } else {
488                 elm_object_part_text_set(layout, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
489         }
490
491         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0);
492         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0);
493
494         evas_object_show(layout);
495         return layout;
496 }
497
498 /**
499 * Create a text box, which cannot be edited, just to show a specilization segment.
500 *
501 * @return a text box, which cannot be edited
502 */
503 Evas_Object *setting_create_textbox(Evas_Object *parent, const char *content)
504 {
505         Evas_Object *obj = NULL;
506
507         obj = elm_entry_add(parent);
508         evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, 0.0);
509         evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, 0.5);
510         elm_entry_single_line_set(obj, 0);
511         /* elm_entry_line_wrap_set(obj, 1); */
512         elm_entry_editable_set(obj, 0);
513         elm_entry_context_menu_disabled_set(obj, 1);
514
515         /* setting_disable_evas_object(obj); ***disable any events on entry */
516
517         elm_entry_entry_set(obj, content);
518         evas_object_show(obj);
519         return obj;
520 }
521
522 /**
523 * Make it no effect when clicking on a evas object and its sub-objects, such as, layout, genlist
524 *
525 * @param[in] obj
526 */
527 void setting_disable_evas_object(Evas_Object *obj)
528 {                               /* layout\genlist\scroller\elm_entry  etc.. */
529         if (obj) {
530                 evas_object_pass_events_set(obj, EINA_TRUE);
531         }
532 }
533
534 /**
535 * Make it normal acting when clicking on a evas object, such as, layout, genlist
536 *
537 * @param[in] obj
538 */
539 void setting_enable_evas_object(Evas_Object *obj)
540 {
541         if (obj) {
542                 evas_object_pass_events_set(obj, EINA_FALSE);
543         }
544 }
545
546 /**
547 * To resize a evas object, such as, icon, button..
548 *
549 * @param[in] obj
550 * @param[in] w
551 * @param[in] h
552 */
553 void setting_resize_object(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
554 {
555         if (obj) {
556                 evas_object_size_hint_min_set(obj, w, h);
557                 evas_object_size_hint_max_set(obj, w, h);
558                 evas_object_resize(obj, w, h);
559         }
560 }
561
562 /**
563 * To create a bg object
564 *
565 * @param[in] parent
566 * @param[in] bg_style
567 * @return bg object
568 */
569 Evas_Object *setting_create_bg(Evas_Object *parent,Evas_Object *win, const char *bg_style)
570 {
571         retv_if(!parent, NULL);
572         Evas_Object *bg = elm_bg_add(parent);
573         retv_if(!bg, NULL);
574         elm_object_style_set(bg, bg_style);
575         evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
576                                          EVAS_HINT_EXPAND);
577         elm_win_resize_object_add(win, bg);
578         evas_object_show(bg);
579         return bg;
580 }
581
582
583 #define DIFF_TIMES      2
584 /**
585 * To make an object which is operated by setting_dim_evas_object normal color
586 *
587 * @param[in] obj
588 * @param[in] b_transparency_set:
589 *       1:the appearence of obj is made up of transparent backgroud color.
590 *       0:the appearence of obj is made up of non transparent color.
591 */
592 void setting_undo_dim_evas_object(Evas_Object *obj, bool b_transparenct)
593 {
594         if (obj) {
595                 int r;
596                 int g;
597                 int b;
598                 int a;
599                 evas_object_color_get(obj, &r, &g, &b, &a);
600                 if (b_transparenct) {//the appearence of obj is made up of transparent backgroud color.
601                         a *= DIFF_TIMES;
602                 }
603                 evas_object_color_set(obj, r * DIFF_TIMES, g * DIFF_TIMES, b * DIFF_TIMES, a);
604         }
605 }
606
607 /**
608 * To make an object dim color
609 *
610 * @param[in] obj
611 * @param[in] b_transparency_set:
612 *       1:the appearence of obj is made up of transparent backgroud color.
613 *       0:the appearence of obj is made up of non transparent color.
614 */
615 void setting_dim_evas_object(Evas_Object *obj, bool b_transparenct)
616 {
617         if (obj) {
618                 int r;
619                 int g;
620                 int b;
621                 int a;
622                 evas_object_color_get(obj, &r, &g, &b, &a);
623                 if (b_transparenct) {//the appearence of obj is made up of transparent backgroud color.
624                         a /= DIFF_TIMES;
625                 }
626                 evas_object_color_set(obj, r / DIFF_TIMES, g / DIFF_TIMES, b / DIFF_TIMES, a);
627         }
628 }
629
630 static void __btn_select_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
631 {
632         setting_dim_evas_object(obj, FALSE);
633 }
634
635 static void __btn_release_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
636 {
637         setting_undo_dim_evas_object(obj, FALSE);
638 }
639
640 /**
641 * To make an object looks clickable: if pressed, it is dim color;if unpressed, it is normal color;
642 *
643 * @param[in] obj
644 */
645 void setting_make_evas_object_clickable(Evas_Object *obj)
646 {
647         if (obj) {
648                 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, __btn_select_cb, NULL);
649                 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP, __btn_release_cb, NULL);
650         }
651 }
652
653 /**
654 * To create an icon which looks clickable(if pressed, it is dim color;if unpressed, it is normal color)
655 *
656 * @param[in] parent
657 * @param[in] img_path
658 * @param[in] up_cb
659 * @param[in] down_cb
660 * @param[in] move_cb
661 * @param[in] data
662 */
663 Evas_Object *setting_create_icon(Evas_Object *parent, const char *img_path,
664                                  Evas_Object_Event_Cb up_cb,
665                                  Evas_Object_Event_Cb down_cb,
666                                  Evas_Object_Event_Cb move_cb,
667                                  void *data)
668 {
669         SETTING_TRACE_BEGIN;
670         retv_if(!parent || !img_path, NULL);
671         Evas_Object *icon = elm_icon_add(parent);
672         retvm_if(!icon, NULL, "Failed Create icon!");
673         elm_icon_file_set(icon, img_path, NULL);
674         setting_make_evas_object_clickable(icon);
675
676         if (up_cb) {
677                 evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_UP,
678                                                 up_cb, data);
679         }
680         if (down_cb) {
681                 evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_DOWN,
682                                                 down_cb, data);
683         }
684         if (move_cb) {
685                 evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_MOVE,
686                                                 move_cb, data);
687         }
688
689         return icon;
690 }
691
692 /**
693 * To create a button which only has a image and looks clickable
694 * (if pressed, it is dim color;if unpressed, it is normal color)
695 * @param[in] parent
696 * @param[in] img_path
697 * @param[in] up_cb
698 * @param[in] down_cb
699 * @param[in] move_cb
700 * @param[in] data
701 */
702 Evas_Object *setting_create_image_button(Evas_Object *parent,
703                                         const char *btn_img,
704                                         setting_call_back_func clicked_cb,
705                                         setting_call_back_func unpressed_cb,
706                                         void *data)
707 {
708         SETTING_TRACE_BEGIN;
709         retv_if(!parent, NULL);
710         Evas_Object *btn = elm_button_add(parent);
711         retvm_if(!btn, NULL, "Failed Create button!");
712         if (clicked_cb) {
713                 evas_object_smart_callback_add(btn, "clicked", clicked_cb, data);
714         }
715
716         if (unpressed_cb) {
717                 evas_object_smart_callback_add(btn, "unpressed", unpressed_cb, data);
718         }
719
720         if (btn_img) {
721                 Evas_Object *icon = elm_icon_add(parent);
722                 retvm_if(!icon, NULL, "Failed Create icon!");
723                 elm_icon_file_set(icon, btn_img, NULL);
724                 elm_object_part_content_set(btn, "elm.swallow.content", icon);
725                 setting_make_evas_object_clickable(btn);
726         }
727
728         return btn;
729 }
730
731
732
733 /*
734 * set font_size, color or align(right, left, middle),if need, you
735 * can add </font_siz>, </color> or </align> to controll a segment words; or else
736 * the text will take the same effect until the end of text.
737 * @param[in] input_str
738 * @param[in] font_size
739 * @param[in] color
740 * @param[in] align :may be right, left, middle/center
741 */
742 char *setting_customize_text(const char *input_str, const int font_size,
743                                  const char *color, const char *align)
744 {
745         SETTING_TRACE_BEGIN;
746         char speciliztion[MAX_SPECIALIZITION_LEN] = { 0, };
747
748         //<font_size=%d><align=middle><color=#9C9C9C>bbb</color></align></font_size>
749         if (font_size > 0)
750         {
751                 snprintf(speciliztion, sizeof(speciliztion),
752                          "<font_size=%d>", font_size);
753         }
754
755         if (align)
756         {
757             g_strlcat(speciliztion, "<align=", MAX_SPECIALIZITION_LEN);
758             g_strlcat(speciliztion, align, MAX_SPECIALIZITION_LEN);
759             g_strlcat(speciliztion, ">", MAX_SPECIALIZITION_LEN);
760         }
761
762         if (color)
763         {
764                 g_strlcat(speciliztion, "<color=", MAX_SPECIALIZITION_LEN);
765                 g_strlcat(speciliztion, color, MAX_SPECIALIZITION_LEN);
766                 g_strlcat(speciliztion, ">", MAX_SPECIALIZITION_LEN);
767         }
768         g_strlcat(speciliztion, input_str, MAX_SPECIALIZITION_LEN);
769
770         if (color)
771         {
772                 g_strlcat(speciliztion, "</color>", MAX_SPECIALIZITION_LEN);
773         }
774         if (align)
775         {
776                 g_strlcat(speciliztion, "</align>", MAX_SPECIALIZITION_LEN);
777         }
778         if (font_size > 0)
779         {
780                 g_strlcat(speciliztion, "</font_size>", MAX_SPECIALIZITION_LEN);
781         }
782
783         SETTING_TRACE("Exit %s, return :%s", __FUNCTION__, speciliztion);
784         return (char *)strdup(speciliztion);;
785 }
786