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