Tizen Native API
4.0
|
Our example is remarkably simple, all it does is create an Ecore_Evas and register a callback for a bunch of events. What's interesting here is knowing when each of these callbacks will be called, however since that depends on the underlying windowing system there are no guarantees that all of the callbacks will be called for your windowing system. To know which callbacks will be called for your windowing system run the example and redirect the output to a file, and take a look at it.
- Note:
- Make sure you minimize, resize, give and remove focus to see more callbacks called.
The example is constituted of two main parts, first is the implementation of callbacks that will be called for each event(all our callbacks do is print their own name) and the second is the main function where we register the event callbacks and run the main loop:
#include <Ecore.h> #include <Ecore_Evas.h> static void _destroy(Ecore_Evas *ee EINA_UNUSED) { printf("destroy\n"); ecore_main_loop_quit(); } static void _delete(Ecore_Evas *ee EINA_UNUSED) { printf("delete\n"); ecore_main_loop_quit(); } static void _focus_in(Ecore_Evas *ee EINA_UNUSED) { printf("focus_in\n"); } static void _focus_out(Ecore_Evas *ee EINA_UNUSED) { printf("focus_out\n"); } static void _hide(Ecore_Evas *ee EINA_UNUSED) { printf("hide\n"); } static void _mouse_in(Ecore_Evas *ee EINA_UNUSED) { printf("mouse_in\n"); } static void _show(Ecore_Evas *ee EINA_UNUSED) { printf("show\n"); } static void _mouse_out(Ecore_Evas *ee EINA_UNUSED) { printf("mouse_out\n"); } static void _move(Ecore_Evas *ee EINA_UNUSED) { printf("move\n"); } static void _post_render(Ecore_Evas *ee EINA_UNUSED) { printf("post_render\n"); } static void _pre_free(Ecore_Evas *ee EINA_UNUSED) { printf("pre_free\n"); } static void _pre_render(Ecore_Evas *ee EINA_UNUSED) { printf("pre_render\n"); } static void _resize(Ecore_Evas *ee EINA_UNUSED) { printf("resize\n"); } int main(void) { Ecore_Evas *ee; Evas_Object *bg; ecore_evas_init(); ee = ecore_evas_new(NULL, 0, 0, 200, 100, NULL); ecore_evas_title_set(ee, "Ecore Evas Callbacks Example"); ecore_evas_show(ee); bg = evas_object_rectangle_add(ecore_evas_get(ee)); evas_object_color_set(bg, 255, 128, 0, 255); evas_object_resize(bg, 9999, 9999); evas_object_show(bg); //callbacks ecore_evas_callback_delete_request_set(ee, _delete); ecore_evas_callback_destroy_set(ee, _destroy); ecore_evas_callback_focus_in_set(ee, _focus_in); ecore_evas_callback_focus_out_set(ee, _focus_out); ecore_evas_callback_hide_set(ee, _hide); ecore_evas_callback_mouse_in_set(ee, _mouse_in); ecore_evas_callback_mouse_out_set(ee, _mouse_out); ecore_evas_callback_move_set(ee, _move); ecore_evas_callback_post_render_set(ee, _post_render); ecore_evas_callback_pre_free_set(ee, _pre_free); ecore_evas_callback_pre_render_set(ee, _pre_render); ecore_evas_callback_resize_set(ee, _resize); ecore_evas_callback_show_set(ee, _show); ecore_main_loop_begin(); ecore_evas_free(ee); ecore_evas_shutdown(); return 0; }