diff -r c1a75454b444 -r 39b9b86ec452 ui/motif/button.c --- a/ui/motif/button.c Sat Mar 22 10:37:12 2014 +0100 +++ b/ui/motif/button.c Sat Mar 22 15:34:20 2014 +0100 @@ -30,6 +30,40 @@ #include #include "button.h" +#include "container.h" +#include "../common/context.h" +#include "../../ucx/mempool.h" + + +UIWIDGET ui_button(UiObject *obj, char *label, ui_callback f, void *data) { + XmString str = XmStringCreateLocalized(label); + + int n = 0; + Arg args[16]; + XtSetArg(args[n], XmNlabelString, str); + n++; + + Widget parent = obj->container->add(obj->container, args, &n); + Widget button = XmCreatePushButton(parent, "button", args, n); + + if(f) { + UiEventData *event = ucx_mempool_malloc( + obj->ctx->mempool, + sizeof(UiEventData)); + event->obj = obj; + event->user_data = data; + event->callback = f; + XtAddCallback( + button, + XmNactivateCallback, + (XtCallbackProc)ui_push_button_callback, + event); + } + + XtManageChild(button); + + return button; +} // wrapper int ui_toggle_button_get(UiInteger *i) {