objc2_core_text/generated/
CTTextTab.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/coretext/cttexttab?language=objc)
14#[doc(alias = "CTTextTabRef")]
15#[repr(C)]
16pub struct CTTextTab {
17    inner: [u8; 0],
18    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21cf_type!(
22    unsafe impl CTTextTab {}
23);
24#[cfg(feature = "objc2")]
25cf_objc2_type!(
26    unsafe impl RefEncode<"__CTTextTab"> for CTTextTab {}
27);
28
29unsafe impl ConcreteType for CTTextTab {
30    /// Returns the CFType of the text tab object
31    #[doc(alias = "CTTextTabGetTypeID")]
32    #[inline]
33    fn type_id() -> CFTypeID {
34        extern "C-unwind" {
35            fn CTTextTabGetTypeID() -> CFTypeID;
36        }
37        unsafe { CTTextTabGetTypeID() }
38    }
39}
40
41extern "C" {
42    /// Used to specify the terminating character for a tab column
43    ///
44    ///
45    /// The value associated with this attribute is a CFCharacterSet. The
46    /// character set is used to determine the terminating character for
47    /// a tab column. The tab and newline characters are implied even if
48    /// they don't exist in the character set. This attribute can be used
49    /// to implement decimal tabs, for instance. This attribute is
50    /// optional.
51    ///
52    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kcttabcolumnterminatorsattributename?language=objc)
53    pub static kCTTabColumnTerminatorsAttributeName: &'static CFString;
54}
55
56impl CTTextTab {
57    /// Creates and initializes a new text tab.
58    ///
59    ///
60    /// Parameter `alignment`: The tab's alignment. This is used to determine the position of
61    /// text inside the tab column. This parameter must be set to a valid
62    /// CTTextAlignment value or this function will return NULL.
63    ///
64    ///
65    /// Parameter `location`: The tab's ruler location, relative to the back margin.
66    ///
67    ///
68    /// Parameter `options`: Options to pass in when the tab is created. Currently, the only
69    /// option available is kCTTabColumnTerminatorsAttributeName. This
70    /// parameter is optional and can be set to NULL if not needed.
71    ///
72    ///
73    /// Returns: The new CTTextTab.
74    ///
75    /// # Safety
76    ///
77    /// `options` generics must be of the correct type.
78    #[doc(alias = "CTTextTabCreate")]
79    #[cfg(feature = "CTParagraphStyle")]
80    #[inline]
81    pub unsafe fn new(
82        alignment: CTTextAlignment,
83        location: c_double,
84        options: Option<&CFDictionary>,
85    ) -> CFRetained<CTTextTab> {
86        extern "C-unwind" {
87            fn CTTextTabCreate(
88                alignment: CTTextAlignment,
89                location: c_double,
90                options: Option<&CFDictionary>,
91            ) -> Option<NonNull<CTTextTab>>;
92        }
93        let ret = unsafe { CTTextTabCreate(alignment, location, options) };
94        let ret =
95            ret.expect("function was marked as returning non-null, but actually returned NULL");
96        unsafe { CFRetained::from_raw(ret) }
97    }
98
99    /// Returns the text alignment of the tab.
100    ///
101    ///
102    /// Parameter `tab`: The tab whose text alignment you wish to access.
103    ///
104    ///
105    /// Returns: The tab's text alignment value.
106    #[doc(alias = "CTTextTabGetAlignment")]
107    #[cfg(feature = "CTParagraphStyle")]
108    #[inline]
109    pub unsafe fn alignment(&self) -> CTTextAlignment {
110        extern "C-unwind" {
111            fn CTTextTabGetAlignment(tab: &CTTextTab) -> CTTextAlignment;
112        }
113        unsafe { CTTextTabGetAlignment(self) }
114    }
115
116    /// Returns the tab's ruler location.
117    ///
118    ///
119    /// Parameter `tab`: The tab whose location you wish to access.
120    ///
121    ///
122    /// Returns: The tab's ruler location relative to the back margin.
123    #[doc(alias = "CTTextTabGetLocation")]
124    #[inline]
125    pub unsafe fn location(&self) -> c_double {
126        extern "C-unwind" {
127            fn CTTextTabGetLocation(tab: &CTTextTab) -> c_double;
128        }
129        unsafe { CTTextTabGetLocation(self) }
130    }
131
132    /// Returns the dictionary of attributes associated with the tab.
133    ///
134    ///
135    /// Parameter `tab`: The tab whose attributes you wish to access.
136    ///
137    ///
138    /// Returns: The dictionary of attributes associated with the tab or NULL if
139    /// no dictionary is present.
140    #[doc(alias = "CTTextTabGetOptions")]
141    #[inline]
142    pub unsafe fn options(&self) -> Option<CFRetained<CFDictionary>> {
143        extern "C-unwind" {
144            fn CTTextTabGetOptions(tab: &CTTextTab) -> Option<NonNull<CFDictionary>>;
145        }
146        let ret = unsafe { CTTextTabGetOptions(self) };
147        ret.map(|ret| unsafe { CFRetained::retain(ret) })
148    }
149}
150
151#[cfg(feature = "CTParagraphStyle")]
152#[deprecated = "renamed to `CTTextTab::new`"]
153#[inline]
154pub unsafe extern "C-unwind" fn CTTextTabCreate(
155    alignment: CTTextAlignment,
156    location: c_double,
157    options: Option<&CFDictionary>,
158) -> CFRetained<CTTextTab> {
159    extern "C-unwind" {
160        fn CTTextTabCreate(
161            alignment: CTTextAlignment,
162            location: c_double,
163            options: Option<&CFDictionary>,
164        ) -> Option<NonNull<CTTextTab>>;
165    }
166    let ret = unsafe { CTTextTabCreate(alignment, location, options) };
167    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
168    unsafe { CFRetained::from_raw(ret) }
169}
170
171extern "C-unwind" {
172    #[cfg(feature = "CTParagraphStyle")]
173    #[deprecated = "renamed to `CTTextTab::alignment`"]
174    pub fn CTTextTabGetAlignment(tab: &CTTextTab) -> CTTextAlignment;
175}
176
177extern "C-unwind" {
178    #[deprecated = "renamed to `CTTextTab::location`"]
179    pub fn CTTextTabGetLocation(tab: &CTTextTab) -> c_double;
180}
181
182#[deprecated = "renamed to `CTTextTab::options`"]
183#[inline]
184pub unsafe extern "C-unwind" fn CTTextTabGetOptions(
185    tab: &CTTextTab,
186) -> Option<CFRetained<CFDictionary>> {
187    extern "C-unwind" {
188        fn CTTextTabGetOptions(tab: &CTTextTab) -> Option<NonNull<CFDictionary>>;
189    }
190    let ret = unsafe { CTTextTabGetOptions(tab) };
191    ret.map(|ret| unsafe { CFRetained::retain(ret) })
192}