//! 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::*;

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipopoverpresentationcontrollerdelegate?language=objc)
    #[cfg(feature = "UIPresentationController")]
    pub unsafe trait UIPopoverPresentationControllerDelegate:
        UIAdaptivePresentationControllerDelegate + MainThreadOnly
    {
        #[optional]
        #[unsafe(method(prepareForPopoverPresentation:))]
        #[unsafe(method_family = none)]
        fn prepareForPopoverPresentation(
            &self,
            popover_presentation_controller: &UIPopoverPresentationController,
        );

        #[deprecated]
        #[optional]
        #[unsafe(method(popoverPresentationControllerShouldDismissPopover:))]
        #[unsafe(method_family = none)]
        fn popoverPresentationControllerShouldDismissPopover(
            &self,
            popover_presentation_controller: &UIPopoverPresentationController,
        ) -> bool;

        #[deprecated]
        #[optional]
        #[unsafe(method(popoverPresentationControllerDidDismissPopover:))]
        #[unsafe(method_family = none)]
        fn popoverPresentationControllerDidDismissPopover(
            &self,
            popover_presentation_controller: &UIPopoverPresentationController,
        );

        #[cfg(all(
            feature = "UIResponder",
            feature = "UIView",
            feature = "objc2-core-foundation"
        ))]
        /// # Safety
        ///
        /// `rect` must be a valid pointer.
        #[optional]
        #[unsafe(method(popoverPresentationController:willRepositionPopoverToRect:inView:))]
        #[unsafe(method_family = none)]
        unsafe fn popoverPresentationController_willRepositionPopoverToRect_inView(
            &self,
            popover_presentation_controller: &UIPopoverPresentationController,
            rect: NonNull<CGRect>,
            view: &mut Retained<UIView>,
        );
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipopoverpresentationcontroller?language=objc)
    #[unsafe(super(UIPresentationController, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "UIPresentationController")]
    pub struct UIPopoverPresentationController;
);

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

#[cfg(all(feature = "UIAppearance", feature = "UIPresentationController"))]
extern_conformance!(
    unsafe impl UIAppearanceContainer for UIPopoverPresentationController {}
);

#[cfg(all(feature = "UIPresentationController", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl UIContentContainer for UIPopoverPresentationController {}
);

#[cfg(all(feature = "UIFocus", feature = "UIPresentationController"))]
extern_conformance!(
    unsafe impl UIFocusEnvironment for UIPopoverPresentationController {}
);

#[cfg(all(feature = "UIPresentationController", feature = "UITraitCollection"))]
extern_conformance!(
    unsafe impl UITraitEnvironment for UIPopoverPresentationController {}
);

#[cfg(feature = "UIPresentationController")]
impl UIPopoverPresentationController {
    extern_methods!(
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UIPopoverPresentationControllerDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn UIPopoverPresentationControllerDelegate>>,
        );

        #[cfg(feature = "UIPopoverSupport")]
        #[unsafe(method(permittedArrowDirections))]
        #[unsafe(method_family = none)]
        pub fn permittedArrowDirections(&self) -> UIPopoverArrowDirection;

        #[cfg(feature = "UIPopoverSupport")]
        /// Setter for [`permittedArrowDirections`][Self::permittedArrowDirections].
        #[unsafe(method(setPermittedArrowDirections:))]
        #[unsafe(method_family = none)]
        pub fn setPermittedArrowDirections(
            &self,
            permitted_arrow_directions: UIPopoverArrowDirection,
        );

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[unsafe(method(sourceView))]
        #[unsafe(method_family = none)]
        pub fn sourceView(&self) -> Option<Retained<UIView>>;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        /// Setter for [`sourceView`][Self::sourceView].
        #[unsafe(method(setSourceView:))]
        #[unsafe(method_family = none)]
        pub fn setSourceView(&self, source_view: Option<&UIView>);

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

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`sourceRect`][Self::sourceRect].
        #[unsafe(method(setSourceRect:))]
        #[unsafe(method_family = none)]
        pub fn setSourceRect(&self, source_rect: CGRect);

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

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

        #[cfg(feature = "UIPopoverPresentationControllerSourceItem")]
        #[unsafe(method(sourceItem))]
        #[unsafe(method_family = none)]
        pub fn sourceItem(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UIPopoverPresentationControllerSourceItem>>>;

        #[cfg(feature = "UIPopoverPresentationControllerSourceItem")]
        /// Setter for [`sourceItem`][Self::sourceItem].
        #[unsafe(method(setSourceItem:))]
        #[unsafe(method_family = none)]
        pub fn setSourceItem(
            &self,
            source_item: Option<&ProtocolObject<dyn UIPopoverPresentationControllerSourceItem>>,
        );

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[deprecated]
        #[unsafe(method(barButtonItem))]
        #[unsafe(method_family = none)]
        pub fn barButtonItem(&self) -> Option<Retained<UIBarButtonItem>>;

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        /// Setter for [`barButtonItem`][Self::barButtonItem].
        #[deprecated]
        #[unsafe(method(setBarButtonItem:))]
        #[unsafe(method_family = none)]
        pub fn setBarButtonItem(&self, bar_button_item: Option<&UIBarButtonItem>);

        #[cfg(feature = "UIPopoverSupport")]
        #[unsafe(method(arrowDirection))]
        #[unsafe(method_family = none)]
        pub fn arrowDirection(&self) -> UIPopoverArrowDirection;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[unsafe(method(passthroughViews))]
        #[unsafe(method_family = none)]
        pub fn passthroughViews(&self) -> Option<Retained<NSArray<UIView>>>;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        /// Setter for [`passthroughViews`][Self::passthroughViews].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPassthroughViews:))]
        #[unsafe(method_family = none)]
        pub fn setPassthroughViews(&self, passthrough_views: Option<&NSArray<UIView>>);

        #[cfg(feature = "UIColor")]
        #[unsafe(method(backgroundColor))]
        #[unsafe(method_family = none)]
        pub fn backgroundColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "UIColor")]
        /// Setter for [`backgroundColor`][Self::backgroundColor].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setBackgroundColor:))]
        #[unsafe(method_family = none)]
        pub fn setBackgroundColor(&self, background_color: Option<&UIColor>);

        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
        #[unsafe(method(popoverLayoutMargins))]
        #[unsafe(method_family = none)]
        pub fn popoverLayoutMargins(&self) -> UIEdgeInsets;

        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
        /// Setter for [`popoverLayoutMargins`][Self::popoverLayoutMargins].
        #[unsafe(method(setPopoverLayoutMargins:))]
        #[unsafe(method_family = none)]
        pub fn setPopoverLayoutMargins(&self, popover_layout_margins: UIEdgeInsets);

        #[cfg(feature = "UIPopoverBackgroundView")]
        #[unsafe(method(popoverBackgroundViewClass))]
        #[unsafe(method_family = none)]
        pub fn popoverBackgroundViewClass(&self) -> Option<&'static AnyClass>;

        #[cfg(feature = "UIPopoverBackgroundView")]
        /// Setter for [`popoverBackgroundViewClass`][Self::popoverBackgroundViewClass].
        ///
        /// # Safety
        ///
        /// `popover_background_view_class` must implement UIPopoverBackgroundViewMethods.
        #[unsafe(method(setPopoverBackgroundViewClass:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPopoverBackgroundViewClass(
            &self,
            popover_background_view_class: Option<&AnyClass>,
        );

        #[cfg(feature = "UISheetPresentationController")]
        #[unsafe(method(adaptiveSheetPresentationController))]
        #[unsafe(method_family = none)]
        pub fn adaptiveSheetPresentationController(
            &self,
        ) -> Retained<UISheetPresentationController>;
    );
}

/// Methods declared on superclass `UIPresentationController`.
#[cfg(feature = "UIPresentationController")]
impl UIPopoverPresentationController {
    extern_methods!(
        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[unsafe(method(initWithPresentedViewController:presentingViewController:))]
        #[unsafe(method_family = init)]
        pub fn initWithPresentedViewController_presentingViewController(
            this: Allocated<Self>,
            presented_view_controller: &UIViewController,
            presenting_view_controller: Option<&UIViewController>,
        ) -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "UIPresentationController")]
impl UIPopoverPresentationController {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}
