From: salt.jeong Date: Fri, 8 Jan 2016 07:14:42 +0000 (+0900) Subject: initial version X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eaac4a469dca0d8618eebbd4f6601643157954fc;p=apps%2Fnative%2Fsample%2Fsample-core-components.git initial version Add more files. (empty files) Change-Id: Ic75099fa71719287f433f8f2484900b4ce11e02d Signed-off-by: Sung-jae Park --- diff --git a/data.c b/data.c new file mode 100644 index 0000000..e69de29 diff --git a/data.h b/data.h new file mode 100644 index 0000000..e69de29 diff --git a/main.c b/main.c new file mode 100644 index 0000000..e69de29 diff --git a/main.h b/main.h new file mode 100644 index 0000000..e69de29 diff --git a/view.c b/view.c new file mode 100644 index 0000000..89b08b6 --- /dev/null +++ b/view.c @@ -0,0 +1,894 @@ +/* + * @brief: Make a essential object for the this app, like window, conformant and layout + * @param[ad]: The object has informations for managing this app + */ +void view_create(appdata_s *ad) +{ + /* Create window */ + ad->win = view_create_win(); + if (ad->win == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a window."); + return; + } + + /* Create conformant */ + ad->conform = view_create_conformant_without_indicator(ad->win); + if (ad->conform == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to create a conformant"); + return; + } + + /* Show window after main view is set up */ + evas_object_show(ad->win); +} + +/* + * @brief: Make a basic window named package + * @param[package]: Name of the window + */ +Evas_Object *view_create_win(const char *pkg_name) +{ + Evas_Object *win = NULL; + + /* Window */ + /* Create and initialize elm_win. + elm_win is mandatory to manipulate window. */ + + win = elm_win_util_standard_add(pkg_name, pkg_name); + elm_win_conformant_set(win, EINA_TRUE); + elm_win_autodel_set(win, EINA_TRUE); + + if (elm_win_wm_rotation_supported_get(win)) { + int rots[4] = { 0, 90, 180, 270 }; + elm_win_wm_rotation_available_rotations_set(win, (const int *)(&rots), 4); + } + + evas_object_smart_callback_add(win, "delete,request", _win_delete_request_cb, NULL); + + return win; +} + +/* + * @brief: Make a conformant without indicator for wearable app + * @param[win]: The object to which you want to set this conformant + * Confromant is mandatory for base GUI to have proper size + */ +Evas_Object *view_create_conformant_without_indicator(Evas_Object *win) +{ + /* Conformant + * Create and initialize elm_conformant. + * elm_conformant is mandatory for base GUI to have proper size + * when indicator or virtual keypad is visible. + */ + Evas_Object *conform = NULL; + + if (win == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "window is NULL."); + return NULL; + } + + conform = elm_conformant_add(win); + evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, conform); + + evas_object_show(conform); + + return conform; +} + +/* + * @brief: Make a layout to target parent object with edje file + * @param[parent]: The object to which you want to add this layout + * @param[file_name]: File path of EDJ + * @param[group_name]: Name of group in EDJ you want to set to + * @param[Evas_Object_Event_Cb]: File path of EDJ + * @param[user_data]: The user data to be passed to the callback functions + */ +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) +{ + Evas_Object *layout = NULL; + char edj_path[PATH_MAX] = { 0, }; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return NULL; + } + + /* Create layout by EDC(edje file) */ + _get_resource(file_name, edj_path, (int)PATH_MAX); + layout = elm_layout_add(parent); + elm_layout_file_set(layout, edj_path, group_name); + + /* Layout size setting */ + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + if(cb_function) + eext_object_event_callback_add(layout, EEXT_CALLBACK_BACK, cb_function, user_data); + + evas_object_show(layout); + + return layout; +} + +/* + * @brief: Make and set a layout to conformant + * @param[parent]: Target conformant object + * @param[file_name]: File path of EDJ used + * @param[group_name]: Group name in EDJ you want to set to layout + * @param[user_data]: The user data to be passed to the callback functions + */ +Evas_Object *view_create_layout_for_conformant(Evas_Object *parent, Evas_Object *conformant, const char *file_name, const char *group_name, void *user_data) +{ + Evas_Object *layout = NULL; + + /* Create layout for conformant */ + layout = view_create_layout(parent, file_name, group_name, user_data); + if (layout == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return NULL; + } + + elm_object_content_set(conformant, layout); + + return layout; +} + +/* + * @brief: Make a layout with theme. + * @param[parent]: Object to which you want to add this layout + * @param[class]: The class of the group + * @param[group_name]: Group name in EDJ you want to set to layout + * @param[style]: The style to use + */ +Evas_Object *view_create_layout_by_theme(Evas_Object *parent, const char *classname, const char *group, const char *style) +{ + /* + * Layout + * Create and initialize elm_layout. + * view_create_layout_by_theme() is used to create layout by using premade edje file. + */ + Evas_Object *layout = NULL; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return NULL; + } + + layout = elm_layout_add(parent); + elm_layout_theme_set(layout, classname, group, style); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + evas_object_show(layout); + + return layout; +} + +/* + * @brief: Make and set a layout to the part + * @param[parent]: Object to which you want to set this layout + * @param[file_name]: File path of EDJ used + * @param[group_name]: Group name in EDJ you want to set to layout + * @param[part]: Part name to which you want to set this layout + */ +Evas_Object *view_create_layout_for_part(Evas_Object *parent, char *part, char *file_name, char *group_name) +{ + Evas_Object *layout = NULL; + + layout = elm_layout_add(parent); + elm_layout_file_set(layout, file_name, group_name); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + evas_object_show(layout); + + elm_object_part_content_set(parent, part, layout); + + return layout; +} + +/* + * @brief: Destroy window and free important data to finish this app + * @param[ad]: The object has informations for managing this app + */ +void view_destroy(void *user_data) +{ + appdata_s *ad = NULL; + + ad = user_data; + if (ad == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to destroy data."); + return; + } + + evas_object_del(ad->win); +} + +/* + * @brief: Destroy given layout + * @param[layout]: The layout you want to destroy + */ +void view_destroy_layout(Evas_Object *layout) +{ + evas_object_del(layout); +} + +/* + * @brief: Set image to given part + * @param[parent]: object has part to which you want to set this image + * @param[part]: part name to which you want to set this image + * @param[image_path]: path of image file + */ +void view_set_image(Evas_Object *parent, const char *part, const char *image_path) +{ + Evas_Object *image = NULL; + + if(!parent) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to parent layout."); + return; + } + + image = elm_object_part_content_get(parent, part); + if (image == NULL) { + image = elm_image_add(parent); + if (!image) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to create image."); + return; + } + } + + if (EINA_FALSE == elm_image_file_set(image, image_path, NULL)) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to set image."); + return; + } + + if (part) { + elm_object_part_content_set(parent, part, image); + } else { + elm_object_content_set(parent, image); + } + + evas_object_show(image); + + return; +} + +/* + * @brief: Set text to the part + * @param[parent]: Object has part to which you want to set text + * @param[part]: Part name to which you want to set text + * @param[text]: text you want to set to the part + */ +void view_set_text(Evas_Object *parent, const char *part, const char *text) +{ + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to get parent."); + return; + } + + /* Set text of target part object */ + elm_object_part_text_set(parent, part, text); +} + +/* + * @brief: Set color of the part + * @param[parent]: Object has part to which you want to set color + * @param[part]: Name of part to which you want to set color + * @param[r]: R of RGBA you want to set to the part + * @param[g]: G of RGBA you want to set to the part + * @param[b]: B of RGBA you want to set to the part + * @param[a]: A of RGBA you want to set to the part + */ +void view_set_color(Evas_Object *parent, const char *part, int r, int g, int b, int a) +{ + Evas_Object *obj = NULL; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to get parent?."); + return; + } + + obj = elm_object_part_content_get(parent, part); + if (obj == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to get parent."); + return; + } + + /* Set color of target part object */ + evas_object_color_set(obj, r, g, b, a); +} + +/* + * @brief: Make a naviframe and set to parent + * @param[parent]: Object to which you want to set naviframe + * @Add callback function will be operated when back key is pressed + */ +Evas_Object *view_create_naviframe(Evas_Object *parent) +{ + /* Naviframe + * Create and initialize elm_naviframe. + * Naviframe stands for navigation frame. + * elm_naviframe is a views manager for applications. + */ + Evas_Object *nf = NULL; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "appdata is NULL."); + return NULL; + } + + nf = elm_naviframe_add(parent); + + elm_object_part_content_set(parent, "elm.swallow.content", nf); + eext_object_event_callback_add(nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL); + eext_object_event_callback_add(nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL); + + evas_object_show(nf); + + return nf; +} + +//TO DO UPDATE +/* + * @brief: Push item to naviframe + * @param[nf]: naviframe + * @param[item]: object will be added to naviframe + * @param[_pop_cb]: function will be operated when this item is poped from naviframe + * @param[cb_data]: data needed to operate '_pop_cb' function + * Naviframe make changing of view is easy and effectively + */ +Elm_Object_Item* view_push_item_to_naviframe(Evas_Object *nf, Evas_Object *item, Elm_Naviframe_Item_Pop_Cb _pop_cb, void *cb_data) +{ + Elm_Object_Item* nf_it = NULL; + + if (nf == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "naviframe is NULL."); + return; + } + + if (item == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "item is NULL."); + return; + } + + nf_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, item, "empty"); + + elm_naviframe_item_pop_cb_set(nf_it, _pop_cb, cb_data); + + return nf_it; +} + + +void view_set_more_button(Evas_Object *parent, const char *part) +{ + Evas_Object *more_btn = NULL; + + if (pirent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return; + } + + more_btn = eext_more_option_add(parent); + if (more_btn == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "more option is NULL."); + return; + } + + /* Add smart callback */ + evas_object_smart_callback_add(more_btn, "more,option,opened", _more_option_opened, NULL); + evas_object_smart_callback_add(more_btn, "more,option,closed", _more_option_closed, NULL); + evas_object_smart_callback_add(more_btn, "item,selected", _item_selected, NULL); + + elm_object_part_content_set(parent, part, more_btn); +} + +/* + * @brief: Make and set button. + * @param[parent]: object to which you want to set the button + * @param[style]: style of the button + * @param[text]: text will be written on the button + * @param[image_path]: path of image file will be used as button icon + * @param[part]: part name in EDJ to which you want to set the button + * @param[down_cb]: function will be operated when the button is pressed + * @param[up_cb]: function will be operated when the button is released + * @param[clicked_cb]: function will be operated when the button is clicked + * @param[data]: data needed in this function + */ +void view_set_button(Evas_Object *parent, const char *part, const char *style, const char *image_path, const char *text, + Evas_Object_Event_Cb down_cb, Evas_Object_Event_Cb up_cb, Evas_Smart_Cb clicked_cb, void *data) +{ + Evas_Object *btn = NULL; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return; + } + + btn = elm_button_add(parent); + if(!btn) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to create button."); + return; + } + + if (style) + elm_object_style_set(btn, style); + + evas_object_size_hint_weight_set(btn ,EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_part_content_set(parent, part, btn); + + if (text) + elm_object_text_set(btn, text); + if (image_path) + view_set_image(btn, NULL, image_path); + + if (down_cb) + evas_object_event_callback_add(btn , EVAS_CALLBACK_MOUSE_DOWN, down_cb, parent); + if (up_cb) + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, up_cb, parent); + if (clicked_cb) + evas_object_smart_callback_add(btn, "clicked", clicked_cb, data); + + evas_object_show(btn); +} + +void view_add_more_button_item(Evas_Object *parent, const char *part, const char *main_txt, const char *sub_txt, const char *img_path, void (clicked_cb)(void *data, Evas_Object *obj, void *event_info), void *user_data) +{ + Evas_Object *img = NULL; + Evas_Object *more_btn = NULL; + char full_path[PATH_MAX] = { 0, }; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return; + } + + more_btn = elm_object_part_content_get(parent, part); + if (more_btn == NULL) { + return; + } + + /* Create the new item */ + Eext_Object_Item *item = eext_more_option_item_append(more_btn); + + /* Set the text in item text part */ + eext_more_option_item_part_text_set(item, "selector,main_text", main_txt); + eext_more_option_item_part_text_set(item, "selector,sub_text", sub_txt); + + img = elm_image_add(more_btn); + _get_resource(img_path, full_path, sizeof(full_path)); + elm_image_file_set(img, full_path, NULL); + + /* Set the content in item content part */ + eext_more_option_item_part_content_set(item, "item,icon", img); + + evas_object_smart_callback_add(more_btn, "item,clicked", clicked_cb, user_data); +} + +/* + * @brief: Make a Entry Object to target window + * @param[parent]: Object to which you want to set Entry + * @param[part]: Part of the layout which you want to locate Entry + * @param[data]: The user data to be passed to the callback function + * @Add callback function will be operated when mouse clicked event is triggered + */ +Evas_Object *view_set_entry(Evas_Object *parent, const char *part, void (_clicked_cb)(void *data, Evas_Object *obj, void *event_info), void *data) +{ + Evas_Object *entry = NULL; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return NULL; + } + + /* Add Entry object to parent */ + entry = elm_entry_add(parent); + if (entry == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to add a entry"); + return NULL; + } + + /* Set Entry size option */ + evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + /* Set Entry option for display and functionalities */ + elm_entry_single_line_set(entry, EINA_TRUE); + elm_entry_scrollable_set(entry, EINA_TRUE); + elm_entry_input_panel_enabled_set(entry, EINA_FALSE); + elm_entry_editable_set(entry, EINA_FALSE); + elm_entry_context_menu_disabled_set(entry, EINA_TRUE); + elm_entry_cursor_handler_disabled_set(entry, EINA_TRUE); + elm_entry_select_allow_set(entry, EINA_FALSE); + + /* Set Entry text style using predefined style description */ + elm_entry_text_style_user_push(entry, DIAL_TEXT_STYLE_NORMAL); + + elm_object_part_content_set(parent, part, entry); + + /* Set callback for event about Entry */ + if (_clicked_cb) { + evas_object_smart_callback_add(entry, "clicked", _clicked_cb, data); + } + + return entry; +} + +/* + * @brief: make genlist for circular shape. + * @param[parent]: object to which you want to set genlist + * @param[circle_surface]: object render a connected circle object + */ +Evas_Object *view_create_circle_genlist(Evas_Object *parent, Eext_Circle_Surface *circle_surface) +{ + Evas_Object *genlist = NULL; + Evas_Object *circle_genlist = NULL; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return NULL; + } + + if (circle_surface == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "circle surface is NULL."); + return NULL; + } + + genlist = elm_genlist_add(parent); + /* this make selected list item is shown compressed */ + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + evas_object_smart_callback_add(genlist, "selected", _gl_selected_cb, NULL); + + /* this make genlist style circular */ + circle_genlist = eext_circle_object_genlist_add(genlist, circle_surface); + eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); + eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE); + + evas_object_show(genlist); + + return genlist; +} + +/* + * @brief: Add item to genlist. + * @param[genlist]: genlist + * @param[style]: style of item determine how to show this item, such as "1text", "1text1icon" and so on + * @param[data]: item data that use item's callback function + * @param[_clicked_cb]: function will be operated when the item is clicked + * @param[cb_data]: data needed in '_clicked_cb' function + * This make item's class and add item to genlist. + */ +Elm_Object_Item *view_append_item_to_genlist(Evas_Object *genlist, const char *style, + const void *data, Evas_Smart_Cb _clicked_cb, const void *cb_data) +{ + Elm_Genlist_Item_Class *item_class; + Elm_Object_Item *item; + + if (genlist == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "genlist is NULL."); + return NULL; + } + + if (style == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "item style is NULL."); + return NULL; + } + + item_class = _set_genlist_item_class(style); + + item = elm_genlist_item_append(genlist, item_class, data, NULL, ELM_GENLIST_ITEM_NONE, _clicked_cb, cb_data); + + elm_genlist_item_class_free(item_class); + + return item; +} + +/* + * @brief: Find item from genlist. + * @param[genlist]: genlist + * @param[val]: value determine which of the itmes has to remove + */ +Elm_Object_Item *view_find_item_from_genlist(Evas_Object *genlist, const char *val) +{ + int item_count; + int i; + Elm_Object_Item *item = NULL; + struct genlist_data *gendata = NULL; + + if (!genlist) { + dlog_print(DLOG_ERROR, LOG_TAG, "genlist is NULL."); + return NULL; + } + + item_count = elm_genlist_items_count(genlist); + + /* + * The fist item and the last item are "padding". + */ + for(i = 1; i < item_count-1; i++) { + item = elm_genlist_nth_item_get(genlist, i); + gendata = elm_object_item_data_get(item); + + if (gendata->alarm_id == atoi(val)) { + return item; + } + } + + return NULL; +} + + +/* + * @brief: Remove item. + * @param[item]: item from genlist + */ +void view_delete_item(Elm_Object_Item *item) +{ + elm_object_item_del(item); +} + +/* + * @brief: Make popup with theme. + * @param[popup_style]: style of the popup's layout + * @param[data]: data needed in this function + */ +void view_create_text_popup(Evas_Object *parent, double timeout, const char *text) +{ + Evas_Object *popup = NULL; + Evas_Object *popup_layout = NULL; + + popup = elm_popup_add(parent); + elm_object_style_set(popup, "circle"); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_hide_cb, NULL); + /* + * Delete popup object in _popup_hide_finished_cb(), when the "dismissed" signal will be called. + */ + evas_object_smart_callback_add(popup, "dismissed", _popup_hide_finished_cb, NULL); + + popup_layout = elm_layout_add(popup); + elm_layout_theme_set(popup_layout, "layout", "popup", "content/circle"); + + elm_object_content_set(popup, popup_layout); + + elm_popup_timeout_set(popup, timeout); + + if (text) + view_set_text(popup_layout, "elm.text", text); + + evas_object_show(popup); +} + +void view_set_content_to_part(Evas_Object *layout, const char *part, Evas_Object *content) +{ + elm_object_part_content_set(layout, part, content); +} + +void view_send_signal_to_edje(Evas_Object *layout, const char *signal, const char *source) +{ + elm_object_signal_emit(layout, signal, source); +} + +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) +{ + elm_object_signal_callback_add(item, signal, source, signal_cb, user_data); +} + +void view_set_rotary_event_callback(Evas_Object *parent, Eina_Bool (*rotary_cb)(void *data, Evas_Object *obj, Eext_Rotary_Event_Info *info), void *user_data) +{ + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return; + } + + eext_rotary_object_event_activated_set(parent, EINA_TRUE); + eext_rotary_object_event_callback_add(parent, rotary_cb, user_data); +} + +Evas_Object *view_create_label(Evas_Object *parent) +{ + Evas_Object *label = elm_label_add(parent); + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return NULL; + } + + elm_object_style_set(label, "slide_short"); + elm_label_wrap_width_set(label, 230); + elm_label_ellipsis_set(label, EINA_TRUE); + elm_label_slide_duration_set(label, 2); + elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_NONE); + elm_label_slide_go(label); + evas_object_show(label); + + return label; +} + +void view_set_label_text(Evas_Object *parent, const char *part, const char *text) +{ + Evas_Object *label = NULL; + char *markup_text = NULL; + char buf[256] = { 0, }; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return; + } + + markup_text = elm_entry_utf8_to_markup(text); + snprintf(buf, sizeof(buf), "%s%s%s", LABEL_STYLE_START, markup_text, LABEL_STYLE_END); + free(markup_text); + + label = elm_object_part_content_get(parent, part); + if (label == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "label is NULL."); + return; + } + + elm_object_text_set(label, buf); +} + +void view_set_label(Evas_Object *parent, const char *part) +{ + Evas_Object *label = NULL; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return; + } + + label = view_create_label(parent); + if (label == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "label is NULL."); + return; + } + + elm_object_part_content_set(parent, "sw.focus.txt", label); +} + +void view_set_prgressbar(Evas_Object *parent, const char *part) +{ + Evas_Object *progressbar = NULL; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return; + } + + progressbar = eext_circle_object_progressbar_add(parent, NULL); + + eext_circle_object_value_min_max_set(progressbar, 0.0, 100.0); + eext_circle_object_radius_set(progressbar, 53); + eext_circle_object_line_width_set(progressbar, 5); + evas_object_show(progressbar); + + elm_object_part_content_set(parent, part, progressbar); +} + +void view_set_progressbar_val(Evas_Object *parent, const char *part, int val) +{ + Evas_Object *progressbar = NULL; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return; + } + + if (part == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "part is NULL."); + return; + } + + progressbar = elm_object_part_content_get(parent, part); + if (progressbar == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "prgressbar is NULL."); + return; + } + + eext_circle_object_value_set(progressbar, val); +} + +Evas_Object *view_create_checkbox(Evas_Object *parent) +{ + Evas_Object *check; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return NULL; + } + + check = elm_check_add(parent); + elm_check_state_set(check, EINA_FALSE); + evas_object_smart_callback_add(check, "changed", _icon_clicked_cb, NULL); + evas_object_show(check); + + return check; +} + +/* + * @brief: Make no voice memo view + * @param[parent]: naviframe + * @param[title]: titile of this view + * @param[detail]: detail text of this view + * @param[image_file]: image file name will be used in this view + * This function make a view consists of one title, one center image and one detail text at the bottom + */ +Evas_Object *view_create_layout_no_content(Evas_Object *parent, char *title, char *detail, char *image_file) +{ + Evas_Object *layout = NULL; + Evas_Object *img; + Elm_Object_Item *it; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return NULL; + } + + layout = elm_layout_add(parent); + /* this make you can use layout consists of one title, one image and one detail text */ + elm_layout_theme_set(layout, "layout", "nocontents", "default"); + evas_object_size_hint_weight_set (layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + if(image_file) { + img = elm_image_add(parent); + elm_image_file_set(img, image_file, NULL); + elm_object_part_content_set(layout, "elm.swallow.icon", img); + evas_object_show(img); + } + + if (detail) { + char detail_text[256] = {0, }; + + /* Customize font style bellow */ + snprintf(detail_text, sizeof(detail_text), "%s", detail); + elm_object_part_text_set(layout, "elm.text", detail_text); + } + if (title) { + char title_text[256] = {0, }; + + snprintf(title_text, sizeof(title_text), "%s", title); + elm_object_part_text_set(layout, "elm.text.title", title_text); + } + + /* if this signal is not sent, title text will be disappear */ + elm_object_signal_emit(layout, "elm,state,title,enable", "elm"); + /* push this no voice memo view to naviframe to show */ + it = elm_naviframe_item_push(parent, "Title Enabled", NULL, NULL, layout, NULL); + /* if this is EINA_TRUE, you can see Title of naviframe on the top of the screen */ + elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE); + + return layout; +} + +/* + * @brief: Set datetime to the part. + * @param[parent]: object to which you want to set datetime + * @param[circle_surface]: object render a connected circle object + * @param[part]: part name to which you want to set this datetime + * @param[style]: style of the datetime + */ +Evas_Object *view_create_datetime(Evas_Object *parent, Eext_Circle_Surface *circle_surface, const char *style) +{ + Evas_Object *datetime = NULL; + Evas_Object *circle_datetime = NULL; + + if (parent == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "parent is NULL."); + return NULL; + } + + if (circle_surface == NULL) { + dlog_print(DLOG_ERROR, LOG_TAG, "failed to get circle_surface."); + return NULL; + } + + datetime = elm_datetime_add(parent); + circle_datetime = eext_circle_object_datetime_add(datetime, circle_surface); + + eext_rotary_object_event_activated_set(datetime, EINA_TRUE); + elm_datetime_format_set(datetime, FORMAT); + + elm_object_style_set(datetime, style); + + return datetime; +} + diff --git a/view.h b/view.h new file mode 100644 index 0000000..e69de29