summaryrefslogtreecommitdiff
path: root/packages/cocoaint/src/appkit/NSLayoutConstraint.inc
blob: 3a4daacfef0fe679a7acba99e0e9d0eb5ca9729c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
{ Parsed from AppKit.framework NSLayoutConstraint.h }


{$ifdef TYPES}
type
  NSLayoutConstraintPtr = ^NSLayoutConstraint;
{$endif}

{$ifdef TYPES}
type
  NSLayoutRelation = NSInteger;
  NSLayoutRelationPtr = ^NSLayoutRelation;

const
  NSLayoutRelationLessThanOrEqual = -1;
  NSLayoutRelationEqual = 0;
  NSLayoutRelationGreaterThanOrEqual = 1;

type
  NSLayoutAttribute = NSInteger;
  NSLayoutAttributePtr = ^NSLayoutAttribute;

const
  NSLayoutAttributeLeft = 1;
  NSLayoutAttributeRight = 2;
  NSLayoutAttributeTop = 3;
  NSLayoutAttributeBottom = 4;
  NSLayoutAttributeLeading = 5;
  NSLayoutAttributeTrailing = 6;
  NSLayoutAttributeWidth = 7;
  NSLayoutAttributeHeight = 8;
  NSLayoutAttributeCenterX = 9;
  NSLayoutAttributeCenterY = 10;
  NSLayoutAttributeBaseline = 11;
  NSLayoutAttributeNotAnAttribute = 0;

type
  NSLayoutFormatOptions = NSUInteger;
  NSLayoutFormatOptionsPtr = ^NSLayoutFormatOptions;

const
  NSLayoutFormatAlignAllLeft = 1 shl NSLayoutAttributeLeft;
  NSLayoutFormatAlignAllRight = 1 shl NSLayoutAttributeRight;
  NSLayoutFormatAlignAllTop = 1 shl NSLayoutAttributeTop;
  NSLayoutFormatAlignAllBottom = 1 shl NSLayoutAttributeBottom;
  NSLayoutFormatAlignAllLeading = 1 shl NSLayoutAttributeLeading;
  NSLayoutFormatAlignAllTrailing = 1 shl NSLayoutAttributeTrailing;
  NSLayoutFormatAlignAllCenterX = 1 shl NSLayoutAttributeCenterX;
  NSLayoutFormatAlignAllCenterY = 1 shl NSLayoutAttributeCenterY;
  NSLayoutFormatAlignAllBaseline = 1 shl NSLayoutAttributeBaseline;
  NSLayoutFormatAlignmentMask = $FFFF;
  NSLayoutFormatDirectionLeadingToTrailing = 0 shl 16;
  NSLayoutFormatDirectionLeftToRight = 1 shl 16;
  NSLayoutFormatDirectionRightToLeft = 2 shl 16;
  NSLayoutFormatDirectionMask = $3 shl 16;

type
  NSLayoutConstraintOrientation = NSInteger;
  NSLayoutConstraintOrientationPtr = ^NSLayoutConstraintOrientation;

const
  NSLayoutConstraintOrientationHorizontal = 0;
  NSLayoutConstraintOrientationVertical = 1;
{$endif}

{$ifndef NSEDGEINSETS_DEFINED}
{$ifdef TYPES}
type
  NSEdgeInsets = record
    top: CGFloat;
    left: CGFloat;
    bottom: CGFloat;
    right: CGFloat;
  end;
type
  NSEdgeInsetsPtr = ^NSEdgeInsets;
{$endif}

{$endif}
{$ifdef TYPES}
type
  NSLayoutPriority = single { available in 10_7 };
  NSLayoutPriorityPtr = ^NSLayoutPriority { available in 10_7 };
{$endif}

{$ifdef CLASSES}

type
  NSLayoutConstraint = objcclass external (NSObject, NSAnimatablePropertyContainerProtocol)
  private
    _container: id;
    _firstItem: id;
    _secondItem: id;
    _constant: CGFloat;
    _loweredConstant: CGFloat;
    _markerAndPositiveExtraVar: id;
    _negativeExtraVar: id;
    {$if defined(__OBJC2__)}
    _layoutConstraintFlags: cuint64;
    _coefficient: single;
    _priority: NSLayoutPriority;
    {$else}
    _coefficient_: single;
    _priority_: NSLayoutPriority;
    _layoutConstraintFlags_: cuint64;
    _flange: id;
    {$endif}
  public
    class function constraintsWithVisualFormat_options_metrics_views (format: NSString; opts: NSLayoutFormatOptions; metrics: NSDictionary; views: NSDictionary): NSArray; message 'constraintsWithVisualFormat:options:metrics:views:';
    class function constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant (view1: id; attr1: NSLayoutAttribute; relation: NSLayoutRelation; view2: id; attr2: NSLayoutAttribute; multiplier: CGFloat; c: CGFloat): instancetype; message 'constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:';
    procedure setPriority(newValue: NSLayoutPriority); message 'setPriority:';
    function priority: NSLayoutPriority; message 'priority';
    procedure setShouldBeArchived(newValue: ObjCBOOL); message 'setShouldBeArchived:';
    function shouldBeArchived: ObjCBOOL; message 'shouldBeArchived';
    function firstItem: id; message 'firstItem';
    function firstAttribute: NSLayoutAttribute; message 'firstAttribute';
    function relation: NSLayoutRelation; message 'relation';
    function secondItem: id; message 'secondItem';
    function secondAttribute: NSLayoutAttribute; message 'secondAttribute';
    function multiplier: CGFloat; message 'multiplier';
    procedure setConstant(newValue: CGFloat); message 'setConstant:';
    function constant: CGFloat; message 'constant';
    procedure setActive(newValue: ObjCBOOL); message 'setActive:';
    function isActive: ObjCBOOL; message 'isActive';
    class procedure activateConstraints (constraints: NSArray); message 'activateConstraints:'; { available in 10_10, 8_0 }
    class procedure deactivateConstraints (constraints: NSArray); message 'deactivateConstraints:'; { available in 10_10, 8_0 }

    { Adopted protocols }
    function animationForKey (key: NSString): id; message 'animationForKey:'; { available in 10_5 }
    function animations: NSDictionary; message 'animations'; { available in 10_5 }
    function animator: instancetype; message 'animator'; { available in 10_5 }
    class function defaultAnimationForKey (key: NSString): id; message 'defaultAnimationForKey:'; { available in 10_5 }
    procedure setAnimations (animations_: NSDictionary); message 'setAnimations:'; { available in 10_5 }
  end;


type
  NSIdentifier = objccategory external (NSLayoutConstraint)
    procedure setIdentifier(newValue: NSString); message 'setIdentifier:';
    function identifier: NSString; message 'identifier';
  end;

type
  NSConstraintBasedLayoutInstallingConstraints = objccategory external (NSView)
    function constraints: NSArray; message 'constraints';
    procedure addConstraint (constraint: NSLayoutConstraint); message 'addConstraint:'; { available in 10_7 }
    procedure addConstraints (constraints_: NSArray); message 'addConstraints:'; { available in 10_7 }
    procedure removeConstraint (constraint: NSLayoutConstraint); message 'removeConstraint:'; { available in 10_7 }
    procedure removeConstraints (constraints_: NSArray); message 'removeConstraints:'; { available in 10_7 }
  end;

type
  NSWindow_NSConstraintBasedLayoutCoreMethods = objccategory external name 'NSConstraintBasedLayoutCoreMethods' (NSWindow)
    procedure updateConstraintsIfNeeded; message 'updateConstraintsIfNeeded'; { available in 10_7 }
    procedure layoutIfNeeded; message 'layoutIfNeeded'; { available in 10_7 }
  end;

type
  NSConstraintBasedLayoutCoreMethods = objccategory external (NSView)
    procedure updateConstraintsForSubtreeIfNeeded; message 'updateConstraintsForSubtreeIfNeeded'; { available in 10_7 }
    procedure updateConstraints; message 'updateConstraints'; { available in 10_7 }
    procedure setNeedsUpdateConstraints(newValue: ObjCBOOL); message 'setNeedsUpdateConstraints:';
    function needsUpdateConstraints: ObjCBOOL; message 'needsUpdateConstraints';
    procedure layoutSubtreeIfNeeded; message 'layoutSubtreeIfNeeded'; { available in 10_7 }
    procedure layout; message 'layout'; { available in 10_7 }
    procedure setNeedsLayout(newValue: ObjCBOOL); message 'setNeedsLayout:';
    function needsLayout: ObjCBOOL; message 'needsLayout';
  end;

type
  NSConstraintBasedCompatibility = objccategory external (NSView)
    procedure setTranslatesAutoresizingMaskIntoConstraints(newValue: ObjCBOOL); message 'setTranslatesAutoresizingMaskIntoConstraints:';
    function translatesAutoresizingMaskIntoConstraints: ObjCBOOL; message 'translatesAutoresizingMaskIntoConstraints';
    class function requiresConstraintBasedLayout: ObjCBOOL; message 'requiresConstraintBasedLayout'; { available in 10_7 }
  end;

type
  NSView_NSConstraintBasedLayoutLayering = objccategory external name 'NSConstraintBasedLayoutLayering' (NSView)
    function alignmentRectForFrame (frame_: NSRect): NSRect; message 'alignmentRectForFrame:'; { available in 10_7 }
    function frameForAlignmentRect (alignmentRect: NSRect): NSRect; message 'frameForAlignmentRect:'; { available in 10_7 }
    function alignmentRectInsets: NSEdgeInsets; message 'alignmentRectInsets';
    function baselineOffsetFromBottom: CGFloat; message 'baselineOffsetFromBottom';
    function intrinsicContentSize: NSSize; message 'intrinsicContentSize';
    procedure invalidateIntrinsicContentSize; message 'invalidateIntrinsicContentSize'; { available in 10_7 }
    function contentHuggingPriorityForOrientation (orientation: NSLayoutConstraintOrientation): NSLayoutPriority; message 'contentHuggingPriorityForOrientation:'; { available in 10_7 }
    procedure setContentHuggingPriority_forOrientation (priority: NSLayoutPriority; orientation: NSLayoutConstraintOrientation); message 'setContentHuggingPriority:forOrientation:'; { available in 10_7 }
    function contentCompressionResistancePriorityForOrientation (orientation: NSLayoutConstraintOrientation): NSLayoutPriority; message 'contentCompressionResistancePriorityForOrientation:'; { available in 10_7 }
    procedure setContentCompressionResistancePriority_forOrientation (priority: NSLayoutPriority; orientation: NSLayoutConstraintOrientation); message 'setContentCompressionResistancePriority:forOrientation:'; { available in 10_7 }
  end;

type
  NSConstraintBasedLayoutLayering = objccategory external (NSControl)
    procedure invalidateIntrinsicContentSizeForCell (cell: NSCell); message 'invalidateIntrinsicContentSizeForCell:'; { available in 10_7 }
  end;

type
  NSConstraintBasedLayoutAnchoring = objccategory external (NSWindow)
    function anchorAttributeForOrientation (orientation: NSLayoutConstraintOrientation): NSLayoutAttribute; message 'anchorAttributeForOrientation:';
    procedure setAnchorAttribute_forOrientation (attr: NSLayoutAttribute; orientation: NSLayoutConstraintOrientation); message 'setAnchorAttribute:forOrientation:';
  end;

type
  NSConstraintBasedLayoutFittingSize = objccategory external (NSView)
    function fittingSize: NSSize; message 'fittingSize';
  end;

type
  NSView_NSConstraintBasedLayoutDebugging = objccategory external name 'NSConstraintBasedLayoutDebugging' (NSView)
    function constraintsAffectingLayoutForOrientation (orientation: NSLayoutConstraintOrientation): NSArray; message 'constraintsAffectingLayoutForOrientation:'; { available in 10_7 }
    function hasAmbiguousLayout: ObjCBOOL; message 'hasAmbiguousLayout';
    procedure exerciseAmbiguityInLayout; message 'exerciseAmbiguityInLayout'; { available in 10_7 }
  end;

type
  NSConstraintBasedLayoutDebugging = objccategory external (NSWindow)
    procedure visualizeConstraints (constraints: NSArray); message 'visualizeConstraints:'; { available in 10_7 }
  end;
{$endif}