//! 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::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
use objc2_quartz_core::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwebviewnavigationtype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIWebViewNavigationType(pub NSInteger);
impl UIWebViewNavigationType {
    #[doc(alias = "UIWebViewNavigationTypeLinkClicked")]
    pub const LinkClicked: Self = Self(0);
    #[doc(alias = "UIWebViewNavigationTypeFormSubmitted")]
    pub const FormSubmitted: Self = Self(1);
    #[doc(alias = "UIWebViewNavigationTypeBackForward")]
    pub const BackForward: Self = Self(2);
    #[doc(alias = "UIWebViewNavigationTypeReload")]
    pub const Reload: Self = Self(3);
    #[doc(alias = "UIWebViewNavigationTypeFormResubmitted")]
    pub const FormResubmitted: Self = Self(4);
    #[doc(alias = "UIWebViewNavigationTypeOther")]
    pub const Other: Self = Self(5);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwebpaginationmode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIWebPaginationMode(pub NSInteger);
impl UIWebPaginationMode {
    #[doc(alias = "UIWebPaginationModeUnpaginated")]
    pub const Unpaginated: Self = Self(0);
    #[doc(alias = "UIWebPaginationModeLeftToRight")]
    pub const LeftToRight: Self = Self(1);
    #[doc(alias = "UIWebPaginationModeTopToBottom")]
    pub const TopToBottom: Self = Self(2);
    #[doc(alias = "UIWebPaginationModeBottomToTop")]
    pub const BottomToTop: Self = Self(3);
    #[doc(alias = "UIWebPaginationModeRightToLeft")]
    pub const RightToLeft: Self = Self(4);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwebpaginationbreakingmode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIWebPaginationBreakingMode(pub NSInteger);
impl UIWebPaginationBreakingMode {
    #[doc(alias = "UIWebPaginationBreakingModePage")]
    pub const Page: Self = Self(0);
    #[doc(alias = "UIWebPaginationBreakingModeColumn")]
    pub const Column: Self = Self(1);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwebview?language=objc)
    #[unsafe(super(UIView, UIResponder, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "UIResponder", feature = "UIView"))]
    #[deprecated = "No longer supported; please adopt WKWebView."]
    pub struct UIWebView;
);

#[cfg(all(
    feature = "UIResponder",
    feature = "UIView",
    feature = "objc2-quartz-core"
))]
#[cfg(not(target_os = "watchos"))]
extern_conformance!(
    unsafe impl CALayerDelegate for UIWebView {}
);

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl NSCoding for UIWebView {}
);

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for UIWebView {}
);

#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIAppearance for UIWebView {}
);

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

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UICoordinateSpace for UIWebView {}
);

#[cfg(all(
    feature = "UIDynamicBehavior",
    feature = "UIResponder",
    feature = "UIView"
))]
extern_conformance!(
    unsafe impl UIDynamicItem for UIWebView {}
);

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

#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIFocusItem for UIWebView {}
);

#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIFocusItemContainer for UIWebView {}
);

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIResponderStandardEditActions for UIWebView {}
);

#[cfg(all(feature = "UIResponder", feature = "UIScrollView", feature = "UIView"))]
extern_conformance!(
    unsafe impl UIScrollViewDelegate for UIWebView {}
);

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

#[cfg(all(feature = "UIResponder", feature = "UIView"))]
impl UIWebView {
    extern_methods!(
        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UIWebViewDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// # Safety
        ///
        /// This is unretained, you must ensure the object is kept alive while in use.
        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn UIWebViewDelegate>>);

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

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(loadRequest:))]
        #[unsafe(method_family = none)]
        pub fn loadRequest(&self, request: &NSURLRequest);

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(loadHTMLString:baseURL:))]
        #[unsafe(method_family = none)]
        pub fn loadHTMLString_baseURL(&self, string: &NSString, base_url: Option<&NSURL>);

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(loadData:MIMEType:textEncodingName:baseURL:))]
        #[unsafe(method_family = none)]
        pub fn loadData_MIMEType_textEncodingName_baseURL(
            &self,
            data: &NSData,
            mime_type: &NSString,
            text_encoding_name: &NSString,
            base_url: &NSURL,
        );

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(request))]
        #[unsafe(method_family = none)]
        pub fn request(&self) -> Option<Retained<NSURLRequest>>;

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(reload))]
        #[unsafe(method_family = none)]
        pub fn reload(&self);

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(stopLoading))]
        #[unsafe(method_family = none)]
        pub fn stopLoading(&self);

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(goBack))]
        #[unsafe(method_family = none)]
        pub fn goBack(&self);

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(goForward))]
        #[unsafe(method_family = none)]
        pub fn goForward(&self);

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(canGoBack))]
        #[unsafe(method_family = none)]
        pub fn canGoBack(&self) -> bool;

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(canGoForward))]
        #[unsafe(method_family = none)]
        pub fn canGoForward(&self) -> bool;

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(isLoading))]
        #[unsafe(method_family = none)]
        pub fn isLoading(&self) -> bool;

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(stringByEvaluatingJavaScriptFromString:))]
        #[unsafe(method_family = none)]
        pub fn stringByEvaluatingJavaScriptFromString(
            &self,
            script: &NSString,
        ) -> Option<Retained<NSString>>;

        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(scalesPageToFit))]
        #[unsafe(method_family = none)]
        pub fn scalesPageToFit(&self) -> bool;

        /// Setter for [`scalesPageToFit`][Self::scalesPageToFit].
        #[deprecated = "No longer supported; please adopt WKWebView."]
        #[unsafe(method(setScalesPageToFit:))]
        #[unsafe(method_family = none)]
        pub fn setScalesPageToFit(&self, scales_page_to_fit: bool);

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

        /// Setter for [`detectsPhoneNumbers`][Self::detectsPhoneNumbers].
        #[deprecated]
        #[unsafe(method(setDetectsPhoneNumbers:))]
        #[unsafe(method_family = none)]
        pub fn setDetectsPhoneNumbers(&self, detects_phone_numbers: bool);

        #[cfg(feature = "UIDataDetectors")]
        #[unsafe(method(dataDetectorTypes))]
        #[unsafe(method_family = none)]
        pub fn dataDetectorTypes(&self) -> UIDataDetectorTypes;

        #[cfg(feature = "UIDataDetectors")]
        /// Setter for [`dataDetectorTypes`][Self::dataDetectorTypes].
        #[unsafe(method(setDataDetectorTypes:))]
        #[unsafe(method_family = none)]
        pub fn setDataDetectorTypes(&self, data_detector_types: UIDataDetectorTypes);

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

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

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

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

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

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

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

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

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

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

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

        /// Setter for [`paginationMode`][Self::paginationMode].
        #[unsafe(method(setPaginationMode:))]
        #[unsafe(method_family = none)]
        pub fn setPaginationMode(&self, pagination_mode: UIWebPaginationMode);

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

        /// Setter for [`paginationBreakingMode`][Self::paginationBreakingMode].
        #[unsafe(method(setPaginationBreakingMode:))]
        #[unsafe(method_family = none)]
        pub fn setPaginationBreakingMode(
            &self,
            pagination_breaking_mode: UIWebPaginationBreakingMode,
        );

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

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

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

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

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

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

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

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

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

/// Methods declared on superclass `UIView`.
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
impl UIWebView {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

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

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwebviewdelegate?language=objc)
    pub unsafe trait UIWebViewDelegate: NSObjectProtocol + MainThreadOnly {
        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "No longer supported."]
        #[optional]
        #[unsafe(method(webView:shouldStartLoadWithRequest:navigationType:))]
        #[unsafe(method_family = none)]
        fn webView_shouldStartLoadWithRequest_navigationType(
            &self,
            web_view: &UIWebView,
            request: &NSURLRequest,
            navigation_type: UIWebViewNavigationType,
        ) -> bool;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "No longer supported."]
        #[optional]
        #[unsafe(method(webViewDidStartLoad:))]
        #[unsafe(method_family = none)]
        fn webViewDidStartLoad(&self, web_view: &UIWebView);

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "No longer supported."]
        #[optional]
        #[unsafe(method(webViewDidFinishLoad:))]
        #[unsafe(method_family = none)]
        fn webViewDidFinishLoad(&self, web_view: &UIWebView);

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "No longer supported."]
        #[optional]
        #[unsafe(method(webView:didFailLoadWithError:))]
        #[unsafe(method_family = none)]
        fn webView_didFailLoadWithError(&self, web_view: &UIWebView, error: &NSError);
    }
);
