ui/cocoa/container.h

changeset 100
d2bd73d28ff1
parent 0
2483f517c562
--- a/ui/cocoa/container.h	Fri Nov 29 22:21:36 2024 +0100
+++ b/ui/cocoa/container.h	Thu Dec 12 20:01:43 2024 +0100
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
+ * Copyright 2024 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:
@@ -26,19 +26,65 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "../ui/toolkit.h"
 #import "toolkit.h"
 
-typedef void(*ui_container_add_f)(UiContainer*, NSView*);
+#import "../ui/container.h"
+
+#define ui_lb2bool(b) ((b) == UI_LAYOUT_TRUE ? TRUE : FALSE)
+#define ui_bool2lb(b) ((b) ? UI_LAYOUT_TRUE : UI_LAYOUT_FALSE)
+
+typedef struct UiLayout UiLayout;
+typedef enum UiLayoutBool UiLayoutBool;
 
-struct UiContainer {
-    NSView* widget;
-    void   (*add)(UiContainer*, NSView*);
-    NSRect (*getframe)(UiContainer*);
+enum UiLayoutBool {
+    UI_LAYOUT_UNDEFINED = 0,
+    UI_LAYOUT_TRUE,
+    UI_LAYOUT_FALSE,
+};
+
+struct UiLayout {
+    UiTri        fill;
+    //UiBool       newline;
+    //char         *label;
+    UiBool       hexpand;
+    UiBool       vexpand;
+    UiBool       hfill;
+    UiBool       vfill;
+    //int          width;
+    int          colspan;
+    int          rowspan;
 };
 
-UiContainer* ui_window_container(UiObject *obj, NSWindow *window);
+#define UI_INIT_LAYOUT(args) (UiLayout) {\
+    .fill = args.fill, \
+    .hexpand = args.hexpand, \
+    .vexpand = args.vexpand, \
+    .hfill = args.hfill, \
+    .vfill = args.vfill, \
+    .colspan = args.colspan, \
+    .rowspan = args.rowspan }
+
+
+@protocol Container
+
+@property UiLayout uilayout;
+@property const char *label;
+@property UiBool newline;
 
-NSRect ui_container_getframe(UiContainer *ct);
-void ui_container_add(UiContainer *ct, NSView *view);
+- (void) addView:(NSView*)view fill:(BOOL)fill;
+
+@end
+
+@interface BoxContainer : NSStackView<Container>
+
+- (BoxContainer*)init:(NSUserInterfaceLayoutOrientation)orientation spacing:(int)spacing;
 
+@end
+
+
+
+
+
+UiContainerX* ui_create_container(UiObject *obj, id<Container> container);
+
+void ui_container_add(UiObject *obj, NSView *view, UiLayout *layout, UiBool fill);

mercurial