376900cdf141298c0bff7ed6c1ff9695774bdcb4
[apps/home/ug-memo-efl.git] / extend / extended-elm.c
1 /*
2 *
3 * Copyright 2012  Samsung Electronics Co., Ltd
4 *
5 * Licensed under the Flora License, Version 1.0 (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
8 *
9 *    http://floralicense.org/license/
10 *
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.
16 *
17 */
18
19 #include <extended-elm.h>
20
21 /**
22  * elm_scroller_create
23  *
24  * @brief This function is an encapsulated vesion of elm_scroller_add
25  *
26  * @param   [in] parent The parent object
27  *
28  * @return       Return pointer to elm object (Success) or NULL (Failed)
29  *
30  * @exception    None
31  *
32  * @remark       None
33  *
34  * @see
35  *
36  */
37 Evas_Object *elm_scroller_create(Evas_Object *parent)
38 {
39     Evas_Object *sc;
40     sc = elm_scroller_add(parent);
41     elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
42     elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
43     evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
44     evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
45     evas_object_show(sc);
46     return sc;
47 }
48
49 /**
50  * elm_layout_create
51  *
52  * @brief This function is an encapsulated vesion of elm_layout_add
53  *
54  * @param   [in] parent The parent object
55  *
56  * @param   [in] file The path to file (edj) that will be used as layout
57  *
58  * @param   [in] group The group that the layout belongs in edje file
59  *
60  * @return       Return pointer to elm object (Success) or NULL (Failed)
61  *
62  * @exception    None
63  *
64  * @remark       None
65  *
66  * @see
67  *
68  */
69 Evas_Object *elm_layout_create(Evas_Object *parent, const char *file, const char *group)
70 {
71     Evas_Object *ly;
72     ly = elm_layout_add(parent);
73     if (elm_layout_file_set(ly, file, group)) {
74         evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, 0);
75         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, 0);
76         evas_object_show(ly);
77     } else {
78         evas_object_del(ly);
79         ly = NULL;
80     }
81     return ly;
82 }
83
84 /**
85  * elm_label_create
86  *
87  * @brief This function is an encapsulated vesion of elm_label_add
88  *
89  * @param   [in] parent The parent object
90  *
91  * @param   [in] text The label will be used on the object
92  *
93  * @return       Return pointer to elm object (Success) or NULL (Failed)
94  *
95  * @exception    None
96  *
97  * @remark       None
98  *
99  * @see
100  *
101  */
102 Evas_Object *elm_label_create(Evas_Object *parent, const char *text)
103 {
104     Evas_Object *label;
105     label = elm_label_add(parent);
106     elm_label_line_wrap_set(label, ELM_WRAP_CHAR);
107     elm_object_text_set(label, text);
108     evas_object_size_hint_align_set(label, EVAS_HINT_FILL, 0);
109     evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0);
110     evas_object_show(label);
111     return label;
112 }
113
114 /**
115  * elm_check_create
116  *
117  * @brief This function is an encapsulated vesion of elm_check_add
118  *
119  * @param   [in] parent The parent object
120  *
121  * @return       Return pointer to elm object (Success) or NULL (Failed)
122  *
123  * @exception    None
124  *
125  * @remark       None
126  *
127  * @see
128  *
129  */
130 Evas_Object *elm_check_create(Evas_Object *parent)
131 {
132     Evas_Object *check;
133     check = elm_check_add(parent);
134     evas_object_size_hint_align_set(check, EVAS_HINT_FILL, 0);
135     evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0);
136     evas_object_show(check);
137     return check;
138 }
139
140 /**
141  * elm_button_create
142  *
143  * @brief This function is an encapsulated vesion of elm_button_add
144  *
145  * @param   [in] parent The parent object
146  *
147  * @param   [in] text The label will be used on the object
148  *
149  * @param   [in] click_cb The callback function when clicked
150  *
151  * @param   [in] data User data to be passed to the callback function
152  *
153  * @return       Return pointer to elm object (Success) or NULL (Failed)
154  *
155  * @exception    None
156  *
157  * @remark       None
158  *
159  * @see
160  *
161  */
162 Evas_Object *elm_button_create(Evas_Object *parent, const char *text, Evas_Smart_Cb click_cb,
163                    void *data)
164 {
165     Evas_Object *btn;
166     btn = elm_button_add(parent);
167     elm_object_text_set(btn, text);
168     evas_object_smart_callback_add(btn, "clicked", click_cb, data);
169     evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 0);
170     evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0);
171     evas_object_show(btn);
172     return btn;
173 }
174
175 /**
176  * elm_entry_create
177  *
178  * @brief This function is an encapsulated vesion of elm_entry_add
179  *
180  * @param   [in] parent The parent object
181  *
182  * @param   [in] text The label will be used on the object
183  *
184  * @return       Return pointer to elm object (Success) or NULL (Failed)
185  *
186  * @exception    None
187  *
188  * @remark       None
189  *
190  * @see
191  *
192  */
193 Evas_Object *elm_entry_create(Evas_Object *parent, const char *text)
194 {
195     Evas_Object *entry;
196     entry = elm_entry_add(parent);
197     elm_entry_entry_set(entry, text);
198     evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0);
199     evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0);
200     elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
201     elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
202     evas_object_show(entry);
203     return entry;
204 }
205
206 /**
207  * elm_icon_create
208  *
209  * @brief This function is an encapsulated vesion of elm_icon_add
210  *
211  * @param   [in] parent The parent object
212  *
213  * @param   [in] file The path of icon file
214  *
215  * @return       Return pointer to elm object (Success) or NULL (Failed)
216  *
217  * @exception    None
218  *
219  * @remark       None
220  *
221  * @see
222  *
223  */
224 Evas_Object *elm_icon_create(Evas_Object *parent, const char *file)
225 {
226     Evas_Object *ic;
227     ic = elm_icon_add(parent);
228     elm_icon_file_set(ic, file, NULL);
229     evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
230     elm_icon_resizable_set(ic, 1, 1);
231     evas_object_show(ic);
232     return ic;
233 }
234
235 /**
236  * elm_navigator_btn_create
237  *
238  * @brief This function is an encapsulated vesion of elm_icon_add
239  *
240  * @param   [in] parent The parent object
241  *
242  * @param   [in] text The label will be used on the object
243  *
244  * @param   [in] icon_path The icon will be displayed on the object
245  *
246  * @param   [in] style "navigationbar_control/left(center|right)"
247  *
248  * @param   [in] click_cb The callback function when clicked
249  *
250  * @param   [in] data User data to be passed to the callback function
251  *
252  * @return       Return pointer to elm object (Success) or NULL (Failed)
253  *
254  * @exception    None
255  *
256  * @remark       None
257  *
258  * @see
259  *
260  */
261 Evas_Object *elm_navigator_btn_create(Evas_Object *parent, const char *text,
262                       const char *icon_path, const char *style,
263                       Evas_Smart_Cb click_cb, void *data)
264 {
265     Evas_Object *btn = NULL;
266
267     btn = elm_button_create(parent, text, click_cb, data);
268     elm_object_style_set(btn, "naviframe/title/default");
269     return btn;
270 }
271
272 /**
273  * elm_swallowed_scroller
274  *
275  * @brief This function is an encapsulated vesion of elm_scroller_add
276  *
277  * @param   [in] parent The parent object
278  *
279  * @param   [in] part The swallow part name in the parent layout obj
280  *
281  * @return       Return pointer to elm object (Success) or NULL (Failed)
282  *
283  * @exception    None
284  *
285  * @remark       None
286  *
287  * @see
288  *
289  */
290 Evas_Object *elm_swallowed_scroller(Evas_Object *parent, const char *part)
291 {
292     Evas_Object *eo = elm_scroller_create(parent);
293     elm_object_part_content_set(parent, part, eo);
294     return eo;
295 }
296
297 /**
298  * elm_swallowed_layout
299  *
300  * @brief This function is an encapsulated vesion of elm_layout_add
301  *
302  * @param   [in] parent The parent object
303  *
304  * @param   [in] part The swallow part name in the parent layout obj
305  *
306  * @param   [in] file The path to file (edj) that will be used as layout
307  *
308  * @param   [in] group The group that the layout belongs in edje file
309  *
310  * @return       Return pointer to elm object (Success) or NULL (Failed)
311  *
312  * @exception    None
313  *
314  * @remark       None
315  *
316  * @see
317  *
318  */
319 Evas_Object *elm_swallowed_layout(Evas_Object *parent, const char *part, const char *file,
320                   const char *group)
321 {
322     Evas_Object *eo = elm_layout_create(parent, file, group);
323     elm_object_part_content_set(parent, part, eo);
324     return eo;
325 }
326
327 /**
328  * elm_swallowed_button
329  *
330  * @brief This function is an encapsulated vesion of elm_button_add
331  *
332  * @param   [in] parent The parent object
333  *
334  * @param   [in] part The swallow part name in the parent layout obj
335  *
336  * @param   [in] text The label will be used on the object
337  *
338  * @param   [in] click_cb The callback function when clicked
339  *
340  * @param   [in] data User data to be passed to the callback function
341  *
342  * @return       Return pointer to elm object (Success) or NULL (Failed)
343  *
344  * @exception    None
345  *
346  * @remark       None
347  *
348  * @see
349  *
350  */
351 Evas_Object *elm_swallowed_button(Evas_Object *parent, const char *part, const char *text,
352                   Evas_Smart_Cb click_cb, void *data)
353 {
354     Evas_Object *eo = elm_button_create(parent, text, click_cb, data);
355     elm_object_part_content_set(parent, part, eo);
356     return eo;
357 }
358
359 /**
360  * elm_swallowed_entry
361  *
362  * @brief This function is an encapsulated vesion of elm_entry_add
363  *
364  * @param   [in] parent The parent object
365  *
366  * @param   [in] part The swallow part name in the parent layout obj
367  *
368  * @param   [in] text The label will be used on the object
369  *
370  * @return       Return pointer to elm object (Success) or NULL (Failed)
371  *
372  * @exception    None
373  *
374  * @remark       None
375  *
376  * @see
377  *
378  */
379 Evas_Object *elm_swallowed_entry(Evas_Object *parent, const char *part, const char *text)
380 {
381     Evas_Object *eo = elm_entry_create(parent, text);
382     elm_object_part_content_set(parent, part, eo);
383     return eo;
384 }
385
386 /**
387  * elm_swallowed_icon
388  *
389  * @brief This function is an encapsulated vesion of elm_icon_add
390  *
391  * @param   [in] parent The parent object
392  *
393  * @param   [in] part The swallow part name in the parent layout obj
394  *
395  * @param   [in] file The path of icon file
396  *
397  * @return       Return pointer to elm object (Success) or NULL (Failed)
398  *
399  * @exception    None
400  *
401  * @remark       None
402  *
403  * @see
404  *
405  */
406 Evas_Object *elm_swallowed_icon(Evas_Object *parent, const char *part, const char *file)
407 {
408     Evas_Object *eo = elm_icon_create(parent, file);
409     elm_object_part_content_set(parent, part, eo);
410     return eo;
411 }
412
413 /**
414  * elm_layout_content_del
415  *
416  * @brief Destroy object from layout
417  *
418  * @param   [in] parent The parent object
419  *
420  * @param   [in] part The name of swallowed part in the parent layout obj
421  *
422  * @return       None
423  *
424  * @exception    None
425  *
426  * @remark       None
427  *
428  * @see
429  *
430  */
431 void elm_layout_content_del(Evas_Object *parent, const char *part)
432 {
433     Evas_Object *eo = elm_object_part_content_unset(parent, part);
434     if (eo != NULL) {
435         evas_object_del(eo);
436     }
437 }
438