3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.1 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 #include <setting-display-screen-mode.h>
20 static int setting_display_screen_mode_create(void *cb);
21 static int setting_display_screen_mode_destroy(void *cb);
22 static int setting_display_screen_mode_update(void *cb);
23 static int setting_display_screen_mode_cleanup(void *cb);
25 static char* str_in_arr[] = {"Dynamic", "Standard", "Natural", "Movie"};
26 static char* str_out_arr[] = {Keystr_Dynamic, Keystr_Standard, Keystr_Natural, Keystr_Movie};
28 static void setting_display_screen_mode_mouse_up_Gendial_list_radio_cb(void *data, Evas_Object *obj, void *event_info);
30 setting_view setting_view_display_screen_mode = {
31 .create = setting_display_screen_mode_create,
32 .destroy = setting_display_screen_mode_destroy,
33 .update = setting_display_screen_mode_update,
34 .cleanup = setting_display_screen_mode_cleanup,
38 static Evas_Object *__gl_content_get(void *data, Evas_Object *obj, const char *part)
40 if (!strcmp(part, "elm.icon")) {
42 Evas_Object *sub_layout = elm_layout_add(obj);
43 elm_layout_file_set(sub_layout, SETTING_THEME_EDJ_NAME, "screen_mode");
44 evas_object_size_hint_weight_set(sub_layout, EVAS_HINT_EXPAND, 0.0);
45 evas_object_show(sub_layout);
47 Evas_Object *image = elm_image_add(obj);
48 elm_image_file_set(image, IMG_SCREEN_MODE, NULL);
49 elm_image_resizable_set(image, EINA_TRUE, EINA_TRUE);
50 evas_object_show(image);
54 elm_image_object_size_get(image, &w, &h);
55 setting_resize_object(image, w * WIDGET_SCALE_FACTOR, h * WIDGET_SCALE_FACTOR);
57 elm_object_part_content_set(sub_layout, "content", image);
61 image = elm_image_add(obj);
62 elm_image_file_set(image, IMG_SCREEN_MODE, NULL);
64 int w = 668; /* left padding and right padding is 26, so the width = 720 - 26 -26 */
66 elm_image_object_size_get(image, NULL, &h);
67 evas_object_size_hint_min_set(image, w * WIDGET_SCALE_FACTOR, h * WIDGET_SCALE_FACTOR);
68 evas_object_size_hint_max_set(image, w * WIDGET_SCALE_FACTOR, h * WIDGET_SCALE_FACTOR);
69 evas_object_resize(image, w * WIDGET_SCALE_FACTOR, h * WIDGET_SCALE_FACTOR);
77 static void __gl_item_del(void *data, Evas_Object *obj)
79 setting_retm_if(data == NULL, "Data parameter is NULL");
80 Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *) data;
82 G_FREE(item_data->keyStr);
83 G_FREE(item_data->sub_desc);
88 /* ***************************************************
92 ***************************************************/
93 static int setting_display_screen_mode_create(void *cb)
97 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
99 SettingDisplayUG *ad = (SettingDisplayUG *) cb;
101 setting_call_back_func gl_sel_cb = NULL;
102 Evas_Object *genlist = NULL;
103 Setting_GenGroupItem_Data *item_data = NULL;
105 genlist = elm_genlist_add(ad->navi_bar);
106 retvm_if(genlist == NULL, SETTING_RETURN_FAIL, "scroller == NULL");
107 elm_object_style_set(genlist, "dialogue");
108 elm_genlist_clear(genlist); /* first to clear list */
110 setting_push_layout_navi_bar(_(Keystr_ScreenMode), _("IDS_COM_BODY_BACK"),
112 setting_display_screen_mode_click_softkey_back_cb,
113 NULL, NULL, ad, genlist, ad->navi_bar, NULL);
115 Elm_Object_Item *item = elm_genlist_item_append(genlist,
118 ELM_GENLIST_ITEM_NONE,
120 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
122 ad->itc_screen_mode.item_style = "1icon/with_no_line";
123 ad->itc_screen_mode.func.text_get = NULL;
124 ad->itc_screen_mode.func.content_get = __gl_content_get;
125 ad->itc_screen_mode.func.state_get = NULL;
126 ad->itc_screen_mode.func.del = __gl_item_del;
128 Setting_GenGroupItem_Data *screen_mode = (Setting_GenGroupItem_Data *) calloc(1, sizeof(Setting_GenGroupItem_Data));
129 setting_retvm_if(!screen_mode, SETTING_RETURN_FAIL, "calloc failed");
132 screen_mode->userdata = ad;
133 screen_mode->item = elm_genlist_item_append(genlist, &(ad->itc_screen_mode), screen_mode, NULL,
134 ELM_GENLIST_ITEM_NONE, NULL, NULL);
135 elm_genlist_item_select_mode_set(screen_mode->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
137 SETTING_TRACE_ERROR("screen_mode is NULL");
138 return SETTING_RETURN_FAIL;
141 gl_sel_cb = setting_display_screen_mode_mouse_up_Gendial_list_radio_cb;
143 Evas_Object *radio = elm_radio_add(genlist);
144 elm_radio_state_value_set(radio, -1);
146 char* curmode = vconf_get_str(VCONFKEY_SETAPPL_SCREENMODE_SELNAME);
147 SETTING_TRACE(">>> CUR SCREEN MODE : %s ", curmode);
151 for (i=0; i< sizeof(str_in_arr)/sizeof(str_in_arr[0]) ;i++)
153 item_data = setting_create_Gendial_field_1radio(genlist,
154 &(itc_1text_1icon_2),
156 radio, /* sel data */
159 str_out_arr[i], NULL);
161 item_data->userdata = ad;
163 SETTING_TRACE_ERROR("item_data is NULL");
169 for (j=0; j< sizeof(str_in_arr)/sizeof(str_in_arr[0]) ;j++) {
170 if (0 == strcmp(str_in_arr[j], curmode)) {
171 elm_radio_value_set(radio, j);
176 item = elm_genlist_item_append(genlist, &itc_bottom_seperator, NULL, NULL,
177 ELM_GENLIST_ITEM_NONE, NULL, NULL);
178 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
180 setting_view_display_screen_mode.is_create = 1;
181 return SETTING_RETURN_SUCCESS;
184 static int setting_display_screen_mode_destroy(void *cb)
188 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
190 SettingDisplayUG *ad = (SettingDisplayUG *) cb;
192 elm_naviframe_item_pop(ad->navi_bar);
194 setting_view_display_screen_mode.is_create = 0;
196 return SETTING_RETURN_SUCCESS;
199 static int setting_display_screen_mode_update(void *cb)
203 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
205 return SETTING_RETURN_SUCCESS;
208 static int setting_display_screen_mode_cleanup(void *cb)
211 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
213 SettingDisplayUG *ad = (SettingDisplayUG *) cb;
215 setting_display_screen_mode_destroy(ad);
217 return SETTING_RETURN_SUCCESS;
220 /* ***************************************************
224 ***************************************************/
227 setting_display_screen_mode_click_softkey_back_cb(void *data, Evas_Object *obj, void *event_info)
231 setting_retm_if(data == NULL,
232 "[Setting > Display] Data parameter is NULL");
234 SettingDisplayUG *ad = (SettingDisplayUG *) data;
236 setting_view_change(&setting_view_display_screen_mode, &setting_view_display_main, ad);
242 setting_display_screen_mode_mouse_up_Gendial_list_radio_cb(void *data, Evas_Object *obj, void *event_info)
246 setting_retm_if(data == NULL, "Data parameter is NULL");
247 setting_retm_if(event_info == NULL,
248 "Invalid argument: event info is NULL");
250 Evas_Object *radio = (Evas_Object *) data;
251 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
252 elm_genlist_item_selected_set(item, 0);
254 Setting_GenGroupItem_Data *list_item =
255 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
256 //SettingDisplayUG *ad = (SettingDisplayUG *) list_item->userdata;
258 elm_radio_value_set(radio, list_item->chk_status);
259 vconf_set_str(VCONFKEY_SETAPPL_SCREENMODE_SELNAME, str_in_arr[list_item->chk_status]);
260 /* Set status to device manager */
261 device_set_image_enhance_mode(list_item->chk_status);
262 SETTING_TRACE(">>> AFTER VCONF SET : %s ", str_in_arr[list_item->chk_status]);