implement some general widget functions (Cocoa)

Mon, 25 Aug 2025 17:52:06 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 25 Aug 2025 17:52:06 +0200
changeset 725
f190e440e469
parent 724
ba7a2f7675b9
child 726
525a14307887

implement some general widget functions (Cocoa)

make/xcode/toolkit/toolkit.xcodeproj/project.pbxproj file | annotate | diff | comparison | revisions
ui/cocoa/objs.mk file | annotate | diff | comparison | revisions
ui/cocoa/widget.h 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:33:52 2025 +0200
+++ b/make/xcode/toolkit/toolkit.xcodeproj/project.pbxproj	Mon Aug 25 17:52:06 2025 +0200
@@ -46,6 +46,7 @@
 		ED679B0A2E5B266C001D4F71 /* label.m in Sources */ = {isa = PBXBuildFile; fileRef = ED679B092E5B266C001D4F71 /* label.m */; };
 		ED679B0D2E5B2FB0001D4F71 /* UiThread.m in Sources */ = {isa = PBXBuildFile; fileRef = ED679B0C2E5B2FB0001D4F71 /* UiThread.m */; };
 		ED8687E52D999CF3002F3EC2 /* menu.m in Sources */ = {isa = PBXBuildFile; fileRef = ED8687E42D999CF3002F3EC2 /* menu.m */; };
+		ED99F04A2E5CBD2E00A4CC97 /* widget.m in Sources */ = {isa = PBXBuildFile; fileRef = ED99F0492E5CBD2E00A4CC97 /* widget.m */; };
 		EDB452C32E302C65006FB12D /* image.m in Sources */ = {isa = PBXBuildFile; fileRef = EDB452C22E302C65006FB12D /* image.m */; };
 		EDCD22272E59EEF5000612AF /* list.m in Sources */ = {isa = PBXBuildFile; fileRef = EDCD22262E59EEF5000612AF /* list.m */; };
 		EDCD22352E59F3B1000612AF /* ListDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = EDCD22342E59F3B1000612AF /* ListDataSource.m */; };
@@ -153,6 +154,8 @@
 		ED679B0C2E5B2FB0001D4F71 /* UiThread.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = UiThread.m; path = /Users/olaf/Projekte/toolkit/ui/cocoa/UiThread.m; sourceTree = "<absolute>"; };
 		ED8687E32D999CF3002F3EC2 /* menu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = menu.h; path = ../../../ui/cocoa/menu.h; sourceTree = SOURCE_ROOT; };
 		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>"; };
 		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>"; };
@@ -281,6 +284,8 @@
 		ED65812E2CFF1A7200F5402F /* cocoa */ = {
 			isa = PBXGroup;
 			children = (
+				ED99F0482E5CBD2E00A4CC97 /* widget.h */,
+				ED99F0492E5CBD2E00A4CC97 /* widget.m */,
 				ED679B0B2E5B2FB0001D4F71 /* UiThread.h */,
 				ED679B0C2E5B2FB0001D4F71 /* UiThread.m */,
 				ED679B082E5B266C001D4F71 /* label.h */,
@@ -439,6 +444,7 @@
 				ED6581232CFF1A3000F5402F /* array_list.c in Sources */,
 				ED6581242CFF1A3000F5402F /* list.c in Sources */,
 				ED65815C2CFF3EE900F5402F /* MainWindow.m in Sources */,
+				ED99F04A2E5CBD2E00A4CC97 /* widget.m in Sources */,
 				ED6581252CFF1A3000F5402F /* compare.c in Sources */,
 				ED6581262CFF1A3000F5402F /* hash_key.c in Sources */,
 				ED6581272CFF1A3000F5402F /* iterator.c in Sources */,
--- a/ui/cocoa/objs.mk	Mon Aug 25 17:33:52 2025 +0200
+++ b/ui/cocoa/objs.mk	Mon Aug 25 17:52:06 2025 +0200
@@ -33,7 +33,7 @@
 COCOAOBJ += AppDelegate.o
 COCOAOBJ += GridLayout.o
 COCOAOBJ += EventData.o
-COCOAOBJ += UiJob.o
+COCOAOBJ += UiThread.o
 COCOAOBJ += MainWindow.o
 COCOAOBJ += WindowManager.o
 COCOAOBJ += window.o
@@ -42,6 +42,12 @@
 COCOAOBJ += text.o
 COCOAOBJ += menu.o
 COCOAOBJ += Toolbar.o
+COCOAOBJ += ListDelegate.o
+COCOAOBJ += ListDataSource.o
+COCOAOBJ += label.o
+COCOAOBJ += list.o
+COCOAOBJ += widget.o
+COCOAOBJ += image.o
 
 TOOLKITOBJS += $(COCOAOBJ:%=$(COCOA_OBJPRE)%)
 TOOLKITSOURCE += $(COCOAOBJ:%.o=cocoa/%.m)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/cocoa/widget.h	Mon Aug 25 17:52:06 2025 +0200
@@ -0,0 +1,31 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2025 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the
+ *      documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "toolkit.h"
+#import "container.h"
+#import "../ui/widget.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/cocoa/widget.m	Mon Aug 25 17:52:06 2025 +0200
@@ -0,0 +1,43 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2025 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the
+ *      documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "widget.h"
+
+void ui_set_enabled(UIWIDGET widget, int enabled) {
+    NSControl *control = (__bridge NSControl*)widget;
+    control.enabled = enabled;
+}
+
+void ui_set_show_all(UIWIDGET widget, int value) {
+    // TODO: is this relevant?
+}
+
+void ui_set_visible(UIWIDGET widget, int visible) {
+    NSView *view = (__bridge NSView*)widget;
+    view.hidden = !visible;
+}

mercurial