#include <stdio.h>
#include <stdlib.h>
#include "button.h"
#include "../common/object.h"
UIWIDGET ui_button(UiObject *obj,
char *label, ui_callback f,
void *data) {
UiEventData *event =
NULL;
ui_callback callback =
NULL;
if(f) {
event = malloc(
sizeof(UiEventData));
event->obj = obj;
event->callback = f;
event->user_data = data;
event->value =
0;
callback = (ui_callback)ui_button_callback;
}
UiContainer *container = uic_get_current_container(obj);
return UIbutton(container, label, callback, event);
}
void ui_button_callback(UiObject *obj, UiEventData *e) {
UiEvent event;
event.obj = e->obj;
event.document = event.obj->ctx->document;
event.window = event.obj->window;
event.intval =
0;
e->callback(&event, e->user_data);
}