Removed now-converted files.

This commit is contained in:
Pietro Gagliardi 2015-08-06 23:15:10 -04:00
parent 2b1134625d
commit 260f619b20
4 changed files with 0 additions and 275 deletions

View File

@ -1,100 +0,0 @@
// 31 july 2015
#import "osxaltest.h"
// #qo LDFLAGS: -framework Foundation -framework AppKit
BOOL spaced = NO;
BOOL firstvert = NO;
@interface appDelegate : NSObject<NSApplicationDelegate>
@end
@implementation appDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)note
{
tWindow *mainwin;
tBox *box, *hbox;
tButton *button;
tSpinbox *spinbox;
tEntry *entry;
tLabel *label;
mainwin = [[tWindow alloc] init];
[mainwin tSetMargined:spaced];
box = [[tBox alloc] tInitVertical:firstvert spaced:spaced];
spinbox = [[tSpinbox alloc] init];
[box tAddControl:spinbox stretchy:NO];
[mainwin tSetControl:box];
hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced];
button = [[tButton alloc] tInitWithText:@"Button"];
[hbox tAddControl:button stretchy:YES];
button = [[tButton alloc] tInitWithText:@"Button"];
[hbox tAddControl:button stretchy:YES];
[box tAddControl:hbox stretchy:NO];
hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced];
button = [[tButton alloc] tInitWithText:@"Button"];
[hbox tAddControl:button stretchy:YES];
button = [[tButton alloc] tInitWithText:@"Button"];
[hbox tAddControl:button stretchy:YES];
[box tAddControl:hbox stretchy:NO];
// TODO in vertical mode the three non-stretchy buttons are smaller than they should be
hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced];
button = [[tButton alloc] tInitWithText:@"Button"];
[hbox tAddControl:button stretchy:YES];
button = [[tButton alloc] tInitWithText:@"A"];
[hbox tAddControl:button stretchy:NO];
button = [[tButton alloc] tInitWithText:@"BB"];
[hbox tAddControl:button stretchy:NO];
button = [[tButton alloc] tInitWithText:@"CCC"];
[hbox tAddControl:button stretchy:NO];
[box tAddControl:hbox stretchy:NO];
// TODO this isn't stretchy in the proper order
hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced];
spinbox = [[tSpinbox alloc] init];
[hbox tAddControl:spinbox stretchy:NO];
spinbox = [[tSpinbox alloc] init];
[hbox tAddControl:spinbox stretchy:YES];
[box tAddControl:hbox stretchy:NO];
hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced];
entry = [[tEntry alloc] init];
[hbox tAddControl:entry stretchy:NO];
entry = [[tEntry alloc] init];
[hbox tAddControl:entry stretchy:YES];
[box tAddControl:hbox stretchy:NO];
hbox = [[tBox alloc] tInitVertical:!firstvert spaced:spaced];
label = [[tLabel alloc] init];
[hbox tAddControl:label stretchy:NO];
[box tAddControl:hbox stretchy:NO];
[mainwin tShow];
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)a
{
return YES;
}
@end
int main(int argc, char *argv[])
{
NSApplication *app;
spaced = argc > 1;
app = [NSApplication sharedApplication];
[app setActivationPolicy:NSApplicationActivationPolicyRegular];
[app setDelegate:[appDelegate new]];
[app run];
return 0;
}

View File

@ -1,50 +0,0 @@
// 31 july 2015
#import <Cocoa/Cocoa.h>
#import <stdint.h>
typedef struct tAutoLayoutParams tAutoLayoutParams;
// TODO stretchy across both dimensions
// for a vertical box, the horizontal width should be variable
struct tAutoLayoutParams {
NSView *view;
BOOL attachLeft;
BOOL attachTop;
BOOL attachRight;
BOOL attachBottom;
NSString *nonStretchyWidthPredicate;
NSString *nonStretchyHeightPredicate;
};
@protocol tControl
@required
- (void)tSetParent:(id<tControl>)p addToView:(NSView *)v relayout:(BOOL)relayout;
- (void)tFillAutoLayout:(tAutoLayoutParams *)p;
- (void)tRelayout;
@end
@interface tWindow : NSObject<tControl>
- (void)tSetControl:(id<tControl>)cc;
- (void)tSetMargined:(BOOL)m;
- (void)tShow;
@end
@interface tBox : NSObject<tControl>
- (id)tInitVertical:(BOOL)vert spaced:(BOOL)sp;
- (void)tAddControl:(id<tControl>)c stretchy:(BOOL)s;
@end
@interface tButton : NSObject<tControl>
- (id)tInitWithText:(NSString *)text;
@end
@interface tEntry : NSObject<tControl>
@end
@interface tLabel : NSObject<tControl>
@end
@interface tSpinbox : NSObject<tControl>
@end
extern NSString *tAutoLayoutKey(uintmax_t);

View File

@ -1,7 +0,0 @@
// 1 august 2015
#import "osxaltest.h"
NSString *tAutoLayoutKey(uintmax_t n)
{
return [NSString stringWithFormat:@"view%ju", n];
}

View File

@ -1,118 +0,0 @@
// 1 august 2015
#include "osxaltest.h"
@implementation NSView (AutoLayoutHelpers)
- (void)tIsAmbiguous:(uintmax_t)indent
{
NSMutableString *s;
uintmax_t i;
NSUInteger j;
s = [NSMutableString new];
for (i = 0; i < indent; i++)
[s appendString:@" "];
NSLog(@"%@%@ %d", s, [self className], (int) [self hasAmbiguousLayout]);
if ([self hasAmbiguousLayout])
[[self window] visualizeConstraints:[[self superview] constraints]];
for (j = 0; j < [[self subviews] count]; j++)
[[[self subviews] objectAtIndex:j] tIsAmbiguous:(indent + 1)];
}
@end
@implementation tWindow {
NSWindow *w;
id<tControl> c;
BOOL margined;
}
- (id)init
{
self = [super init];
if (self) {
self->w = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 320, 240)
styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
backing:NSBackingStoreBuffered
defer:YES];
[self->w setTitle:@"Auto Layout Test"];
}
return self;
}
- (void)tSetControl:(id<tControl>)cc
{
self->c = cc;
[self->c tSetParent:self addToView:[self->w contentView] relayout:NO];
[self tRelayout];
}
- (void)tSetMargined:(BOOL)m
{
self->margined = m;
[self tRelayout];
}
- (void)tShow
{
[self->w cascadeTopLeftFromPoint:NSMakePoint(20, 20)];
[self->w makeKeyAndOrderFront:self];
[[self->w contentView] tIsAmbiguous:0];
}
- (void)tRelayout
{
NSView *contentView;
tAutoLayoutParams p;
NSDictionary *views;
NSString *margin;
NSMutableString *constraint;
NSArray *constraints;
if (self->c == nil)
return;
contentView = [self->w contentView];
[contentView removeConstraints:[contentView constraints]];
[self->c tFillAutoLayout:&p];
views = [NSDictionary dictionaryWithObject:p.view forKey:@"view"];
margin = @"";
if (self->margined)
margin = @"-";
// TODO always append margins even if not attached?
// or if not attached, append ->=0- as well?
constraint = [NSMutableString stringWithString:@"H:"];
if (p.attachLeft) {
[constraint appendString:@"|"];
[constraint appendString:margin];
}
[constraint appendString:@"[view]"];
if (p.attachRight) {
[constraint appendString:margin];
[constraint appendString:@"|"];
}
constraints = [NSLayoutConstraint constraintsWithVisualFormat:constraint options:0 metrics:nil views:views];
[contentView addConstraints:constraints];
// TODO do not release constraint; it's autoreleased?
constraint = [NSMutableString stringWithString:@"V:"];
if (p.attachTop) {
[constraint appendString:@"|"];
[constraint appendString:margin];
}
[constraint appendString:@"[view]"];
if (p.attachBottom) {
[constraint appendString:margin];
[constraint appendString:@"|"];
}
constraints = [NSLayoutConstraint constraintsWithVisualFormat:constraint options:0 metrics:nil views:views];
[contentView addConstraints:constraints];
// TODO do not release constraint; it's autoreleased?
// TODO do not release views; it's autoreleased?
// (for all of these, look up whether the constructor autoreleases)
}
@end