port motif code to ucx 3 newapi

Mon, 22 May 2023 21:21:20 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 22 May 2023 21:21:20 +0200
branch
newapi
changeset 176
bc63cb601f6d
parent 175
2cb06c231057
child 178
7c3ff86ee9d4

port motif code to ucx 3

configure file | annotate | diff | comparison | revisions
make/project.xml file | annotate | diff | comparison | revisions
ui/common/menu.c file | annotate | diff | comparison | revisions
ui/gtk/toolbar.h file | annotate | diff | comparison | revisions
ui/motif/button.c file | annotate | diff | comparison | revisions
ui/motif/button.h file | annotate | diff | comparison | revisions
ui/motif/container.c file | annotate | diff | comparison | revisions
ui/motif/container.h file | annotate | diff | comparison | revisions
ui/motif/dnd.c file | annotate | diff | comparison | revisions
ui/motif/label.c file | annotate | diff | comparison | revisions
ui/motif/list.c file | annotate | diff | comparison | revisions
ui/motif/menu.c file | annotate | diff | comparison | revisions
ui/motif/menu.h file | annotate | diff | comparison | revisions
ui/motif/range.c file | annotate | diff | comparison | revisions
ui/motif/stock.c file | annotate | diff | comparison | revisions
ui/motif/text.c file | annotate | diff | comparison | revisions
ui/motif/text.h file | annotate | diff | comparison | revisions
ui/motif/toolbar.c file | annotate | diff | comparison | revisions
ui/motif/toolbar.h file | annotate | diff | comparison | revisions
ui/motif/toolkit.c file | annotate | diff | comparison | revisions
ui/motif/tree.c file | annotate | diff | comparison | revisions
ui/motif/window.c file | annotate | diff | comparison | revisions
--- a/configure	Mon May 22 19:44:27 2023 +0200
+++ b/configure	Mon May 22 21:21:20 2023 +0200
@@ -403,6 +403,18 @@
 dependency_motif()
 {
     printf "checking for motif... "
+    # dependency motif platform="bsd"
+    while true
+    do
+    	if isnotplatform "bsd"; then
+            break
+        fi
+        CFLAGS="$CFLAGS -DUI_MOTIF -I/usr/local/include/X11"    
+        LDFLAGS="$LDFLAGS -lXm -lXt -lX11 -lpthread"    
+		echo yes
+        return 0
+    done
+	
     # dependency motif 
     while true
     do
@@ -499,6 +511,22 @@
     
     break
 done
+while true
+do
+    if isnotplatform "bsd"; then
+        break
+    fi
+    while true
+    do
+        
+        CFLAGS="$CFLAGS -I/usr/local/include"    
+        LDFLAGS="$LDFLAGS -L/usr/local/lib"    
+        
+        break
+    done
+    
+    break
+done
 
 # add general dependency flags to config.mk
 echo >> $TEMP_DIR/config.mk
--- a/make/project.xml	Mon May 22 19:44:27 2023 +0200
+++ b/make/project.xml	Mon May 22 21:21:20 2023 +0200
@@ -40,6 +40,12 @@
 		<cflags>-DUI_COCOA</cflags>
 		<ldflags>-lobjc -framework Cocoa</ldflags>
 	</dependency>
+	
+	<dependency name="motif" platform="bsd">
+		<cflags>-DUI_MOTIF -I/usr/local/include/X11</cflags>
+		<ldflags>-lXm -lXt -lX11 -lpthread</ldflags>
+	</dependency>
+	
 	<dependency name="motif">
 		<cflags>-DUI_MOTIF</cflags>
 		<ldflags>-lXm -lXt -lX11 -lpthread</ldflags>
@@ -56,6 +62,11 @@
 		<make>PACKAGE_SCRIPT = package_unix.sh</make>
 	</dependency>
 	
+	<dependency platform="bsd">
+		<cflags>-I/usr/local/include</cflags>
+		<ldflags>-L/usr/local/lib</ldflags>
+	</dependency>
+	
 	<target name="tk">
 		<option arg="toolkit">
 			<value str="gtk4">
--- a/ui/common/menu.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/common/menu.c	Mon May 22 21:21:20 2023 +0200
@@ -28,6 +28,8 @@
 
 #include "menu.h"
 
+#include <stdarg.h>
+
 #include <cx/linked_list.h>
 #include <cx/array_list.h>
 
--- a/ui/gtk/toolbar.h	Mon May 22 19:44:27 2023 +0200
+++ b/ui/gtk/toolbar.h	Mon May 22 21:21:20 2023 +0200
@@ -97,7 +97,7 @@
 struct UiToolbarComboBoxNV {
     UiToolItemI         item;
     char                *listname;
-    ui_getvaluefunc getvalue;
+    ui_getvaluefunc     getvalue;
     ui_callback         callback;
     void                *userdata;
 };
--- 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;
--- a/ui/motif/button.h	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/button.h	Mon May 22 21:21:20 2023 +0200
@@ -37,7 +37,7 @@
 #endif
 
 typedef struct {
-    UcxList *buttons;
+    CxList  *buttons;
     Widget  current;
     int     ref;
 } RadioButtonGroup;
--- a/ui/motif/container.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/container.c	Mon May 22 21:21:20 2023 +0200
@@ -34,6 +34,10 @@
 #include "../common/context.h"
 #include "../common/object.h"
 
+#include <cx/array_list.h>
+#include <cx/linked_list.h>
+#include <cx/compare.h>
+
 #define UI_GRID_MAX_COLUMNS 512
 
 static UiBool ui_lb2bool(UiLayoutBool b) {
@@ -46,8 +50,8 @@
 
 
 UiContainer* ui_frame_container(UiObject *obj, Widget frame) {
-    UiContainer *ct = ucx_mempool_calloc(
-            obj->ctx->mempool,
+    UiContainer *ct = cxCalloc(
+            obj->ctx->allocator,
             1,
             sizeof(UiContainer));
     ct->widget = frame;
@@ -67,8 +71,8 @@
 
 
 UiContainer* ui_box_container(UiObject *obj, Widget box, int margin, int spacing, UiBoxOrientation orientation) {
-    UiBoxContainer *ct = ucx_mempool_calloc(
-            obj->ctx->mempool,
+    UiBoxContainer *ct = cxCalloc(
+            obj->ctx->allocator,
             1,
             sizeof(UiBoxContainer));
     ct->container.widget = box;
@@ -193,8 +197,8 @@
 }
 
 UiContainer* ui_grid_container(UiObject *obj, Widget form, int columnspacing, int rowspacing) {
-    UiGridContainer *ct = ucx_mempool_calloc(
-            obj->ctx->mempool,
+    UiGridContainer *ct = cxCalloc(
+            obj->ctx->allocator,
             1,
             sizeof(UiGridContainer));
     ct->container.widget = form;
@@ -202,6 +206,7 @@
     ct->container.add = ui_grid_container_add;
     ct->columnspacing = columnspacing;
     ct->rowspacing = rowspacing;
+    ct->lines = cxLinkedListCreateSimple(CX_STORE_POINTERS);
     return (UiContainer*)ct;
 }
 
@@ -224,10 +229,11 @@
     UiGridContainer *grid = (UiGridContainer*)ct;
     
     if(grid->current) {
-        grid->current = ucx_list_append(grid->current, widget);
+        cxListAdd(grid->current, widget);
     } else {
-        grid->current = ucx_list_append(grid->current, widget);
-        grid->lines = ucx_list_append(grid->lines, grid->current);
+        grid->current = cxLinkedListCreateSimple(CX_STORE_POINTERS);
+        cxListAdd(grid->current, widget);
+        cxListAdd(grid->lines, grid->current);
     }
     
     ui_reset_layout(ct->layout);
@@ -237,7 +243,7 @@
 static void ui_grid_resize(Widget widget, XtPointer udata, XtPointer cdata) {
     UiGridContainer *grid = udata;
     
-    UcxList *rowdim = NULL;
+    CxList *rowdim = cxArrayListCreateSimple(sizeof(int), grid->lines->size);
     int coldim[UI_GRID_MAX_COLUMNS];
     memset(coldim, 0, UI_GRID_MAX_COLUMNS*sizeof(int));
     int numcol = 0;
@@ -245,12 +251,13 @@
     // get the minimum size of the columns and rows
     int sumw = 0;
     int sumh = 0;
-    UCX_FOREACH(row, grid->lines) {
+    CxIterator lineIterator = cxListIterator(grid->lines);
+    cx_foreach(CxList *, row, lineIterator) {
         int rheight = 0;
         int i=0;
         int sum_width = 0;
-        UCX_FOREACH(elm, row->data) {
-            Widget w = elm->data;
+        CxIterator colIterator = cxListIterator(row);
+        cx_foreach(Widget, w, colIterator) {
             int widget_width = 0;
             int widget_height = 0;
             XtVaGetValues(
@@ -280,7 +287,7 @@
                 numcol = i;
             }
         }
-        rowdim = ucx_list_append(rowdim, (void*)(intptr_t)rheight);
+        cxListAdd(rowdim, &rheight);
         sumh += rheight;
     }
     
@@ -290,39 +297,40 @@
     XtVaGetValues(widget, XmNwidth, &gwidth, XmNheight, &gheight, NULL);
     if(gwidth < sumw || gheight < sumh) {
         XtVaSetValues(widget, XmNwidth, sumw, XmNheight, sumh, NULL);
-        ucx_list_free(rowdim);
+        cxListDestroy(rowdim);
         return;
     }
     
     
     // adjust the positions of all children
     int y = 0;
-    UCX_FOREACH(row, grid->lines) {
+    lineIterator = cxListIterator(grid->lines);
+    cx_foreach(CxList *, row, lineIterator) {
         int x = 0;       
         int i=0;
-        UCX_FOREACH(elm, row->data) {
-            Widget w = elm->data;
+        int *rowheight = cxListAt(rowdim, lineIterator.index);
+        CxIterator colIterator = cxListIterator(row);
+        cx_foreach(Widget, w, colIterator) {
             XtVaSetValues(
                     w,
                     XmNx, x,
                     XmNy, y,
                     XmNwidth, coldim[i],
-                    XmNheight, rowdim->data,
+                    XmNheight, *rowheight,
                     NULL);
             
             x += coldim[i];
             i++;
         }
-        y += (intptr_t)rowdim->data;
-        rowdim = rowdim->next;
+        y += *rowheight;
     }
     
-    ucx_list_free(rowdim);
+    cxListDestroy(rowdim);
 }
 
 UiContainer* ui_scrolledwindow_container(UiObject *obj, Widget scrolledwindow) {
-    UiContainer *ct = ucx_mempool_calloc(
-            obj->ctx->mempool,
+    UiContainer *ct = cxCalloc(
+            obj->ctx->allocator,
             1,
             sizeof(UiContainer));
     ct->widget = scrolledwindow;
@@ -342,14 +350,15 @@
 
 
 UiContainer* ui_tabview_container(UiObject *obj, Widget frame) {
-    UiTabViewContainer *ct = ucx_mempool_calloc(
-            obj->ctx->mempool,
+    UiTabViewContainer *ct = cxCalloc(
+            obj->ctx->allocator,
             1,
             sizeof(UiTabViewContainer));
     ct->context = obj->ctx;
     ct->container.widget = frame;
     ct->container.prepare = ui_tabview_container_prepare;
     ct->container.add = ui_tabview_container_add;
+    ct->tabs = cxArrayListCreate(cxDefaultAllocator, cx_cmp_uintptr, CX_STORE_POINTERS, 16);
     return (UiContainer*)ct;
 }
 
@@ -371,7 +380,7 @@
     }
 
     tabview->current = widget;
-    tabview->tabs = ucx_list_append(tabview->tabs, widget);
+    cxListAdd(tabview->tabs, widget);
     
     ui_select_tab(ct->widget, 0);
     ui_reset_layout(ct->layout);
@@ -526,10 +535,10 @@
     XtVaGetValues(tabview, XmNuserData, &ct, NULL);
     if(ct) {
         XtUnmanageChild(ct->current);
-        UcxList *elm = ucx_list_get(ct->tabs, tab);
-        if(elm) {
-            XtManageChild(elm->data);
-            ct->current = elm->data;
+        Widget w = cxListAt(ct->tabs, tab);
+        if(w) {
+            XtManageChild(w);
+            ct->current = w;
         } else {
             fprintf(stderr, "UiError: front tab index: %d\n", tab);
         }
@@ -549,8 +558,8 @@
     XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL);
     int button_width = width / 4;
     int x = 0;
-    UCX_FOREACH(elm, v->tabs) {
-        UiTab *tab = elm->data;
+    CxIterator tabIterator = cxListIterator(v->tabs);
+    cx_foreach(UiTab*, tab, tabIterator) {
         XtVaSetValues(
                 tab->tab_button,
                 XmNx, x,
@@ -631,7 +640,7 @@
     tabbedpane->view.widget = tabct;
     tabbedpane->view.document = NULL;
     tabbedpane->tabbar = tabbar;
-    tabbedpane->tabs = NULL;
+    tabbedpane->tabs = cxArrayListCreate(obj->ctx->allocator, cx_cmp_uintptr, CX_STORE_POINTERS, 16);
     tabbedpane->current = NULL;
     tabbedpane->height = 0;
     
@@ -665,7 +674,7 @@
     
     UiObject *content = ui_malloc(view->ctx, sizeof(UiObject));
     content->widget = NULL; // initialization for uic_context()
-    content->ctx = uic_context(content, view->ctx->mempool);
+    content->ctx = uic_context(content, view->ctx->allocator);
     content->ctx->parent = view->ctx;
     content->ctx->attach_document = uic_context_attach_document;
     content->ctx->detach_document2 = uic_context_detach_document2;
@@ -675,7 +684,7 @@
     content->next = NULL;
     
     // add tab button
-    v->tabs = ucx_list_append_a(view->ctx->mempool->allocator, v->tabs, tab);
+    cxListAdd(v->tabs, tab);
     
     XmString label = XmStringCreateLocalized("tab");
     XtSetArg(args[0], XmNlabelString, label);
@@ -735,7 +744,7 @@
     XtVaSetValues(tab->tab_button, XmNshadowThickness, 1, XmNbackground, pane->bg2, NULL);
     
     pane->current = tab;
-    pane->index = ucx_list_find(pane->tabs, tab, NULL, NULL);
+    pane->index = cxListFind(pane->tabs, tab);
     printf("index: %d\n", pane->index);
     
     // redraw tabbar
--- a/ui/motif/container.h	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/container.h	Mon May 22 21:21:20 2023 +0200
@@ -31,7 +31,7 @@
 
 #include "../ui/toolkit.h"
 #include "../ui/container.h"
-#include <ucx/list.h>
+#include <cx/list.h>
 #include <string.h>
 
 #ifdef	__cplusplus
@@ -93,8 +93,8 @@
 
 struct UiGridContainer {
     UiContainer container;
-    UcxList     *lines;
-    UcxList     *current;
+    CxList      *lines;
+    CxList      *current;
     int         columnspacing;
     int         rowspacing;
 };
@@ -103,14 +103,14 @@
     UiContainer container;
     UiContext   *context;
     Widget      widget;
-    UcxList     *tabs;
+    CxList      *tabs;
     Widget      current;
 };
 
 struct MotifTabbedPane {
     UiTabbedPane view;
     Widget       tabbar;
-    UcxList      *tabs;
+    CxList       *tabs;
     UiTab        *current;
     int          index;
     Pixel        bg1;
--- a/ui/motif/dnd.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/dnd.c	Mon May 22 21:21:20 2023 +0200
@@ -37,9 +37,9 @@
 }
 
 char* ui_selection_gettext(UiSelection *sel) {
-    
+    return NULL;
 }
 
 char** ui_selection_geturis(UiSelection *sel, size_t *nelm) {
-    
+    return NULL;
 }
--- a/ui/motif/label.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/label.c	Mon May 22 21:21:20 2023 +0200
@@ -33,7 +33,6 @@
 #include "container.h"
 #include "../common/context.h"
 #include "../common/object.h"
-#include <ucx/mempool.h>
 
 UIWIDGET ui_label(UiObject *obj, char *label) {
     UiContainer *ct = uic_get_current_container(obj);
--- a/ui/motif/list.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/list.c	Mon May 22 21:21:20 2023 +0200
@@ -61,7 +61,7 @@
     ct->add(ct, XtParent(widget));
     XtManageChild(widget);
     
-    UiListView *listview = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiListView));
+    UiListView *listview = cxMalloc(obj->ctx->allocator, sizeof(UiListView));
     listview->widget = widget;
     listview->list = var;
     listview->getvalue = getvalue;
@@ -72,8 +72,8 @@
     XtFree((char *)items);
     
     if(f) {
-        UiListViewEventData *event = ucx_mempool_malloc(
-                obj->ctx->mempool,
+        UiListViewEventData *event = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiListViewEventData));
         event->event.obj = obj;
         event->event.userdata = udata;
@@ -182,8 +182,8 @@
 }
 
 UIWIDGET ui_combobox_var(UiObject *obj, UiVar *var, ui_getvaluefunc getvalue, ui_callback f, void *udata) {
-    UiListView *listview = ucx_mempool_malloc(
-                obj->ctx->mempool,
+    UiListView *listview = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiListView));
     
     UiContainer *ct = uic_get_current_container(obj);
@@ -204,4 +204,5 @@
     
     ui_listview_update(NULL, listview);
     
+    return parent;
 }
--- a/ui/motif/menu.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/menu.c	Mon May 22 21:21:20 2023 +0200
@@ -38,169 +38,24 @@
 #include "../common/context.h"
 #include "../ui/window.h"
 
-UcxList *menus;
-UcxList *current;
-
-void ui_menu(char *label) {
-    // free current menu hierarchy
-    ucx_list_free(current);
-    
-    // create menu
-    UiMenu *menu = malloc(sizeof(UiMenu));
-    menu->item.add_to = (ui_menu_add_f)add_menu_widget;
-    
-    menu->label  = label;
-    menu->items  = NULL;
-    menu->parent = NULL;    
-    
-    current = ucx_list_prepend(NULL, menu);
-    menus = ucx_list_append(menus, menu);
-    
-}
-
-void ui_submenu(char *label) {
-    UiMenu *menu = malloc(sizeof(UiMenu));
-    menu->item.add_to = (ui_menu_add_f)add_menu_widget;
-    
-    menu->label  = label;
-    menu->items  = NULL;
-    menu->parent = NULL;
-    
-    // add submenu to current menu
-    UiMenu *cm = current->data;
-    cm->items = ucx_list_append(cm->items, menu);
-    
-    // set the submenu to current menu
-    current = ucx_list_prepend(current, menu);
-}
-
-void ui_submenu_end() {
-    if(ucx_list_size(current) < 2) {
-        return;
-    }
-    current = ucx_list_remove(current, current);
-}
-
-void ui_menuitem(char *label, ui_callback f, void *userdata) {
-    ui_menuitem_gr(label, f, userdata, -1);
-}
-
-void ui_menuitem_st(char *stockid, ui_callback f, void *userdata) {
-    ui_menuitem_stgr(stockid, f, userdata, -1);
-}
-
-void ui_menuitem_gr(char *label, ui_callback f, void *userdata, ...) {
-    if(!current) {
-        return;
-    }
-    
-    UiMenuItem *item = malloc(sizeof(UiMenuItem));
-    item->item.add_to = (ui_menu_add_f)add_menuitem_widget;
-    
-    item->label = label;
-    item->userdata = userdata;
-    item->callback = f;
-    item->groups = NULL;
-    
-    // add groups
-    va_list ap;
-    va_start(ap, userdata);
-    int group;
-    while((group = va_arg(ap, int)) != -1) {
-        item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group);
-    }
-    va_end(ap);
-    
-    UiMenu *cm = current->data;
-    cm->items = ucx_list_append(cm->items, item);
-}
+#include <cx/linked_list.h>
+#include <cx/array_list.h>
 
-void ui_menuitem_stgr(char *stockid, ui_callback f, void *userdata, ...) {
-    if(!current) {
-        return;
-    }
-    
-    UiStMenuItem *item = malloc(sizeof(UiStMenuItem));
-    item->item.add_to = (ui_menu_add_f)add_menuitem_st_widget;
-    
-    item->stockid = stockid;
-    item->userdata = userdata;
-    item->callback = f;
-    item->groups = NULL;
-    
-    // add groups
-    va_list ap;
-    va_start(ap, userdata);
-    int group;
-    while((group = va_arg(ap, int)) != -1) {
-        item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group);
-    }
-    va_end(ap);
-    
-    UiMenu *cm = current->data;
-    cm->items = ucx_list_append(cm->items, item);
-}
-
-void ui_menuseparator() {
-    if(!current) {
-        return;
-    }
-    
-    UiMenuItemI *item = malloc(sizeof(UiMenuItemI));
-    item->add_to = (ui_menu_add_f)add_menuseparator_widget;
-    
-    UiMenu *cm = current->data;
-    cm->items = ucx_list_append(cm->items, item);
-}
-
-
-void ui_checkitem(char *label, ui_callback f, void *userdata) {
-    if(!current) {
-        return;
-    }
-    
-    UiCheckItem *item = malloc(sizeof(UiCheckItem));
-    item->item.add_to = (ui_menu_add_f)add_checkitem_widget;
-    item->label = label;
-    item->callback = f;
-    item->userdata = userdata;
-    
-    UiMenu *cm = current->data;
-    cm->items = ucx_list_append(cm->items, item);
-}
-
-void ui_checkitem_nv(char *label, char *vname) {
-    if(!current) {
-        return;
-    }
-    
-    UiCheckItemNV *item = malloc(sizeof(UiCheckItemNV));
-    item->item.add_to = (ui_menu_add_f)add_checkitemnv_widget;
-    item->varname = vname;
-    item->label = label;
-    
-    UiMenu *cm = current->data;
-    cm->items = ucx_list_append(cm->items, item);
-}
-
-void ui_menuitem_list(UiList *items, ui_callback f, void *userdata) {
-    if(!current) {
-        return;
-    }
-    
-    UiMenuItemList *item = malloc(sizeof(UiMenuItemList));
-    item->item.add_to = (ui_menu_add_f)add_menuitem_list_widget;
-    item->callback = f;
-    item->userdata = userdata;
-    item->list = items;
-    
-    UiMenu *cm = current->data;
-    cm->items = ucx_list_append(cm->items, item);
-}
-
+static ui_menu_add_f createMenuItem[] = {
+    /* UI_MENU                 */ add_menu_widget,
+    /* UI_MENU_SUBMENU         */ add_menu_widget,
+    /* UI_MENU_ITEM            */ add_menuitem_widget,
+    /* UI_MENU_STOCK_ITEM      */ add_menuitem_st_widget,
+    /* UI_MENU_CHECK_ITEM      */ add_checkitem_widget,
+    /* UI_MENU_CHECK_ITEM_NV   */ add_checkitemnv_widget,
+    /* UI_MENU_ITEM_LIST       */ add_menuitem_list_widget,
+    /* UI_MENU_ITEM_LIST_NV    */ NULL, // TODO
+    /* UI_MENU_SEPARATOR       */ add_menuseparator_widget
+};
 
 // private menu functions
 void ui_create_menubar(UiObject *obj) {
+    UiMenu *menus = uic_get_menu_list();
     if(!menus) {
         return;
     }
@@ -208,13 +63,12 @@
     Widget menubar = XmCreateMenuBar(obj->widget, "main_list", NULL, 0);
     XtManageChild(menubar);
     
-    UcxList *ls = menus;
+    UiMenu *menu = menus;
     int menu_index = 0;
-    while(ls) {
-        UiMenu *menu = ls->data;
-        menu_index += menu->item.add_to(menubar, menu_index, &menu->item, obj);
+    while(menu) {
+        menu_index += add_menu_widget(menubar, menu_index, &menu->item, obj);
         
-        ls = ls->next;
+        menu = (UiMenu*)menu->item.next;
     }
 }
 
@@ -228,12 +82,11 @@
             NULL);
     Widget m = XmVaCreateSimplePulldownMenu(parent, menu->label, i, NULL, NULL);
     
-    UcxList *ls = menu->items;
+    UiMenuItemI *mi = menu->items_begin;
     int menu_index = 0;
-    while(ls) {
-        UiMenuItemI *mi = ls->data;
-        menu_index += mi->add_to(m, menu_index, mi, obj);
-        ls = ls->next;
+    while(mi) {
+        menu_index += createMenuItem[mi->type](m, menu_index, mi, obj);
+        mi = mi->next;
     }
     
     return 1;
@@ -260,8 +113,8 @@
     XmStringFree(label);
     
     if(mi->callback != NULL) {
-        UiEventData *event = ucx_mempool_malloc(
-                obj->ctx->mempool,
+        UiEventData *event = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiEventData));
         event->obj = obj;
         event->userdata = mi->userdata;
@@ -319,8 +172,8 @@
     }
     
     if(mi->callback != NULL) {
-        UiEventData *event = ucx_mempool_malloc(
-                obj->ctx->mempool,
+        UiEventData *event = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiEventData));
         event->obj = obj;
         event->userdata = mi->userdata;
@@ -372,8 +225,8 @@
     XmStringFree(label);
     
     if(ci->callback) {
-        UiEventData *event = ucx_mempool_malloc(
-                obj->ctx->mempool,
+        UiEventData *event = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiEventData));
         event->obj = obj;
         event->userdata = ci->userdata;
@@ -429,10 +282,9 @@
         UiObject *obj)
 {
     UiMenuItemList *il = (UiMenuItemList*)item;
-    UcxMempool *mp = obj->ctx->mempool;
     
-    UiActiveMenuItemList *ls = ucx_mempool_malloc(
-            mp,
+    UiActiveMenuItemList *ls = cxMalloc(
+            obj->ctx->allocator,
             sizeof(UiActiveMenuItemList));
     
     ls->object = obj;
@@ -575,12 +427,15 @@
     }
     
     // add groups
-    UcxList *groups = NULL;
+    CxList *groups = NULL;
     va_list ap;
     va_start(ap, userdata);
     int group;
     while((group = va_arg(ap, int)) != -1) {
-        ucx_list_append(groups, (void*)(intptr_t)group);
+        if(!groups) {
+            groups = cxArrayListCreate(cxDefaultAllocator, NULL, sizeof(int), 16);
+        }
+        cxListAdd(groups, &group);
     }
     va_end(ap);
     
@@ -605,12 +460,15 @@
     }
     
     // add groups
-    UcxList *groups = NULL;
+    CxList *groups = NULL;
     va_list ap;
     va_start(ap, userdata);
     int group;
     while((group = va_arg(ap, int)) != -1) {
-        ucx_list_append(groups, (void*)(intptr_t)group);
+        if(!groups) {
+            groups = cxArrayListCreate(cxDefaultAllocator, NULL, sizeof(int), 16);
+        }
+        cxListAdd(groups, &group);
     }
     va_end(ap);
     
--- a/ui/motif/menu.h	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/menu.h	Mon May 22 21:21:20 2023 +0200
@@ -30,70 +30,16 @@
 #define	MENU_H
 
 #include "../ui/menu.h"
-#include <ucx/list.h>
+#include "../common/menu.h"
 
 #ifdef	__cplusplus
 extern "C" {
 #endif
 
-typedef struct UiMenuItemI      UiMenuItemI;
-typedef struct UiMenu           UiMenu;
-typedef struct UiMenuItem       UiMenuItem;
-typedef struct UiStMenuItem     UiStMenuItem;
-typedef struct UiCheckItem      UiCheckItem;
-typedef struct UiCheckItemNV    UiCheckItemNV;
-typedef struct UiMenuItemList   UiMenuItemList;
 
 typedef struct UiActiveMenuItemList UiActiveMenuItemList;
 
 typedef int(*ui_menu_add_f)(Widget, int, UiMenuItemI*, UiObject*);
-    
-struct UiMenuItemI {
-    ui_menu_add_f  add_to;
-};
-
-struct UiMenu {
-    UiMenuItemI    item;
-    char           *label;
-    UcxList        *items;
-    UiMenu         *parent;
-};
-
-struct UiMenuItem {
-    UiMenuItemI    item;
-    ui_callback    callback;
-    char           *label;
-    void           *userdata;
-    UcxList        *groups;
-};
-
-struct UiStMenuItem {
-    UiMenuItemI    item;
-    ui_callback    callback;
-    char           *stockid;
-    void           *userdata;
-    UcxList        *groups;
-};
-
-struct UiCheckItem {
-    UiMenuItemI    item;
-    char           *label;
-    ui_callback    callback;
-    void           *userdata;
-};
-
-struct UiCheckItemNV {
-    UiMenuItemI    item;
-    char           *label;
-    char           *varname;
-};
-
-struct UiMenuItemList {
-    UiMenuItemI    item;
-    ui_callback    callback;
-    void           *userdata;
-    UiList         *list;
-};
 
 struct UiActiveMenuItemList {
     UiObject     *object;
--- a/ui/motif/range.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/range.c	Mon May 22 21:21:20 2023 +0200
@@ -31,7 +31,6 @@
 
 #include "range.h"
 #include "container.h"
-#include <ucx/mempool.h>
 #include "../common/context.h"
 #include "../common/object.h"
 
@@ -61,8 +60,8 @@
     }
     
     if(f) {
-        UiEventData *event = ucx_mempool_malloc(
-                obj->ctx->mempool,
+        UiEventData *event = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiEventData));
         event->obj = obj;
         event->userdata = userdata;
--- a/ui/motif/stock.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/stock.c	Mon May 22 21:21:20 2023 +0200
@@ -31,12 +31,12 @@
 
 #include "stock.h"
 #include "../ui/properties.h"
-#include <ucx/map.h>
+#include <cx/hash_map.h>
 
-static UcxMap *stock_items;
+static CxMap *stock_items;
 
 void ui_stock_init() {
-    stock_items = ucx_map_new(64);
+    stock_items = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 64);
     
     ui_add_stock_item(UI_STOCK_NEW, "New", "Ctrl<Key>N", "Ctrl+N", NULL);
     ui_add_stock_item(UI_STOCK_OPEN, "Open", "Ctrl<Key>O", "Ctrl+O", NULL);
@@ -61,11 +61,11 @@
     i->accelerator_label = accelerator_label;
     // TODO: icon
     
-    ucx_map_cstr_put(stock_items, id, i);
+    cxMapPut(stock_items, id, i);
 }
 
 UiStockItem* ui_get_stock_item(char *id) {
-    UiStockItem *item = ucx_map_cstr_get(stock_items, id);
+    UiStockItem *item = cxMapGet(stock_items, id);
     if(item) {
         char *label = uistr_n(id);
         if(label) {
--- a/ui/motif/text.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/text.c	Mon May 22 21:21:20 2023 +0200
@@ -48,8 +48,8 @@
     ct->add(ct, XtParent(text_area));
     XtManageChild(text_area);
     
-    UiTextArea *uitext = ucx_mempool_malloc(
-            obj->ctx->mempool,
+    UiTextArea *uitext = cxMalloc(
+            obj->ctx->allocator,
             sizeof(UiTextArea));
     uitext->ctx = obj->ctx;
     uitext->last_selection_state = 0;
@@ -192,12 +192,26 @@
 UiUndoMgr* ui_create_undomgr() {
     UiUndoMgr *mgr = malloc(sizeof(UiUndoMgr));
     mgr->begin = NULL;
+    mgr->end = NULL;
     mgr->cur = NULL;
     mgr->length = 0;
     mgr->event = 1;
     return mgr;
 }
 
+void ui_destroy_undomgr(UiUndoMgr *mgr) {
+    UiTextBufOp *op = mgr->begin;
+    while(op) {
+        UiTextBufOp *nextOp = op->next;
+        if(op->text) {
+            free(op->text);
+        }
+        free(op);
+        op = nextOp;
+    }
+    free(mgr);
+}
+
 void ui_text_selection_callback(
         Widget widget,
         UiTextArea *textarea,
@@ -238,37 +252,35 @@
     int length = txv->text->length;
     
     if(mgr->cur) {
-        UcxList *elm = mgr->cur->next;
+        UiTextBufOp *elm = mgr->cur->next;
         if(elm) {
             mgr->cur->next = NULL;
+            mgr->end = mgr->cur;
             while(elm) {
                 elm->prev = NULL;   
-                UcxList *next = elm->next;
-                ui_free_textbuf_op(elm->data);
-                free(elm);
+                UiTextBufOp *next = elm->next;
+                ui_free_textbuf_op(elm);
                 elm = next;
             }
         }
         
-        if(type == UI_TEXTBUF_INSERT) {
-            UiTextBufOp *last_op = mgr->cur->data;
-            if(
-                last_op->type == UI_TEXTBUF_INSERT &&
-                ui_check_insertstr(last_op->text, last_op->len, text, length) == 0)
-            {
-                // append text to last op
-                int ln = last_op->len;
-                char *newtext = malloc(ln + length + 1);
-                memcpy(newtext, last_op->text, ln);
-                memcpy(newtext+ln, text, length);
-                newtext[ln+length] = '\0';
-                
-                last_op->text = newtext;
-                last_op->len = ln + length;
-                last_op->end += length;
-
-                return;
-            }
+        UiTextBufOp *last_op = mgr->cur;
+        if(
+            last_op->type == UI_TEXTBUF_INSERT &&
+            ui_check_insertstr(last_op->text, last_op->len, text, length) == 0)
+        {
+            // append text to last op       
+            int ln = last_op->len;
+            char *newtext = malloc(ln + length + 1);
+            memcpy(newtext, last_op->text, ln);
+            memcpy(newtext+ln, text, length);
+            newtext[ln+length] = '\0';
+            
+            last_op->text = newtext;
+            last_op->len = ln + length;
+            last_op->end += length;
+            
+            return;
         }
     }
     
@@ -284,15 +296,22 @@
     }
     
     UiTextBufOp *op = malloc(sizeof(UiTextBufOp));
+    op->prev = NULL;
+    op->next = NULL;
     op->type = type;
     op->start = txv->startPos;
     op->end = txv->endPos + 1;
     op->len = length;
     op->text = str;
     
-    UcxList *elm = ucx_list_append(NULL, op);
-    mgr->cur = elm;
-    mgr->begin = ucx_list_concat(mgr->begin, elm);
+    cx_linked_list_add(
+            (void**)&mgr->begin,
+            (void**)&mgr->end,
+            offsetof(UiTextBufOp, prev),
+            offsetof(UiTextBufOp, next),
+            op);
+    
+    mgr->cur = op;
 }
 
 int ui_check_insertstr(char *oldstr, int oldlen, char *newstr, int newlen) {
@@ -327,7 +346,7 @@
     UiUndoMgr *mgr = value->undomgr;
     
     if(mgr->cur) {
-        UiTextBufOp *op = mgr->cur->data;
+        UiTextBufOp *op = mgr->cur;
         mgr->event = 0;
         switch(op->type) {
             case UI_TEXTBUF_INSERT: {
@@ -347,7 +366,7 @@
 void ui_text_redo(UiText *value) {
     UiUndoMgr *mgr = value->undomgr;
     
-    UcxList *elm = NULL;
+    UiTextBufOp *elm = NULL;
     if(mgr->cur) {
         if(mgr->cur->next) {
             elm = mgr->cur->next;
@@ -357,7 +376,7 @@
     }
     
     if(elm) {
-        UiTextBufOp *op = elm->data;
+        UiTextBufOp *op = elm;
         mgr->event = 0;
         switch(op->type) {
             case UI_TEXTBUF_INSERT: {
--- a/ui/motif/text.h	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/text.h	Mon May 22 21:21:20 2023 +0200
@@ -31,7 +31,7 @@
 
 #include "../ui/text.h"
 #include "toolkit.h"
-#include <ucx/list.h>
+#include <cx/list.h>
 
 #ifdef	__cplusplus
 extern "C" {
@@ -39,19 +39,23 @@
 
 #define UI_TEXTBUF_INSERT 0
 #define UI_TEXTBUF_DELETE 1
-typedef struct UiTextBufOp {
+typedef struct UiTextBufOp UiTextBufOp;
+struct UiTextBufOp {
+    UiTextBufOp *prev;
+    UiTextBufOp *next;
     int  type; // UI_TEXTBUF_INSERT, UI_TEXTBUF_DELETE
     int  start;
     int  end;
     int  len;
     char *text;
-} UiTextBufOp;
+};
     
 typedef struct UiUndoMgr {
-    UcxList *begin;
-    UcxList *cur;
-    int     length;
-    int     event;
+    UiTextBufOp *begin;
+    UiTextBufOp *end;
+    UiTextBufOp *cur;
+    int         length;
+    int         event;
 } UiUndoMgr;
 
 typedef struct UiTextArea {
@@ -69,6 +73,7 @@
 int ui_textarea_length(UiText *text);
 
 UiUndoMgr* ui_create_undomgr();
+void ui_destroy_undomgr(UiUndoMgr *mgr);
 void ui_text_selection_callback(
         Widget widget,
         UiTextArea *textarea,
--- a/ui/motif/toolbar.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/toolbar.c	Mon May 22 21:21:20 2023 +0200
@@ -35,14 +35,19 @@
 #include "button.h"
 #include "stock.h"
 #include "list.h"
-#include <ucx/mempool.h>
+
+#include <cx/hash_map.h>
+#include <cx/linked_list.h>
+#include <cx/array_list.h>
+
 #include "../common/context.h"
 
-static UcxMap *toolbar_items;
-static UcxList *defaults;
+static CxMap *toolbar_items;
+static CxList *defaults;
 
 void ui_toolbar_init() {
-    toolbar_items = ucx_map_new(16);
+    toolbar_items = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16);
+    defaults = cxLinkedListCreateSimple(CX_STORE_POINTERS);
 }
 
 void ui_toolitem(char *name, char *label, ui_callback f, void *userdata) {
@@ -55,7 +60,7 @@
     item->groups = NULL;
     item->isimportant = FALSE;
     
-    ucx_map_cstr_put(toolbar_items, name, item);
+    cxMapPut(toolbar_items, name, item);
 }
 
 void ui_toolitem_st(char *name, char *stockid, ui_callback f, void *userdata) {
@@ -76,11 +81,14 @@
     va_start(ap, userdata);
     int group;
     while((group = va_arg(ap, int)) != -1) {
-        item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group);
+        if(!item->groups) {
+            item->groups = cxArrayListCreateSimple(sizeof(int), 16);
+        }
+        cxListAdd(item->groups, &group);
     }
     va_end(ap);
     
-    ucx_map_cstr_put(toolbar_items, name, item);
+    cxMapPut(toolbar_items, name, item);
 }
 
 void ui_toolitem_img(char *name, char *label, char *img, ui_callback f, void *udata) {
@@ -95,7 +103,7 @@
     item->groups = NULL;
     item->isimportant = FALSE;
     
-    ucx_map_cstr_put(toolbar_items, name, item);
+    cxMapPut(toolbar_items, name, item);
 }
 
 
@@ -115,11 +123,14 @@
     va_start(ap, udata);
     int group;
     while((group = va_arg(ap, int)) != -1) {
-        item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group);
+        if(!item->groups) {
+            item->groups = cxArrayListCreateSimple(sizeof(int), 16);
+        }
+        cxListAdd(item->groups, &group);
     }
     va_end(ap);
     
-    ucx_map_cstr_put(toolbar_items, name, item);
+    cxMapPut(toolbar_items, name, item);
 }
 
 void ui_toolitem_toggle_imggr(char *name, char *label, char *img, ui_callback f, void *udata, ...) {
@@ -139,11 +150,14 @@
     va_start(ap, udata);
     int group;
     while((group = va_arg(ap, int)) != -1) {
-        item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group);
+        if(!item->groups) {
+            item->groups = cxArrayListCreateSimple(sizeof(int), 16);
+        }
+        cxListAdd(item->groups, &group);
     }
     va_end(ap);
     
-    ucx_map_cstr_put(toolbar_items, name, item);
+    cxMapPut(toolbar_items, name, item);
 }
 
 void ui_toolbar_combobox(
@@ -160,7 +174,7 @@
     cb->callback = f;
     cb->userdata = udata;
     
-    ucx_map_cstr_put(toolbar_items, name, cb);
+    cxMapPut(toolbar_items, name, cb);
 }
 
 void ui_toolbar_combobox_str(
@@ -186,13 +200,13 @@
     cb->callback = f;
     cb->userdata = udata;
     
-    ucx_map_cstr_put(toolbar_items, name, cb);
+    cxMapPut(toolbar_items, name, cb);
 }
 
 
 void ui_toolbar_add_default(char *name) {
     char *s = strdup(name);
-    defaults = ucx_list_append(defaults, s);
+    cxListAdd(defaults, s);
 }
 
 Widget ui_create_toolbar(UiObject *obj, Widget parent) {
@@ -213,14 +227,15 @@
     XtSetArg(args[2], XmNspacing, 1);
     Widget toolbar = XmCreateRowColumn (frame, "toolbar", args, 3);
     
-    UCX_FOREACH(elm, defaults) {
-        UiToolItemI *item = ucx_map_cstr_get(toolbar_items, elm->data);
+    CxIterator i = cxListIterator(defaults);
+    cx_foreach(char *, def, i) {
+        UiToolItemI *item = cxMapGet(toolbar_items, def);
         if(item) {
             item->add_to(toolbar, item, obj);
-        } else if(!strcmp(elm->data, "@separator")) {
+        } else if(!strcmp(def, "@separator")) {
             // TODO
         } else {
-            fprintf(stderr, "UI Error: Unknown toolbar item: %s\n", elm->data);
+            fprintf(stderr, "UI Error: Unknown toolbar item: %s\n", def);
         }
     }
     
@@ -242,8 +257,8 @@
     XmStringFree(label);
     
     if(item->callback) {
-        UiEventData *event = ucx_mempool_malloc(
-                obj->ctx->mempool,
+        UiEventData *event = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiEventData));
         event->obj = obj;
         event->userdata = item->userdata;
@@ -276,8 +291,8 @@
     XmStringFree(label);
     
     if(item->callback) {
-        UiEventData *event = ucx_mempool_malloc(
-                obj->ctx->mempool,
+        UiEventData *event = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiEventData));
         event->obj = obj;
         event->userdata = item->userdata;
@@ -309,8 +324,8 @@
     XmStringFree(label);
     
     if(item->callback) {
-        UiEventData *event = ucx_mempool_malloc(
-                obj->ctx->mempool,
+        UiEventData *event = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiEventData));
         event->obj = obj;
         event->userdata = item->userdata;
@@ -334,11 +349,11 @@
 }
 
 void add_toolbar_combobox(Widget tb, UiToolbarComboBox *item, UiObject *obj) {
-    UiListView *listview = ucx_mempool_malloc(
-                obj->ctx->mempool,
+    UiListView *listview = cxMalloc(
+                obj->ctx->allocator,
                 sizeof(UiListView));
     
-    UiVar *var = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiVar));
+    UiVar *var = cxMalloc(obj->ctx->allocator, sizeof(UiVar));
     var->value = item->list;
     var->type = UI_VAR_SPECIAL;
     
--- a/ui/motif/toolbar.h	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/toolbar.h	Mon May 22 21:21:20 2023 +0200
@@ -30,8 +30,8 @@
 #define	TOOLBAR_H
 
 #include "../ui/toolbar.h"
-#include <ucx/map.h>
-#include <ucx/list.h>
+#include <cx/hash_map.h>
+#include <cx/linked_list.h>
 
 #ifdef	__cplusplus
 extern "C" {
@@ -56,7 +56,7 @@
     void           *image;
     ui_callback    callback;
     void           *userdata;
-    UcxList        *groups;
+    CxList         *groups;
     Boolean        isimportant;
 };
 
@@ -65,7 +65,7 @@
     char           *stockid;
     ui_callback    callback;
     void           *userdata;
-    UcxList        *groups;
+    CxList         *groups;
     Boolean        isimportant;
 };
 
--- a/ui/motif/toolkit.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/toolkit.c	Mon May 22 21:21:20 2023 +0200
@@ -36,7 +36,7 @@
 #include "stock.h"
 #include "../common/document.h"
 #include "../common/properties.h"
-#include <ucx/buffer.h>
+#include <cx/buffer.h>
 
 static XtAppContext app;
 static Display *display;
@@ -206,6 +206,7 @@
         XtAppAddWorkProc(app, ui_job_finished, job);
         
     }
+    return NULL;
 }
 
 void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd) {
--- a/ui/motif/tree.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/tree.c	Mon May 22 21:21:20 2023 +0200
@@ -36,7 +36,9 @@
 #include "container.h"
 #include "../common/object.h"
 #include "../common/context.h"
-#include <ucx/utils.h>
+#include <cx/utils.h>
+#include <cx/compare.h>
+#include <cx/printf.h>
 
 UIWIDGET ui_table_var(UiObject *obj, UiVar *var, UiModel *model, UiListCallbacks cb) {
     // TODO: check if modelinfo is complete
@@ -119,7 +121,7 @@
         data = list->next(list);
     }
     
-    UiTableView *tableview = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiTableView));
+    UiTableView *tableview = cxMalloc(obj->ctx->allocator, sizeof(UiTableView));
     tableview->widget = container;
     tableview->var = var;
     tableview->model = model;
@@ -246,9 +248,11 @@
         case UI_INTEGER: {
             *free = TRUE;
             int *val = data;
-            sstr_t str = ucx_asprintf(ucx_default_allocator(), "%d", *val);
+            cxmutstr str = cx_asprintf("%d", *val);
             return str.ptr;
         }
+        case UI_ICON: break; // TODO
+        case UI_ICON_TEXT: break; // TODO
     }
     *free = FALSE;
     return NULL;
--- a/ui/motif/window.c	Mon May 22 19:44:27 2023 +0200
+++ b/ui/motif/window.c	Mon May 22 21:21:20 2023 +0200
@@ -36,6 +36,8 @@
 #include "../ui/window.h"
 #include "../common/context.h"
 
+#include <cx/basic_mempool.h>
+
 static int nwindows = 0;
 
 static int window_default_width = 600;
@@ -62,9 +64,10 @@
 }
 
 static UiObject* create_window(char *title, void *window_data, UiBool simple) {
-    UcxMempool *mp = ucx_mempool_new(256);
-    UiObject *obj = ucx_mempool_calloc(mp, 1, sizeof(UiObject));
-    obj->ctx = uic_context(obj, mp);
+    CxMempool *mp = cxBasicMempoolCreate(256);
+    const CxAllocator *a = mp->allocator;
+    UiObject *obj = cxCalloc(a, 1, sizeof(UiObject));
+    obj->ctx = uic_context(obj, a);
     obj->window = window_data;
     
     Arg args[16];

mercurial