objc2-ui-kit 0.2.2

Bindings to the UIKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIFindSessionSearchResultDisplayStyle(pub NSInteger);
impl UIFindSessionSearchResultDisplayStyle {
    #[doc(alias = "UIFindSessionSearchResultDisplayStyleCurrentAndTotal")]
    pub const CurrentAndTotal: Self = Self(0);
    #[doc(alias = "UIFindSessionSearchResultDisplayStyleTotal")]
    pub const Total: Self = Self(1);
    #[doc(alias = "UIFindSessionSearchResultDisplayStyleNone")]
    pub const None: Self = Self(2);
}

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

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITextSearchMatchMethod(pub NSInteger);
impl UITextSearchMatchMethod {
    #[doc(alias = "UITextSearchMatchMethodContains")]
    pub const Contains: Self = Self(0);
    #[doc(alias = "UITextSearchMatchMethodStartsWith")]
    pub const StartsWith: Self = Self(1);
    #[doc(alias = "UITextSearchMatchMethodFullWord")]
    pub const FullWord: Self = Self(2);
}

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

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

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UITextSearchOptions;

    unsafe impl ClassType for UITextSearchOptions {
        type Super = NSObject;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSObjectProtocol for UITextSearchOptions {}

extern_methods!(
    unsafe impl UITextSearchOptions {
        #[method(wordMatchMethod)]
        pub unsafe fn wordMatchMethod(&self) -> UITextSearchMatchMethod;

        #[method(stringCompareOptions)]
        pub unsafe fn stringCompareOptions(&self) -> NSStringCompareOptions;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UITextSearchOptions {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UIFindSession;

    unsafe impl ClassType for UIFindSession {
        type Super = NSObject;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSObjectProtocol for UIFindSession {}

extern_methods!(
    unsafe impl UIFindSession {
        #[method(resultCount)]
        pub unsafe fn resultCount(&self) -> NSInteger;

        #[method(highlightedResultIndex)]
        pub unsafe fn highlightedResultIndex(&self) -> NSInteger;

        #[method(searchResultDisplayStyle)]
        pub unsafe fn searchResultDisplayStyle(&self) -> UIFindSessionSearchResultDisplayStyle;

        #[method(setSearchResultDisplayStyle:)]
        pub unsafe fn setSearchResultDisplayStyle(
            &self,
            search_result_display_style: UIFindSessionSearchResultDisplayStyle,
        );

        #[method(supportsReplacement)]
        pub unsafe fn supportsReplacement(&self) -> bool;

        #[method(allowsReplacementForCurrentlyHighlightedResult)]
        pub unsafe fn allowsReplacementForCurrentlyHighlightedResult(&self) -> bool;

        #[method(performSearchWithQuery:options:)]
        pub unsafe fn performSearchWithQuery_options(
            &self,
            query: &NSString,
            options: Option<&UITextSearchOptions>,
        );

        #[method(performSingleReplacementWithSearchQuery:replacementString:options:)]
        pub unsafe fn performSingleReplacementWithSearchQuery_replacementString_options(
            &self,
            search_query: &NSString,
            replacement_string: &NSString,
            options: Option<&UITextSearchOptions>,
        );

        #[method(replaceAllInstancesOfSearchQuery:withReplacementString:options:)]
        pub unsafe fn replaceAllInstancesOfSearchQuery_withReplacementString_options(
            &self,
            search_query: &NSString,
            replacement_string: &NSString,
            options: Option<&UITextSearchOptions>,
        );

        #[cfg(feature = "UITextInput")]
        #[method(highlightNextResultInDirection:)]
        pub unsafe fn highlightNextResultInDirection(&self, direction: UITextStorageDirection);

        #[method(invalidateFoundResults)]
        pub unsafe fn invalidateFoundResults(&self);

        #[deprecated]
        #[method(allowsReplacement)]
        pub unsafe fn allowsReplacement(&self) -> bool;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UIFindSession {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UITextSearchingFindSession;

    unsafe impl ClassType for UITextSearchingFindSession {
        #[inherits(NSObject)]
        type Super = UIFindSession;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSObjectProtocol for UITextSearchingFindSession {}

extern_methods!(
    unsafe impl UITextSearchingFindSession {
        #[cfg(feature = "UITextSearching")]
        #[method_id(@__retain_semantics Other searchableObject)]
        pub unsafe fn searchableObject(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UITextSearching>>>;

        #[cfg(feature = "UITextSearching")]
        #[method_id(@__retain_semantics Init initWithSearchableObject:)]
        pub unsafe fn initWithSearchableObject(
            this: Allocated<Self>,
            searchable_object: &ProtocolObject<dyn UITextSearching>,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);