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

use crate::*;

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

    unsafe impl ClassType for NSStringDrawingContext {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for NSStringDrawingContext {}

extern_methods!(
    unsafe impl NSStringDrawingContext {
        #[method(minimumScaleFactor)]
        pub unsafe fn minimumScaleFactor(&self) -> CGFloat;

        #[method(setMinimumScaleFactor:)]
        pub unsafe fn setMinimumScaleFactor(&self, minimum_scale_factor: CGFloat);

        #[method(actualScaleFactor)]
        pub unsafe fn actualScaleFactor(&self) -> CGFloat;

        #[method(totalBounds)]
        pub unsafe fn totalBounds(&self) -> NSRect;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSStringDrawingContext {
        #[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() -> Retained<Self>;
    }
);

extern_category!(
    /// Category on [`NSString`].
    pub unsafe trait NSStringDrawing {
        #[method(sizeWithAttributes:)]
        unsafe fn sizeWithAttributes(
            &self,
            attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
        ) -> NSSize;

        #[method(drawAtPoint:withAttributes:)]
        unsafe fn drawAtPoint_withAttributes(
            &self,
            point: NSPoint,
            attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
        );

        #[method(drawInRect:withAttributes:)]
        unsafe fn drawInRect_withAttributes(
            &self,
            rect: NSRect,
            attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
        );
    }

    unsafe impl NSStringDrawing for NSString {}
);

extern_category!(
    /// Category "NSStringDrawing" on [`NSAttributedString`].
    #[doc(alias = "NSStringDrawing")]
    pub unsafe trait NSAttributedStringNSStringDrawing {
        #[method(size)]
        unsafe fn size(&self) -> NSSize;

        #[method(drawAtPoint:)]
        unsafe fn drawAtPoint(&self, point: NSPoint);

        #[method(drawInRect:)]
        unsafe fn drawInRect(&self, rect: NSRect);
    }

    unsafe impl NSAttributedStringNSStringDrawing for NSAttributedString {}
);

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSStringDrawingOptions(pub NSInteger);
bitflags::bitflags! {
    impl NSStringDrawingOptions: NSInteger {
        const NSStringDrawingUsesLineFragmentOrigin = 1<<0;
        const NSStringDrawingUsesFontLeading = 1<<1;
        const NSStringDrawingUsesDeviceMetrics = 1<<3;
        const NSStringDrawingTruncatesLastVisibleLine = 1<<5;
#[deprecated]
        const NSStringDrawingDisableScreenFontSubstitution = 1<<2;
#[deprecated]
        const NSStringDrawingOneShot = 1<<4;
    }
}

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

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

extern_category!(
    /// Category "NSExtendedStringDrawing" on [`NSString`].
    #[doc(alias = "NSExtendedStringDrawing")]
    pub unsafe trait NSStringNSExtendedStringDrawing {
        #[method(drawWithRect:options:attributes:context:)]
        unsafe fn drawWithRect_options_attributes_context(
            &self,
            rect: NSRect,
            options: NSStringDrawingOptions,
            attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
            context: Option<&NSStringDrawingContext>,
        );

        #[method(boundingRectWithSize:options:attributes:context:)]
        unsafe fn boundingRectWithSize_options_attributes_context(
            &self,
            size: NSSize,
            options: NSStringDrawingOptions,
            attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
            context: Option<&NSStringDrawingContext>,
        ) -> NSRect;
    }

    unsafe impl NSStringNSExtendedStringDrawing for NSString {}
);

extern_category!(
    /// Category "NSExtendedStringDrawing" on [`NSAttributedString`].
    #[doc(alias = "NSExtendedStringDrawing")]
    pub unsafe trait NSAttributedStringNSExtendedStringDrawing {
        #[method(drawWithRect:options:context:)]
        unsafe fn drawWithRect_options_context(
            &self,
            rect: NSRect,
            options: NSStringDrawingOptions,
            context: Option<&NSStringDrawingContext>,
        );

        #[method(boundingRectWithSize:options:context:)]
        unsafe fn boundingRectWithSize_options_context(
            &self,
            size: NSSize,
            options: NSStringDrawingOptions,
            context: Option<&NSStringDrawingContext>,
        ) -> NSRect;
    }

    unsafe impl NSAttributedStringNSExtendedStringDrawing for NSAttributedString {}
);

extern_category!(
    /// Category on [`NSString`].
    pub unsafe trait NSStringDrawingDeprecated {
        #[method(drawWithRect:options:attributes:)]
        unsafe fn drawWithRect_options_attributes(
            &self,
            rect: NSRect,
            options: NSStringDrawingOptions,
            attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
        );

        #[method(boundingRectWithSize:options:attributes:)]
        unsafe fn boundingRectWithSize_options_attributes(
            &self,
            size: NSSize,
            options: NSStringDrawingOptions,
            attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
        ) -> NSRect;
    }

    unsafe impl NSStringDrawingDeprecated for NSString {}
);

extern_category!(
    /// Category "NSStringDrawingDeprecated" on [`NSAttributedString`].
    #[doc(alias = "NSStringDrawingDeprecated")]
    pub unsafe trait NSAttributedStringNSStringDrawingDeprecated {
        #[method(drawWithRect:options:)]
        unsafe fn drawWithRect_options(&self, rect: NSRect, options: NSStringDrawingOptions);

        #[method(boundingRectWithSize:options:)]
        unsafe fn boundingRectWithSize_options(
            &self,
            size: NSSize,
            options: NSStringDrawingOptions,
        ) -> NSRect;
    }

    unsafe impl NSAttributedStringNSStringDrawingDeprecated for NSAttributedString {}
);
