use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
#[doc(alias = "CTParagraphStyleRef")]
#[repr(C)]
pub struct CTParagraphStyle {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
cf_type!(
unsafe impl CTParagraphStyle {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"__CTParagraphStyle"> for CTParagraphStyle {}
);
unsafe impl ConcreteType for CTParagraphStyle {
#[doc(alias = "CTParagraphStyleGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn CTParagraphStyleGetTypeID() -> CFTypeID;
}
unsafe { CTParagraphStyleGetTypeID() }
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CTTextAlignment(pub u8);
impl CTTextAlignment {
#[doc(alias = "kCTTextAlignmentLeft")]
pub const Left: Self = Self(0);
#[doc(alias = "kCTTextAlignmentRight")]
pub const Right: Self = Self(1);
#[doc(alias = "kCTTextAlignmentCenter")]
pub const Center: Self = Self(2);
#[doc(alias = "kCTTextAlignmentJustified")]
pub const Justified: Self = Self(3);
#[doc(alias = "kCTTextAlignmentNatural")]
pub const Natural: Self = Self(4);
#[deprecated = "Deprecated"]
pub const kCTLeftTextAlignment: Self = Self(CTTextAlignment::Left.0);
#[deprecated = "Deprecated"]
pub const kCTRightTextAlignment: Self = Self(CTTextAlignment::Right.0);
#[deprecated = "Deprecated"]
pub const kCTCenterTextAlignment: Self = Self(CTTextAlignment::Center.0);
#[deprecated = "Deprecated"]
pub const kCTJustifiedTextAlignment: Self = Self(CTTextAlignment::Justified.0);
#[deprecated = "Deprecated"]
pub const kCTNaturalTextAlignment: Self = Self(CTTextAlignment::Natural.0);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CTTextAlignment {
const ENCODING: Encoding = u8::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTTextAlignment {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CTLineBreakMode(pub u8);
impl CTLineBreakMode {
#[doc(alias = "kCTLineBreakByWordWrapping")]
pub const ByWordWrapping: Self = Self(0);
#[doc(alias = "kCTLineBreakByCharWrapping")]
pub const ByCharWrapping: Self = Self(1);
#[doc(alias = "kCTLineBreakByClipping")]
pub const ByClipping: Self = Self(2);
#[doc(alias = "kCTLineBreakByTruncatingHead")]
pub const ByTruncatingHead: Self = Self(3);
#[doc(alias = "kCTLineBreakByTruncatingTail")]
pub const ByTruncatingTail: Self = Self(4);
#[doc(alias = "kCTLineBreakByTruncatingMiddle")]
pub const ByTruncatingMiddle: Self = Self(5);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CTLineBreakMode {
const ENCODING: Encoding = u8::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTLineBreakMode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CTWritingDirection(pub i8);
impl CTWritingDirection {
#[doc(alias = "kCTWritingDirectionNatural")]
pub const Natural: Self = Self(-1);
#[doc(alias = "kCTWritingDirectionLeftToRight")]
pub const LeftToRight: Self = Self(0);
#[doc(alias = "kCTWritingDirectionRightToLeft")]
pub const RightToLeft: Self = Self(1);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CTWritingDirection {
const ENCODING: Encoding = i8::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTWritingDirection {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CTParagraphStyleSpecifier(pub u32);
impl CTParagraphStyleSpecifier {
#[doc(alias = "kCTParagraphStyleSpecifierAlignment")]
pub const Alignment: Self = Self(0);
#[doc(alias = "kCTParagraphStyleSpecifierFirstLineHeadIndent")]
pub const FirstLineHeadIndent: Self = Self(1);
#[doc(alias = "kCTParagraphStyleSpecifierHeadIndent")]
pub const HeadIndent: Self = Self(2);
#[doc(alias = "kCTParagraphStyleSpecifierTailIndent")]
pub const TailIndent: Self = Self(3);
#[doc(alias = "kCTParagraphStyleSpecifierTabStops")]
pub const TabStops: Self = Self(4);
#[doc(alias = "kCTParagraphStyleSpecifierDefaultTabInterval")]
pub const DefaultTabInterval: Self = Self(5);
#[doc(alias = "kCTParagraphStyleSpecifierLineBreakMode")]
pub const LineBreakMode: Self = Self(6);
#[doc(alias = "kCTParagraphStyleSpecifierLineHeightMultiple")]
pub const LineHeightMultiple: Self = Self(7);
#[doc(alias = "kCTParagraphStyleSpecifierMaximumLineHeight")]
pub const MaximumLineHeight: Self = Self(8);
#[doc(alias = "kCTParagraphStyleSpecifierMinimumLineHeight")]
pub const MinimumLineHeight: Self = Self(9);
#[doc(alias = "kCTParagraphStyleSpecifierLineSpacing")]
#[deprecated = "See documentation for replacements"]
pub const LineSpacing: Self = Self(10);
#[doc(alias = "kCTParagraphStyleSpecifierParagraphSpacing")]
pub const ParagraphSpacing: Self = Self(11);
#[doc(alias = "kCTParagraphStyleSpecifierParagraphSpacingBefore")]
pub const ParagraphSpacingBefore: Self = Self(12);
#[doc(alias = "kCTParagraphStyleSpecifierBaseWritingDirection")]
pub const BaseWritingDirection: Self = Self(13);
#[doc(alias = "kCTParagraphStyleSpecifierMaximumLineSpacing")]
pub const MaximumLineSpacing: Self = Self(14);
#[doc(alias = "kCTParagraphStyleSpecifierMinimumLineSpacing")]
pub const MinimumLineSpacing: Self = Self(15);
#[doc(alias = "kCTParagraphStyleSpecifierLineSpacingAdjustment")]
pub const LineSpacingAdjustment: Self = Self(16);
#[doc(alias = "kCTParagraphStyleSpecifierLineBoundsOptions")]
pub const LineBoundsOptions: Self = Self(17);
#[doc(alias = "kCTParagraphStyleSpecifierCount")]
pub const Count: Self = Self(18);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CTParagraphStyleSpecifier {
const ENCODING: Encoding = u32::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTParagraphStyleSpecifier {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct CTParagraphStyleSetting {
pub spec: CTParagraphStyleSpecifier,
pub valueSize: usize,
pub value: NonNull<c_void>,
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CTParagraphStyleSetting {
const ENCODING: Encoding = Encoding::Struct(
"CTParagraphStyleSetting",
&[
<CTParagraphStyleSpecifier>::ENCODING,
<usize>::ENCODING,
<NonNull<c_void>>::ENCODING,
],
);
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTParagraphStyleSetting {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
impl CTParagraphStyle {
#[doc(alias = "CTParagraphStyleCreate")]
#[inline]
pub unsafe fn new(
settings: *const CTParagraphStyleSetting,
setting_count: usize,
) -> CFRetained<CTParagraphStyle> {
extern "C-unwind" {
fn CTParagraphStyleCreate(
settings: *const CTParagraphStyleSetting,
setting_count: usize,
) -> Option<NonNull<CTParagraphStyle>>;
}
let ret = unsafe { CTParagraphStyleCreate(settings, setting_count) };
let ret =
ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::from_raw(ret) }
}
#[doc(alias = "CTParagraphStyleCreateCopy")]
#[inline]
pub unsafe fn copy(&self) -> CFRetained<CTParagraphStyle> {
extern "C-unwind" {
fn CTParagraphStyleCreateCopy(
paragraph_style: &CTParagraphStyle,
) -> Option<NonNull<CTParagraphStyle>>;
}
let ret = unsafe { CTParagraphStyleCreateCopy(self) };
let ret =
ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::from_raw(ret) }
}
#[doc(alias = "CTParagraphStyleGetValueForSpecifier")]
#[inline]
pub unsafe fn value_for_specifier(
&self,
spec: CTParagraphStyleSpecifier,
value_buffer_size: usize,
value_buffer: NonNull<c_void>,
) -> bool {
extern "C-unwind" {
fn CTParagraphStyleGetValueForSpecifier(
paragraph_style: &CTParagraphStyle,
spec: CTParagraphStyleSpecifier,
value_buffer_size: usize,
value_buffer: NonNull<c_void>,
) -> bool;
}
unsafe { CTParagraphStyleGetValueForSpecifier(self, spec, value_buffer_size, value_buffer) }
}
}
#[deprecated = "renamed to `CTParagraphStyle::new`"]
#[inline]
pub unsafe extern "C-unwind" fn CTParagraphStyleCreate(
settings: *const CTParagraphStyleSetting,
setting_count: usize,
) -> CFRetained<CTParagraphStyle> {
extern "C-unwind" {
fn CTParagraphStyleCreate(
settings: *const CTParagraphStyleSetting,
setting_count: usize,
) -> Option<NonNull<CTParagraphStyle>>;
}
let ret = unsafe { CTParagraphStyleCreate(settings, setting_count) };
let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::from_raw(ret) }
}
#[deprecated = "renamed to `CTParagraphStyle::copy`"]
#[inline]
pub unsafe extern "C-unwind" fn CTParagraphStyleCreateCopy(
paragraph_style: &CTParagraphStyle,
) -> CFRetained<CTParagraphStyle> {
extern "C-unwind" {
fn CTParagraphStyleCreateCopy(
paragraph_style: &CTParagraphStyle,
) -> Option<NonNull<CTParagraphStyle>>;
}
let ret = unsafe { CTParagraphStyleCreateCopy(paragraph_style) };
let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::from_raw(ret) }
}
extern "C-unwind" {
#[deprecated = "renamed to `CTParagraphStyle::value_for_specifier`"]
pub fn CTParagraphStyleGetValueForSpecifier(
paragraph_style: &CTParagraphStyle,
spec: CTParagraphStyleSpecifier,
value_buffer_size: usize,
value_buffer: NonNull<c_void>,
) -> bool;
}