/* * Copyright 2012 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.tizenopensource.org/license * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "ivug-popup.h" #include // ug_destroy_me, ug_send_result #include #define NOTIFY_TIMEOUT 3.0 static void _ivug_popup_timeout_cb(void *data, Evas_Object *obj, void *event_info) { ivug_ret_if(obj == NULL); evas_object_del(obj); obj = NULL; } static void _on_warningpopup_response(void *data, Evas_Object *obj, void *event_info ) { IV_ASSERT(data != NULL); Evas_Object *popup = (Evas_Object *)data; Popup_Response response = (Popup_Response)evas_object_data_get(obj, "response"); MSG_IMAGEVIEW_HIGH("response callback=%d", response); evas_object_del(popup); // Remove popup } Evas_Object* ivug_popup_warning(Evas_Object* parent, const char* title, const char* contents) { Evas_Object *popup; Evas_Object *btn_ok; //create popup popup = elm_popup_add(parent); evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_object_text_set(popup, contents); elm_object_part_text_set(popup, "title,text", title); btn_ok = elm_button_add(popup); elm_object_text_set(btn_ok, IDS_OK); elm_object_part_content_set(popup, "button1", btn_ok); evas_object_data_set(btn_ok, "response", (void *)POPUP_RESPONSE_OK); evas_object_smart_callback_add(btn_ok, "clicked", _on_warningpopup_response, popup); evas_object_show(popup); return popup; } static void _on_questionpopup_response(void *data, Evas_Object *obj, void *event_info ) { IV_ASSERT(data != NULL); Evas_Object *popup = (Evas_Object *)data; Popup_Response response = (Popup_Response)evas_object_data_get(obj, "response"); MSG_IMAGEVIEW_HIGH("response callback=%d", response); if ( response == POPUP_RESPONSE_OK ) { void *user_data = NULL; Evas_Smart_Cb responseCB = NULL; responseCB = evas_object_data_get(popup, "question-response"); user_data = evas_object_data_get(popup, "question-data"); responseCB(user_data, popup, (void *)POPUP_RESPONSE_OK); } evas_object_del(popup); // Remove popup } Evas_Object* ivug_popup_question(Evas_Object* parent, const char* title, const char* contents, Evas_Smart_Cb response_cb, void* user_data) { Evas_Object *popup; Evas_Object *btn_yes; Evas_Object *btn_no; //create popup IV_ASSERT(response_cb != NULL); popup = elm_popup_add(parent); evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_object_text_set(popup, contents); elm_object_part_text_set(popup, "title,text", title); btn_yes = elm_button_add(popup); elm_object_text_set(btn_yes, IDS_YES); elm_object_part_content_set(popup, "button1", btn_yes); evas_object_data_set(btn_yes, "response", (void *)POPUP_RESPONSE_OK); evas_object_smart_callback_add(btn_yes, "clicked", _on_questionpopup_response, popup); btn_no = elm_button_add(popup); elm_object_text_set(btn_no, IDS_NO); elm_object_part_content_set(popup, "button2", btn_no); evas_object_data_set(btn_no, "response", (void *)POPUP_RESPONSE_CANCEL); evas_object_smart_callback_add(btn_no, "clicked", _on_questionpopup_response, popup); evas_object_data_set(popup, "question-response", response_cb); evas_object_data_set(popup, "question-data", user_data); evas_object_show(popup); return popup; } Evas_Object* ivug_popup_selectioninfo(Evas_Object* parent, const char* contents) { Evas_Object *notify; notify = elm_notify_add(parent); ivug_retv_if(notify == NULL, NULL); elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM); evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(notify, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_smart_callback_add(notify, "timeout", _ivug_popup_timeout_cb, NULL); elm_notify_timeout_set(notify, NOTIFY_TIMEOUT); Evas_Object* layout = elm_layout_add(parent); elm_object_theme_set(layout, gGetSystemTheme()); elm_layout_theme_set(layout, "standard", "selectioninfo", "vertical/bottom_86"); 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); elm_object_content_set(notify, layout); edje_object_part_text_set(_EDJ(layout), "elm.text", contents); evas_object_show(notify); return notify; } static void _on_popup_response_exit( void *data, Evas_Object *obj, void *event_info ) { MSG_IMAGEVIEW_HIGH("response callback=%d",(int)event_info); evas_object_del(obj); ug_destroy_me(gGetUGHandle()); } static void _on_popup_response( void *data, Evas_Object *obj, void *event_info ) { MSG_IMAGEVIEW_HIGH("response callback=%d",(int)event_info); evas_object_del(obj); // Remove popup } Evas_Object *ivug_show_exit_popup(Evas_Object *parent, const char *sztitle, const char *szmsg) { Evas_Object *popup; popup = elm_popup_add(parent); evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); if ( szmsg ) elm_object_text_set(popup, szmsg); if ( sztitle ) elm_object_part_text_set(popup, "title,text", sztitle); elm_popup_timeout_set(popup, 3.0); evas_object_smart_callback_add(popup, "timeout", _on_popup_response_exit, NULL); evas_object_show(popup); return popup; } Evas_Object *ivug_show_popup(Evas_Object *parent, const char *sztitle, const char *szmsg, Evas_Smart_Cb response_cb, void *user_data) { Evas_Object *popup; popup = elm_popup_add(parent); evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); if ( szmsg ) { elm_object_text_set(popup, szmsg); } if ( sztitle ) elm_object_part_text_set(popup, "title,text", sztitle); elm_popup_timeout_set(popup, 3.0); if(response_cb) evas_object_smart_callback_add(popup, "timeout", response_cb, user_data); else evas_object_smart_callback_add(popup, "timeout", _on_popup_response, user_data); evas_object_show(popup); evas_object_focus_set(popup, EINA_TRUE); return popup; } Evas_Object *ivug_show_popup_va(Evas_Object *parent, const char *sztitle, const char *fmt, ...) { char buf[1024]; Evas_Object *popup; popup = elm_popup_add(parent); evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); va_list ap; va_start(ap, fmt); vsnprintf(buf, (size_t)sizeof(buf), fmt, ap); va_end(ap); elm_object_text_set(popup, buf); if ( sztitle ) elm_object_part_text_set(popup, "title,text", sztitle); elm_popup_timeout_set(popup, 3.0); evas_object_smart_callback_add(popup, "timeout", _on_popup_response, NULL); // evas_object_focus_set(popup, EINA_TRUE); evas_object_show(popup); return popup; }