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