objc2-app-kit 0.3.2

Bindings to the AppKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscollectionviewscrolldirection?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSCollectionViewScrollDirection(pub NSInteger);
impl NSCollectionViewScrollDirection {
    #[doc(alias = "NSCollectionViewScrollDirectionVertical")]
    pub const Vertical: Self = Self(0);
    #[doc(alias = "NSCollectionViewScrollDirectionHorizontal")]
    pub const Horizontal: Self = Self(1);
}

unsafe impl Encode for NSCollectionViewScrollDirection {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSCollectionViewScrollDirection {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscollectionelementkindsectionheader?language=objc)
    #[cfg(feature = "NSCollectionView")]
    pub static NSCollectionElementKindSectionHeader:
        &'static NSCollectionViewSupplementaryElementKind;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscollectionelementkindsectionfooter?language=objc)
    #[cfg(feature = "NSCollectionView")]
    pub static NSCollectionElementKindSectionFooter:
        &'static NSCollectionViewSupplementaryElementKind;
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscollectionviewflowlayoutinvalidationcontext?language=objc)
    #[unsafe(super(NSCollectionViewLayoutInvalidationContext, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSCollectionViewLayout")]
    pub struct NSCollectionViewFlowLayoutInvalidationContext;
);

#[cfg(feature = "NSCollectionViewLayout")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSCollectionViewFlowLayoutInvalidationContext {}
);

#[cfg(feature = "NSCollectionViewLayout")]
impl NSCollectionViewFlowLayoutInvalidationContext {
    extern_methods!(
        #[unsafe(method(invalidateFlowLayoutDelegateMetrics))]
        #[unsafe(method_family = none)]
        pub fn invalidateFlowLayoutDelegateMetrics(&self) -> bool;

        /// Setter for [`invalidateFlowLayoutDelegateMetrics`][Self::invalidateFlowLayoutDelegateMetrics].
        #[unsafe(method(setInvalidateFlowLayoutDelegateMetrics:))]
        #[unsafe(method_family = none)]
        pub fn setInvalidateFlowLayoutDelegateMetrics(
            &self,
            invalidate_flow_layout_delegate_metrics: bool,
        );

        #[unsafe(method(invalidateFlowLayoutAttributes))]
        #[unsafe(method_family = none)]
        pub fn invalidateFlowLayoutAttributes(&self) -> bool;

        /// Setter for [`invalidateFlowLayoutAttributes`][Self::invalidateFlowLayoutAttributes].
        #[unsafe(method(setInvalidateFlowLayoutAttributes:))]
        #[unsafe(method_family = none)]
        pub fn setInvalidateFlowLayoutAttributes(&self, invalidate_flow_layout_attributes: bool);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSCollectionViewLayout")]
impl NSCollectionViewFlowLayoutInvalidationContext {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscollectionviewdelegateflowlayout?language=objc)
    #[cfg(feature = "NSCollectionView")]
    pub unsafe trait NSCollectionViewDelegateFlowLayout:
        NSCollectionViewDelegate + MainThreadOnly
    {
        #[cfg(all(
            feature = "NSCollectionViewLayout",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[unsafe(method(collectionView:layout:sizeForItemAtIndexPath:))]
        #[unsafe(method_family = none)]
        fn collectionView_layout_sizeForItemAtIndexPath(
            &self,
            collection_view: &NSCollectionView,
            collection_view_layout: &NSCollectionViewLayout,
            index_path: &NSIndexPath,
        ) -> NSSize;

        #[cfg(all(
            feature = "NSCollectionViewLayout",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[unsafe(method(collectionView:layout:insetForSectionAtIndex:))]
        #[unsafe(method_family = none)]
        fn collectionView_layout_insetForSectionAtIndex(
            &self,
            collection_view: &NSCollectionView,
            collection_view_layout: &NSCollectionViewLayout,
            section: NSInteger,
        ) -> NSEdgeInsets;

        #[cfg(all(
            feature = "NSCollectionViewLayout",
            feature = "NSResponder",
            feature = "NSView",
            feature = "objc2-core-foundation"
        ))]
        #[optional]
        #[unsafe(method(collectionView:layout:minimumLineSpacingForSectionAtIndex:))]
        #[unsafe(method_family = none)]
        fn collectionView_layout_minimumLineSpacingForSectionAtIndex(
            &self,
            collection_view: &NSCollectionView,
            collection_view_layout: &NSCollectionViewLayout,
            section: NSInteger,
        ) -> CGFloat;

        #[cfg(all(
            feature = "NSCollectionViewLayout",
            feature = "NSResponder",
            feature = "NSView",
            feature = "objc2-core-foundation"
        ))]
        #[optional]
        #[unsafe(method(collectionView:layout:minimumInteritemSpacingForSectionAtIndex:))]
        #[unsafe(method_family = none)]
        fn collectionView_layout_minimumInteritemSpacingForSectionAtIndex(
            &self,
            collection_view: &NSCollectionView,
            collection_view_layout: &NSCollectionViewLayout,
            section: NSInteger,
        ) -> CGFloat;

        #[cfg(all(
            feature = "NSCollectionViewLayout",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[unsafe(method(collectionView:layout:referenceSizeForHeaderInSection:))]
        #[unsafe(method_family = none)]
        fn collectionView_layout_referenceSizeForHeaderInSection(
            &self,
            collection_view: &NSCollectionView,
            collection_view_layout: &NSCollectionViewLayout,
            section: NSInteger,
        ) -> NSSize;

        #[cfg(all(
            feature = "NSCollectionViewLayout",
            feature = "NSResponder",
            feature = "NSView"
        ))]
        #[optional]
        #[unsafe(method(collectionView:layout:referenceSizeForFooterInSection:))]
        #[unsafe(method_family = none)]
        fn collectionView_layout_referenceSizeForFooterInSection(
            &self,
            collection_view: &NSCollectionView,
            collection_view_layout: &NSCollectionViewLayout,
            section: NSInteger,
        ) -> NSSize;
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscollectionviewflowlayout?language=objc)
    #[unsafe(super(NSCollectionViewLayout, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSCollectionViewLayout")]
    pub struct NSCollectionViewFlowLayout;
);

#[cfg(feature = "NSCollectionViewLayout")]
extern_conformance!(
    unsafe impl NSCoding for NSCollectionViewFlowLayout {}
);

#[cfg(feature = "NSCollectionViewLayout")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSCollectionViewFlowLayout {}
);

#[cfg(feature = "NSCollectionViewLayout")]
impl NSCollectionViewFlowLayout {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(minimumLineSpacing))]
        #[unsafe(method_family = none)]
        pub fn minimumLineSpacing(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`minimumLineSpacing`][Self::minimumLineSpacing].
        #[unsafe(method(setMinimumLineSpacing:))]
        #[unsafe(method_family = none)]
        pub fn setMinimumLineSpacing(&self, minimum_line_spacing: CGFloat);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(minimumInteritemSpacing))]
        #[unsafe(method_family = none)]
        pub fn minimumInteritemSpacing(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`minimumInteritemSpacing`][Self::minimumInteritemSpacing].
        #[unsafe(method(setMinimumInteritemSpacing:))]
        #[unsafe(method_family = none)]
        pub fn setMinimumInteritemSpacing(&self, minimum_interitem_spacing: CGFloat);

        #[unsafe(method(itemSize))]
        #[unsafe(method_family = none)]
        pub fn itemSize(&self) -> NSSize;

        /// Setter for [`itemSize`][Self::itemSize].
        #[unsafe(method(setItemSize:))]
        #[unsafe(method_family = none)]
        pub fn setItemSize(&self, item_size: NSSize);

        #[unsafe(method(estimatedItemSize))]
        #[unsafe(method_family = none)]
        pub fn estimatedItemSize(&self) -> NSSize;

        /// Setter for [`estimatedItemSize`][Self::estimatedItemSize].
        #[unsafe(method(setEstimatedItemSize:))]
        #[unsafe(method_family = none)]
        pub fn setEstimatedItemSize(&self, estimated_item_size: NSSize);

        #[unsafe(method(scrollDirection))]
        #[unsafe(method_family = none)]
        pub fn scrollDirection(&self) -> NSCollectionViewScrollDirection;

        /// Setter for [`scrollDirection`][Self::scrollDirection].
        #[unsafe(method(setScrollDirection:))]
        #[unsafe(method_family = none)]
        pub fn setScrollDirection(&self, scroll_direction: NSCollectionViewScrollDirection);

        #[unsafe(method(headerReferenceSize))]
        #[unsafe(method_family = none)]
        pub fn headerReferenceSize(&self) -> NSSize;

        /// Setter for [`headerReferenceSize`][Self::headerReferenceSize].
        #[unsafe(method(setHeaderReferenceSize:))]
        #[unsafe(method_family = none)]
        pub fn setHeaderReferenceSize(&self, header_reference_size: NSSize);

        #[unsafe(method(footerReferenceSize))]
        #[unsafe(method_family = none)]
        pub fn footerReferenceSize(&self) -> NSSize;

        /// Setter for [`footerReferenceSize`][Self::footerReferenceSize].
        #[unsafe(method(setFooterReferenceSize:))]
        #[unsafe(method_family = none)]
        pub fn setFooterReferenceSize(&self, footer_reference_size: NSSize);

        #[unsafe(method(sectionInset))]
        #[unsafe(method_family = none)]
        pub fn sectionInset(&self) -> NSEdgeInsets;

        /// Setter for [`sectionInset`][Self::sectionInset].
        #[unsafe(method(setSectionInset:))]
        #[unsafe(method_family = none)]
        pub fn setSectionInset(&self, section_inset: NSEdgeInsets);

        #[unsafe(method(sectionHeadersPinToVisibleBounds))]
        #[unsafe(method_family = none)]
        pub fn sectionHeadersPinToVisibleBounds(&self) -> bool;

        /// Setter for [`sectionHeadersPinToVisibleBounds`][Self::sectionHeadersPinToVisibleBounds].
        #[unsafe(method(setSectionHeadersPinToVisibleBounds:))]
        #[unsafe(method_family = none)]
        pub fn setSectionHeadersPinToVisibleBounds(
            &self,
            section_headers_pin_to_visible_bounds: bool,
        );

        #[unsafe(method(sectionFootersPinToVisibleBounds))]
        #[unsafe(method_family = none)]
        pub fn sectionFootersPinToVisibleBounds(&self) -> bool;

        /// Setter for [`sectionFootersPinToVisibleBounds`][Self::sectionFootersPinToVisibleBounds].
        #[unsafe(method(setSectionFootersPinToVisibleBounds:))]
        #[unsafe(method_family = none)]
        pub fn setSectionFootersPinToVisibleBounds(
            &self,
            section_footers_pin_to_visible_bounds: bool,
        );

        #[unsafe(method(sectionAtIndexIsCollapsed:))]
        #[unsafe(method_family = none)]
        pub fn sectionAtIndexIsCollapsed(&self, section_index: NSUInteger) -> bool;

        #[unsafe(method(collapseSectionAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn collapseSectionAtIndex(&self, section_index: NSUInteger);

        #[unsafe(method(expandSectionAtIndex:))]
        #[unsafe(method_family = none)]
        pub fn expandSectionAtIndex(&self, section_index: NSUInteger);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSCollectionViewLayout")]
impl NSCollectionViewFlowLayout {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}