#include #include static void cb_window_destroy(Ewl_Widget *w, void *ev, void *data); static void cb_window_close(Ewl_Widget *w, void *ev, void *data); static void cb_key_down(Ewl_Widget *w, void *ev, void *data); static void cb_clicked(Ewl_Widget *w, void *ev, void *data); int main(int argc, char ** argv) { Ewl_Widget *win, *scroll, *o, *s, *box, *so, *button, *vbox; if (!ewl_init(&argc, argv)) { fprintf(stderr, "Unable to init Elive Image Viewer.\n"); return 1; } if (argc < 2) { fprintf(stderr, "Need image to view .\n"); return 1; } /*main window*/ win = ewl_window_new(); ewl_window_title_set(EWL_WINDOW(win), "Elive Image Viewer"); ewl_window_class_set(EWL_WINDOW(win), "elive_image_viewer"); ewl_window_name_set(EWL_WINDOW(win), "elive_image_viewer"); ewl_object_fill_policy_set(EWL_OBJECT(win), EWL_FLAG_FILL_ALL); ewl_object_size_request(EWL_OBJECT(win), 640, 480); ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, cb_window_close, NULL); ewl_callback_append(win, EWL_CALLBACK_KEY_DOWN, cb_key_down, NULL); ewl_callback_append(win, EWL_CALLBACK_DESTROY, cb_window_destroy, NULL); ewl_widget_name_set(win, "main_win"); ewl_widget_show(win); /*vertical box*/ vbox = ewl_vbox_new(); ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_ALL); ewl_container_child_append(EWL_CONTAINER(win), vbox); ewl_widget_name_set(vbox, "Vertical Box"); ewl_widget_show(vbox); /*\vertical box*/ /*notebox where the image will be in*/ box = ewl_notebook_new(); ewl_notebook_tabbar_visible_set(EWL_NOTEBOOK(box), FALSE); ewl_object_fill_policy_set(EWL_OBJECT(box), EWL_FLAG_FILL_ALL); ewl_container_child_append(EWL_CONTAINER(vbox), box); ewl_widget_name_set(box, "Image Box"); ewl_widget_show(box); /*\notebox where the image will be in*/ /*button*/ button = ewl_button_new(); ewl_button_label_set(EWL_BUTTON(button), "Scale"); ewl_callback_append(button, EWL_CALLBACK_CLICKED, cb_clicked, NULL); ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); ewl_container_child_append(EWL_CONTAINER(vbox), button); ewl_widget_show(button); /*\button*/ o = ewl_image_new(); ewl_image_file_path_set(EWL_IMAGE(o), argv[1]); ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_ALL); ewl_container_child_append(EWL_CONTAINER(box), o); ewl_widget_show(o); ewl_main(); return 0; } /*button call back*/ static void cb_clicked(Ewl_Widget *w, void *ev, void *data) { Ewl_Widget *o, *so; o = ewl_widget_name_find("Scale"); if (!o) { printf("u just clicked on Scale\n"); ewl_button_label_set(EWL_BUTTON(button), "Fit"); /*scroll bar*/ so = ewl_scrollpane_new(); ewl_container_child_append(EWL_CONTAINER(box), so); ewl_widget_show(so); /*\scroll bar*/ } } /*end of button call back*/ static void cb_window_destroy(Ewl_Widget *w, void *ev, void *data) { ewl_main_quit(); } static void cb_window_close(Ewl_Widget *w, void *ev, void *data) { ewl_widget_destroy(w); } static void cb_key_down(Ewl_Widget *w, void *ev, void *data) { Ewl_Event_Key_Down *e; e = ev; if (!strcmp(e->base.keyname, "Escape")|| !strcmp(e->base.keyname, "q")) { Ewl_Widget *win; win = ewl_widget_name_find("main_win"); ewl_widget_destroy(win); } }