implement ui_customwidget_create (Cocoa)

Mon, 25 Aug 2025 17:55:41 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 25 Aug 2025 17:55:41 +0200
changeset 726
525a14307887
parent 725
f190e440e469
child 727
de40bc4811b1

implement ui_customwidget_create (Cocoa)

make/xcode/toolkit/toolkit.xcodeproj/project.pbxproj file | annotate | diff | comparison | revisions
ui/cocoa/widget.m file | annotate | diff | comparison | revisions
--- a/make/xcode/toolkit/toolkit.xcodeproj/project.pbxproj	Mon Aug 25 17:52:06 2025 +0200
+++ b/make/xcode/toolkit/toolkit.xcodeproj/project.pbxproj	Mon Aug 25 17:55:41 2025 +0200
@@ -156,6 +156,8 @@
 		ED8687E42D999CF3002F3EC2 /* menu.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = menu.m; path = ../../../ui/cocoa/menu.m; sourceTree = SOURCE_ROOT; };
 		ED99F0482E5CBD2E00A4CC97 /* widget.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = widget.h; path = /Users/olaf/Projekte/toolkit/ui/cocoa/widget.h; sourceTree = "<absolute>"; };
 		ED99F0492E5CBD2E00A4CC97 /* widget.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = widget.m; path = /Users/olaf/Projekte/toolkit/ui/cocoa/widget.m; sourceTree = "<absolute>"; };
+		ED99F04B2E5CBE5000A4CC97 /* webview.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = webview.h; path = /Users/olaf/Projekte/toolkit/ui/ui/webview.h; sourceTree = "<absolute>"; };
+		ED99F04C2E5CBE5000A4CC97 /* widget.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = widget.h; path = /Users/olaf/Projekte/toolkit/ui/ui/widget.h; sourceTree = "<absolute>"; };
 		EDB452C12E302C65006FB12D /* image.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = image.h; path = /Users/olaf/Projekte/toolkit/ui/cocoa/image.h; sourceTree = "<absolute>"; };
 		EDB452C22E302C65006FB12D /* image.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = image.m; path = /Users/olaf/Projekte/toolkit/ui/cocoa/image.m; sourceTree = "<absolute>"; };
 		EDCD22252E59EEF5000612AF /* list.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = list.h; path = /Users/olaf/Projekte/toolkit/ui/cocoa/list.h; sourceTree = "<absolute>"; };
@@ -329,6 +331,8 @@
 		ED6581472CFF3C8300F5402F /* public */ = {
 			isa = PBXGroup;
 			children = (
+				ED99F04B2E5CBE5000A4CC97 /* webview.h */,
+				ED99F04C2E5CBE5000A4CC97 /* widget.h */,
 				ED6581482CFF3CA000F5402F /* button.h */,
 				ED6581492CFF3CA000F5402F /* container.h */,
 				ED65814A2CFF3CA000F5402F /* display.h */,
--- a/ui/cocoa/widget.m	Mon Aug 25 17:52:06 2025 +0200
+++ b/ui/cocoa/widget.m	Mon Aug 25 17:55:41 2025 +0200
@@ -28,6 +28,8 @@
 
 #import "widget.h"
 
+/* genereal widget functions */
+
 void ui_set_enabled(UIWIDGET widget, int enabled) {
     NSControl *control = (__bridge NSControl*)widget;
     control.enabled = enabled;
@@ -41,3 +43,17 @@
     NSView *view = (__bridge NSView*)widget;
     view.hidden = !visible;
 }
+
+
+
+/* custom widget */
+
+UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs *args) {
+    UIWIDGET widget = create_widget(obj, args, userdata);
+    
+    NSView *view = (__bridge NSView*)widget;
+    UiLayout layout = UI_INIT_LAYOUT(args);
+    ui_container_add(obj, view, &layout);
+    
+    return widget;
+}

mercurial