2 * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.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://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing,
11 * software 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 #include "bt-widget.h"
19 #include "bt-main-ug.h"
20 #include "bt-type-define.h"
22 Evas_Object *_bt_create_naviframe(Evas_Object *parent)
28 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
30 nf = elm_naviframe_add(parent);
31 elm_object_part_content_set(parent, "elm.swallow.content", nf);
39 Evas_Object *_bt_create_icon(Evas_Object *parent, char *img)
44 char buf[BT_IMG_PATH_MAX] = { 0, };
46 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
47 retvm_if(img == NULL, NULL, "Invalid argument: img is NULL\n");
49 if (strlen(img) >= BT_IMG_PATH_MAX) {
50 BT_DBG("image path is wrong [%s]", img);
53 ic = elm_image_add(parent);
54 snprintf(buf, BT_IMG_PATH_MAX, "%s", img);
55 elm_image_file_set(ic, buf, NULL);
56 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL,
58 elm_image_resizable_set(ic, 1, 1);
67 Evas_Object *_bt_create_button(Evas_Object *parent, char *style, char *text,
68 char *icon_path, Evas_Smart_Cb func, void *data)
72 Evas_Object *btn = NULL;
73 Evas_Object *icon = NULL;
75 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
76 btn = elm_button_add(parent);
79 elm_object_style_set(btn, style);
82 icon = elm_image_add(btn);
83 elm_image_file_set(icon, icon_path, NULL);
84 elm_object_part_content_set(btn, "elm.icon", icon);
88 elm_object_text_set(btn, text);
91 evas_object_smart_callback_add(btn, "clicked", func, data);
93 evas_object_show(btn);
100 Evas_Object *_bt_modify_button(Evas_Object *btn, char *style, char *text,
105 Evas_Object *icon = NULL;
107 retvm_if(btn == NULL, NULL, "Invalid argument: parent is NULL\n");
110 elm_object_style_set(btn, style);
113 icon = elm_image_add(btn);
114 elm_image_file_set(icon, icon_path, NULL);
115 elm_object_part_content_set(btn, "elm.icon", icon);
117 elm_object_part_content_set(btn, "elm.icon", NULL);
121 elm_object_text_set(btn, text);
123 evas_object_show(btn);
130 Evas_Object *_bt_create_progressbar(Evas_Object *parent, const char *style)
134 Evas_Object *progress_bar = NULL;
136 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
138 progress_bar = elm_progressbar_add(parent);
141 elm_object_style_set(progress_bar, style);
143 elm_object_style_set(progress_bar, "list_process");
145 evas_object_show(progress_bar);
146 elm_progressbar_pulse(progress_bar, EINA_TRUE);
153 Evas_Object *_bt_create_genlist(Evas_Object *parent)
157 Evas_Object *genlist = NULL;
159 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
161 genlist = elm_genlist_add(parent);
162 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND,
164 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL,
166 evas_object_show(genlist);
172 Evas_Object *_bt_create_separator(Evas_Object *parent, const char *style)
176 Evas_Object *separator = NULL;
178 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
180 separator = elm_separator_add(parent);
181 elm_separator_horizontal_set(separator, EINA_TRUE);
182 elm_object_style_set(separator, style);
183 evas_object_show(separator);
189 Evas_Object *_bt_create_box(Evas_Object *parent)
193 Evas_Object *box = NULL;
195 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
197 box = elm_box_add(parent);
198 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
199 evas_object_size_hint_align_set(box, 0.0, 0.0);
200 evas_object_show(box);
206 Evas_Object *_bt_create_controlbar(Evas_Object *parent, char *style)
210 Evas_Object *toolbar = NULL;
212 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
214 toolbar = elm_toolbar_add(parent);
215 elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);
218 elm_object_style_set(toolbar, style);
220 evas_object_show(toolbar);
227 Evas_Object *_bt_create_scroller(Evas_Object *parent, Evas_Object *ly)
231 Evas_Object *scroller;
233 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
235 scroller = elm_scroller_add(parent);
237 elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
238 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF,
239 ELM_SCROLLER_POLICY_AUTO);
242 elm_object_content_set(scroller, ly);
244 evas_object_show(scroller);
252 Evas_Object *_bt_create_bg(Evas_Object *parent, char *style)
258 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
260 bg = elm_bg_add(parent);
262 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
266 elm_object_style_set(bg, style);
268 elm_win_resize_object_add(parent, bg);
270 evas_object_show(bg);
277 Evas_Object *_bt_create_layout(Evas_Object *parent, char *edj, char *content)
283 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
285 layout = elm_layout_add(parent);
287 if (edj != NULL && content != NULL)
288 elm_layout_file_set(layout, edj, content);
290 elm_layout_theme_set(layout, "layout", "application",
292 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
296 evas_object_show(layout);
303 Evas_Object *_bt_create_conformant(Evas_Object *parent, Evas_Object *content)
307 Evas_Object *conform = NULL;
309 elm_win_conformant_set(parent, 1);
310 conform = elm_conformant_add(parent);
311 elm_object_style_set(conform, "internal_layout");
312 evas_object_show(conform);
315 elm_object_content_set(conform, content);
322 Evas_Object *_bt_create_popup(Evas_Object *parent, char *title, char *text,
323 void *cb, void *cb_data, int timer_val)
326 retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
328 Evas_Object *popup = NULL;
330 popup = elm_popup_add(parent);
331 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
335 elm_object_part_text_set(popup, "title,text", title);
338 elm_object_text_set(popup, text);
341 evas_object_smart_callback_add(popup, "block,clicked",
342 (Evas_Smart_Cb) cb, cb_data);
345 elm_popup_timeout_set(popup, (double)timer_val);
347 evas_object_show(popup);
353 Evas_Object *_bt_create_selectioninfo(Evas_Object *parent, char *text,
354 int rotation, void *cb,
355 void *cb_data,int timeout)
359 Evas_Object *selectioninfo = NULL;
360 Evas_Object *layout = NULL;
362 retv_if(parent == NULL, NULL);
363 retv_if(text == NULL, NULL);
366 selectioninfo = elm_notify_add(parent);
367 retv_if(selectioninfo == NULL, NULL);
368 evas_object_size_hint_weight_set(selectioninfo,
372 /* selectioninfo layout add */
373 layout = elm_layout_add(selectioninfo);
374 retv_if(layout == NULL, NULL);
376 if (rotation == BT_ROTATE_LANDSCAPE ||
377 rotation == BT_ROTATE_LANDSCAPE_UPSIDEDOWN) {
378 elm_layout_theme_set(layout,
379 "standard", "selectioninfo",
380 "horizontal/bottom_64");
382 elm_layout_theme_set(layout,
383 "standard", "selectioninfo",
384 "vertical/bottom_64");
387 /* selectioninfo layout content set to notify */
388 elm_object_content_set(selectioninfo, layout);
393 evas_object_event_callback_add(selectioninfo,
398 /* text set and timeout set */
399 edje_object_part_text_set(_EDJ(layout), "elm.text", text);
400 elm_notify_timeout_set(selectioninfo, timeout);
401 evas_object_show(selectioninfo);
405 return selectioninfo;
408 void _bt_rotate_selectioninfo(Evas_Object *selectioninfo, int rotation)
412 Evas_Object *layout = NULL;
413 const char *text = NULL;
415 ret_if(selectioninfo == NULL);
417 layout = elm_object_content_get(selectioninfo);
418 ret_if(layout == NULL);
420 text = edje_object_part_text_get(_EDJ(layout), "elm.text");
421 ret_if(text == NULL);
423 BT_DBG("rotation: %d", rotation);
424 BT_DBG("text: %s", text);
426 if (rotation == BT_ROTATE_LANDSCAPE ||
427 rotation == BT_ROTATE_LANDSCAPE_UPSIDEDOWN) {
428 elm_layout_theme_set(layout,
429 "standard", "selectioninfo",
430 "horizontal/bottom_12");
432 elm_layout_theme_set(layout,
433 "standard", "selectioninfo",
434 "vertical/bottom_12");
437 edje_object_part_text_set(_EDJ(layout), "elm.text", text);