2020-05-10 06:26:06 +00:00
|
|
|
/* Implementation of class NSLayoutAnchor
|
|
|
|
Copyright (C) 2020 Free Software Foundation, Inc.
|
|
|
|
|
2020-05-10 10:38:06 +00:00
|
|
|
By: Gregory Casamento <greg.casamento@gmail.com>
|
2020-05-10 06:26:06 +00:00
|
|
|
Date: Sat May 9 16:30:52 EDT 2020
|
|
|
|
|
|
|
|
This file is part of the GNUstep Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110 USA.
|
|
|
|
*/
|
|
|
|
|
2020-05-10 20:38:52 +00:00
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
|
2020-05-10 06:26:06 +00:00
|
|
|
#import "AppKit/NSLayoutAnchor.h"
|
2020-05-10 20:38:52 +00:00
|
|
|
#import "AppKit/NSLayoutConstraint.h"
|
2020-05-10 06:26:06 +00:00
|
|
|
|
|
|
|
@implementation NSLayoutAnchor
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintEqualToAnchor: (NSLayoutAnchor *)anchor
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 01:34:59 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationEqual
|
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: 1.0
|
|
|
|
constant: 0.0];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintGreaterThanOrEqualToAnchor: (NSLayoutAnchor *)anchor
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 01:34:59 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationGreaterThanOrEqual
|
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: 1.0
|
|
|
|
constant: 0.0];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintLessThanOrEqualToAnchor: (NSLayoutAnchor *)anchor
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 01:34:59 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
2020-07-09 01:36:09 +00:00
|
|
|
relatedBy: NSLayoutRelationLessThanOrEqual
|
2020-07-09 01:34:59 +00:00
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: 1.0
|
|
|
|
constant: 0.0];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintEqualToAnchor: (NSLayoutAnchor *)anchor constant: (CGFloat)c
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 01:34:59 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
2020-07-09 01:36:09 +00:00
|
|
|
relatedBy: NSLayoutRelationEqual
|
2020-07-09 01:34:59 +00:00
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: 1.0
|
|
|
|
constant: 0.0];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintGreaterThanOrEqualToAnchor: (NSLayoutAnchor *)anchor constant: (CGFloat)c
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 01:34:59 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationGreaterThanOrEqual
|
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: 1.0
|
|
|
|
constant: c];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2023-11-20 21:43:49 +00:00
|
|
|
- (NSLayoutConstraint *) constraintLessThanOrEqualToAnchor: (NSLayoutAnchor *)anchor constant: (CGFloat)c
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 01:34:59 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationLessThanOrEqual
|
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: 1.0
|
|
|
|
constant: c];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype) init
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self != nil)
|
|
|
|
{
|
|
|
|
_name = nil;
|
|
|
|
_item = nil;
|
|
|
|
_hasAmbiguousLayout = NO;
|
|
|
|
_constraintsAffectingLayout = [[NSMutableArray alloc] init];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
RELEASE(_name);
|
|
|
|
RELEASE(_item);
|
|
|
|
RELEASE(_constraintsAffectingLayout);
|
|
|
|
[super dealloc];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) name
|
|
|
|
{
|
2020-07-09 01:34:59 +00:00
|
|
|
return _name;
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) item
|
|
|
|
{
|
2020-07-09 01:34:59 +00:00
|
|
|
return _item;
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasAmbiguousLayout
|
|
|
|
{
|
2020-07-09 01:34:59 +00:00
|
|
|
return _hasAmbiguousLayout;
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) constraintsAffectingLayout
|
|
|
|
{
|
2020-07-09 01:34:59 +00:00
|
|
|
return _constraintsAffectingLayout;
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
2020-05-10 20:44:48 +00:00
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)c
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)c
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) copyWithZone: (NSZone *)z
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2020-05-10 20:38:52 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSLayoutDimension
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintEqualToConstant: (CGFloat)c
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 04:57:36 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationEqual
|
|
|
|
toItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: 1.0
|
|
|
|
constant: c];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintGreaterThanOrEqualToConstant: (CGFloat)c
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 04:57:36 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationGreaterThanOrEqual
|
|
|
|
toItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: 1.0
|
|
|
|
constant: c];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintLessThanOrEqualToConstant: (CGFloat)c
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 04:57:36 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationLessThanOrEqual
|
|
|
|
toItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: 1.0
|
|
|
|
constant: c];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintEqualToAnchor: (NSLayoutDimension *)anchor multiplier: (CGFloat)m
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 04:57:36 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationEqual
|
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: m
|
|
|
|
constant: 0.0];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintGreaterThanOrEqualToAnchor: (NSLayoutDimension *)anchor multiplier: (CGFloat)m
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 04:57:36 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationGreaterThanOrEqual
|
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: m
|
|
|
|
constant: 0.0];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintLessThanOrEqualToAnchor: (NSLayoutDimension *)anchor multiplier: (CGFloat)m
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 04:57:36 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationLessThanOrEqual
|
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: m
|
|
|
|
constant: 0.0];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintEqualToAnchor: (NSLayoutDimension *)anchor multiplier: (CGFloat)m constant: (CGFloat)c
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 04:57:36 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationEqual
|
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: m
|
|
|
|
constant: c];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintGreaterThanOrEqualToAnchor: (NSLayoutDimension *)anchor multiplier: (CGFloat)m constant: (CGFloat)c
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 04:57:36 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationGreaterThanOrEqual
|
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: m
|
|
|
|
constant: c];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutConstraint *) constraintLessThanOrEqualToAnchor: (NSLayoutDimension *)anchor multiplier: (CGFloat)m constant: (CGFloat)c
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
2020-07-09 04:57:36 +00:00
|
|
|
return [NSLayoutConstraint constraintWithItem: _item
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
relatedBy: NSLayoutRelationLessThanOrEqual
|
|
|
|
toItem: [anchor item]
|
|
|
|
attribute: NSLayoutAttributeLeft
|
|
|
|
multiplier: m
|
|
|
|
constant: c];
|
2020-05-10 20:38:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-26 06:05:50 +00:00
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self != nil)
|
|
|
|
{
|
|
|
|
NSLog(@"Decoding");
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
|
|
|
{
|
|
|
|
[super encodeWithCoder: coder];
|
|
|
|
}
|
2020-05-10 20:38:52 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSLayoutXAxisAnchor
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutDimension *) anchorWithOffsetToAnchor: (NSLayoutXAxisAnchor *)anchor
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSLayoutYAxisAnchor
|
|
|
|
|
2020-05-10 20:44:48 +00:00
|
|
|
- (NSLayoutDimension *) anchorWithOffsetToAnchor: (NSLayoutYAxisAnchor *)anchor
|
2020-05-10 20:38:52 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2020-05-10 06:26:06 +00:00
|
|
|
@end
|
|
|
|
|