ui/motif/button.c

branch
newapi
changeset 176
bc63cb601f6d
parent 157
0b33b9396851
--- a/ui/motif/button.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/button.c	Mon May 22 21:21:20 2023 +0200
@@ -32,7 +32,11 @@
 #include "button.h"
 #include "container.h"
 #include "../common/context.h"
-#include <ucx/mempool.h>
+#include <cx/mempool.h>
+
+#include <cx/linked_list.h>
+#include <cx/array_list.h>
+#include <cx/compare.h>
 
 
 UIWIDGET ui_button(UiObject *obj, char *label, ui_callback f, void *data) {
@@ -50,8 +54,8 @@
     ct->add(ct, button);
     
     if(f) {
-        UiEventData *event = ucx_mempool_malloc(
-                obj->ctx->mempool,
+        UiEventData *event = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiEventData));
         event->obj = obj;
         event->userdata = data;
@@ -143,11 +147,15 @@
         RadioButtonGroup *group;
         if(rgroup->obj) {
             group = rgroup->obj;
-            group->buttons = ucx_list_append(group->buttons, button);
+            if(!group->buttons) {
+                group->buttons = cxArrayListCreate(cxDefaultAllocator, cx_cmp_uintptr, CX_STORE_POINTERS, 8);
+            }
+            cxListAdd(group->buttons, button);
             group->ref++;
         } else {
             group = malloc(sizeof(RadioButtonGroup));
-            group->buttons = ucx_list_append(NULL, button);
+            group->buttons = cxArrayListCreate(cxDefaultAllocator, cx_cmp_uintptr, CX_STORE_POINTERS, 8);
+            cxListAdd(group->buttons, button);
             group->current = button;
             // this is the first button in the radiobutton group
             // so we should enable it
@@ -181,7 +189,7 @@
 int64_t ui_radiobutton_get(UiInteger *value) {
     RadioButtonGroup *group = value->obj;
     
-    int i = ucx_list_find(group->buttons, group->current, NULL, NULL);
+    int i = cxListFind(group->buttons, group->current);
     if (i >= 0) {
         value->value = i;
         return i;
@@ -197,9 +205,8 @@
     XtSetArg(arg, XmNset, FALSE);
     XtSetValues(group->current, &arg, 1);
     
-    UcxList *elm = ucx_list_get(group->buttons, i);
-    if(elm) {
-        Widget button = elm->data;
+    Widget button = cxListAt(group->buttons, i);
+    if(button) {
         XtSetArg(arg, XmNset, TRUE);
         XtSetValues(button, &arg, 1);
         group->current = button;

mercurial