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/nstextcursoraccessoryplacement?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextCursorAccessoryPlacement(pub NSInteger);
impl NSTextCursorAccessoryPlacement {
    #[doc(alias = "NSTextCursorAccessoryPlacementUnspecified")]
    pub const Unspecified: Self = Self(0);
    #[doc(alias = "NSTextCursorAccessoryPlacementBackward")]
    pub const Backward: Self = Self(1);
    #[doc(alias = "NSTextCursorAccessoryPlacementForward")]
    pub const Forward: Self = Self(2);
    #[doc(alias = "NSTextCursorAccessoryPlacementInvisible")]
    pub const Invisible: Self = Self(3);
    #[doc(alias = "NSTextCursorAccessoryPlacementCenter")]
    pub const Center: Self = Self(4);
    #[doc(alias = "NSTextCursorAccessoryPlacementOffscreenLeft")]
    pub const OffscreenLeft: Self = Self(5);
    #[doc(alias = "NSTextCursorAccessoryPlacementOffscreenTop")]
    pub const OffscreenTop: Self = Self(6);
    #[doc(alias = "NSTextCursorAccessoryPlacementOffscreenRight")]
    pub const OffscreenRight: Self = Self(7);
    #[doc(alias = "NSTextCursorAccessoryPlacementOffscreenBottom")]
    pub const OffscreenBottom: Self = Self(8);
}

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

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextinputclient?language=objc)
    pub unsafe trait NSTextInputClient {
        /// # Safety
        ///
        /// `string` should be of the correct type.
        #[unsafe(method(insertText:replacementRange:))]
        #[unsafe(method_family = none)]
        unsafe fn insertText_replacementRange(
            &self,
            string: &AnyObject,
            replacement_range: NSRange,
        );

        /// # Safety
        ///
        /// `selector` must be a valid selector.
        #[unsafe(method(doCommandBySelector:))]
        #[unsafe(method_family = none)]
        unsafe fn doCommandBySelector(&self, selector: Sel);

        /// # Safety
        ///
        /// `string` should be of the correct type.
        #[unsafe(method(setMarkedText:selectedRange:replacementRange:))]
        #[unsafe(method_family = none)]
        unsafe fn setMarkedText_selectedRange_replacementRange(
            &self,
            string: &AnyObject,
            selected_range: NSRange,
            replacement_range: NSRange,
        );

        #[unsafe(method(unmarkText))]
        #[unsafe(method_family = none)]
        fn unmarkText(&self);

        #[unsafe(method(selectedRange))]
        #[unsafe(method_family = none)]
        fn selectedRange(&self) -> NSRange;

        #[unsafe(method(markedRange))]
        #[unsafe(method_family = none)]
        fn markedRange(&self) -> NSRange;

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

        /// # Safety
        ///
        /// `actual_range` must be a valid pointer or null.
        #[unsafe(method(attributedSubstringForProposedRange:actualRange:))]
        #[unsafe(method_family = none)]
        unsafe fn attributedSubstringForProposedRange_actualRange(
            &self,
            range: NSRange,
            actual_range: NSRangePointer,
        ) -> Option<Retained<NSAttributedString>>;

        #[unsafe(method(validAttributesForMarkedText))]
        #[unsafe(method_family = none)]
        fn validAttributesForMarkedText(&self) -> Retained<NSArray<NSAttributedStringKey>>;

        /// # Safety
        ///
        /// `actual_range` must be a valid pointer or null.
        #[unsafe(method(firstRectForCharacterRange:actualRange:))]
        #[unsafe(method_family = none)]
        unsafe fn firstRectForCharacterRange_actualRange(
            &self,
            range: NSRange,
            actual_range: NSRangePointer,
        ) -> NSRect;

        #[unsafe(method(characterIndexForPoint:))]
        #[unsafe(method_family = none)]
        fn characterIndexForPoint(&self, point: NSPoint) -> NSUInteger;

        #[optional]
        #[unsafe(method(attributedString))]
        #[unsafe(method_family = none)]
        fn attributedString(&self) -> Retained<NSAttributedString>;

        #[cfg(feature = "objc2-core-foundation")]
        #[optional]
        #[unsafe(method(fractionOfDistanceThroughGlyphForPoint:))]
        #[unsafe(method_family = none)]
        fn fractionOfDistanceThroughGlyphForPoint(&self, point: NSPoint) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        #[optional]
        #[unsafe(method(baselineDeltaForCharacterAtIndex:))]
        #[unsafe(method_family = none)]
        fn baselineDeltaForCharacterAtIndex(&self, an_index: NSUInteger) -> CGFloat;

        #[optional]
        #[unsafe(method(windowLevel))]
        #[unsafe(method_family = none)]
        fn windowLevel(&self) -> NSInteger;

        #[optional]
        #[unsafe(method(drawsVerticallyForCharacterAtIndex:))]
        #[unsafe(method_family = none)]
        fn drawsVerticallyForCharacterAtIndex(&self, char_index: NSUInteger) -> bool;

        #[optional]
        #[unsafe(method(preferredTextAccessoryPlacement))]
        #[unsafe(method_family = none)]
        fn preferredTextAccessoryPlacement(&self) -> NSTextCursorAccessoryPlacement;

        #[optional]
        #[unsafe(method(unionRectInVisibleSelectedRange))]
        #[unsafe(method_family = none)]
        fn unionRectInVisibleSelectedRange(&self) -> NSRect;

        #[optional]
        #[unsafe(method(documentVisibleRect))]
        #[unsafe(method_family = none)]
        fn documentVisibleRect(&self) -> NSRect;

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

        #[cfg(feature = "NSAdaptiveImageGlyph")]
        #[optional]
        #[unsafe(method(insertAdaptiveImageGlyph:replacementRange:))]
        #[unsafe(method_family = none)]
        fn insertAdaptiveImageGlyph_replacementRange(
            &self,
            adaptive_image_glyph: &NSAdaptiveImageGlyph,
            replacement_range: NSRange,
        );
    }
);