include stdio include ewl Ewl include Evas static void cb_window_destr

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
#include <stdio.h>
#include <ewl/Ewl.h>
#include <Evas.h>
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_image_reveal(Ewl_Widget *w, void *ev, void *data)
{
}
static void
cb_key_down(Ewl_Widget *w, void *ev, void *data)
{
Ewl_Event_Key_Down *e;
Evas_Object *img;
Ewl_Embed *emb;
Evas_Coord img_w, img_h;
int *_data;
int i;
e = (Ewl_Event_Key_Down*)ev;
if(!strcmp(e->base.keyname, "q")
|| !strcmp(e->base.keyname, "Escape")) {
Ewl_Widget *win;
win = ewl_widget_name_find("main_win");
ewl_widget_destroy(win);
} else {
Ewl_Widget *win, *o;
Evas_Object *img;
Ewl_Embed *emb;
Evas_Coord img_w, img_h;
int *data;
int i;
win = ewl_widget_name_find("main_win");
o = ewl_widget_name_find("image");
img = (Evas_Object*)EWL_IMAGE(o)->image;
if(!img)
return;
evas_object_image_size_set(img, CURRENT_W(win), CURRENT_H(win));
evas_object_image_size_get(img, &img_w, &img_h);
data = (int*)evas_object_image_data_get(img, 1);
if(!data)
return;
evas_object_image_data_update_add(img, 0, 0, img_w, img_h);
}
}
int main(int argc, char **argv)
{
Ewl_Widget *win, *o;
if(!ewl_init(&argc, argv)) {
fprintf(stderr, "Unable to init EWL.\n");
exit(-1);
}
win = ewl_window_new();
ewl_window_title_set(EWL_WINDOW(win), "FBReader");
ewl_window_class_set(EWL_WINDOW(win), "fbreader");
ewl_window_name_set(EWL_WINDOW(win), "fbreader");
ewl_object_fill_policy_set(EWL_OBJECT(win), EWL_FLAG_FILL_ALL);
ewl_object_size_request(EWL_OBJECT(win), 600, 800);
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_theme_data_str_set(EWL_WIDGET(win), "/window/group", "ewl/blank");
ewl_widget_show(win);
o = ewl_image_new();
EWL_IMAGE(o)->image = NULL;
ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_FILL);
ewl_container_child_append(EWL_CONTAINER(win), o);
ewl_callback_append(o, EWL_CALLBACK_REVEAL, cb_image_reveal, NULL);
ewl_object_position_request(EWL_OBJECT(o), CURRENT_X(win), CURRENT_Y(win));
ewl_object_size_request(EWL_OBJECT(o), CURRENT_W(win), CURRENT_H(win));
ewl_widget_name_set(o, "image");
ewl_widget_show(o);
ewl_main();
return 0;
}