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