#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "menu.h"
void ui_menu(
char *label) {
UImenu(label);
}
void ui_submenu(
char *label) {
UIsubmenu(label);
}
void ui_submenu_end() {
UIsubmenu_end();
}
void ui_menuitem(
char *label, ui_callback f,
void *userdata) {
UIcallback cb =
NULL;
void *e =
NULL;
if (f) {
UiEventData *event = malloc(
sizeof(UiEventData));
event->obj =
NULL;
event->user_data = userdata;
event->callback = f;
event->value =
0;
cb = (UIcallback)ui_obj_callback;
e = event;
}
UImenuitem(label, cb, e);
}
void ui_obj_callback(UiObject *obj, UiEventData *e) {
UiEvent event;
event.obj = obj;
event.window = obj->window;
event.intval =
0;
event.eventdata =
NULL;
event.document = obj->ctx->document;
e->callback(&event, e->user_data);
}