4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <setting-common-draw-widget.h>
23 #include <efl_assist.h>
26 #include <libhelpui.h>
29 * Hide the input pannel
34 void setting_hide_input_pannel_cb(Evas_Object *entry)
36 ret_if(entry == NULL);
37 Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(entry);
39 ecore_imf_context_input_panel_hide(imf_context);
42 elm_object_focus_set(entry, EINA_FALSE);
43 Evas_Object *entry_container = elm_object_parent_widget_get(entry);
44 if (entry_container) {
45 if (elm_entry_is_empty(entry))
46 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
47 elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
52 Evas_Object *setting_create_button(Evas_Object *parent, const char *btn_str,
53 const char *btn_style,
54 setting_call_back_func btn_click_cb,
58 retv_if(!parent || !btn_str, NULL);
59 if ('\0' == btn_str[0]) {/*Empty rectangle */
60 return setting_create_blank_rect_customize(parent,
61 SETTING_PADDING_WIDTH,
62 SETTING_PADDING_WIDTH);
65 Evas_Object *button = elm_button_add(parent);
67 elm_object_style_set(button, btn_style);
70 if (0 != safeStrCmp("naviframe/end_btn/default", btn_style)) {/*not '<-' button */
71 elm_object_text_set(button, _(btn_str));
73 evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
74 evas_object_size_hint_align_set(button, EVAS_HINT_FILL, 0.5);
78 evas_object_smart_callback_add(button, "clicked",
79 btn_click_cb, cb_data);
81 evas_object_show(button);
86 static double _step_size_calculate(Evas_Object *obj, double min, double max)
99 * To create slider object of a genlist item
101 *@return a slider container object
103 EXPORT_PUBLIC Evas_Object *setting_create_5step_slider(Evas_Object *parent, Evas *evas,
104 const char *l_swallow_path,
105 const char *r_swallow_path, double value,
106 bool indicator, double slider_min, double slider_max,
107 setting_call_back_func slider_change_cb,
108 setting_call_back_func slider_start_change_cb,
109 setting_call_back_func slider_stop_change_cb,
113 Evas_Object *layout = elm_layout_add(parent);
114 int r = elm_layout_file_set(layout, SETTING_5STEP_SLIDER_EDJ_NAME, "elm/slider/horizontal/music/soundalive");
116 SETTING_TRACE_ERROR("elm_layout_add failed : %s", "elm/slider/horizontal/music/soundalive");
117 evas_object_del(layout);
121 Evas_Object *slider = elm_slider_add(layout); /* "elm/slider/horizontal/default" */
122 retv_if(slider == NULL, NULL);
123 elm_object_style_set(slider, "music/soundalive");
125 elm_slider_indicator_format_set(slider, "%1.0f");
126 elm_slider_indicator_show_set(slider, 5);
128 evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, 0.0);
129 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
131 double step = _step_size_calculate(slider, slider_min, slider_max);
132 elm_slider_step_set(slider, step);
134 SETTING_TRACE("slider_change_cb:%p", slider_change_cb);
136 if (slider_change_cb) evas_object_smart_callback_add(slider, "changed", slider_change_cb, cb_data);
137 if (slider_stop_change_cb) evas_object_smart_callback_add(slider, "slider,drag,stop", slider_stop_change_cb, cb_data);
138 if (slider_start_change_cb) evas_object_smart_callback_add(slider, "slider,drag,start", slider_start_change_cb, cb_data);
140 if (l_swallow_path) {
141 Evas_Object *icon1 = elm_icon_add(slider);
142 elm_image_file_set(icon1, l_swallow_path, NULL);
143 evas_object_size_hint_aspect_set(icon1, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
144 elm_object_content_set(slider, icon1);
147 if (r_swallow_path) {
148 Evas_Object *icon2 = elm_icon_add(slider);
149 elm_image_file_set(icon2, r_swallow_path, NULL);
150 evas_object_size_hint_aspect_set(icon2, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
151 elm_object_part_content_set(slider, "end", icon2);
154 elm_slider_min_max_set(slider, slider_min, slider_max);
155 elm_slider_value_set(slider, value);
160 * To create slider object of a genlist item
162 *@return a slider container object
164 EXPORT_PUBLIC Evas_Object *setting_create_slider(Evas_Object *parent, Evas *evas,
165 const char *l_swallow_path,
166 const char *r_swallow_path, double value,
167 bool indicator, double slider_min, double slider_max,
168 setting_call_back_func slider_change_cb,
169 setting_call_back_func slider_start_change_cb,
170 setting_call_back_func slider_stop_change_cb,
173 Evas_Object *slider = elm_slider_add(parent); /* "elm/slider/horizontal/default" */
174 retv_if(slider == NULL, NULL);
177 elm_slider_indicator_format_set(slider, "%1.0f");
178 elm_slider_indicator_show_set(slider, 1);
180 /* for brightness slider */
181 elm_slider_indicator_show_set(slider, 0);
182 elm_object_style_set(slider, "tap_to_drag");
185 evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, 0.0);
186 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
188 double step = _step_size_calculate(slider, slider_min, slider_max);
189 elm_slider_step_set(slider, step);
191 SETTING_TRACE("slider_change_cb:%p", slider_change_cb);
192 if (slider_change_cb)
193 evas_object_smart_callback_add(slider, "changed", slider_change_cb, cb_data);
195 if (slider_stop_change_cb)
196 evas_object_smart_callback_add(slider, "slider,drag,stop", slider_stop_change_cb, cb_data);
198 if (slider_start_change_cb)
199 evas_object_smart_callback_add(slider, "slider,drag,start", slider_start_change_cb, cb_data);
201 if (l_swallow_path) {
202 Evas_Object *icon1 = elm_icon_add(slider);
203 elm_image_file_set(icon1, l_swallow_path, NULL);
204 evas_object_size_hint_aspect_set(icon1, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
205 elm_object_content_set(slider, icon1);
208 if (r_swallow_path) {
209 Evas_Object *icon2 = elm_icon_add(slider);
210 elm_image_file_set(icon2, r_swallow_path, NULL);
211 evas_object_size_hint_aspect_set(icon2, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
212 elm_object_part_content_set(slider, "end", icon2);
215 elm_slider_min_max_set(slider, slider_min, slider_max);
216 elm_slider_value_set(slider, value);
221 * The main implement body of create a certain size icon
224 void create_image_box_add_ex(void *data, Evas_Object *win_main, Evas *evas,
225 char *img_path, int img_w, int img_h,
226 Evas_Object_Event_Cb mouse_down_cb,
227 Evas_Object_Event_Cb mouse_up_cb,
228 Evas_Object **image_box, Evas_Object **img)
230 /* SETTING_TRACE_BEGIN; */
231 *image_box = elm_box_add(win_main);
232 retm_if(*image_box == NULL, "Cannot get box");
233 elm_box_horizontal_set(*image_box, 1);
234 evas_object_size_hint_align_set(*image_box, 0.0, EVAS_HINT_FILL); /* */
235 evas_object_show(*image_box);
237 *img = evas_object_image_add(evas);
238 evas_object_size_hint_weight_set(*img, 0.0, EVAS_HINT_EXPAND);
243 evas_object_image_file_set(*img, img_path, NULL);
244 if (img_h <= 0 || temp_w <= 0) { /*error handling. load the image as it's own size */
245 evas_object_image_size_get(*img, &temp_w, &temp_h);
248 evas_object_image_load_size_set(*img, temp_w, temp_h);
249 evas_object_image_fill_set(*img, 0, 0, temp_w, temp_h);
251 evas_object_size_hint_min_set(*img, ELM_SCALE_SIZE(temp_w), ELM_SCALE_SIZE(temp_h));
252 evas_object_show(*img);
254 evas_object_event_callback_add(*img, EVAS_CALLBACK_MOUSE_DOWN,
255 mouse_down_cb, data);
256 evas_object_event_callback_add(*img, EVAS_CALLBACK_MOUSE_UP,
259 elm_box_pack_end(*image_box, *img);
263 * To create a size fixed icon
264 * @return a image container object
268 Evas_Object *create_image_box_add(void *data, Evas_Object *win_main,
269 Evas *evas, char *img_path, int img_w,
270 int img_h, Evas_Object_Event_Cb mouse_down_cb,
271 Evas_Object_Event_Cb mouse_up_cb)
273 /* SETTING_TRACE_BEGIN; */
274 Evas_Object *image_box = NULL;
275 Evas_Object *img = NULL;
276 create_image_box_add_ex(data, win_main, evas, img_path,
277 img_w * WIDGET_SCALE_FACTOR,
278 img_h * WIDGET_SCALE_FACTOR, mouse_down_cb,
279 mouse_up_cb, &image_box, &img);
285 * To create a size specialized icon
287 * @return a image container object
291 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 */
292 Evas_Object_Event_Cb mouse_down_cb,
293 Evas_Object_Event_Cb mouse_up_cb)
295 Evas_Object *image_box = NULL;
296 Evas_Object *img = NULL;
297 create_image_box_add_ex(data, win_main, evas, img_path, img_w, img_h,
298 mouse_down_cb, mouse_up_cb, &image_box, &img);
303 * @ create a box container
305 * @param[in] win_main
307 * @return a box container
310 Evas_Object *setting_create_client_bx(Evas_Object *win_main)
312 Evas_Object *client_bx = NULL;
314 client_bx = elm_box_add(win_main);
315 retvm_if(client_bx == NULL, NULL, "Cannot create client box object");
317 elm_box_horizontal_set(client_bx, 0);
318 evas_object_size_hint_weight_set(client_bx, EVAS_HINT_EXPAND, 0.0);
319 evas_object_size_hint_align_set(client_bx, EVAS_HINT_FILL, 0.0);
326 Evas_Object *setting_create_lable(Evas_Object *parent, const char *text,
327 const char *style, const char *align)
329 retvm_if(!parent || !text, NULL, "Cannot create client box object");
330 Evas_Object *label = NULL;
331 if (0 == safeStrCmp(style, "entry")) {
332 SETTING_TRACE("style:%s", style);
333 label = elm_entry_add(parent);
334 elm_entry_editable_set(label, EINA_FALSE);
336 label = elm_label_add(parent);
337 elm_object_style_set(label, style);
338 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
340 const char *str = setting_customize_text(text, 0, NULL, align);
341 elm_object_text_set(label, str);
343 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
344 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
345 evas_object_show(label);
349 #define DEMO_STEP 0.8
350 typedef struct _setting_gif_data {
351 Ecore_Timer *update_timer;
352 const char **png_list;
356 static void __gif_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
360 setting_gif_data *gif_data = data;
361 if (gif_data->update_timer) {/*first delete the timer */
362 ecore_timer_del(gif_data->update_timer);
363 gif_data->update_timer = NULL;
365 FREE(gif_data);/*delete the date. */
366 evas_object_data_set(obj, "gif_data", NULL);
369 Eina_Bool __gif_updater(void *data)
371 retv_if(!data, FALSE);
372 Evas_Object *gif = data;
373 setting_gif_data *gif_data = evas_object_data_get(gif, "gif_data");
374 retv_if(!gif_data, FALSE);
375 /*SETTING_TRACE_BEGIN; */
377 gif_data->cur_png_idx++;
378 if (NULL == gif_data->png_list[gif_data->cur_png_idx]) { /*the last element of current array. */
379 gif_data->cur_png_idx = 0;
381 elm_image_file_set(gif, gif_data->png_list[gif_data->cur_png_idx], NULL);
384 elm_image_object_size_get(gif, &w, &h);
385 setting_resize_object(gif, w, h);
391 Evas_Object *setting_create_image(Evas_Object *parent, const char *img_path)
393 Evas_Object *image = elm_image_add(parent);
394 /*SETTING_TRACE("icon_path:%s", icon_path); */
395 elm_image_file_set(image, img_path, NULL);
396 elm_image_resizable_set(image, EINA_TRUE, EINA_TRUE);
400 elm_image_object_size_get(image, &w, &h);
401 setting_resize_object(image, w, h);
402 evas_object_show(image);
407 Evas_Object *setting_create_image_with_round_corner(Evas *evas, const char *img_path, int w, int h)
409 Evas_Object *image = evas_object_image_add(evas);
410 evas_object_size_hint_weight_set(image, 0.0, EVAS_HINT_EXPAND);
411 evas_object_image_load_size_set(image, w, h);
412 evas_object_image_file_set(image, img_path, NULL);
414 evas_object_image_fill_set(image, 0, 0, w, h);
416 /*Set the dimensions for an image object's border, a region which @b
417 * @param obj The given image object.
418 * @param l The border's left width.
419 * @param r The border's right width.
420 * @param t The border's top width.
421 * @param b The border's bottom width.
423 evas_object_image_border_set(image, 16, 16, 16, 16); /*for round corner */
424 evas_object_image_filled_set(image, 1); /*to full fill */
425 evas_object_size_hint_min_set(image, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
426 evas_object_size_hint_max_set(image, w, h);
430 /* @png_list is an array end with 'NULL'. like ,
431 const char *png_list[] = {
432 SETTING_ICON_PATH_CFG"motions/motion_overturn_01.png",
433 SETTING_ICON_PATH_CFG"motions/motion_overturn_02.png",
434 SETTING_ICON_PATH_CFG"motions/motion_overturn_03.png",
435 SETTING_ICON_PATH_CFG"motions/motion_overturn_04.png",
436 SETTING_ICON_PATH_CFG"motions/motion_overturn_05.png",
437 NULL //must end with 'NULL'
441 Evas_Object *setting_create_gif(Evas_Object *parent, const char **png_list)
443 retv_if(!png_list, NULL);
444 setting_gif_data *gif_data = calloc(1, sizeof(setting_gif_data));
445 setting_retvm_if(!gif_data, NULL, "calloc failed");
446 gif_data->cur_png_idx = 0;
447 gif_data->png_list = png_list;
451 Evas_Object *gif = setting_create_image(parent, *png_list);/*the first element */
452 /*bind object data */
453 evas_object_data_set(gif, "gif_data", gif_data);
454 evas_object_event_callback_add(gif, EVAS_CALLBACK_DEL, __gif_del_cb, gif_data);
456 if (gif_data->update_timer) {
457 ecore_timer_del(gif_data->update_timer);
458 gif_data->update_timer = NULL;
460 gif_data->update_timer = ecore_timer_add(DEMO_STEP, (Ecore_Task_Cb)__gif_updater, gif);
462 setting_decorate_image_RGBA(gif, 14, 41, 73, 255);/*W011:bg, T051:text */
467 * Alternate the check object status and its binded vcof value via original vcofn value
470 int setting_draw_onoff_status(Evas_Object *obj, setting_bool_slp_list key)
476 setting_get_bool_slp_key(key, &value, &err);
478 elm_check_state_set(obj, !value);
479 ret = setting_set_bool_slp_key(key, !value, &err);
484 * Set the status of check object via its binded vconf value.
485 * @return 0: sucess, other: failed
488 int setting_check_onoff_status(Evas_Object *obj, setting_bool_slp_list key)
494 ret = setting_get_bool_slp_key(key, &value, &err);
495 elm_check_state_set(obj, value);
500 * Set the status of radio group object via its binded vconf value.
501 * @return 0: sucess, other: failed
504 int setting_update_chk_status(Evas_Object *chk, setting_int_slp_list type)
509 return SETTING_GENERAL_ERR_NULL_DATA_PARAMETER;
514 int ret = SETTING_RETURN_FAIL;
519 ret = setting_get_int_slp_key(type, &value, &err);
520 SETTING_TRACE("binded: %d, checked: %d, err: %d", type, value, err);
522 elm_radio_value_set(chk, value);
528 * Create a size specilized rectangle object
529 * @return a size specilized rectangle object
532 Evas_Object *setting_create_blank_rect_customize(Evas_Object *layout, int w,
537 rect = evas_object_rectangle_add(evas_object_evas_get(layout));
538 evas_object_size_hint_min_set(rect, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
539 evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, 0);
540 /*evas_object_color_set(rect, 0, 0, 0, 0); */
541 evas_object_color_set(rect, 8, 8, 8, 8);
547 * Create a size fixed rectangle object
551 * @return a size fixed rectangle object
554 Evas_Object *setting_create_blank_rect(Evas_Object *layout)
556 return setting_create_blank_rect_customize(layout,
557 SETTING_PADDING_WIDTH, 80);
561 * The API to Create an editfiled object
562 * @return an editfiled object
565 Evas_Object * /* multi-line is default, use elm_editfield_entry_single_line_set(ef, EINA_TRUE) to set single-line */
566 setting_create_editfiled(Evas_Object *win_main, char *title, char *def_str, char *guide_text)
568 Evas_Object *layout = NULL;
569 Evas_Object *entry = NULL;
570 layout = elm_layout_add(win_main);
573 elm_layout_theme_set(layout, "layout", "editfield", "title");
574 elm_object_part_text_set(layout, "elm.text", title);
576 elm_layout_theme_set(layout, "layout", "editfield", "default");
578 entry = elm_entry_add(win_main);
579 elm_object_part_content_set(layout, "elm.swallow.content", entry);
580 /*elm_entry_context_menu_disabled_set(entry, TRUE); */
581 /*elm_entry_magnifier_disabled_set(entry, TRUE); */
582 elm_entry_prediction_allow_set(entry, FALSE);
584 if (def_str && safeStrLen(def_str) > 0) {
585 elm_entry_entry_set(entry, def_str);
588 elm_object_part_text_set(layout, "elm.guidetext", _(guide_text));
590 elm_object_part_text_set(layout, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
594 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0);
595 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0);
597 evas_object_show(layout);
602 * Create a text box, which cannot be edited, just to show a specilization segment.
604 * @return a text box, which cannot be edited
607 Evas_Object *setting_create_textbox(Evas_Object *parent, const char *content)
609 Evas_Object *obj = NULL;
611 obj = elm_entry_add(parent);
612 evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, 0.0);
613 evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, 0.5);
614 elm_entry_single_line_set(obj, 0);
615 /* elm_entry_line_wrap_set(obj, 1); */
616 elm_entry_editable_set(obj, 0);
617 elm_entry_context_menu_disabled_set(obj, 1);
619 /* setting_disable_evas_object(obj); ***disable any events on entry */
621 elm_entry_entry_set(obj, content);
622 evas_object_show(obj);
627 * Make it no effect when clicking on a evas object and its sub-objects, such as, layout, genlist
632 void setting_disable_evas_object(Evas_Object *obj)
634 /* layout\genlist\scroller\elm_entry etc.. */
636 evas_object_pass_events_set(obj, EINA_TRUE);
641 * Make it normal acting when clicking on a evas object, such as, layout, genlist
646 void setting_enable_evas_object(Evas_Object *obj)
649 evas_object_pass_events_set(obj, EINA_FALSE);
654 * To resize a evas object, such as, icon, button..
661 void setting_resize_object(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
664 evas_object_size_hint_min_set(obj, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
665 evas_object_size_hint_max_set(obj, w, h);
666 evas_object_resize(obj, w, h);
671 * To create a bg object
674 * @param[in] bg_style
678 Evas_Object *setting_create_bg(Evas_Object *parent, Evas_Object *win, const char *bg_style)
680 retv_if(!parent, NULL);
681 Evas_Object *bg = elm_bg_add(parent);
683 if (bg_style) elm_object_style_set(bg, bg_style);
684 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
686 /*elm_win_resize_object_add(win, bg); */
687 evas_object_show(bg);
694 * To make an object which is operated by setting_dim_evas_object normal color
697 * @param[in] b_transparency_set:
698 * 1:the appearence of obj is made up of transparent backgroud color.
699 * 0:the appearence of obj is made up of non transparent color.
702 void setting_undo_dim_evas_object(Evas_Object *obj, bool b_transparenct)
709 evas_object_color_get(obj, &r, &g, &b, &a);
710 if (b_transparenct) {/*the appearence of obj is made up of transparent backgroud color. */
713 evas_object_color_set(obj, r * DIFF_TIMES, g * DIFF_TIMES, b * DIFF_TIMES, a);
718 * To make an object dim color
721 * @param[in] b_transparency_set:
722 * 1:the appearence of obj is made up of transparent backgroud color.
723 * 0:the appearence of obj is made up of non transparent color.
726 void setting_dim_evas_object(Evas_Object *obj, bool b_transparenct)
733 evas_object_color_get(obj, &r, &g, &b, &a);
734 if (b_transparenct) {/*the appearence of obj is made up of transparent backgroud color. */
737 evas_object_color_set(obj, r / DIFF_TIMES, g / DIFF_TIMES, b / DIFF_TIMES, a);
741 static void __btn_select_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
743 /*SETTING_TRACE_BEGIN; */
744 setting_dim_evas_object(obj, FALSE);
745 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
746 retm_if(data == NULL, "Invalid argument: data is NULL");
747 Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *)event_info;
748 Evas_Point *point_down = data;
749 point_down->x = ev->output.x;
750 point_down->y = ev->output.y;
753 static void __btn_release_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
755 /*SETTING_TRACE_BEGIN; */
756 setting_undo_dim_evas_object(obj, FALSE);
759 static void __btn_mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
761 /*SETTING_TRACE_BEGIN; */
762 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
763 retm_if(data == NULL, "Invalid argument: data is NULL");
764 Evas_Point *point_down = data;
765 Evas_Event_Mouse_Move *ev = (Evas_Event_Mouse_Move *)event_info;
766 int x_offset = ev->cur.output.x - point_down->x;
767 int y_offset = ev->cur.output.y - point_down->y;
768 if (x_offset < 0) x_offset = -x_offset;
769 if (y_offset < 0) y_offset = -y_offset;
770 if (x_offset <= MIN_MOVE_DISTANCE && y_offset <= MIN_MOVE_DISTANCE) {
773 setting_undo_dim_evas_object(obj, FALSE);
775 static void __btn_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
777 /*SETTING_TRACE_BEGIN; */
779 Evas_Point *point_down = data;
780 FREE(point_down);/*delete the date. */
784 * To make an object looks clickable: if pressed, it is dim color;if unpressed, it is normal color;
789 void setting_make_evas_object_clickable(Evas_Object *obj)
792 Evas_Point *point_down = calloc(1, sizeof(Evas_Point));
793 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, __btn_select_cb, point_down);
794 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP, __btn_release_cb, NULL);
795 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, __btn_mouse_move_cb, point_down);
796 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, __btn_del_cb, point_down);
801 * To create an icon which looks clickable(if pressed, it is dim color;if unpressed, it is normal color)
804 * @param[in] img_path
811 Evas_Object *setting_create_icon(Evas_Object *parent, const char *img_path,
812 Evas_Object_Event_Cb up_cb,
813 Evas_Object_Event_Cb down_cb,
814 Evas_Object_Event_Cb move_cb,
818 retv_if(!parent || !img_path, NULL);
819 Evas_Object *icon = elm_icon_add(parent);
820 retvm_if(!icon, NULL, "Failed Create icon!");
821 elm_image_file_set(icon, img_path, NULL);
822 setting_make_evas_object_clickable(icon);
825 evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_UP,
829 evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_DOWN,
833 evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_MOVE,
841 * To create a button which only has a image and looks clickable
842 * (if pressed, it is dim color;if unpressed, it is normal color)
844 * @param[in] img_path
851 Evas_Object *setting_create_image_button(Evas_Object *parent,
853 setting_call_back_func clicked_cb,
854 setting_call_back_func unpressed_cb,
858 retv_if(!parent, NULL);
859 Evas_Object *btn = elm_button_add(parent);
860 retvm_if(!btn, NULL, "Failed Create button!");
862 evas_object_smart_callback_add(btn, "clicked", clicked_cb, data);
866 evas_object_smart_callback_add(btn, "unpressed", unpressed_cb, data);
870 Evas_Object *icon = elm_icon_add(parent);
871 retvm_if(!icon, NULL, "Failed Create icon!");
872 elm_image_file_set(icon, btn_img, NULL);
873 elm_object_part_content_set(btn, "elm.swallow.content", icon);
874 setting_make_evas_object_clickable(btn);
880 EXPORT_PUBLIC void setting_entry_entry_set(Evas_Object *entry, const char *text, const int font_size)
882 if (isEmptyStr(text)) return;
886 snprintf(buf, sizeof(buf), "DEFAULT='font_size=%d'", font_size);
888 elm_entry_text_style_user_push(entry, buf);
889 elm_entry_entry_set(entry, text);
895 * set font_size, color or align(right, left, middle),if need, you
896 * can add </font_siz>, </color> or </align> to controll a segment words; or else
897 * the text will take the same effect until the end of text.
898 * @param[in] input_str
899 * @param[in] font_size
901 * @param[in] align :may be right, left, middle/center
904 char *setting_customize_text(const char *input_str, const int font_size,
905 const char *color, const char *align)
907 /*SETTING_TRACE_BEGIN; */
908 retv_if(isEmptyStr(input_str), NULL);
909 /*SETTING_TRACE("input_str:%s, color:%s", input_str, color); */
910 char speciliztion[MAX_SPECIALIZITION_LEN] = { 0, };
911 /*<font_size=%d><align=middle><color=#9C9C9C>bbb</color></align></font_size> */
913 snprintf(speciliztion, sizeof(speciliztion),
914 "<font_size=%d>", font_size);
918 g_strlcat(speciliztion, "<align=", MAX_SPECIALIZITION_LEN);
919 g_strlcat(speciliztion, align, MAX_SPECIALIZITION_LEN);
920 g_strlcat(speciliztion, ">", MAX_SPECIALIZITION_LEN);
924 char input_str1[MAX_SPECIALIZITION_LEN] = { 0, };
925 safeCopyStr(input_str1, input_str, MAX_SPECIALIZITION_LEN);
926 char *p = strstr(input_str1, "<color=");
927 if (p) { /*already has customed color,to replace color sub_string */
928 p += strlen("<color=");
929 /*memcpy(p, color, strlen(color)); */
930 char *q = (char *)color;
931 while ('\0' != p[0] && '\0' != q[0]) {
936 if ('>' != p[0]) { /*invalid format */
937 g_strlcat(speciliztion, "<color=", MAX_SPECIALIZITION_LEN);
938 g_strlcat(speciliztion, color, MAX_SPECIALIZITION_LEN);
939 g_strlcat(speciliztion, ">", MAX_SPECIALIZITION_LEN);
940 g_strlcat(speciliztion, input_str, MAX_SPECIALIZITION_LEN);
941 g_strlcat(speciliztion, "</color>", MAX_SPECIALIZITION_LEN);
943 g_strlcat(speciliztion, input_str1, MAX_SPECIALIZITION_LEN);
945 g_strlcat(speciliztion, "<color=", MAX_SPECIALIZITION_LEN);
946 g_strlcat(speciliztion, color, MAX_SPECIALIZITION_LEN);
947 g_strlcat(speciliztion, ">", MAX_SPECIALIZITION_LEN);
948 g_strlcat(speciliztion, input_str, MAX_SPECIALIZITION_LEN);
949 g_strlcat(speciliztion, "</color>", MAX_SPECIALIZITION_LEN);
952 g_strlcat(speciliztion, input_str, MAX_SPECIALIZITION_LEN);
955 g_strlcat(speciliztion, "</align>", MAX_SPECIALIZITION_LEN);
958 g_strlcat(speciliztion, "</font_size>", MAX_SPECIALIZITION_LEN);
961 /*SETTING_TRACE("Exit %s, return :%s", __FUNCTION__, speciliztion); */
962 return (char *)strdup(speciliztion);;
965 /*if pass traits=" ",means make tts omit the traits-reading */
967 void setting_set_tts_info(Evas_Object *obj, const char *label,
968 const char *traits, const char *state,
975 /*SETTING_TRACE("label:%s,traits:%s,state:%s,guide:%s", label, traits,state,guide); */
977 elm_access_info_set(obj, ELM_ACCESS_INFO, label);
979 if (traits)/* && isEmptyStr(elm_access_info_get(obj, ELM_ACCESS_TYPE))) */
980 elm_access_info_set(obj, ELM_ACCESS_TYPE, traits);
983 elm_access_info_set(obj, ELM_ACCESS_STATE, state);
985 elm_access_info_set(obj, ELM_ACCESS_CONTEXT_INFO, NULL);
986 elm_access_info_set(obj, ELM_ACCESS_CONTEXT_INFO, guide);
991 void __toogle_gl_sel(void *data, Evas_Object *obj, void *event_info)
993 /* SETTING_TRACE_BEGIN; */
994 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
995 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
996 elm_genlist_item_selected_set(item, 0);
997 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
1001 setting_update_gl_item_chk_status(list_item, !(list_item->chk_status));
1003 /*int ret = setting_set_bool_slp_key(list_item->int_slp_setting_binded, list_item->chk_status, &err); */
1004 const char *use_vconf = (char *)(list_item->int_slp_setting_binded);
1005 int ret = vconf_set_bool(use_vconf, list_item->chk_status);
1007 setting_retm_if(0 != ret, "Failed to set vconf [%s]", list_item->int_slp_setting_binded);
1012 void __toogle_chk_changed(void *data, Evas_Object *obj, void *event_info)
1014 retm_if(data == NULL, "Data parameter is NULL");
1015 Setting_GenGroupItem_Data *list_item =
1016 (Setting_GenGroupItem_Data *) data;
1017 list_item->chk_status = elm_check_state_get(obj); /* for update */
1020 /*int ret = setting_set_bool_slp_key(list_item->int_slp_setting_binded, list_item->chk_status, &err); */
1021 const char *use_vconf = (char *)(list_item->int_slp_setting_binded);
1022 int ret = vconf_set_bool(use_vconf, list_item->chk_status);
1023 if (0 != ret) { /*rollback */
1024 setting_update_gl_item_chk_status(list_item, !(list_item->chk_status));
1029 EXPORT_PUBLIC void setting_conformant_keypad_state(Evas_Object *win_main, bool enable)
1031 Evas_Object *conform = evas_object_data_get(win_main, "conformant");
1033 SETTING_TRACE("conformant keypad %d", enable);
1035 elm_object_signal_emit(conform, "elm,state,virtualkeypad,enable", "");
1036 elm_object_signal_emit(conform, "elm,state,clipboard,enable", "");
1038 elm_object_signal_emit(conform, "elm,state,virtualkeypad,disable", "");
1039 elm_object_signal_emit(conform, "elm,state,clipboard,disable", "");
1044 static void __title_btn_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
1047 SETTING_TRACE_BEGIN;
1049 evas_object_data_set(obj, "text", NULL);
1052 EXPORT_PUBLIC Evas_Object *setting_create_navibar_title_text_btn(Evas_Object *parent, const char *text, Evas_Smart_Cb func, void *data)
1054 Evas_Object *btn = elm_button_add(parent);
1058 elm_object_style_set(btn, "naviframe/title_text");
1059 evas_object_event_callback_add(btn, EVAS_CALLBACK_DEL, __title_btn_del_cb, NULL);
1061 elm_object_text_set(btn, _(text));
1062 evas_object_data_set(btn, "text", text);
1065 evas_object_smart_callback_add(btn, "clicked", func, data);
1071 EXPORT_PUBLIC void setting_help_popup_circle_block_create(Evas_Object *win, Evas_Object *parent, Evas_Object **circle,
1072 Evas_Object **popup, char *string_id, int x, int y, Evas_Coord_Rectangle *rect)
1074 helpui_set_block_win(win);
1075 setting_help_popup_circle_unblock_create(parent, circle, popup, string_id, x, y);
1076 helpui_set_unblock_rect(win, rect);
1079 EXPORT_PUBLIC void setting_help_popup_circle_block_move(Evas_Object *win, Evas_Object *circle, Evas_Object *popup, int x,
1080 int y, Evas_Coord_Rectangle *rect)
1082 helpui_set_unblock_win(win);
1083 helpui_set_block_win(win);
1084 evas_object_move(circle, x, y);
1085 evas_object_move(popup, x, y + 10);
1086 helpui_set_unblock_rect(win, rect);
1089 static void __help_popup_language_change_cb(void *data, Evas_Object *obj, void *source)
1091 char *string_id = (char *)data;
1092 char *message = _(string_id);
1093 helpui_set_popup_text(obj, message);
1096 EXPORT_PUBLIC void setting_help_popup_circle_unblock_create(Evas_Object *parent, Evas_Object **circle,
1097 Evas_Object **popup, char *string_id, int x, int y)
1099 *circle = helpui_add_circle(parent, HELP_CIRCLE_BIG);
1100 evas_object_move(*circle, x, y);
1101 char *message = _(string_id);
1102 *popup = helpui_add_popup(parent, message, HELP_POPUP_WITH_ARROW, NULL, NULL);
1103 helpui_set_popup_language_changed_cb(*popup, __help_popup_language_change_cb,
1105 evas_object_move(*popup, x, y + 8);
1108 EXPORT_PUBLIC void setting_help_popup_circle_block_delete(Evas_Object *win, Evas_Object **circle, Evas_Object **popup)
1110 helpui_set_unblock_win(win);
1112 evas_object_del(*circle);
1116 evas_object_del(*popup);
1121 EXPORT_PUBLIC void setting_help_popup_block_create(Evas_Object *win, Evas_Object *parent,
1122 Evas_Object **popup, char *string_id, int x, int y, Evas_Coord_Rectangle *rect)
1124 helpui_set_block_win(win);
1125 setting_help_popup_unblock_create(parent, popup, string_id, x, y);
1127 helpui_set_unblock_rect(win, rect);
1131 EXPORT_PUBLIC void setting_help_popup_block_move(Evas_Object *win, Evas_Object *popup, int x, int y,
1132 Evas_Coord_Rectangle *rect)
1134 helpui_set_unblock_win(win);
1135 helpui_set_block_win(win);
1136 evas_object_move(popup, x, y);
1138 helpui_set_unblock_rect(win, rect);
1142 EXPORT_PUBLIC void setting_help_popup_unblock_create(Evas_Object *parent,
1143 Evas_Object **popup, char *string_id, int x, int y)
1145 char *message = _(string_id);
1146 *popup = helpui_add_popup(parent, message, HELP_POPUP_WITHOUT_ARROW, NULL, NULL);
1147 helpui_set_popup_language_changed_cb(*popup, __help_popup_language_change_cb,
1149 evas_object_move(*popup, x, y);
1153 #define MIN_SWIP_DISTANCE_X 300
1154 #define MIN_SWIP_DISTANCE_Y 75
1156 static void __tabbar_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
1158 /*SETTING_TRACE_BEGIN; */
1159 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1160 retm_if(data == NULL, "Invalid argument: data is NULL");
1161 Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *)event_info;
1162 Evas_Point *point_down = data;
1163 point_down->x = ev->output.x;
1164 point_down->y = ev->output.y;
1167 static void __tabbar_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
1169 /*SETTING_TRACE_BEGIN; */
1170 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1171 retm_if(data == NULL, "Invalid argument: data is NULL");
1172 Evas_Point *point_down = data;
1173 Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *)event_info;
1175 int x_offset = ev->output.x - point_down->x;
1176 int y_offset = ev->output.y - point_down->y;
1180 Evas_Object *navi = NULL;
1181 Elm_Object_Item *top_item = NULL;
1182 Evas_Object *eo_view = NULL;
1183 Evas_Object *tabbar = NULL;
1184 /*char *tabbar_t = NULL; */
1185 if ((navi = elm_object_part_content_get(obj, "elm.swallow.content"))
1186 && (top_item = elm_naviframe_top_item_get(navi))) {
1187 /*SETTING_TRACE("top_item:%p", top_item); */
1188 if ((eo_view = elm_object_item_content_get(top_item))
1189 && (tabbar = elm_object_part_content_get(eo_view, "elm.swallow.tabbar"))
1190 && 0 == safeStrCmp(evas_object_type_get(tabbar), "elm_toolbar")) {
1191 /*SETTING_TRACE("Skip Case 1"); */
1195 if (skip && (tabbar = elm_object_item_part_content_get(top_item, "tabbar"))
1196 && 0 == safeStrCmp(evas_object_type_get(tabbar), "elm_toolbar")) {
1197 /*SETTING_TRACE("Skip case 2"); */
1203 /*SETTING_TRACE("tabbar:%p", tabbar); */
1204 /*SETTING_TRACE("SWIPE VALUE : x=(%d) : y=(%d)", x_offset, y_offset); */
1205 if (-x_offset > MIN_SWIP_DISTANCE_X && abs(y_offset) < MIN_SWIP_DISTANCE_Y) {
1207 Elm_Object_Item *cur_item = elm_toolbar_selected_item_get(tabbar);
1209 Elm_Object_Item *dest_item = elm_toolbar_item_next_get(cur_item);
1210 elm_toolbar_item_selected_set(dest_item, EINA_TRUE);
1213 } else if (x_offset > MIN_SWIP_DISTANCE_X && abs(y_offset) < MIN_SWIP_DISTANCE_Y) {
1214 Elm_Object_Item *cur_item = elm_toolbar_selected_item_get(tabbar);
1216 Elm_Object_Item *dest_item = elm_toolbar_item_prev_get(cur_item);
1217 elm_toolbar_item_selected_set(dest_item, EINA_TRUE);
1223 static void __tabbar_btn_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
1225 /*SETTING_TRACE_BEGIN; */
1227 Evas_Point *point_down = data;
1228 FREE(point_down);/*delete the date. */
1229 evas_object_data_set(obj, "tabbar", NULL);
1232 static void __tabbar_mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
1234 /*SETTING_TRACE_BEGIN; */
1237 EXPORT_PUBLIC void setting_tabbar_enable_swip_effect(Evas_Object *ly_main, Evas_Object *tabbar)
1239 SETTING_TRACE_BEGIN;
1241 evas_object_data_set(ly_main, "tabbar", tabbar);
1242 Evas_Point *point_down = calloc(1, sizeof(Evas_Point));
1243 evas_object_event_callback_add(ly_main, EVAS_CALLBACK_MOUSE_DOWN, __tabbar_mouse_down_cb, point_down);
1244 evas_object_event_callback_add(ly_main, EVAS_CALLBACK_MOUSE_UP, __tabbar_mouse_up_cb, point_down);
1245 evas_object_event_callback_add(ly_main, EVAS_CALLBACK_MOUSE_MOVE, __tabbar_mouse_move_cb, point_down);
1246 evas_object_event_callback_add(ly_main, EVAS_CALLBACK_DEL, __tabbar_btn_del_cb, point_down);
1250 EXPORT_PUBLIC void setting_tabbar_disable_swip_effect(Evas_Object *ly_main, Evas_Object *tabbar)
1252 SETTING_TRACE_BEGIN;
1254 evas_object_data_set(ly_main, "tabbar", tabbar);
1255 /*Evas_Point *point_down = calloc(1,sizeof(Evas_Point)); */
1256 evas_object_event_callback_del(ly_main, EVAS_CALLBACK_MOUSE_DOWN, __tabbar_mouse_down_cb);
1257 evas_object_event_callback_del(ly_main, EVAS_CALLBACK_MOUSE_UP, __tabbar_mouse_up_cb);
1258 evas_object_event_callback_del(ly_main, EVAS_CALLBACK_MOUSE_MOVE, __tabbar_mouse_move_cb);
1259 evas_object_event_callback_del(ly_main, EVAS_CALLBACK_DEL, __tabbar_btn_del_cb);
1260 /* evas_object_event_callback_del(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func) */
1264 static void __obj_listen_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
1268 const char *vconf = (const char *)evas_object_data_get(obj, "vconf");
1269 vconf_callback_fn cb = (vconf_callback_fn)evas_object_data_get(obj, "cb");
1270 (void)vconf_ignore_key_changed(vconf, cb);
1272 evas_object_data_set(obj, "vconf", NULL);
1273 evas_object_data_set(obj, "cb", NULL);
1274 evas_object_data_set(obj, "data", NULL);
1278 setting_obj_listen_on(Evas_Object *obj, const char *vconf, vconf_callback_fn cb, void *data)
1280 /*Bind the life of obj and vconf listen */
1281 evas_object_data_set(obj, "vconf", vconf);
1283 evas_object_data_set(obj, "cb", cb);
1285 evas_object_data_set(obj, "data", data);
1287 vconf_notify_key_changed(vconf, cb, data);
1288 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, __obj_listen_del_cb, NULL);
1292 setting_decorate_image_RGBA(Evas_Object *obj, int r, int g, int b, int a)
1295 evas_object_color_set(obj, r, g, b, a);
1301 setting_protect_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
1303 /*SETTING_TRACE("data:%p", data); */
1304 if (NULL != data) *((void **)data) = NULL;