ea4e7252f9d8c968042df5edd75102aa4369c5e5
[apps/native/volume-app.git] / src / _util_efl.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  * 
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
7  * 
8  *     http://www.tizenopensource.org/license
9  * 
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.
15  */
16
17
18 #include <Ecore.h>
19 #include <Ecore_X.h>
20
21 #include "volume.h"
22 #include "_util_log.h"
23
24 Evas_Object *_add_window(const char *name)
25 {
26         Evas_Object *eo = NULL;
27         int w = -1, h = -1;
28         eo = elm_win_add(NULL, name, ELM_WIN_NOTIFICATION);
29         if (eo) {
30                 elm_win_title_set(eo, name);
31                 elm_win_borderless_set(eo, EINA_TRUE);
32                 elm_win_alpha_set(eo, EINA_TRUE);
33                 ecore_x_window_size_get(
34                                 ecore_x_window_root_first_get(),
35                                 &w, &h);
36                 if(w == -1 || h == -1){
37                         _E("ecore_x_window_seiz_get() is failed\n");
38                         return NULL;
39                 }
40                 evas_object_resize(eo, w, h);
41         }
42         return eo;
43 }
44
45 Evas_Object *_add_slider(Evas_Object *parent, int min, int max, int val)
46 {
47         Evas_Object *sl = NULL;
48         sl = elm_slider_add(parent);
49         retvm_if(sl == NULL, NULL, "Failed to add slider\n");
50         elm_slider_horizontal_set(sl, EINA_TRUE);
51         elm_slider_indicator_show_set(sl, EINA_TRUE);
52         elm_slider_indicator_format_set(sl, "%.0f");
53         evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
54         evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
55         elm_slider_min_max_set(sl, min, max);
56         elm_slider_value_set(sl, val);
57         return sl;
58 }
59
60 Evas_Object *_add_layout(Evas_Object *parent, const char *file,
61                              const char *group)
62 {
63         Evas_Object *eo = NULL;
64         int r = -1;
65
66         retvm_if(parent == NULL, NULL, "Invalid argument: parent is NULL\n");
67         retvm_if(file == NULL, NULL, "Invalid argument: file is NULL\n");
68         retvm_if(group == NULL, NULL, "Invalid argument: group is NULL\n");
69
70         eo = elm_layout_add(parent);
71         retvm_if(eo == NULL, NULL, "Failed to add layout\n");
72
73         r = elm_layout_file_set(eo, file, group);
74         if (!r) {
75                 _E("Failed to set file[%s]\n", file);
76                 evas_object_del(eo);
77                 return NULL;
78         }
79
80         evas_object_size_hint_weight_set(eo,
81                         EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
82         evas_object_show(eo);
83         return eo;
84 }
85
86 Evas_Object *_add_button(Evas_Object *parent, const char *style, const char *text)
87 {
88         Evas_Object *bt = NULL;
89         bt = elm_button_add(parent);
90         retvm_if(bt == NULL, NULL, "Failed to add button\n");
91         if (style) elm_object_style_set(bt, style);
92         elm_object_focus_set(bt, EINA_FALSE);
93         elm_object_text_set(bt, text);
94         evas_object_show(bt);
95         return bt;
96 }
97
98 Evas_Object *_add_popup(Evas_Object *parent, const char *style)
99 {
100         Evas_Object *pu = NULL;
101         pu = elm_popup_add(parent);
102         retvm_if(pu == NULL, NULL, "[Error] Failed to add popup\n");
103         evas_object_size_hint_weight_set(pu, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
104         if (style) elm_object_style_set(pu, style);
105         evas_object_show(pu);
106         return pu;
107 }
108 Evas_Object *_add_label(Evas_Object *parent, const char *style, const char *text)
109 {
110         Evas_Object *lb = NULL;
111         lb = elm_label_add(parent);
112         retvm_if(lb == NULL, NULL, "Failed to add label\n");
113         elm_object_style_set(lb, style);
114         evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
115         evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
116         elm_label_line_wrap_set(lb, ELM_WRAP_MIXED);
117         elm_object_text_set(lb, text);
118         return lb;
119 }
120