ui/win32/button.c

changeset 814
bcb3c7d486f3
parent 665
73689d24080c
child 815
7ddf5fb7ec2a
--- a/ui/win32/button.c	Wed Oct 08 09:46:23 2025 +0200
+++ b/ui/win32/button.c	Wed Oct 08 10:41:35 2025 +0200
@@ -27,7 +27,40 @@
  */
 
 #include "button.h"
+#include "widget.h"
+
+static W32WidgetClass button_widget_class = {
+    .enable = w32_widget_default_enable,
+    .show = w32_widget_default_show,
+    .get_preferred_size = ui_button_get_preferred_size,
+    .destroy  = w32_widget_default_destroy
+};
 
 UIWIDGET ui_button_create(UiObject *obj, UiButtonArgs *args) {
-    return NULL;
+    HINSTANCE hInstance = GetModuleHandle(NULL);
+    UiContainerPrivate *container = ui_obj_container(obj);
+    HWND parent = ui_container_get_parent(container);
+    UiLayout layout = UI_ARGS2LAYOUT(args);
+
+    HWND hwnd = CreateWindow(
+            "BUTTON",
+            args->label,
+            WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
+            0, 0, 100, 30,
+            parent,
+            (HMENU)0,
+            hInstance,
+            NULL);
+
+    W32Widget *widget = w32_widget_create(&button_widget_class, hwnd, sizeof(W32Button));
+    ui_container_add(container, widget, &layout);
+
+    return widget;
 }
+
+W32Size ui_button_get_preferred_size(W32Widget *widget) {
+    W32Size size;
+    size.width = 100;
+    size.height = 30;
+    return size;
+}

mercurial