28 |
28 |
29 #include <stdio.h> |
29 #include <stdio.h> |
30 #include <stdlib.h> |
30 #include <stdlib.h> |
31 |
31 |
32 #include "button.h" |
32 #include "button.h" |
|
33 #include "container.h" |
|
34 #include "../common/context.h" |
|
35 #include "../../ucx/mempool.h" |
|
36 |
|
37 |
|
38 UIWIDGET ui_button(UiObject *obj, char *label, ui_callback f, void *data) { |
|
39 XmString str = XmStringCreateLocalized(label); |
|
40 |
|
41 int n = 0; |
|
42 Arg args[16]; |
|
43 XtSetArg(args[n], XmNlabelString, str); |
|
44 n++; |
|
45 |
|
46 Widget parent = obj->container->add(obj->container, args, &n); |
|
47 Widget button = XmCreatePushButton(parent, "button", args, n); |
|
48 |
|
49 if(f) { |
|
50 UiEventData *event = ucx_mempool_malloc( |
|
51 obj->ctx->mempool, |
|
52 sizeof(UiEventData)); |
|
53 event->obj = obj; |
|
54 event->user_data = data; |
|
55 event->callback = f; |
|
56 XtAddCallback( |
|
57 button, |
|
58 XmNactivateCallback, |
|
59 (XtCallbackProc)ui_push_button_callback, |
|
60 event); |
|
61 } |
|
62 |
|
63 XtManageChild(button); |
|
64 |
|
65 return button; |
|
66 } |
33 |
67 |
34 // wrapper |
68 // wrapper |
35 int ui_toggle_button_get(UiInteger *i) { |
69 int ui_toggle_button_get(UiInteger *i) { |
36 int state = 0; |
70 int state = 0; |
37 XtVaGetValues(i->obj, XmNset, &state, NULL); |
71 XtVaGetValues(i->obj, XmNset, &state, NULL); |