ui/cocoa/BoxContainer.m

Thu, 02 Oct 2025 14:49:17 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 02 Oct 2025 14:49:17 +0200
changeset 785
b943e3d618f0
child 799
f8ff8df41713
permissions
-rw-r--r--

create new BoxContainer based on GridLayout



#import "BoxContainer.h"

@implementation BoxContainer

- (BoxContainer*)init:(NSUserInterfaceLayoutOrientation)orientation spacing:(int)spacing {
    self = [super init];
    _orientation = orientation;
    self.columnspacing = spacing;
    self.rowspacing = spacing;
    
    return self;
}

- (void) addView:(NSView*)view {
    UiLayout layout = self.uilayout;
    if(_orientation == NSUserInterfaceLayoutOrientationVertical) {
        layout.hexpand = TRUE;
        layout.hfill = TRUE;
    } else {
        layout.vexpand = TRUE;
        layout.vfill = TRUE;
        self.newline = FALSE;
    }
    self.uilayout = layout;
    [super addView:view];
    if(_orientation == NSUserInterfaceLayoutOrientationVertical) {
        self.newline = TRUE;
    }
}

@end

mercurial