Fix errta
[apps/native/sample/sample-core-components.git] / rule / 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: Create Essential Object window, conformant and layout
19  * @param[ad]: Structure has some important information for managing this application
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(PACKAGE);
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         /* Rotation setting */
63         if (elm_win_wm_rotation_supported_get(win)) {
64                 int rots[4] = { 0, 90, 180, 270 };
65                 elm_win_wm_rotation_available_rotations_set(win, (const int *)(&rots), 4);
66         }
67
68         evas_object_smart_callback_add(win, "delete,request", _win_delete_request_cb, NULL);
69
70         return win;
71 }
72
73 /*
74  * @brief: Make a conformant without indicator for wearable app
75  * @param[win]: The object to which you want to set this conformant
76  * Confromant is mandatory for base GUI to have proper size
77  */
78 Evas_Object *view_create_conformant_without_indicator(Evas_Object *win)
79 {
80         /* Conformant
81          * Create and initialize elm_conformant.
82          * elm_conformant is mandatory for base GUI to have proper size
83          * when indicator or virtual keypad is visible.
84          */
85         Evas_Object *conform = NULL;
86
87         if (win == NULL) {
88                 dlog_print(DLOG_ERROR, LOG_TAG, "window is NULL.");
89                 return NULL;
90         }
91
92         conform = elm_conformant_add(win);
93         evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
94         elm_win_resize_object_add(win, conform);
95
96         evas_object_show(conform);
97
98         return conform;
99 }
100
101 /*
102  * @brief: Make a layout to target parent object with edje file
103  * @param[parent]: The object to which you want to add this layout
104  * @param[file_name]: File path of EDJ
105  * @param[group_name]: Name of group in EDJ you want to set to
106  * @param[Evas_Object_Event_Cb]: File path of EDJ
107  * @param[user_data]: The user data to be passed to the callback functions
108  */
109 Evas_Object *view_create_layout(Evas_Object *parent, const char *edj_path, const char *group_name, Eext_Event_Cb cb_function, void *user_data)
110 {
111         Evas_Object *layout = NULL;
112
113         if (parent == NULL) {
114                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
115                 return NULL;
116         }
117
118         /* Create layout by EDC(edje file) */
119         layout = elm_layout_add(parent);
120         elm_layout_file_set(layout, edj_path, group_name);
121
122         /* Layout size setting */
123         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
124
125         if(cb_function)
126                 eext_object_event_callback_add(layout, EEXT_CALLBACK_BACK, cb_function, user_data);
127
128         evas_object_show(layout);
129
130         return layout;
131 }
132
133 /*
134  * @brief: Make and set a layout to conformant
135  * @param[parent]: Target conformant object
136  * @param[file_name]: File path of EDJ used
137  * @param[group_name]: Group name in EDJ you want to set to layout
138  * @param[cb_function]: Callback for back event handling
139  * @param[user_data]: The user data to be passed to the callback functions
140  */
141 Evas_Object *view_create_layout_for_conformant(Evas_Object *parent, const char *file_name, const char *group_name, Eext_Event_Cb cb_function, void *user_data)
142 {
143         Evas_Object *layout = NULL;
144
145         if (parent == NULL) {
146                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
147                 return NULL;
148         }
149
150         /* Create layout for conformant */
151         layout = view_create_layout(parent, file_name, group_name, cb_function, user_data);
152         if (layout == NULL) {
153                 dlog_print(DLOG_ERROR, LOG_TAG, "layout is NULL.");
154                 return NULL;
155         }
156
157         elm_object_content_set(parent, layout);
158
159         return layout;
160 }
161
162 /*
163  * @brief: Make a layout with theme.
164  * @param[parent]: Object to which you want to add this layout
165  * @param[class]: The class of the group
166  * @param[group_name]: Group name in EDJ you want to set to layout
167  * @param[style]: The style to use
168  */
169 Evas_Object *view_create_layout_by_theme(Evas_Object *parent, const char *classname, const char *group, const char *style)
170 {
171         /*
172          * Layout
173          * Create and initialize elm_layout.
174          * view_create_layout_by_theme() is used to create layout by using premade edje file.
175          */
176         Evas_Object *layout = NULL;
177
178         if (parent == NULL) {
179                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
180                 return NULL;
181         }
182
183         layout = elm_layout_add(parent);
184         elm_layout_theme_set(layout, classname, group, style);
185         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
186
187         evas_object_show(layout);
188
189         return layout;
190 }
191
192 /*
193  * @brief: Make and set a layout to the part
194  * @param[parent]: Object to which you want to set this layout
195  * @param[file_name]: File path of EDJ used
196  * @param[group_name]: Group name in EDJ you want to set to layout
197  * @param[part]: Part name to which you want to set this layout
198  */
199 Evas_Object *view_create_layout_for_part(Evas_Object *parent, char *part, char *file_name, char *group_name)
200 {
201         Evas_Object *layout = NULL;
202
203         if (parent == NULL) {
204                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
205                 return NULL;
206         }
207
208         layout = elm_layout_add(parent);
209         elm_layout_file_set(layout, file_name, group_name);
210         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
211
212         evas_object_show(layout);
213
214         elm_object_part_content_set(parent, part, layout);
215
216         return layout;
217 }
218
219 /*
220  * @brief: Destroy window and free important data to finish this application
221  * @param[user_data]: Structure has informations for managing this application
222  */
223 void view_destroy(void *user_data)
224 {
225         appdata_s *ad = NULL;
226
227         ad = user_data;
228         if (ad == NULL) {
229                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to destroy data.");
230                 return;
231         }
232
233         evas_object_del(ad->win);
234 }
235
236 /*
237  * @brief: Destroy given layout
238  * @param[layout]: The layout you want to destroy
239  */
240 void view_destroy_layout(Evas_Object *layout)
241 {
242         evas_object_del(layout);
243 }
244
245 /*
246  * @brief: Set image to given part
247  * @param[parent]: object has part to which you want to set this image
248  * @param[part]: part name to which you want to set this image
249  * @param[image_path]: path of image file
250  */
251 void view_set_image(Evas_Object *parent, const char *part, const char *image_path)
252 {
253         Evas_Object *image = NULL;
254
255         if (parent == NULL) {
256                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
257                 return;
258         }
259
260         image = elm_object_part_content_get(parent, part);
261         if (image == NULL) {
262                 image = elm_image_add(parent);
263                 if (!image) {
264                         dlog_print(DLOG_ERROR, LOG_TAG, "failed to create an image object.");
265                         return;
266                 }
267         }
268
269         if (EINA_FALSE == elm_image_file_set(image, image_path, NULL)) {
270                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to set image.");
271                 return;
272         }
273
274         if (part) {
275                 elm_object_part_content_set(parent, part, image);
276         } else {
277                 elm_object_content_set(parent, image);
278         }
279
280         evas_object_show(image);
281
282         return;
283 }
284
285 /*
286  * @brief: Set text to the part
287  * @param[parent]: Object has part to which you want to set text
288  * @param[part]: Part name to which you want to set text
289  * @param[text]: text you want to set to the part
290  */
291 void view_set_text(Evas_Object *parent, const char *part, const char *text)
292 {
293         if (parent == NULL) {
294                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
295                 return;
296         }
297
298         /* Set text of target part object */
299         elm_object_part_text_set(parent, part, text);
300 }
301
302 /*
303  * @brief: Set color of the part
304  * @param[parent]: Object has part to which you want to set color
305  * @param[part]: Name of part to which you want to set color
306  * @param[r]: R of RGBA you want to set to the part
307  * @param[g]: G of RGBA you want to set to the part
308  * @param[b]: B of RGBA you want to set to the part
309  * @param[a]: A of RGBA you want to set to the part
310  */
311 void view_set_color(Evas_Object *parent, const char *part, int r, int g, int b, int a)
312 {
313         Evas_Object *obj = NULL;
314
315         if (parent == NULL) {
316                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
317                 return;
318         }
319
320         obj = elm_object_part_content_get(parent, part);
321         if (obj == NULL) {
322                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to get parent.");
323                 return;
324         }
325
326         /* Set color of target part object */
327         evas_object_color_set(obj, r, g, b, a);
328 }
329
330 /*
331  * @brief: Make a naviframe and set to parent
332  * @param[parent]: Object to which you want to set naviframe
333  * @Add callback function will be operated when back key is pressed
334  */
335 Evas_Object *view_create_naviframe(Evas_Object *parent)
336 {
337         /* Naviframe
338          * Create and initialize elm_naviframe.
339          * Naviframe stands for navigation frame.
340          * elm_naviframe is a views manager for applications.
341          */
342         Evas_Object *nf = NULL;
343
344         if (parent == NULL) {
345                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
346                 return NULL;
347         }
348
349         nf = elm_naviframe_add(parent);
350
351         elm_object_part_content_set(parent, "elm.swallow.content", nf);
352         eext_object_event_callback_add(nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
353         eext_object_event_callback_add(nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
354
355         evas_object_show(nf);
356
357         return nf;
358 }
359
360 /*
361  * @brief: Push item to naviframe
362  * @param[nf]: naviframe
363  * @param[item]: object will be added to naviframe
364  * @param[_pop_cb]: function will be operated when this item is poped from naviframe
365  * @param[cb_data]: data needed to operate '_pop_cb' function
366  * Naviframe make changing of view is easy and effectively
367  */
368 Elm_Object_Item* view_push_item_to_naviframe(Evas_Object *nf, Evas_Object *item, Elm_Naviframe_Item_Pop_Cb _pop_cb, void *cb_data)
369 {
370         Elm_Object_Item* nf_it = NULL;
371
372         if (nf == NULL) {
373                 dlog_print(DLOG_ERROR, LOG_TAG, "naviframe is NULL.");
374                 return NULL;
375         }
376
377         if (item == NULL) {
378                 dlog_print(DLOG_ERROR, LOG_TAG, "item is NULL.");
379                 return NULL;
380         }
381
382         nf_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, item, "empty");
383
384         if (_pop_cb != NULL)
385                 elm_naviframe_item_pop_cb_set(nf_it, _pop_cb, cb_data);
386
387         return nf_it;
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, data);
455         if (up_cb)
456                 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, up_cb, data);
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  * @brief: Remove item.
658  * @param[item]: item from genlist
659  */
660 void view_delete_item(Elm_Object_Item *item)
661 {
662         elm_object_item_del(item);
663 }
664
665 /*
666  * @brief: Make popup with theme.
667  * @param[popup_style]: style of the popup's layout
668  * @param[data]: data needed in this function
669  */
670 void view_create_text_popup(Evas_Object *parent, double timeout, const char *text)
671 {
672         Evas_Object *popup = NULL;
673         Evas_Object *popup_layout = NULL;
674
675         if (parent == NULL) {
676                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
677                 return;
678         }
679
680         popup = elm_popup_add(parent);
681         elm_object_style_set(popup, "circle");
682         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
683
684         eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_hide_cb, NULL);
685         /*
686          * Delete popup object in _popup_hide_finished_cb(), when the "dismissed" signal will be called.
687          */
688         evas_object_smart_callback_add(popup, "dismissed", _popup_hide_finished_cb, NULL);
689
690         popup_layout = elm_layout_add(popup);
691         elm_layout_theme_set(popup_layout, "layout", "popup", "content/circle");
692
693         elm_object_content_set(popup, popup_layout);
694
695         elm_popup_timeout_set(popup, timeout);
696
697         if (text)
698                 view_set_text(popup_layout, "elm.text", text);
699
700         evas_object_show(popup);
701 }
702
703 void view_set_content_to_part(Evas_Object *layout, const char *part, Evas_Object *content)
704 {
705         elm_object_part_content_set(layout, part, content);
706 }
707
708 void view_send_signal_to_edje(Evas_Object *layout, const char *signal, const char *source)
709 {
710         elm_object_signal_emit(layout, signal, source);
711 }
712
713 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)
714 {
715         elm_object_signal_callback_add(item, signal, source, signal_cb, user_data);
716 }
717
718 /*
719  * @brief: Register roatry event callback function.
720  * @param[obj]: object that will receive rotary event
721  * @param[rotary_cb]: function will be operated when rotary event happens
722  * @param[user_data]: data needed in this function
723  */
724 void view_set_rotary_event_callback(Evas_Object *obj, Eext_Rotary_Event_Cb rotary_cb, void *user_data)
725 {
726         if (obj == NULL) {
727                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
728                 return;
729         }
730
731         eext_rotary_object_event_activated_set(obj, EINA_TRUE);
732         eext_rotary_object_event_callback_add(obj, rotary_cb, user_data);
733 }
734
735 /*
736  * @brief: Make a label and set label options.
737  * @param[parent]: The object to which you want to add this label
738  */
739 Evas_Object *view_create_label(Evas_Object *parent)
740 {
741         Evas_Object *label = elm_label_add(parent);
742
743         if (parent == NULL) {
744                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
745                 return NULL;
746         }
747
748         elm_object_style_set(label, "slide_short");
749         elm_label_wrap_width_set(label, 230);
750         elm_label_ellipsis_set(label, EINA_TRUE);
751         elm_label_slide_duration_set(label, 2);
752         elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_NONE);
753         elm_label_slide_go(label);
754         evas_object_show(label);
755
756         return label;
757 }
758
759 /*
760  * @brief: Set a text to label object
761  * @param[parent]: Object has part to which you want to set text
762  * @param[part]: Part name to which you want to set text
763  * @param[text]: text you want to set to the part
764  */
765 void view_set_label_text(Evas_Object *parent, const char *part, const char *text)
766 {
767         Evas_Object *label = NULL;
768         char *markup_text = NULL;
769         char buf[256] = { 0, };
770
771         if (parent == NULL) {
772                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
773                 return;
774         }
775
776         markup_text = elm_entry_utf8_to_markup(text);
777         snprintf(buf, sizeof(buf), "%s%s%s", LABEL_STYLE_START, markup_text, LABEL_STYLE_END);
778         free(markup_text);
779
780         label = elm_object_part_content_get(parent, part);
781         if (label == NULL) {
782                 dlog_print(DLOG_ERROR, LOG_TAG, "label is NULL.");
783                 return;
784         }
785
786         elm_object_text_set(label, buf);
787 }
788
789 /*
790  * @brief: Set a label to given part
791  * @param[parent]: object has part to which you want to set this label
792  * @param[part]: part name to which you want to set this label
793  */
794 void view_set_label(Evas_Object *parent, const char *part)
795 {
796         Evas_Object *label = NULL;
797
798         if (parent == NULL) {
799                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
800                 return;
801         }
802
803         label = view_create_label(parent);
804         if (label == NULL) {
805                 dlog_print(DLOG_ERROR, LOG_TAG, "label is NULL.");
806                 return;
807         }
808
809         elm_object_part_content_set(parent, part, label);
810 }
811
812 /*
813  * @brief: Create a progressbar
814  * @param[parent]: object has part to which you want to set this progressbar
815  */
816 Evas_Object *view_create_progressbar(Evas_Object *parent)
817 {
818         Evas_Object *progressbar = NULL;
819
820         if (parent == NULL) {
821                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
822                 return NULL;
823         }
824
825         progressbar = eext_circle_object_progressbar_add(parent, NULL);
826
827         eext_circle_object_value_min_max_set(progressbar, 0.0, 100.0);
828         eext_circle_object_radius_set(progressbar, 53);
829         eext_circle_object_line_width_set(progressbar, 5);
830         evas_object_show(progressbar);
831
832         return progressbar;
833 }
834
835 /*
836  * @brief: Set a progressbar to given part
837  * @param[parent]: object has part to which you want to set this progressbar
838  * @param[part]: part name to which you want to set this progressbar
839  */
840 void view_set_progressbar(Evas_Object *parent, const char *part)
841 {
842         Evas_Object *progressbar = NULL;
843
844         if (parent == NULL) {
845                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
846                 return;
847         }
848
849         progressbar = view_create_progressbar(parent);
850         if (progressbar == NULL) {
851                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
852                 return;
853         }
854
855         elm_object_part_content_set(parent, part, progressbar);
856 }
857
858 /*
859  * @brief: Set value to a progressbar
860  * @param[parent]: object has part to which you want to set
861  * @param[part]: part name to which you want to set
862  * @param[val]: value to which you want to set
863  */
864 void view_set_progressbar_val(Evas_Object *parent, const char *part, int val)
865 {
866         Evas_Object *progressbar = NULL;
867
868         if (parent == NULL) {
869                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
870                 return;
871         }
872
873         if (part == NULL) {
874                 dlog_print(DLOG_ERROR, LOG_TAG, "part is NULL.");
875                 return;
876         }
877
878         progressbar = elm_object_part_content_get(parent, part);
879         if (progressbar == NULL) {
880                 dlog_print(DLOG_ERROR, LOG_TAG, "prgressbar is NULL.");
881                 return;
882         }
883
884         eext_circle_object_value_set(progressbar, val);
885 }
886
887 /*
888  * @brief: Make a checkbox
889  * @param[parent]: The object to which you want to add this checkbox
890  */
891 Evas_Object *view_create_checkbox(Evas_Object *parent)
892 {
893         Evas_Object *check;
894
895         if (parent == NULL) {
896                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
897                 return NULL;
898         }
899
900         check = elm_check_add(parent);
901         elm_check_state_set(check, EINA_FALSE);
902         evas_object_smart_callback_add(check, "changed", _icon_clicked_cb, NULL);
903         evas_object_show(check);
904
905         return check;
906 }
907
908 /*
909  * @brief: Make no voice memo view
910  * @param[parent]: naviframe
911  * @param[title]: titile of this view
912  * @param[detail]: detail text of this view
913  * @param[image_file]: image file name will be used in this view
914  * This function make a view consists of one title, one center image and one detail text at the bottom
915  */
916 Evas_Object *view_create_layout_no_content(Evas_Object *parent, char *title, char *detail, char *image_file)
917 {
918         Evas_Object *layout = NULL;
919         Evas_Object *img;
920         Elm_Object_Item *it;
921
922         if (parent == NULL) {
923                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
924                 return NULL;
925         }
926
927         layout = elm_layout_add(parent);
928         /* this make you can use layout consists of one title, one image and one detail text */
929         elm_layout_theme_set(layout, "layout", "nocontents", "default");
930         evas_object_size_hint_weight_set (layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
931         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
932
933         if(image_file) {
934                 img = elm_image_add(parent);
935                 elm_image_file_set(img, image_file, NULL);
936                 elm_object_part_content_set(layout, "elm.swallow.icon", img);
937                 evas_object_show(img);
938         }
939
940         if (detail) {
941                 char detail_text[256] = {0, };
942
943                 /* Customize font style bellow */
944                 snprintf(detail_text, sizeof(detail_text), "<font=TIZEN:style=Medium align=center color=#FFFFFF><font_size=28>%s</font_size></font>", detail);
945                 elm_object_part_text_set(layout, "elm.text", detail_text);
946         }
947         if (title) {
948                 char title_text[256] = {0, };
949
950                 snprintf(title_text, sizeof(title_text), "<font=TIZEN:style=Medium align=center color=#12B4FF><font_size=28>%s</font_size></font>", title);
951                 elm_object_part_text_set(layout, "elm.text.title", title_text);
952         }
953
954         /* if this signal is not sent, title text will be disappear */
955         elm_object_signal_emit(layout, "elm,state,title,enable", "elm");
956         /* push this no voice memo view to naviframe to show */
957         it = elm_naviframe_item_push(parent, "Title Enabled", NULL, NULL, layout, NULL);
958         /* if this is EINA_TRUE, you can see Title of naviframe on the top of the screen */
959         elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE);
960
961         return layout;
962 }
963
964 /*
965  * @brief: Set datetime to the part.
966  * @param[parent]: object to which you want to set datetime
967  * @param[circle_surface]: object render a connected circle object
968  * @param[part]: part name to which you want to set this datetime
969  * @param[style]: style of the datetime
970  */
971 Evas_Object *view_create_datetime(Evas_Object *parent, Eext_Circle_Surface *circle_surface, const char *style)
972 {
973         Evas_Object *datetime = NULL;
974         Evas_Object *circle_datetime = NULL;
975
976         if (parent == NULL) {
977                 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
978                 return NULL;
979         }
980
981         if (circle_surface == NULL) {
982                 dlog_print(DLOG_ERROR, LOG_TAG, "failed to get circle_surface.");
983                 return NULL;
984         }
985
986         datetime = elm_datetime_add(parent);
987         circle_datetime = eext_circle_object_datetime_add(datetime, circle_surface);
988
989         eext_rotary_object_event_activated_set(datetime, EINA_TRUE);
990         elm_datetime_format_set(datetime, FORMAT);
991
992         elm_object_style_set(datetime, style);
993
994         return datetime;
995 }
996