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 #include <stdio.h>
30 #include <stdlib.h>
31
32 #include "button.h"
33 #include "../common/object.h"
34
35 UIWIDGET ui_button(UiObject *obj,
char *label, ui_callback f,
void *data) {
36 UiEventData *event =
NULL;
37 ui_callback callback =
NULL;
38 if(f) {
39 event = malloc(
sizeof(UiEventData));
40 event->obj = obj;
41 event->callback = f;
42 event->user_data = data;
43 event->value =
0;
44 callback = (ui_callback)ui_button_callback;
45 }
46
47 UiContainer *container = uic_get_current_container(obj);
48 return UIbutton(container, label, callback, event);
49 }
50
51 void ui_button_callback(UiObject *obj, UiEventData *e) {
52 UiEvent event;
53 event.obj = e->obj;
54 event.document = event.obj->ctx->document;
55 event.window = event.obj->window;
56 event.intval =
0;
57 e->callback(&event, e->user_data);
58 }
59