1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextLayoutFragmentEnumerationOptions(pub NSUInteger);
impl NSTextLayoutFragmentEnumerationOptions {
    #[doc(alias = "NSTextLayoutFragmentEnumerationOptionsNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "NSTextLayoutFragmentEnumerationOptionsReverse")]
    pub const Reverse: Self = Self(1 << 0);
    #[doc(alias = "NSTextLayoutFragmentEnumerationOptionsEstimatesSize")]
    pub const EstimatesSize: Self = Self(1 << 1);
    #[doc(alias = "NSTextLayoutFragmentEnumerationOptionsEnsuresLayout")]
    pub const EnsuresLayout: Self = Self(1 << 2);
    #[doc(alias = "NSTextLayoutFragmentEnumerationOptionsEnsuresExtraLineFragment")]
    pub const EnsuresExtraLineFragment: Self = Self(1 << 3);
}

unsafe impl Encode for NSTextLayoutFragmentEnumerationOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextLayoutFragmentState(pub NSUInteger);
impl NSTextLayoutFragmentState {
    #[doc(alias = "NSTextLayoutFragmentStateNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "NSTextLayoutFragmentStateEstimatedUsageBounds")]
    pub const EstimatedUsageBounds: Self = Self(1);
    #[doc(alias = "NSTextLayoutFragmentStateCalculatedUsageBounds")]
    pub const CalculatedUsageBounds: Self = Self(2);
    #[doc(alias = "NSTextLayoutFragmentStateLayoutAvailable")]
    pub const LayoutAvailable: Self = Self(3);
}

unsafe impl Encode for NSTextLayoutFragmentState {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

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

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

unsafe impl NSCoding for NSTextLayoutFragment {}

unsafe impl NSObjectProtocol for NSTextLayoutFragment {}

unsafe impl NSSecureCoding for NSTextLayoutFragment {}

extern_methods!(
    unsafe impl NSTextLayoutFragment {
        #[cfg(all(feature = "NSTextElement", feature = "NSTextRange"))]
        #[method_id(@__retain_semantics Init initWithTextElement:range:)]
        pub unsafe fn initWithTextElement_range(
            this: Allocated<Self>,
            text_element: &NSTextElement,
            range_in_element: Option<&NSTextRange>,
        ) -> Id<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Option<Id<Self>>;

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

        #[cfg(feature = "NSTextLayoutManager")]
        #[method_id(@__retain_semantics Other textLayoutManager)]
        pub unsafe fn textLayoutManager(&self) -> Option<Id<NSTextLayoutManager>>;

        #[cfg(feature = "NSTextElement")]
        #[method_id(@__retain_semantics Other textElement)]
        pub unsafe fn textElement(&self) -> Option<Id<NSTextElement>>;

        #[cfg(feature = "NSTextRange")]
        #[method_id(@__retain_semantics Other rangeInElement)]
        pub unsafe fn rangeInElement(&self) -> Id<NSTextRange>;

        #[cfg(feature = "NSTextLineFragment")]
        #[method_id(@__retain_semantics Other textLineFragments)]
        pub unsafe fn textLineFragments(&self) -> Id<NSArray<NSTextLineFragment>>;

        #[cfg(feature = "NSTextLineFragment")]
        #[method_id(@__retain_semantics Other textLineFragmentForVerticalOffset:requiresExactMatch:)]
        pub unsafe fn textLineFragmentForVerticalOffset_requiresExactMatch(
            &self,
            vertical_offset: CGFloat,
            requires_exact_match: bool,
        ) -> Option<Id<NSTextLineFragment>>;

        #[cfg(all(feature = "NSTextLineFragment", feature = "NSTextRange"))]
        #[method_id(@__retain_semantics Other textLineFragmentForTextLocation:isUpstreamAffinity:)]
        pub unsafe fn textLineFragmentForTextLocation_isUpstreamAffinity(
            &self,
            text_location: &ProtocolObject<dyn NSTextLocation>,
            is_upstream_affinity: bool,
        ) -> Option<Id<NSTextLineFragment>>;

        #[method_id(@__retain_semantics Other layoutQueue)]
        pub unsafe fn layoutQueue(&self) -> Option<Id<NSOperationQueue>>;

        #[method(setLayoutQueue:)]
        pub unsafe fn setLayoutQueue(&self, layout_queue: Option<&NSOperationQueue>);

        #[method(state)]
        pub unsafe fn state(&self) -> NSTextLayoutFragmentState;

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

        #[method(layoutFragmentFrame)]
        pub unsafe fn layoutFragmentFrame(&self) -> CGRect;

        #[method(renderingSurfaceBounds)]
        pub unsafe fn renderingSurfaceBounds(&self) -> CGRect;

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

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

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

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

        #[cfg(feature = "NSTextAttachment")]
        #[method_id(@__retain_semantics Other textAttachmentViewProviders)]
        pub unsafe fn textAttachmentViewProviders(
            &self,
        ) -> Id<NSArray<NSTextAttachmentViewProvider>>;

        #[cfg(feature = "NSTextRange")]
        #[method(frameForTextAttachmentAtLocation:)]
        pub unsafe fn frameForTextAttachmentAtLocation(
            &self,
            location: &ProtocolObject<dyn NSTextLocation>,
        ) -> CGRect;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSTextLayoutFragment {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);