5019a882719a6d6903a48cf2bca3c410b85a5282
[apps/native/sample/sample-core-components.git] / project / src / view.c
1 /*
2 * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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  * @brief: Make a essential object for the this app, like window, conformant and layout
19  * @param[ad]: The object has informations for managing this app
20  */
21 void view_create(appdata_s *ad)
22 {
23         if (ad == NULL) {
24                 dlog_print(DLOG_ERROR, LOG_TAG, "appdata is NULL.");
25                 return;
26         }
27
28         /* Create window */
29         ad->win = view_create_win();
30         if (ad->win == NULL) {
31                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a window.");
32                 return;
33         }
34
35         /* Create conformant */
36         ad->conform = view_create_conformant_without_indicator(ad->win);
37         if (ad->conform == NULL) {
38                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a conformant");
39                 return;
40         }
41
42         /* Show window after main view is set up */
43         evas_object_show(ad->win);
44 }
45
46 /*
47  * @brief: Make a basic window named package
48  * @param[package]: Name of the window
49  */
50 Evas_Object *view_create_win(const char *pkg_name)
51 {
52         Evas_Object *win = NULL;
53
54         /* Window */
55         /* Create and initialize elm_win.
56            elm_win is mandatory to manipulate window. */
57
58         win = elm_win_util_standard_add(pkg_name, pkg_name);
59         elm_win_conformant_set(win, EINA_TRUE);
60         elm_win_autodel_set(win, EINA_TRUE);
61
62         if (elm_win_wm_rotation_supported_get(win)) {
63                 int rots[4] = { 0, 90, 180, 270 };
64                 elm_win_wm_rotation_available_rotations_set(win, (const int *)(&rots), 4);
65         }
66
67         evas_object_smart_callback_add(win, "delete,request", _win_delete_request_cb, NULL);
68
69         return win;
70 }
71
72 /*
73  * @brief: Make a conformant without indicator for wearable app
74  * @param[win]: The object to which you want to set this conformant
75  * Confromant is mandatory for base GUI to have proper size
76  */
77 Evas_Object *view_create_conformant_without_indicator(Evas_Object *win)
78 {
79         /* Conformant
80          * Create and initialize elm_conformant.
81          * elm_conformant is mandatory for base GUI to have proper size
82          * when indicator or virtual keypad is visible.
83          */
84         Evas_Object *conform = NULL;
85
86         if (win == NULL) {
87                 dlog_print(DLOG_ERROR, LOG_TAG, "window is NULL.");
88                 return NULL;
89         }
90
91         conform = elm_conformant_add(win);
92         evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
93         elm_win_resize_object_add(win, conform);
94
95         evas_object_show(conform);
96
97         return conform;
98 }
99
100 /*
101  * @brief: Make a layout to target parent object with edje file
102  * @param[parent]: The object to which you want to add this layout
103  * @param[file_name]: File path of EDJ
104  * @param[group_name]: Name of group in EDJ you want to set to
105  * @param[Evas_Object_Event_Cb]: File path of EDJ
106  * @param[user_data]: The user data to be passed to the callback functions
107  */
108 Evas_Object *view_create_layout(Evas_Object *parent, const char *edj_path, const char *group_name, Eext_Event_Cb cb_function, void *user_data)
109 {
110         Evas_Object *layout = NULL;
111
112         if (parent == NULL) {
113                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
114                 return NULL;
115         }
116
117         /* Create layout by EDC(edje file) */
118         layout = elm_layout_add(parent);
119         elm_layout_file_set(layout, edj_path, group_name);
120
121         /* Layout size setting */
122         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
123
124         if(cb_function)
125                 eext_object_event_callback_add(layout, EEXT_CALLBACK_BACK, cb_function, user_data);
126
127         evas_object_show(layout);
128
129         return layout;
130 }
131
132 /*
133  * @brief: Make and set a layout to conformant
134  * @param[parent]: Target conformant object
135  * @param[file_name]: File path of EDJ used
136  * @param[group_name]: Group name in EDJ you want to set to layout
137  * @param[user_data]: The user data to be passed to the callback functions
138  */
139 Evas_Object *view_create_layout_for_conformant(Evas_Object *parent, Evas_Object *conformant, const char *file_name, const char *group_name, void *user_data)
140 {
141         Evas_Object *layout = NULL;
142
143         if (parent == NULL) {
144                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
145                 return NULL;
146         }
147
148         /* Create layout for conformant */
149         layout = view_create_layout(parent, file_name, group_name, NULL, user_data);
150         if (layout == NULL) {
151                 dlog_print(DLOG_ERROR, LOG_TAG, "layout is NULL.");
152                 return NULL;
153         }
154
155         elm_object_content_set(conformant, layout);
156
157         return layout;
158 }
159
160 /*
161  * @brief: Make a layout with theme.
162  * @param[parent]: Object to which you want to add this layout
163  * @param[class]: The class of the group
164  * @param[group_name]: Group name in EDJ you want to set to layout
165  * @param[style]: The style to use
166  */
167 Evas_Object *view_create_layout_by_theme(Evas_Object *parent, const char *classname, const char *group, const char *style)
168 {
169         /*
170          * Layout
171          * Create and initialize elm_layout.
172          * view_create_layout_by_theme() is used to create layout by using premade edje file.
173          */
174         Evas_Object *layout = NULL;
175
176         if (parent == NULL) {
177                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
178                 return NULL;
179         }
180
181         layout = elm_layout_add(parent);
182         elm_layout_theme_set(layout, classname, group, style);
183         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
184
185         evas_object_show(layout);
186
187         return layout;
188 }
189
190 /*
191  * @brief: Make and set a layout to the part
192  * @param[parent]: Object to which you want to set this layout
193  * @param[file_name]: File path of EDJ used
194  * @param[group_name]: Group name in EDJ you want to set to layout
195  * @param[part]: Part name to which you want to set this layout
196  */
197 Evas_Object *view_create_layout_for_part(Evas_Object *parent, char *part, char *file_name, char *group_name)
198 {
199         Evas_Object *layout = NULL;
200
201         if (parent == NULL) {
202                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
203                 return NULL;
204         }
205
206         layout = elm_layout_add(parent);
207         elm_layout_file_set(layout, file_name, group_name);
208         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
209
210         evas_object_show(layout);
211
212         elm_object_part_content_set(parent, part, layout);
213
214         return layout;
215 }
216
217 /*
218  * @brief: Destroy window and free important data to finish this app
219  * @param[ad]: The object has informations for managing this app
220  */
221 void view_destroy(void *user_data)
222 {
223         appdata_s *ad = NULL;
224
225         ad = user_data;
226         if (ad == NULL) {
227                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to destroy data.");
228                 return;
229         }
230
231         evas_object_del(ad->win);
232 }
233
234 /*
235  * @brief: Destroy given layout
236  * @param[layout]: The layout you want to destroy
237  */
238 void view_destroy_layout(Evas_Object *layout)
239 {
240         evas_object_del(layout);
241 }
242
243 /*
244  * @brief: Set image to given part
245  * @param[parent]: object has part to which you want to set this image
246  * @param[part]: part name to which you want to set this image
247  * @param[image_path]: path of image file
248  */
249 void view_set_image(Evas_Object *parent, const char *part, const char *image_path)
250 {
251         Evas_Object *image = NULL;
252
253         if (parent == NULL) {
254                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
255                 return;
256         }
257
258         image = elm_object_part_content_get(parent, part);
259         if (image == NULL) {
260                 image = elm_image_add(parent);
261                 if (!image) {
262                         dlog_print(DLOG_ERROR, LOG_TAG, "failed to create an image object.");
263                         return;
264                 }
265         }
266
267         if (EINA_FALSE == elm_image_file_set(image, image_path, NULL)) {
268                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to set image.");
269                 return;
270         }
271
272         if (part) {
273                 elm_object_part_content_set(parent, part, image);
274         } else {
275                 elm_object_content_set(parent, image);
276         }
277
278         evas_object_show(image);
279
280         return;
281 }
282
283 /*
284  * @brief: Set text to the part
285  * @param[parent]: Object has part to which you want to set text
286  * @param[part]: Part name to which you want to set text
287  * @param[text]: text you want to set to the part
288  */
289 void view_set_text(Evas_Object *parent, const char *part, const char *text)
290 {
291         if (parent == NULL) {
292                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
293                 return;
294         }
295
296         /* Set text of target part object */
297         elm_object_part_text_set(parent, part, text);
298 }
299
300 /*
301  * @brief: Set color of the part
302  * @param[parent]: Object has part to which you want to set color
303  * @param[part]: Name of part to which you want to set color
304  * @param[r]: R of RGBA you want to set to the part
305  * @param[g]: G of RGBA you want to set to the part
306  * @param[b]: B of RGBA you want to set to the part
307  * @param[a]: A of RGBA you want to set to the part
308  */
309 void view_set_color(Evas_Object *parent, const char *part, int r, int g, int b, int a)
310 {
311         Evas_Object *obj = NULL;
312
313         if (parent == NULL) {
314                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
315                 return;
316         }
317
318         obj = elm_object_part_content_get(parent, part);
319         if (obj == NULL) {
320                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to get parent.");
321                 return;
322         }
323
324         /* Set color of target part object */
325         evas_object_color_set(obj, r, g, b, a);
326 }
327
328 /*
329  * @brief: Make a naviframe and set to parent
330  * @param[parent]: Object to which you want to set naviframe
331  * @Add callback function will be operated when back key is pressed
332  */
333 Evas_Object *view_create_naviframe(Evas_Object *parent)
334 {
335         /* Naviframe
336          * Create and initialize elm_naviframe.
337          * Naviframe stands for navigation frame.
338          * elm_naviframe is a views manager for applications.
339          */
340         Evas_Object *nf = NULL;
341
342         if (parent == NULL) {
343                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
344                 return NULL;
345         }
346
347         nf = elm_naviframe_add(parent);
348
349         elm_object_part_content_set(parent, "elm.swallow.content", nf);
350         eext_object_event_callback_add(nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
351         eext_object_event_callback_add(nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
352
353         evas_object_show(nf);
354
355         return nf;
356 }
357
358 //TO DO UPDATE
359 /*
360  * @brief: Push item to naviframe
361  * @param[nf]: naviframe
362  * @param[item]: object will be added to naviframe
363  * @param[_pop_cb]: function will be operated when this item is poped from naviframe
364  * @param[cb_data]: data needed to operate '_pop_cb' function
365  * Naviframe make changing of view is easy and effectively
366  */
367 Elm_Object_Item* view_push_item_to_naviframe(Evas_Object *nf, Evas_Object *item, Elm_Naviframe_Item_Pop_Cb _pop_cb, void *cb_data)
368 {
369         Elm_Object_Item* nf_it = NULL;
370
371         if (nf == NULL) {
372                 dlog_print(DLOG_ERROR, LOG_TAG, "naviframe is NULL.");
373                 return NULL;
374         }
375
376         if (item == NULL) {
377                 dlog_print(DLOG_ERROR, LOG_TAG, "item is NULL.");
378                 return NULL;
379         }
380
381         nf_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, item, "empty");
382
383         if (_pop_cb != NULL)
384                 elm_naviframe_item_pop_cb_set(nf_it, _pop_cb, cb_data);
385
386         return nf_it;
387 }
388
389
390 void view_set_more_button(Evas_Object *parent, const char *part)
391 {
392         Evas_Object *more_btn = NULL;
393
394         if (pirent == NULL) {
395                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
396                 return;
397         }
398
399         more_btn = eext_more_option_add(parent);
400         if (more_btn == NULL) {
401                 dlog_print(DLOG_ERROR, LOG_TAG, "more option is NULL.");
402                 return;
403         }
404
405         /* Add smart callback */
406         evas_object_smart_callback_add(more_btn, "more,option,opened", _more_option_opened, NULL);
407         evas_object_smart_callback_add(more_btn, "more,option,closed", _more_option_closed, NULL);
408         evas_object_smart_callback_add(more_btn, "item,selected", _item_selected, NULL);
409
410         elm_object_part_content_set(parent, part, more_btn);
411 }
412
413 /*
414  * @brief: Make and set button.
415  * @param[parent]: object to which you want to set the button
416  * @param[style]: style of the button
417  * @param[text]: text will be written on the button
418  * @param[image_path]: path of image file will be used as button icon
419  * @param[part]: part name in EDJ to which you want to set the button
420  * @param[down_cb]: function will be operated when the button is pressed
421  * @param[up_cb]: function will be operated when the button is released
422  * @param[clicked_cb]: function will be operated when the button is clicked
423  * @param[data]: data needed in this function
424  */
425 void view_set_button(Evas_Object *parent, const char *part, const char *style, const char *image_path, const char *text,
426                 Evas_Object_Event_Cb down_cb, Evas_Object_Event_Cb up_cb, Evas_Smart_Cb clicked_cb, void *data)
427 {
428         Evas_Object *btn = NULL;
429
430         if (parent == NULL) {
431                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
432                 return;
433         }
434
435         btn = elm_button_add(parent);
436         if(!btn) {
437                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to create button.");
438                 return;
439         }
440
441         if (style)
442                 elm_object_style_set(btn, style);
443
444         evas_object_size_hint_weight_set(btn ,EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
445         elm_object_part_content_set(parent, part, btn);
446
447         if (text)
448                 elm_object_text_set(btn, text);
449
450         if (image_path)
451                 view_set_image(btn, NULL, image_path);
452
453         if (down_cb)
454                 evas_object_event_callback_add(btn , EVAS_CALLBACK_MOUSE_DOWN, down_cb, parent);
455         if (up_cb)
456                 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, up_cb, parent);
457         if (clicked_cb)
458                 evas_object_smart_callback_add(btn, "clicked", clicked_cb, data);
459
460         evas_object_show(btn);
461 }
462
463 /*
464  * @brief: Add a more button item
465  * @param[parent]: object that contains more button
466  * @param[main_txt]: text will be written in the middle of the selector
467  * @param[sub_txt] Text will be written under the main_txt
468  * @param[img_path]: path of image file will be used as more button item icon
469  * @param[clicked_cb]: function will be operated when the more button item is clicked
470  * @param[user_data]: data needed in this function
471  */
472 void view_add_more_button_item(Evas_Object *parent, const char *part, const char *main_txt, const char *sub_txt, const char *img_path, Evas_Smart_Cb clicked_cb, void *user_data)
473 {
474         Evas_Object *img = NULL;
475         Evas_Object *more_btn = NULL;
476         char full_path[PATH_MAX] = { 0, };
477
478         if (parent == NULL) {
479                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
480                 return;
481         }
482
483         more_btn = elm_object_part_content_get(parent, part);
484         if (more_btn == NULL) {
485                 return;
486         }
487
488         /* Create the new item */
489         Eext_Object_Item *item  = eext_more_option_item_append(more_btn);
490
491         /* Set the text in item text part */
492         eext_more_option_item_part_text_set(item, "selector,main_text", main_txt);
493         eext_more_option_item_part_text_set(item, "selector,sub_text", sub_txt);
494
495         img = elm_image_add(more_btn);
496         _get_resource(img_path, full_path, sizeof(full_path));
497         elm_image_file_set(img, full_path, NULL);
498
499         /* Set the content in item content part */
500         eext_more_option_item_part_content_set(item, "item,icon", img);
501
502         evas_object_smart_callback_add(more_btn, "item,clicked", clicked_cb, user_data);
503 }
504
505 /*
506  * @brief: Make a Entry Object to target window
507  * @param[parent]: Object to which you want to set Entry
508  * @param[part]: Part of the layout which you want to locate Entry
509  * @param[data]: The user data to be passed to the callback function
510  * @Add callback function will be operated when mouse clicked event is triggered
511  */
512 Evas_Object *view_set_entry(Evas_Object *parent, const char *part, void (_clicked_cb)(void *data, Evas_Object *obj, void *event_info), void *data)
513 {
514         Evas_Object *entry = NULL;
515
516         if (parent == NULL) {
517                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
518                 return NULL;
519         }
520
521         /* Add Entry object to parent */
522         entry = elm_entry_add(parent);
523         if (entry == NULL) {
524                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to add a entry");
525                 return NULL;
526         }
527
528         /* Set Entry size option */
529         evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
530
531         /* Set Entry option for display and functionalities */
532         elm_entry_single_line_set(entry, EINA_TRUE);
533         elm_entry_scrollable_set(entry, EINA_TRUE);
534         elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
535         elm_entry_editable_set(entry, EINA_FALSE);
536         elm_entry_context_menu_disabled_set(entry, EINA_TRUE);
537         elm_entry_cursor_handler_disabled_set(entry, EINA_TRUE);
538         elm_entry_select_allow_set(entry, EINA_FALSE);
539
540         /* Set Entry text style using predefined style description */
541     elm_entry_text_style_user_push(entry, DIAL_TEXT_STYLE_NORMAL);
542
543     elm_object_part_content_set(parent, part, entry);
544
545         /* Set callback for event about Entry */
546     if (_clicked_cb) {
547                 evas_object_smart_callback_add(entry, "clicked", _clicked_cb, data);
548         }
549
550         return entry;
551 }
552
553 /*
554  * @brief: make genlist for circular shape.
555  * @param[parent]: object to which you want to set genlist
556  * @param[circle_surface]: object render a connected circle object
557  */
558 Evas_Object *view_create_circle_genlist(Evas_Object *parent, Eext_Circle_Surface *circle_surface)
559 {
560         Evas_Object *genlist = NULL;
561         Evas_Object *circle_genlist = NULL;
562
563         if (parent == NULL) {
564                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
565                 return NULL;
566         }
567
568         if (circle_surface == NULL) {
569                 dlog_print(DLOG_ERROR, LOG_TAG, "circle surface is NULL.");
570                 return NULL;
571         }
572
573         genlist = elm_genlist_add(parent);
574     /* this make selected list item is shown compressed */
575         elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
576         evas_object_smart_callback_add(genlist, "selected", _gl_selected_cb, NULL);
577
578         /* this make genlist style circular */
579         circle_genlist = eext_circle_object_genlist_add(genlist, circle_surface);
580         eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
581         eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
582
583         evas_object_show(genlist);
584
585         return genlist;
586 }
587
588 /*
589  * @brief: Add item to genlist.
590  * @param[genlist]: genlist
591  * @param[style]: style of item determine how to show this item, such as "1text", "1text1icon" and so on
592  * @param[data]: item data that use item's callback function
593  * @param[_clicked_cb]: function will be operated when the item is clicked
594  * @param[cb_data]: data needed in '_clicked_cb' function
595  * This make item's class and add item to genlist.
596  */
597 Elm_Object_Item *view_append_item_to_genlist(Evas_Object *genlist, const char *style,
598                 const void *data, Evas_Smart_Cb _clicked_cb, const void *cb_data)
599 {
600         Elm_Genlist_Item_Class *item_class;
601         Elm_Object_Item *item;
602
603         if (genlist == NULL) {
604                 dlog_print(DLOG_ERROR, LOG_TAG, "genlist is NULL.");
605                 return NULL;
606         }
607
608         if (style == NULL) {
609                 dlog_print(DLOG_ERROR, LOG_TAG, "item style is NULL.");
610                 return NULL;
611         }
612
613         item_class = _set_genlist_item_class(style);
614
615         item = elm_genlist_item_append(genlist, item_class, data, NULL, ELM_GENLIST_ITEM_NONE, _clicked_cb, cb_data);
616
617         elm_genlist_item_class_free(item_class);
618
619         return item;
620 }
621
622 /*
623  * @brief: Find item from genlist.
624  * @param[genlist]: genlist
625  * @param[val]: value determine which of the itmes has to remove
626  */
627 Elm_Object_Item *view_find_item_from_genlist(Evas_Object *genlist, const char *val)
628 {
629         int item_count;
630         int i;
631         Elm_Object_Item *item = NULL;
632         struct genlist_data *gendata = NULL;
633
634         if (!genlist) {
635                 dlog_print(DLOG_ERROR, LOG_TAG, "genlist is NULL.");
636                 return NULL;
637         }
638
639         item_count = elm_genlist_items_count(genlist);
640
641         /*
642          * The fist item and the last item are "padding".
643          */
644         for(i = 1; i < item_count-1; i++) {
645                 item = elm_genlist_nth_item_get(genlist, i);
646                 gendata = elm_object_item_data_get(item);
647
648                 if (gendata->alarm_id == atoi(val)) {
649                         return item;
650                 }
651         }
652
653         return NULL;
654 }
655
656
657 /*
658  * @brief: Remove item.
659  * @param[item]: item from genlist
660  */
661 void view_delete_item(Elm_Object_Item *item)
662 {
663         elm_object_item_del(item);
664 }
665
666 /*
667  * @brief: Make popup with theme.
668  * @param[popup_style]: style of the popup's layout
669  * @param[data]: data needed in this function
670  */
671 void view_create_text_popup(Evas_Object *parent, double timeout, const char *text)
672 {
673         Evas_Object *popup = NULL;
674         Evas_Object *popup_layout = NULL;
675
676         if (parent == NULL) {
677                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
678                 return;
679         }
680
681         popup = elm_popup_add(parent);
682         elm_object_style_set(popup, "circle");
683         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
684
685         eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_hide_cb, NULL);
686         /*
687          * Delete popup object in _popup_hide_finished_cb(), when the "dismissed" signal will be called.
688          */
689         evas_object_smart_callback_add(popup, "dismissed", _popup_hide_finished_cb, NULL);
690
691         popup_layout = elm_layout_add(popup);
692         elm_layout_theme_set(popup_layout, "layout", "popup", "content/circle");
693
694         elm_object_content_set(popup, popup_layout);
695
696         elm_popup_timeout_set(popup, timeout);
697
698         if (text)
699                 view_set_text(popup_layout, "elm.text", text);
700
701         evas_object_show(popup);
702 }
703
704 void view_set_content_to_part(Evas_Object *layout, const char *part, Evas_Object *content)
705 {
706         elm_object_part_content_set(layout, part, content);
707 }
708
709 void view_send_signal_to_edje(Evas_Object *layout, const char *signal, const char *source)
710 {
711         elm_object_signal_emit(layout, signal, source);
712 }
713
714 void view_set_customized_event_callback(Evas_Object *item, char *signal, char *source, void (*signal_cb)(void *data, Evas_Object *obj, const char *emission, const char *source), void *user_data)
715 {
716         elm_object_signal_callback_add(item, signal, source, signal_cb, user_data);
717 }
718
719 /*
720  * @brief: Register roatry event callback function.
721  * @param[obj]: object that will receive rotary event
722  * @param[rotary_cb]: function will be operated when rotary event happens
723  * @param[user_data]: data needed in this function
724  */
725 void view_set_rotary_event_callback(Evas_Object *obj, Eext_Rotary_Event_Cb rotary_cb, void *user_data)
726 {
727         if (obj == NULL) {
728                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
729                 return;
730         }
731
732         eext_rotary_object_event_activated_set(obj, EINA_TRUE);
733         eext_rotary_object_event_callback_add(obj, rotary_cb, user_data);
734 }
735
736 /*
737  * @brief: Make a label and set label options.
738  * @param[parent]: The object to which you want to add this label
739  */
740 Evas_Object *view_create_label(Evas_Object *parent)
741 {
742         Evas_Object *label = elm_label_add(parent);
743
744         if (parent == NULL) {
745                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
746                 return NULL;
747         }
748
749         elm_object_style_set(label, "slide_short");
750         elm_label_wrap_width_set(label, 230);
751         elm_label_ellipsis_set(label, EINA_TRUE);
752         elm_label_slide_duration_set(label, 2);
753         elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_NONE);
754         elm_label_slide_go(label);
755         evas_object_show(label);
756
757         return label;
758 }
759
760 /*
761  * @brief: Set a text to label object
762  * @param[parent]: Object has part to which you want to set text
763  * @param[part]: Part name to which you want to set text
764  * @param[text]: text you want to set to the part
765  */
766 void view_set_label_text(Evas_Object *parent, const char *part, const char *text)
767 {
768         Evas_Object *label = NULL;
769         char *markup_text = NULL;
770         char buf[256] = { 0, };
771
772         if (parent == NULL) {
773                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
774                 return;
775         }
776
777         markup_text = elm_entry_utf8_to_markup(text);
778         snprintf(buf, sizeof(buf), "%s%s%s", LABEL_STYLE_START, markup_text, LABEL_STYLE_END);
779         free(markup_text);
780
781         label = elm_object_part_content_get(parent, part);
782         if (label == NULL) {
783                 dlog_print(DLOG_ERROR, LOG_TAG, "label is NULL.");
784                 return;
785         }
786
787         elm_object_text_set(label, buf);
788 }
789
790 /*
791  * @brief: Set a label to given part
792  * @param[parent]: object has part to which you want to set this label
793  * @param[part]: part name to which you want to set this label
794  */
795 void view_set_label(Evas_Object *parent, const char *part)
796 {
797         Evas_Object *label = NULL;
798
799         if (parent == NULL) {
800                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
801                 return;
802         }
803
804         label = view_create_label(parent);
805         if (label == NULL) {
806                 dlog_print(DLOG_ERROR, LOG_TAG, "label is NULL.");
807                 return;
808         }
809
810         elm_object_part_content_set(parent, "sw.focus.txt", label);
811 }
812
813 /*
814  * @brief: Create a progressbar
815  * @param[parent]: object has part to which you want to set this progressbar
816  */
817 Evas_Object *view_create_progressbar(Evas_Object *parent)
818 {
819         Evas_Object *progressbar = NULL;
820
821         if (parent == NULL) {
822                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
823                 return NULL;
824         }
825
826         progressbar = eext_circle_object_progressbar_add(parent, NULL);
827
828         eext_circle_object_value_min_max_set(progressbar, 0.0, 100.0);
829         eext_circle_object_radius_set(progressbar, 53);
830         eext_circle_object_line_width_set(progressbar, 5);
831         evas_object_show(progressbar);
832
833         return progressbar;
834 }
835
836 /*
837  * @brief: Set a progressbar to given part
838  * @param[parent]: object has part to which you want to set this progressbar
839  * @param[part]: part name to which you want to set this progressbar
840  */
841 void view_set_progressbar(Evas_Object *parent, const char *part)
842 {
843         Evas_Object *progressbar = NULL;
844
845         if (parent == NULL) {
846                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
847                 return;
848         }
849
850         progressbar = view_create_progressbar(parent);
851         if (progressbar == NULL) {
852                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
853                 return;
854         }
855
856         elm_object_part_content_set(parent, part, progressbar);
857 }
858
859 /*
860  * @brief: Set value to a progressbar
861  * @param[parent]: object has part to which you want to set
862  * @param[part]: part name to which you want to set
863  * @param[val]: value to which you want to set
864  */
865 void view_set_progressbar_val(Evas_Object *parent, const char *part, int val)
866 {
867         Evas_Object *progressbar = NULL;
868
869         if (parent == NULL) {
870                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
871                 return;
872         }
873
874         if (part == NULL) {
875                 dlog_print(DLOG_ERROR, LOG_TAG, "part is NULL.");
876                 return;
877         }
878
879         progressbar = elm_object_part_content_get(parent, part);
880         if (progressbar == NULL) {
881                 dlog_print(DLOG_ERROR, LOG_TAG, "prgressbar is NULL.");
882                 return;
883         }
884
885         eext_circle_object_value_set(progressbar, val);
886 }
887
888 /*
889  * @brief: Make a checkbox
890  * @param[parent]: The object to which you want to add this checkbox
891  */
892 Evas_Object *view_create_checkbox(Evas_Object *parent)
893 {
894         Evas_Object *check;
895
896         if (parent == NULL) {
897                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
898                 return NULL;
899         }
900
901         check = elm_check_add(parent);
902         elm_check_state_set(check, EINA_FALSE);
903         evas_object_smart_callback_add(check, "changed", _icon_clicked_cb, NULL);
904         evas_object_show(check);
905
906         return check;
907 }
908
909 /*
910  * @brief: Make no voice memo view
911  * @param[parent]: naviframe
912  * @param[title]: titile of this view
913  * @param[detail]: detail text of this view
914  * @param[image_file]: image file name will be used in this view
915  * This function make a view consists of one title, one center image and one detail text at the bottom
916  */
917 Evas_Object *view_create_layout_no_content(Evas_Object *parent, char *title, char *detail, char *image_file)
918 {
919         Evas_Object *layout = NULL;
920         Evas_Object *img;
921         Elm_Object_Item *it;
922
923         if (parent == NULL) {
924                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
925                 return NULL;
926         }
927
928         layout = elm_layout_add(parent);
929         /* this make you can use layout consists of one title, one image and one detail text */
930         elm_layout_theme_set(layout, "layout", "nocontents", "default");
931         evas_object_size_hint_weight_set (layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
932         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
933
934         if(image_file) {
935                 img = elm_image_add(parent);
936                 elm_image_file_set(img, image_file, NULL);
937                 elm_object_part_content_set(layout, "elm.swallow.icon", img);
938                 evas_object_show(img);
939         }
940
941         if (detail) {
942                 char detail_text[256] = {0, };
943
944                 /* Customize font style bellow */
945                 snprintf(detail_text, sizeof(detail_text), "<font=TIZEN:style=Medium align=center color=#FFFFFF><font_size=28>%s</font_size></font>", detail);
946                 elm_object_part_text_set(layout, "elm.text", detail_text);
947         }
948         if (title) {
949                 char title_text[256] = {0, };
950
951                 snprintf(title_text, sizeof(title_text), "<font=TIZEN:style=Medium align=center color=#12B4FF><font_size=28>%s</font_size></font>", title);
952                 elm_object_part_text_set(layout, "elm.text.title", title_text);
953         }
954
955         /* if this signal is not sent, title text will be disappear */
956         elm_object_signal_emit(layout, "elm,state,title,enable", "elm");
957         /* push this no voice memo view to naviframe to show */
958         it = elm_naviframe_item_push(parent, "Title Enabled", NULL, NULL, layout, NULL);
959         /* if this is EINA_TRUE, you can see Title of naviframe on the top of the screen */
960         elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE);
961
962         return layout;
963 }
964
965 /*
966  * @brief: Set datetime to the part.
967  * @param[parent]: object to which you want to set datetime
968  * @param[circle_surface]: object render a connected circle object
969  * @param[part]: part name to which you want to set this datetime
970  * @param[style]: style of the datetime
971  */
972 Evas_Object *view_create_datetime(Evas_Object *parent, Eext_Circle_Surface *circle_surface, const char *style)
973 {
974         Evas_Object *datetime = NULL;
975         Evas_Object *circle_datetime = NULL;
976
977         if (parent == NULL) {
978                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
979                 return NULL;
980         }
981
982         if (circle_surface == NULL) {
983                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to get circle_surface.");
984                 return NULL;
985         }
986
987         datetime = elm_datetime_add(parent);
988         circle_datetime = eext_circle_object_datetime_add(datetime, circle_surface);
989
990         eext_rotary_object_event_activated_set(datetime, EINA_TRUE);
991         elm_datetime_format_set(datetime, FORMAT);
992
993         elm_object_style_set(datetime, style);
994
995         return datetime;
996 }
997