]> uap-core.de Git - rssreader.git/commitdiff
add kotlin listview
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 30 Jun 2025 16:31:08 +0000 (18:31 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 30 Jun 2025 16:31:08 +0000 (18:31 +0200)
ui-kotlin/src/main/kotlin/de/unixwork/ui/kotlin/Toplevel.kt

index 0a694e59ed4f4d07d3a77e254c42876494f88234..56954c36b3fcf544424a1e807c600d40307bf127 100644 (file)
@@ -7,8 +7,11 @@ import de.unixwork.ui.ContainerBuilder
 import de.unixwork.ui.ContainerUI
 import de.unixwork.ui.EventHandler
 import de.unixwork.ui.EventWrapper.eventHandler
+import de.unixwork.ui.ListValueConverter
+import de.unixwork.ui.ListView
 import de.unixwork.ui.ToggleBuilder
 import de.unixwork.ui.UiInteger
+import de.unixwork.ui.UiList
 import de.unixwork.ui.UiObject
 import de.unixwork.ui.UiWidget
 import java.lang.foreign.MemorySegment
@@ -492,4 +495,62 @@ class Toplevel(obj: UiObject) {
             onChange = onChange
         )
     }
+
+    fun <T>listview(
+        varname: String? = null,
+        value: UiList<T>? = null,
+        fill: Boolean = false,
+        hexpand: Boolean = false,
+        vexpand: Boolean = false,
+        hfill: Boolean = false,
+        vfill: Boolean = false,
+        overrideDefaults: Boolean = false,
+        colspan: Int = -1,
+        rowspan: Int = -1,
+        name: String? = null,
+        styleClass: String? = null,
+        getvalue: ListValueConverter<T>? = null
+    ): UiWidget {
+        val list = ListView.list<T>(obj)
+        varname?.let {
+            list.varname(varname)
+        }
+        value?.let {
+            // TODO
+        }
+        if(fill) {
+            list.fill(true)
+        }
+        if(hexpand) {
+            list.hexpand(true)
+        }
+        if(vexpand) {
+            list.vexpand(true)
+        }
+        if(hfill) {
+            list.hfill(true)
+        }
+        if(vfill) {
+            list.vfill(true)
+        }
+        if(overrideDefaults) {
+            list.overrideDefaults(true)
+        }
+        if(colspan > 0) {
+            list.colspan(colspan)
+        }
+        if(rowspan > 0) {
+            list.rowspan(rowspan)
+        }
+        name?.let {
+            list.name(it)
+        }
+        styleClass?.let {
+            list.styleClass(it)
+        }
+        getvalue?.let {
+            list.getvalue(it)
+        }
+        return list.create()
+    }
 }
\ No newline at end of file