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