objc2_foundation/generated/
NSGeometry.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspointpointer?language=objc)
12#[cfg(feature = "objc2-core-foundation")]
13pub type NSPointPointer = *mut NSPoint;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspointarray?language=objc)
16#[cfg(feature = "objc2-core-foundation")]
17pub type NSPointArray = *mut NSPoint;
18
19/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssizepointer?language=objc)
20#[cfg(feature = "objc2-core-foundation")]
21pub type NSSizePointer = *mut NSSize;
22
23/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssizearray?language=objc)
24#[cfg(feature = "objc2-core-foundation")]
25pub type NSSizeArray = *mut NSSize;
26
27/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrectpointer?language=objc)
28#[cfg(feature = "objc2-core-foundation")]
29pub type NSRectPointer = *mut NSRect;
30
31/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrectarray?language=objc)
32#[cfg(feature = "objc2-core-foundation")]
33pub type NSRectArray = *mut NSRect;
34
35/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsedgeinsets?language=objc)
36#[cfg(feature = "objc2-core-foundation")]
37#[repr(C)]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub struct NSEdgeInsets {
40    pub top: CGFloat,
41    pub left: CGFloat,
42    pub bottom: CGFloat,
43    pub right: CGFloat,
44}
45
46#[cfg(feature = "objc2-core-foundation")]
47unsafe impl Encode for NSEdgeInsets {
48    const ENCODING: Encoding = Encoding::Struct(
49        "NSEdgeInsets",
50        &[
51            <CGFloat>::ENCODING,
52            <CGFloat>::ENCODING,
53            <CGFloat>::ENCODING,
54            <CGFloat>::ENCODING,
55        ],
56    );
57}
58
59#[cfg(feature = "objc2-core-foundation")]
60unsafe impl RefEncode for NSEdgeInsets {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64#[cfg(feature = "objc2-core-foundation")]
65unsafe impl Send for NSEdgeInsets {}
66
67#[cfg(feature = "objc2-core-foundation")]
68unsafe impl Sync for NSEdgeInsets {}
69
70/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsalignmentoptions?language=objc)
71// NS_OPTIONS
72#[repr(transparent)]
73#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
74pub struct NSAlignmentOptions(pub c_ulonglong);
75bitflags::bitflags! {
76    impl NSAlignmentOptions: c_ulonglong {
77        #[doc(alias = "NSAlignMinXInward")]
78        const AlignMinXInward = 1<<0;
79        #[doc(alias = "NSAlignMinYInward")]
80        const AlignMinYInward = 1<<1;
81        #[doc(alias = "NSAlignMaxXInward")]
82        const AlignMaxXInward = 1<<2;
83        #[doc(alias = "NSAlignMaxYInward")]
84        const AlignMaxYInward = 1<<3;
85        #[doc(alias = "NSAlignWidthInward")]
86        const AlignWidthInward = 1<<4;
87        #[doc(alias = "NSAlignHeightInward")]
88        const AlignHeightInward = 1<<5;
89        #[doc(alias = "NSAlignMinXOutward")]
90        const AlignMinXOutward = 1<<8;
91        #[doc(alias = "NSAlignMinYOutward")]
92        const AlignMinYOutward = 1<<9;
93        #[doc(alias = "NSAlignMaxXOutward")]
94        const AlignMaxXOutward = 1<<10;
95        #[doc(alias = "NSAlignMaxYOutward")]
96        const AlignMaxYOutward = 1<<11;
97        #[doc(alias = "NSAlignWidthOutward")]
98        const AlignWidthOutward = 1<<12;
99        #[doc(alias = "NSAlignHeightOutward")]
100        const AlignHeightOutward = 1<<13;
101        #[doc(alias = "NSAlignMinXNearest")]
102        const AlignMinXNearest = 1<<16;
103        #[doc(alias = "NSAlignMinYNearest")]
104        const AlignMinYNearest = 1<<17;
105        #[doc(alias = "NSAlignMaxXNearest")]
106        const AlignMaxXNearest = 1<<18;
107        #[doc(alias = "NSAlignMaxYNearest")]
108        const AlignMaxYNearest = 1<<19;
109        #[doc(alias = "NSAlignWidthNearest")]
110        const AlignWidthNearest = 1<<20;
111        #[doc(alias = "NSAlignHeightNearest")]
112        const AlignHeightNearest = 1<<21;
113        #[doc(alias = "NSAlignRectFlipped")]
114        const AlignRectFlipped = 1<<63;
115        #[doc(alias = "NSAlignAllEdgesInward")]
116        const AlignAllEdgesInward = NSAlignmentOptions::AlignMinXInward.0|NSAlignmentOptions::AlignMaxXInward.0|NSAlignmentOptions::AlignMinYInward.0|NSAlignmentOptions::AlignMaxYInward.0;
117        #[doc(alias = "NSAlignAllEdgesOutward")]
118        const AlignAllEdgesOutward = NSAlignmentOptions::AlignMinXOutward.0|NSAlignmentOptions::AlignMaxXOutward.0|NSAlignmentOptions::AlignMinYOutward.0|NSAlignmentOptions::AlignMaxYOutward.0;
119        #[doc(alias = "NSAlignAllEdgesNearest")]
120        const AlignAllEdgesNearest = NSAlignmentOptions::AlignMinXNearest.0|NSAlignmentOptions::AlignMaxXNearest.0|NSAlignmentOptions::AlignMinYNearest.0|NSAlignmentOptions::AlignMaxYNearest.0;
121    }
122}
123
124unsafe impl Encode for NSAlignmentOptions {
125    const ENCODING: Encoding = c_ulonglong::ENCODING;
126}
127
128unsafe impl RefEncode for NSAlignmentOptions {
129    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
130}
131
132extern "C" {
133    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nszeropoint?language=objc)
134    #[cfg(feature = "objc2-core-foundation")]
135    pub static NSZeroPoint: NSPoint;
136}
137
138extern "C" {
139    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nszerosize?language=objc)
140    #[cfg(feature = "objc2-core-foundation")]
141    pub static NSZeroSize: NSSize;
142}
143
144extern "C" {
145    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nszerorect?language=objc)
146    #[cfg(feature = "objc2-core-foundation")]
147    pub static NSZeroRect: NSRect;
148}
149
150extern "C" {
151    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsedgeinsetszero?language=objc)
152    #[cfg(feature = "objc2-core-foundation")]
153    pub static NSEdgeInsetsZero: NSEdgeInsets;
154}
155
156// TODO: pub fn NSMakePoint(x: CGFloat,y: CGFloat,) -> NSPoint;
157
158// TODO: pub fn NSMakeSize(w: CGFloat,h: CGFloat,) -> NSSize;
159
160// TODO: pub fn NSMakeRect(x: CGFloat,y: CGFloat,w: CGFloat,h: CGFloat,) -> NSRect;
161
162// TODO: pub fn NSMaxX(a_rect: NSRect,) -> CGFloat;
163
164// TODO: pub fn NSMaxY(a_rect: NSRect,) -> CGFloat;
165
166// TODO: pub fn NSMidX(a_rect: NSRect,) -> CGFloat;
167
168// TODO: pub fn NSMidY(a_rect: NSRect,) -> CGFloat;
169
170// TODO: pub fn NSMinX(a_rect: NSRect,) -> CGFloat;
171
172// TODO: pub fn NSMinY(a_rect: NSRect,) -> CGFloat;
173
174// TODO: pub fn NSWidth(a_rect: NSRect,) -> CGFloat;
175
176// TODO: pub fn NSHeight(a_rect: NSRect,) -> CGFloat;
177
178// TODO: pub fn NSRectFromCGRect(cgrect: CGRect,) -> NSRect;
179
180// TODO: pub fn NSRectToCGRect(nsrect: NSRect,) -> CGRect;
181
182// TODO: pub fn NSPointFromCGPoint(cgpoint: CGPoint,) -> NSPoint;
183
184// TODO: pub fn NSPointToCGPoint(nspoint: NSPoint,) -> CGPoint;
185
186// TODO: pub fn NSSizeFromCGSize(cgsize: CGSize,) -> NSSize;
187
188// TODO: pub fn NSSizeToCGSize(nssize: NSSize,) -> CGSize;
189
190// TODO: pub fn NSEdgeInsetsMake(top: CGFloat,left: CGFloat,bottom: CGFloat,right: CGFloat,) -> NSEdgeInsets;
191
192#[cfg(feature = "objc2-core-foundation")]
193#[inline]
194pub unsafe extern "C-unwind" fn NSEqualPoints(a_point: NSPoint, b_point: NSPoint) -> bool {
195    extern "C-unwind" {
196        fn NSEqualPoints(a_point: NSPoint, b_point: NSPoint) -> Bool;
197    }
198    unsafe { NSEqualPoints(a_point, b_point) }.as_bool()
199}
200
201#[cfg(feature = "objc2-core-foundation")]
202#[inline]
203pub unsafe extern "C-unwind" fn NSEqualSizes(a_size: NSSize, b_size: NSSize) -> bool {
204    extern "C-unwind" {
205        fn NSEqualSizes(a_size: NSSize, b_size: NSSize) -> Bool;
206    }
207    unsafe { NSEqualSizes(a_size, b_size) }.as_bool()
208}
209
210#[cfg(feature = "objc2-core-foundation")]
211#[inline]
212pub unsafe extern "C-unwind" fn NSEqualRects(a_rect: NSRect, b_rect: NSRect) -> bool {
213    extern "C-unwind" {
214        fn NSEqualRects(a_rect: NSRect, b_rect: NSRect) -> Bool;
215    }
216    unsafe { NSEqualRects(a_rect, b_rect) }.as_bool()
217}
218
219#[cfg(feature = "objc2-core-foundation")]
220#[inline]
221pub unsafe extern "C-unwind" fn NSIsEmptyRect(a_rect: NSRect) -> bool {
222    extern "C-unwind" {
223        fn NSIsEmptyRect(a_rect: NSRect) -> Bool;
224    }
225    unsafe { NSIsEmptyRect(a_rect) }.as_bool()
226}
227
228#[cfg(feature = "objc2-core-foundation")]
229#[inline]
230pub unsafe extern "C-unwind" fn NSEdgeInsetsEqual(
231    a_insets: NSEdgeInsets,
232    b_insets: NSEdgeInsets,
233) -> bool {
234    extern "C-unwind" {
235        fn NSEdgeInsetsEqual(a_insets: NSEdgeInsets, b_insets: NSEdgeInsets) -> Bool;
236    }
237    unsafe { NSEdgeInsetsEqual(a_insets, b_insets) }.as_bool()
238}
239
240extern "C-unwind" {
241    #[cfg(feature = "objc2-core-foundation")]
242    pub fn NSInsetRect(a_rect: NSRect, d_x: CGFloat, d_y: CGFloat) -> NSRect;
243}
244
245extern "C-unwind" {
246    #[cfg(feature = "objc2-core-foundation")]
247    pub fn NSIntegralRect(a_rect: NSRect) -> NSRect;
248}
249
250extern "C-unwind" {
251    #[cfg(feature = "objc2-core-foundation")]
252    pub fn NSIntegralRectWithOptions(a_rect: NSRect, opts: NSAlignmentOptions) -> NSRect;
253}
254
255extern "C-unwind" {
256    #[cfg(feature = "objc2-core-foundation")]
257    pub fn NSUnionRect(a_rect: NSRect, b_rect: NSRect) -> NSRect;
258}
259
260extern "C-unwind" {
261    #[cfg(feature = "objc2-core-foundation")]
262    pub fn NSIntersectionRect(a_rect: NSRect, b_rect: NSRect) -> NSRect;
263}
264
265extern "C-unwind" {
266    #[cfg(feature = "objc2-core-foundation")]
267    pub fn NSOffsetRect(a_rect: NSRect, d_x: CGFloat, d_y: CGFloat) -> NSRect;
268}
269
270extern "C-unwind" {
271    #[cfg(feature = "objc2-core-foundation")]
272    pub fn NSDivideRect(
273        in_rect: NSRect,
274        slice: NonNull<NSRect>,
275        rem: NonNull<NSRect>,
276        amount: CGFloat,
277        edge: NSRectEdge,
278    );
279}
280
281#[cfg(feature = "objc2-core-foundation")]
282#[inline]
283pub unsafe extern "C-unwind" fn NSPointInRect(a_point: NSPoint, a_rect: NSRect) -> bool {
284    extern "C-unwind" {
285        fn NSPointInRect(a_point: NSPoint, a_rect: NSRect) -> Bool;
286    }
287    unsafe { NSPointInRect(a_point, a_rect) }.as_bool()
288}
289
290#[cfg(feature = "objc2-core-foundation")]
291#[inline]
292pub unsafe extern "C-unwind" fn NSMouseInRect(
293    a_point: NSPoint,
294    a_rect: NSRect,
295    flipped: bool,
296) -> bool {
297    extern "C-unwind" {
298        fn NSMouseInRect(a_point: NSPoint, a_rect: NSRect, flipped: Bool) -> Bool;
299    }
300    unsafe { NSMouseInRect(a_point, a_rect, Bool::new(flipped)) }.as_bool()
301}
302
303#[cfg(feature = "objc2-core-foundation")]
304#[inline]
305pub unsafe extern "C-unwind" fn NSContainsRect(a_rect: NSRect, b_rect: NSRect) -> bool {
306    extern "C-unwind" {
307        fn NSContainsRect(a_rect: NSRect, b_rect: NSRect) -> Bool;
308    }
309    unsafe { NSContainsRect(a_rect, b_rect) }.as_bool()
310}
311
312#[cfg(feature = "objc2-core-foundation")]
313#[inline]
314pub unsafe extern "C-unwind" fn NSIntersectsRect(a_rect: NSRect, b_rect: NSRect) -> bool {
315    extern "C-unwind" {
316        fn NSIntersectsRect(a_rect: NSRect, b_rect: NSRect) -> Bool;
317    }
318    unsafe { NSIntersectsRect(a_rect, b_rect) }.as_bool()
319}
320
321#[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
322#[inline]
323pub unsafe extern "C-unwind" fn NSStringFromPoint(a_point: NSPoint) -> Retained<NSString> {
324    extern "C-unwind" {
325        fn NSStringFromPoint(a_point: NSPoint) -> *mut NSString;
326    }
327    let ret = unsafe { NSStringFromPoint(a_point) };
328    unsafe { Retained::retain_autoreleased(ret) }
329        .expect("function was marked as returning non-null, but actually returned NULL")
330}
331
332#[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
333#[inline]
334pub unsafe extern "C-unwind" fn NSStringFromSize(a_size: NSSize) -> Retained<NSString> {
335    extern "C-unwind" {
336        fn NSStringFromSize(a_size: NSSize) -> *mut NSString;
337    }
338    let ret = unsafe { NSStringFromSize(a_size) };
339    unsafe { Retained::retain_autoreleased(ret) }
340        .expect("function was marked as returning non-null, but actually returned NULL")
341}
342
343#[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
344#[inline]
345pub unsafe extern "C-unwind" fn NSStringFromRect(a_rect: NSRect) -> Retained<NSString> {
346    extern "C-unwind" {
347        fn NSStringFromRect(a_rect: NSRect) -> *mut NSString;
348    }
349    let ret = unsafe { NSStringFromRect(a_rect) };
350    unsafe { Retained::retain_autoreleased(ret) }
351        .expect("function was marked as returning non-null, but actually returned NULL")
352}
353
354extern "C-unwind" {
355    #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
356    pub fn NSPointFromString(a_string: &NSString) -> NSPoint;
357}
358
359extern "C-unwind" {
360    #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
361    pub fn NSSizeFromString(a_string: &NSString) -> NSSize;
362}
363
364extern "C-unwind" {
365    #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
366    pub fn NSRectFromString(a_string: &NSString) -> NSRect;
367}
368
369/// NSValueGeometryExtensions.
370#[cfg(feature = "NSValue")]
371impl NSValue {
372    extern_methods!(
373        #[cfg(feature = "objc2-core-foundation")]
374        #[unsafe(method(valueWithPoint:))]
375        #[unsafe(method_family = none)]
376        pub unsafe fn valueWithPoint(point: NSPoint) -> Retained<NSValue>;
377
378        #[cfg(feature = "objc2-core-foundation")]
379        #[unsafe(method(valueWithSize:))]
380        #[unsafe(method_family = none)]
381        pub unsafe fn valueWithSize(size: NSSize) -> Retained<NSValue>;
382
383        #[cfg(feature = "objc2-core-foundation")]
384        #[unsafe(method(valueWithRect:))]
385        #[unsafe(method_family = none)]
386        pub unsafe fn valueWithRect(rect: NSRect) -> Retained<NSValue>;
387
388        #[cfg(feature = "objc2-core-foundation")]
389        #[unsafe(method(valueWithEdgeInsets:))]
390        #[unsafe(method_family = none)]
391        pub unsafe fn valueWithEdgeInsets(insets: NSEdgeInsets) -> Retained<NSValue>;
392
393        #[cfg(feature = "objc2-core-foundation")]
394        #[unsafe(method(pointValue))]
395        #[unsafe(method_family = none)]
396        pub unsafe fn pointValue(&self) -> NSPoint;
397
398        #[cfg(feature = "objc2-core-foundation")]
399        #[unsafe(method(sizeValue))]
400        #[unsafe(method_family = none)]
401        pub unsafe fn sizeValue(&self) -> NSSize;
402
403        #[cfg(feature = "objc2-core-foundation")]
404        #[unsafe(method(rectValue))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn rectValue(&self) -> NSRect;
407
408        #[cfg(feature = "objc2-core-foundation")]
409        #[unsafe(method(edgeInsetsValue))]
410        #[unsafe(method_family = none)]
411        pub unsafe fn edgeInsetsValue(&self) -> NSEdgeInsets;
412    );
413}
414
415/// NSGeometryCoding.
416#[cfg(feature = "NSCoder")]
417impl NSCoder {
418    extern_methods!(
419        #[cfg(feature = "objc2-core-foundation")]
420        #[unsafe(method(encodePoint:))]
421        #[unsafe(method_family = none)]
422        pub unsafe fn encodePoint(&self, point: NSPoint);
423
424        #[cfg(feature = "objc2-core-foundation")]
425        #[unsafe(method(decodePoint))]
426        #[unsafe(method_family = none)]
427        pub unsafe fn decodePoint(&self) -> NSPoint;
428
429        #[cfg(feature = "objc2-core-foundation")]
430        #[unsafe(method(encodeSize:))]
431        #[unsafe(method_family = none)]
432        pub unsafe fn encodeSize(&self, size: NSSize);
433
434        #[cfg(feature = "objc2-core-foundation")]
435        #[unsafe(method(decodeSize))]
436        #[unsafe(method_family = none)]
437        pub unsafe fn decodeSize(&self) -> NSSize;
438
439        #[cfg(feature = "objc2-core-foundation")]
440        #[unsafe(method(encodeRect:))]
441        #[unsafe(method_family = none)]
442        pub unsafe fn encodeRect(&self, rect: NSRect);
443
444        #[cfg(feature = "objc2-core-foundation")]
445        #[unsafe(method(decodeRect))]
446        #[unsafe(method_family = none)]
447        pub unsafe fn decodeRect(&self) -> NSRect;
448    );
449}
450
451/// NSGeometryKeyedCoding.
452#[cfg(feature = "NSCoder")]
453impl NSCoder {
454    extern_methods!(
455        #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
456        #[unsafe(method(encodePoint:forKey:))]
457        #[unsafe(method_family = none)]
458        pub unsafe fn encodePoint_forKey(&self, point: NSPoint, key: &NSString);
459
460        #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
461        #[unsafe(method(encodeSize:forKey:))]
462        #[unsafe(method_family = none)]
463        pub unsafe fn encodeSize_forKey(&self, size: NSSize, key: &NSString);
464
465        #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
466        #[unsafe(method(encodeRect:forKey:))]
467        #[unsafe(method_family = none)]
468        pub unsafe fn encodeRect_forKey(&self, rect: NSRect, key: &NSString);
469
470        #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
471        #[unsafe(method(decodePointForKey:))]
472        #[unsafe(method_family = none)]
473        pub unsafe fn decodePointForKey(&self, key: &NSString) -> NSPoint;
474
475        #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
476        #[unsafe(method(decodeSizeForKey:))]
477        #[unsafe(method_family = none)]
478        pub unsafe fn decodeSizeForKey(&self, key: &NSString) -> NSSize;
479
480        #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
481        #[unsafe(method(decodeRectForKey:))]
482        #[unsafe(method_family = none)]
483        pub unsafe fn decodeRectForKey(&self, key: &NSString) -> NSRect;
484    );
485}