2 * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 static struct view_info {
26 * @brief: Create Essential Object window, conformant and layout
28 void view_create(void)
31 s_info.win = view_create_win(PACKAGE);
32 if (s_info.win == NULL) {
33 dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a window.");
37 /* Create conformant */
38 s_info.conform = view_create_conformant_without_indicator(s_info.win);
39 if (s_info.conform == NULL) {
40 dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a conformant");
44 /* Show window after main view is set up */
45 evas_object_show(s_info.win);
49 * @brief: Make a basic window named package
50 * @param[pkg_name]: Name of the window
52 Evas_Object *view_create_win(const char *pkg_name)
54 Evas_Object *win = NULL;
58 * Create and initialize elm_win.
59 * elm_win is mandatory to manipulate window
61 win = elm_win_util_standard_add(pkg_name, pkg_name);
62 elm_win_conformant_set(win, EINA_TRUE);
63 elm_win_autodel_set(win, EINA_TRUE);
65 /* Rotation setting */
66 if (elm_win_wm_rotation_supported_get(win)) {
67 int rots[4] = { 0, 90, 180, 270 };
68 elm_win_wm_rotation_available_rotations_set(win, (const int *)(&rots), 4);
71 evas_object_smart_callback_add(win, "delete,request", _win_delete_request_cb, NULL);
77 * @brief: Make a conformant without indicator for wearable app
78 * @param[win]: The object to which you want to set this conformant
79 * Conformant is mandatory for base GUI to have proper size
81 Evas_Object *view_create_conformant_without_indicator(Evas_Object *win)
85 * Create and initialize elm_conformant.
86 * elm_conformant is mandatory for base GUI to have proper size
87 * when indicator or virtual keypad is visible.
89 Evas_Object *conform = NULL;
92 dlog_print(DLOG_ERROR, LOG_TAG, "window is NULL.");
96 conform = elm_conformant_add(win);
97 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
98 elm_win_resize_object_add(win, conform);
100 evas_object_show(conform);
106 * @brief: Make a layout to target parent object with edje file
107 * @param[parent]: The object to which you want to add this layout
108 * @param[file_path]: File path of EDJ file will be used
109 * @param[group_name]: Name of group in EDJ you want to set to
110 * @param[cb_function]: The function will be called when back event is detected
111 * @param[user_data]: The user data to be passed to the callback functions
113 Evas_Object *view_create_layout(Evas_Object *parent, const char *file_path, const char *group_name, Eext_Event_Cb cb_function, void *user_data)
115 Evas_Object *layout = NULL;
117 if (parent == NULL) {
118 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
122 /* Create layout by EDC(edje file) */
123 layout = elm_layout_add(parent);
124 elm_layout_file_set(layout, file_path, group_name);
126 /* Layout size setting */
127 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
130 eext_object_event_callback_add(layout, EEXT_CALLBACK_BACK, cb_function, user_data);
132 evas_object_show(layout);
138 * @brief: Make and set a layout to conformant
139 * @param[parent]: Target conformant object
140 * @param[file_path]: File path of EDJ will be used
141 * @param[group_name]: Group name in EDJ you want to set to layout
142 * @param[cb_function]: The function will be called when the back event is detected
143 * @param[user_data]: The user data to be passed to the callback functions
145 Evas_Object *view_create_layout_for_conformant(Evas_Object *parent, const char *file_path, const char *group_name, Eext_Event_Cb cb_function, void *user_data)
147 Evas_Object *layout = NULL;
149 if (parent == NULL) {
150 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
154 /* Create layout for conformant */
155 if (file_path == NULL) {
156 layout = view_create_layout_by_theme(parent, "layout", "application", "default");
158 layout = view_create_layout(parent, file_path, group_name, cb_function, user_data);
161 if (layout == NULL) {
162 dlog_print(DLOG_ERROR, LOG_TAG, "layout is NULL.");
166 elm_object_content_set(parent, layout);
172 * @brief: Make a layout with theme.
173 * @param[parent]: Object to which you want to add this layout
174 * @param[class_name]: The class of the group
175 * @param[group_name]: Group name in EDJ that you want to set to layout
176 * @param[style]: The style to use
178 Evas_Object *view_create_layout_by_theme(Evas_Object *parent, const char *class_name, const char *group_name, const char *style)
182 * Create and initialize elm_layout.
183 * view_create_layout_by_theme() is used to create layout by using premade edje file.
185 Evas_Object *layout = NULL;
187 if (parent == NULL) {
188 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
192 layout = elm_layout_add(parent);
193 elm_layout_theme_set(layout, class_name, group_name, style);
194 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
196 evas_object_show(layout);
202 * @brief: Make and set a layout to the part
203 * @param[parent]: Object to which you want to set this layout
204 * @param[file_path]: File path of EDJ will be used
205 * @param[group_name]: Group name in EDJ that you want to set to layout
206 * @param[part_name]: Part name to which you want to set this layout
208 Evas_Object *view_create_layout_for_part(Evas_Object *parent, char *file_path, char *group_name, char *part_name)
210 Evas_Object *layout = NULL;
212 if (parent == NULL) {
213 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
217 layout = elm_layout_add(parent);
218 elm_layout_file_set(layout, file_path, group_name);
219 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
221 evas_object_show(layout);
223 elm_object_part_content_set(parent, part_name, layout);
229 * @brief: Destroy window and free important data to finish this application
231 void view_destroy(void)
233 if (s_info.win == NULL) {
237 evas_object_del(s_info.win);
241 * @brief: Destroy given layout
242 * @param[layout]: The layout you want to destroy
244 void view_destroy_layout(Evas_Object *layout)
246 evas_object_del(layout);
250 * @brief: Set image to given part
251 * @param[parent]: Object has part to which you want to set this image
252 * @param[part_name]: Part name to which you want to set this image
253 * @param[image_path]: Path of the image file
255 void view_set_image(Evas_Object *parent, const char *part_name, const char *image_path)
257 Evas_Object *image = NULL;
259 if (parent == NULL) {
260 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
264 image = elm_object_part_content_get(parent, part_name);
266 image = elm_image_add(parent);
268 dlog_print(DLOG_ERROR, LOG_TAG, "failed to create an image object.");
272 elm_object_part_content_set(parent, part_name, image);
275 if (EINA_FALSE == elm_image_file_set(image, image_path, NULL)) {
276 dlog_print(DLOG_ERROR, LOG_TAG, "failed to set image: %s", image_path);
280 evas_object_show(image);
286 * @brief: Set text to the part
287 * @param[parent]: Object has part to which you want to set text
288 * @param[part_name]: Part name to which you want to set the text
289 * @param[text]: Text you want to set to the part
291 void view_set_text(Evas_Object *parent, const char *part_name, const char *text)
293 if (parent == NULL) {
294 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
298 /* Set text of target part object */
299 elm_object_part_text_set(parent, part_name, text);
303 * @brief: Set color of the part
304 * @param[parent]: Object has part to which you want to set color
305 * @param[part_name]: 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
311 void view_set_color(Evas_Object *parent, const char *part_name, int r, int g, int b, int a)
313 Evas_Object *obj = NULL;
315 if (parent == NULL) {
316 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
320 obj = elm_object_part_content_get(parent, part_name);
322 dlog_print(DLOG_ERROR, LOG_TAG, "failed to get parent.");
326 /* Set color of target part object */
327 evas_object_color_set(obj, r, g, b, a);
331 * @brief: Set the color of circle line and font in a given circle object
332 * @param[parent]: Object has part to which you want to set color
333 * @param[part_name]: Name of part to which you want to set color
334 * @param[r] The red component of the given color
335 * @param[g] The green component of the given color
336 * @param[b] The blue component of the given color
337 * @param[a] The alpha component of the given color
339 void view_set_color_of_circle_object(Evas_Object *parent, const char *part_name, int r, int g, int b, int a)
341 Evas_Object *obj = NULL;
343 if (parent == NULL) {
344 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
348 /* if the "part" is NULL, this function will get the content from "default" part */
349 obj = elm_object_part_content_get(parent, part_name);
351 dlog_print(DLOG_ERROR, LOG_TAG, "failed to get parent.");
355 /* Set color of target part object */
356 eext_circle_object_color_set(obj, r, g, b, a);
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
364 Evas_Object *view_create_naviframe(Evas_Object *parent)
367 * Create and initialize elm_naviframe.
368 * Naviframe stands for navigation frame.
369 * elm_naviframe is a views manager for applications.
371 Evas_Object *nf = NULL;
373 if (parent == NULL) {
374 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
378 nf = elm_naviframe_add(parent);
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);
384 evas_object_show(nf);
390 * @brief: Push item to naviframe
391 * @param[nf]: Naviframe has several views
392 * @param[item]: Object will be added to naviframe
393 * @param[pop_cb]: Function will be operated when this item is popped from naviframe
394 * @param[user_data]: Data passed to the 'pop_cb' function
395 * Naviframe make changing of view is easy and effectively
397 Elm_Object_Item* view_push_item_to_naviframe(Evas_Object *nf, Evas_Object *item, Elm_Naviframe_Item_Pop_Cb pop_cb, void *user_data)
399 Elm_Object_Item* nf_it = NULL;
402 dlog_print(DLOG_ERROR, LOG_TAG, "naviframe is NULL.");
407 dlog_print(DLOG_ERROR, LOG_TAG, "item is NULL.");
411 nf_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, item, "empty");
414 elm_naviframe_item_pop_cb_set(nf_it, pop_cb, user_data);
420 * @brief: Set a more button
421 * @param[parent]: Object has part to which you want to set
422 * @param[part]: Part name to which you want to set
423 * @param[opened_cb]: Function will be operated when the more button is opened
424 * @param[closed_cb]: Function will be operated when the more button is closed
425 * @param[seleted_cb]: Function will be operated when the more button item is selected
426 * @param[user_data]: Data needed in this function
428 void view_set_more_button(Evas_Object *parent, const char *part, Evas_Smart_Cb opened_cb, Evas_Smart_Cb closed_cb, Evas_Smart_Cb seleted_cb, void *user_data)
430 Evas_Object *more_btn = NULL;
432 if (parent == NULL) {
433 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
437 more_btn = eext_more_option_add(parent);
438 if (more_btn == NULL) {
439 dlog_print(DLOG_ERROR, LOG_TAG, "more option is NULL.");
443 /* Add smart callback */
444 evas_object_smart_callback_add(more_btn, "more,option,opened", opened_cb, user_data);
445 evas_object_smart_callback_add(more_btn, "more,option,closed", closed_cb, user_data);
446 evas_object_smart_callback_add(more_btn, "item,selected", seleted_cb, user_data);
448 elm_object_part_content_set(parent, part, more_btn);
452 * @brief: Make and set button.
453 * @param[parent]: Object to which you want to set the button
454 * @param[part_name]: Name of part to which you want to set the button
455 * @param[style]: Style of the button
456 * @param[image_path]: Path of image file will be used as button icon
457 * @param[text]: The text will be written on the button
458 * @param[down_cb]: Function will be operated when the button is pressed
459 * @param[up_cb]: Function will be operated when the button is released
460 * @param[clicked_cb]: Function will be operated when the button is clicked
461 * @param[user_data]: Data passed to the 'clicked_cb' function
463 void view_set_button(Evas_Object *parent, const char *part_name, const char *style, const char *image_path, const char *text,
464 Evas_Object_Event_Cb down_cb, Evas_Object_Event_Cb up_cb, Evas_Smart_Cb clicked_cb, void *user_data)
466 Evas_Object *btn = NULL;
468 if (parent == NULL) {
469 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
473 btn = elm_button_add(parent);
475 dlog_print(DLOG_ERROR, LOG_TAG, "failed to create button.");
480 elm_object_style_set(btn, style);
482 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
483 elm_object_part_content_set(parent, part_name, btn);
486 elm_object_text_set(btn, text);
489 view_set_image(btn, NULL, image_path);
492 evas_object_event_callback_add(btn , EVAS_CALLBACK_MOUSE_DOWN, down_cb, user_data);
494 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, up_cb, user_data);
496 evas_object_smart_callback_add(btn, "clicked", clicked_cb, user_data);
498 evas_object_show(btn);
502 * @brief: Add a more button item
503 * @param[parent]: object that contains more button
504 * @param[part_name]: Name of the part has more option
505 * @param[main_txt]: text will be written in the middle of the selector
506 * @param[sub_txt] Text will be written under the main_txt
507 * @param[image_path]: path of image file will be used as more button item icon
508 * @param[clicked_cb]: function will be operated when the more button item is clicked
509 * @param[user_data]: data needed in this function
511 void view_add_more_button_item(Evas_Object *parent, const char *part_name, const char *main_txt, const char *sub_txt, const char *image_path, Evas_Smart_Cb clicked_cb, void *user_data)
513 Evas_Object *image = NULL;
514 Evas_Object *more_btn = NULL;
515 char full_path[PATH_MAX] = { 0, };
517 if (parent == NULL) {
518 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
522 more_btn = elm_object_part_content_get(parent, part_name);
523 if (more_btn == NULL) {
527 /* Create the new item */
528 Eext_Object_Item *item = eext_more_option_item_append(more_btn);
530 /* Set the text in item text part */
531 eext_more_option_item_part_text_set(item, "selector,main_text", main_txt);
532 eext_more_option_item_part_text_set(item, "selector,sub_text", sub_txt);
534 image = elm_image_add(more_btn);
535 _get_resource(image_path, full_path, sizeof(full_path));
536 elm_image_file_set(image, full_path, NULL);
538 /* Set the content in item content part */
539 eext_more_option_item_part_content_set(item, "item,icon", image);
541 evas_object_smart_callback_add(more_btn, "item,clicked", clicked_cb, user_data);
545 * @brief: Make a Entry Object to target window
546 * @param[parent]: Object to which you want to set Entry
547 * @param[part_name]: Part of the layout which you want to locate Entry
548 * @param[clicked_cb]: The function will be called when the entry is clicked
549 * @param[user_data]: The user data passed to the callback function
550 * @Add callback function will be operated when mouse clicked event is triggered
552 Evas_Object *view_create_entry(Evas_Object *parent, const char *part_name, Evas_Smart_Cb clicked_cb, void *user_data)
554 Evas_Object *entry = NULL;
556 if (parent == NULL) {
557 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
561 /* Add Entry object to parent */
562 entry = elm_entry_add(parent);
564 dlog_print(DLOG_ERROR, LOG_TAG, "failed to add a entry");
568 /* Set Entry size option */
569 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
571 /* Set Entry option for display and functionalities */
572 elm_entry_single_line_set(entry, EINA_TRUE);
573 elm_entry_scrollable_set(entry, EINA_TRUE);
574 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
575 elm_entry_editable_set(entry, EINA_FALSE);
576 elm_entry_context_menu_disabled_set(entry, EINA_TRUE);
577 elm_entry_cursor_handler_disabled_set(entry, EINA_TRUE);
578 elm_entry_select_allow_set(entry, EINA_FALSE);
580 /* Set Entry text style using predefined style description */
581 elm_entry_text_style_user_push(entry, DIAL_TEXT_STYLE_NORMAL);
583 elm_object_part_content_set(parent, part_name, entry);
585 /* Set callback for event about Entry */
587 evas_object_smart_callback_add(entry, "clicked", clicked_cb, user_data);
594 * @brief: make genlist for circular shape
595 * @param[parent]: object to which you want to set genlist
597 Evas_Object *view_create_circle_genlist(Evas_Object *parent)
599 Evas_Object *genlist = NULL;
600 Evas_Object *circle_genlist = NULL;
602 if (parent == NULL) {
603 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
607 if (s_info.circle_surface == NULL) {
608 dlog_print(DLOG_ERROR, LOG_TAG, "circle surface is NULL.");
612 genlist = elm_genlist_add(parent);
614 * This make selected list item is shown compressed.
616 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
617 evas_object_smart_callback_add(genlist, "selected", _gl_selected_cb, NULL);
620 * This make genlist style circular.
622 circle_genlist = eext_circle_object_genlist_add(genlist, s_info.circle_surface);
623 eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
624 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
626 evas_object_show(genlist);
632 * @brief: Add item to genlist.
633 * @param[genlist]: Genlist shows several items
634 * @param[style]: Style of item determine how to show this item, such as "1text", "1text1icon" and so on
635 * @param[gen_data]: Item data that use item's callback function
636 * @param[clicked_cb]: function will be operated when the item is clicked
637 * @param[user_data]: Data passed to 'clicked_cb' function
638 * This make item's class and add item to genlist.
640 Elm_Object_Item *view_append_item_to_genlist(Evas_Object *genlist, const char *style,
641 const void *gen_data, Evas_Smart_Cb clicked_cb, const void *user_data)
643 Elm_Genlist_Item_Class *item_class;
644 Elm_Object_Item *item;
646 if (genlist == NULL) {
647 dlog_print(DLOG_ERROR, LOG_TAG, "genlist is NULL.");
652 dlog_print(DLOG_ERROR, LOG_TAG, "item style is NULL.");
656 item_class = _set_genlist_item_class(style);
658 item = elm_genlist_item_append(genlist, item_class, gen_data, NULL, ELM_GENLIST_ITEM_NONE, clicked_cb, user_data);
660 elm_genlist_item_class_free(item_class);
666 * @brief: Find item from genlist.
667 * @param[genlist]: Genlist shows several items
668 * @param[val]: value determine which of the items has to remove
670 Elm_Object_Item *view_find_item_from_genlist(Evas_Object *genlist, const char *val)
674 Elm_Object_Item *item = NULL;
675 struct genlist_data *gendata = NULL;
677 if (genlist == NULL) {
678 dlog_print(DLOG_ERROR, LOG_TAG, "genlist is NULL.");
682 item_count = elm_genlist_items_count(genlist);
685 * The fist item and the last item are "padding".
687 for (i = 1; i < item_count-1; i++) {
688 item = elm_genlist_nth_item_get(genlist, i);
689 gendata = elm_object_item_data_get(item);
691 if (gendata->alarm_id == atoi(val)) {
700 * @brief: Remove item.
701 * @param[item]: item from genlist
703 void view_delete_item(Elm_Object_Item *item)
705 elm_object_item_del(item);
709 * @brief: Make popup with theme.
710 * @param[timeout]: Duration that popup is showing
711 * @param[text]: Text displayed on the popup
713 void view_create_text_popup(Evas_Object *parent, double timeout, const char *text)
715 Evas_Object *popup = NULL;
716 Evas_Object *popup_layout = NULL;
718 if (parent == NULL) {
719 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
723 popup = elm_popup_add(parent);
724 elm_object_style_set(popup, "circle");
725 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
727 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_hide_cb, NULL);
729 * Delete popup object in _popup_hide_finished_cb(), when the "dismissed" signal will be called.
731 evas_object_smart_callback_add(popup, "dismissed", _popup_hide_finished_cb, NULL);
733 popup_layout = elm_layout_add(popup);
734 elm_layout_theme_set(popup_layout, "layout", "popup", "content/circle");
736 elm_object_content_set(popup, popup_layout);
738 elm_popup_timeout_set(popup, timeout);
741 view_set_text(popup_layout, "elm.text", text);
743 evas_object_show(popup);
747 * @brief: Set the content to the given part
748 * @param[part_name]: Name of the part to which you want to set
749 * @param[content]: The object will be set to the given part
751 void view_set_content_to_part(Evas_Object *layout, const char *part_name, Evas_Object *content)
753 elm_object_part_content_set(layout, part_name, content);
757 * @brief: Send signal with source to the EDJ object
758 * @param[layout]: The layout object will receive the signal
759 * @param[signal]: The appointed signal to trigger the function
760 * @param[source]: The appointed source that normally indicate the object triggered the event
762 void view_send_signal_to_edje(Evas_Object *layout, const char *signal, const char *source)
764 elm_object_signal_emit(layout, signal, source);
768 * @brief: Set the function will be called when the appointed signal is occurred
769 * @param[item]: The object triggered the signal
770 * @param[signal]: The appointed signal to trigger the function
771 * @param[source]: The appointed source that normally indicate the object triggered the event
772 * @param[signal_cb]: The function will be called when the signal is detected
773 * @param[user_data]: The data passed to the 'signal_cb' function
775 void view_set_customized_event_callback(Evas_Object *item, char *signal, char *source, Edje_Signal_Cb signal_cb, void *user_data)
777 elm_object_signal_callback_add(item, signal, source, signal_cb, user_data);
781 * @brief: Register rotary event callback function.
782 * @param[obj]: object that will receive rotary event
783 * @param[rotary_cb]: function will be operated when rotary event happens
784 * @param[user_data]: Data passed to the 'rotary_cb' function
786 void view_set_rotary_event_callback(Evas_Object *obj, Eext_Rotary_Event_Cb rotary_cb, void *user_data)
789 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
793 eext_rotary_object_event_activated_set(obj, EINA_TRUE);
794 eext_rotary_object_event_callback_add(obj, rotary_cb, user_data);
798 * @brief: Make a label and set label options.
799 * @param[parent]: The object to which you want to add this label
801 Evas_Object *view_create_label(Evas_Object *parent)
803 Evas_Object *label = elm_label_add(parent);
805 if (parent == NULL) {
806 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
810 elm_object_style_set(label, "slide_short");
811 elm_label_wrap_width_set(label, 230);
812 elm_label_ellipsis_set(label, EINA_TRUE);
813 elm_label_slide_duration_set(label, 2);
814 elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_NONE);
815 elm_label_slide_go(label);
816 evas_object_show(label);
822 * @brief: Set a text to label object
823 * @param[parent]: Object has part to which you want to set text
824 * @param[part_name]: Part name to which you want to set text
825 * @param[text]: text you want to set to the part
827 void view_set_label_text(Evas_Object *parent, const char *part_name, const char *text)
829 Evas_Object *label = NULL;
830 char *markup_text = NULL;
831 char buf[256] = { 0, };
833 if (parent == NULL) {
834 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
838 markup_text = elm_entry_utf8_to_markup(text);
839 snprintf(buf, sizeof(buf), "%s%s%s", LABEL_STYLE_START, markup_text, LABEL_STYLE_END);
842 label = elm_object_part_content_get(parent, part_name);
844 dlog_print(DLOG_ERROR, LOG_TAG, "label is NULL.");
848 elm_object_text_set(label, buf);
852 * @brief: Set a label to given part
853 * @param[parent]: Object has part to which you want to set this label
854 * @param[part_name]: Part name to which you want to set this label
856 void view_set_label(Evas_Object *parent, const char *part_name)
858 Evas_Object *label = NULL;
860 if (parent == NULL) {
861 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
865 label = view_create_label(parent);
867 dlog_print(DLOG_ERROR, LOG_TAG, "label is NULL.");
871 elm_object_part_content_set(parent, part_name, label);
875 * @brief: Create a progressbar
876 * @param[parent]: Object has part to which you want to set this progressbar
877 * @param[radius]: Radius The radius value of a given circle object
878 * @param[line_width]: Line_width The line width value of the circle object
880 Evas_Object *view_create_progressbar(Evas_Object *parent, int radius, int line_width)
882 Evas_Object *progressbar = NULL;
884 if (parent == NULL) {
885 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
889 progressbar = eext_circle_object_progressbar_add(parent, NULL);
891 eext_circle_object_value_min_max_set(progressbar, 0.0, 100.0);
892 eext_circle_object_radius_set(progressbar, radius);
893 eext_circle_object_line_width_set(progressbar, line_width);
894 evas_object_show(progressbar);
900 * @brief: Set a progressbar to given part
901 * @param[parent]: Object has part to which you want to set
902 * @param[part_name]: Part name to which you want to set
903 * @param[radius]: Radius The radius value of a given circle object
904 * @param[line_width]: Line_width The line width value of the circle object
906 void view_set_progressbar(Evas_Object *parent, const char *part_name, int radius, int line_width)
908 Evas_Object *progressbar = NULL;
910 if (parent == NULL) {
911 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
915 progressbar = view_create_progressbar(parent, radius, line_width);
916 if (progressbar == NULL) {
917 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
921 elm_object_part_content_set(parent, part_name, progressbar);
925 * @brief: Set value to a progressbar
926 * @param[parent]: Object has part to which you want to set
927 * @param[part_name]: Part name to which you want to set
928 * @param[val]: Value to which you want to set
930 void view_set_progressbar_val(Evas_Object *parent, const char *part_name, int val)
932 Evas_Object *progressbar = NULL;
934 if (parent == NULL) {
935 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
939 if (part_name == NULL) {
940 dlog_print(DLOG_ERROR, LOG_TAG, "part is NULL.");
944 progressbar = elm_object_part_content_get(parent, part_name);
945 if (progressbar == NULL) {
946 dlog_print(DLOG_ERROR, LOG_TAG, "progressbar is NULL.");
950 eext_circle_object_value_set(progressbar, val);
954 * @brief: Make a check box
955 * @param[parent]: The object to which you want to add this check box
957 Evas_Object *view_create_checkbox(Evas_Object *parent)
961 if (parent == NULL) {
962 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
966 check = elm_check_add(parent);
967 elm_check_state_set(check, EINA_FALSE);
968 evas_object_smart_callback_add(check, "changed", _icon_clicked_cb, NULL);
969 evas_object_show(check);
975 * @brief: Make no content view
976 * @param[parent]: Naviframe has several views
977 * @param[title]: title of this view
978 * @param[detail]: detail text of this view
979 * @param[image_path]: Image file path will be used in this view
980 * This function make a view consists of one title, one center image and one detail text at the bottom
982 Evas_Object *view_create_layout_no_content(Evas_Object *parent, char *title, char *detail, char *image_path)
984 Evas_Object *layout = NULL;
988 if (parent == NULL) {
989 dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL.");
993 layout = elm_layout_add(parent);
994 /* this make you can use layout consists of one title, one image and one detail text */
995 elm_layout_theme_set(layout, "layout", "nocontents", "default");
996 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
997 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1000 image = elm_image_add(parent);
1001 elm_image_file_set(image, image_path, NULL);
1002 elm_object_part_content_set(layout, "elm.swallow.icon", image);
1003 evas_object_show(image);
1007 char detail_text[256] = {0, };
1009 /* Customize font style bellow */
1010 snprintf(detail_text, sizeof(detail_text), "<font=TIZEN:style=Medium align=center color=#FFFFFF><font_size=28>%s</font_size></font>", detail);
1011 elm_object_part_text_set(layout, "elm.text", detail_text);
1014 char title_text[256] = {0, };
1016 snprintf(title_text, sizeof(title_text), "<font=TIZEN:style=Medium align=center color=#12B4FF><font_size=28>%s</font_size></font>", title);
1017 elm_object_part_text_set(layout, "elm.text.title", title_text);
1020 /* if this signal is not sent, title text will be disappear */
1021 elm_object_signal_emit(layout, "elm,state,title,enable", "elm");
1022 /* push this no voice memo view to naviframe to show */
1023 it = elm_naviframe_item_push(parent, "Title Enabled", NULL, NULL, layout, NULL);
1024 /* if this is EINA_TRUE, you can see Title of naviframe on the top of the screen */
1025 elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE);
1031 * @brief: Set datetime to the part
1032 * @param[parent]: object to which you want to set datetime
1033 * @param[style]: style of the datetime
1035 Evas_Object *view_create_datetime(Evas_Object *parent, const char *style)
1037 Evas_Object *circle_datetime = NULL;
1039 if (parent == NULL) {
1040 dlog_print(DLOG_ERROR, LOG_TAG, "failed to get parent.");
1044 if (s_info.circle_surface == NULL) {
1045 dlog_print(DLOG_ERROR, LOG_TAG, "failed to get circle_surface.");
1049 s_info.datetime = elm_datetime_add(parent);
1050 circle_datetime = eext_circle_object_datetime_add(s_info.datetime, s_info.circle_surface);
1052 eext_rotary_object_event_activated_set(s_info.datetime, EINA_TRUE);
1053 elm_datetime_format_set(s_info.datetime, FORMAT);
1055 elm_object_style_set(s_info.datetime, style);
1057 elm_object_part_content_set(parent, "elm.swallow.content", s_info.datetime);
1059 return s_info.datetime;