objc2_app_kit/generated/
NSFontManager.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfonttraitmask?language=objc)
13// NS_OPTIONS
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSFontTraitMask(pub NSUInteger);
17bitflags::bitflags! {
18    impl NSFontTraitMask: NSUInteger {
19        #[doc(alias = "NSItalicFontMask")]
20        const ItalicFontMask = 0x00000001;
21        #[doc(alias = "NSBoldFontMask")]
22        const BoldFontMask = 0x00000002;
23        #[doc(alias = "NSUnboldFontMask")]
24        const UnboldFontMask = 0x00000004;
25        #[doc(alias = "NSNonStandardCharacterSetFontMask")]
26        const NonStandardCharacterSetFontMask = 0x00000008;
27        #[doc(alias = "NSNarrowFontMask")]
28        const NarrowFontMask = 0x00000010;
29        #[doc(alias = "NSExpandedFontMask")]
30        const ExpandedFontMask = 0x00000020;
31        #[doc(alias = "NSCondensedFontMask")]
32        const CondensedFontMask = 0x00000040;
33        #[doc(alias = "NSSmallCapsFontMask")]
34        const SmallCapsFontMask = 0x00000080;
35        #[doc(alias = "NSPosterFontMask")]
36        const PosterFontMask = 0x00000100;
37        #[doc(alias = "NSCompressedFontMask")]
38        const CompressedFontMask = 0x00000200;
39        #[doc(alias = "NSFixedPitchFontMask")]
40        const FixedPitchFontMask = 0x00000400;
41        #[doc(alias = "NSUnitalicFontMask")]
42        const UnitalicFontMask = 0x01000000;
43    }
44}
45
46unsafe impl Encode for NSFontTraitMask {
47    const ENCODING: Encoding = NSUInteger::ENCODING;
48}
49
50unsafe impl RefEncode for NSFontTraitMask {
51    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
52}
53
54/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfontcollectionoptions?language=objc)
55// NS_OPTIONS
56#[repr(transparent)]
57#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
58pub struct NSFontCollectionOptions(pub NSUInteger);
59bitflags::bitflags! {
60    impl NSFontCollectionOptions: NSUInteger {
61        #[doc(alias = "NSFontCollectionApplicationOnlyMask")]
62        const ApplicationOnlyMask = 1<<0;
63    }
64}
65
66unsafe impl Encode for NSFontCollectionOptions {
67    const ENCODING: Encoding = NSUInteger::ENCODING;
68}
69
70unsafe impl RefEncode for NSFontCollectionOptions {
71    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfontaction?language=objc)
75// NS_ENUM
76#[repr(transparent)]
77#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
78pub struct NSFontAction(pub NSUInteger);
79impl NSFontAction {
80    #[doc(alias = "NSNoFontChangeAction")]
81    pub const NoFontChangeAction: Self = Self(0);
82    #[doc(alias = "NSViaPanelFontAction")]
83    pub const ViaPanelFontAction: Self = Self(1);
84    #[doc(alias = "NSAddTraitFontAction")]
85    pub const AddTraitFontAction: Self = Self(2);
86    #[doc(alias = "NSSizeUpFontAction")]
87    pub const SizeUpFontAction: Self = Self(3);
88    #[doc(alias = "NSSizeDownFontAction")]
89    pub const SizeDownFontAction: Self = Self(4);
90    #[doc(alias = "NSHeavierFontAction")]
91    pub const HeavierFontAction: Self = Self(5);
92    #[doc(alias = "NSLighterFontAction")]
93    pub const LighterFontAction: Self = Self(6);
94    #[doc(alias = "NSRemoveTraitFontAction")]
95    pub const RemoveTraitFontAction: Self = Self(7);
96}
97
98unsafe impl Encode for NSFontAction {
99    const ENCODING: Encoding = NSUInteger::ENCODING;
100}
101
102unsafe impl RefEncode for NSFontAction {
103    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
104}
105
106extern_class!(
107    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsfontmanager?language=objc)
108    #[unsafe(super(NSObject))]
109    #[thread_kind = MainThreadOnly]
110    #[derive(Debug, PartialEq, Eq, Hash)]
111    pub struct NSFontManager;
112);
113
114#[cfg(feature = "NSMenu")]
115extern_conformance!(
116    unsafe impl NSMenuItemValidation for NSFontManager {}
117);
118
119extern_conformance!(
120    unsafe impl NSObjectProtocol for NSFontManager {}
121);
122
123impl NSFontManager {
124    extern_methods!(
125        #[unsafe(method(setFontPanelFactory:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn setFontPanelFactory(factory_id: Option<&AnyClass>, mtm: MainThreadMarker);
128
129        #[unsafe(method(setFontManagerFactory:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn setFontManagerFactory(factory_id: Option<&AnyClass>, mtm: MainThreadMarker);
132
133        #[unsafe(method(sharedFontManager))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn sharedFontManager(mtm: MainThreadMarker) -> Retained<NSFontManager>;
136
137        #[unsafe(method(isMultiple))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn isMultiple(&self) -> bool;
140
141        #[cfg(feature = "NSFont")]
142        #[unsafe(method(selectedFont))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn selectedFont(&self) -> Option<Retained<NSFont>>;
145
146        #[cfg(feature = "NSFont")]
147        #[unsafe(method(setSelectedFont:isMultiple:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn setSelectedFont_isMultiple(&self, font_obj: &NSFont, flag: bool);
150
151        #[cfg(feature = "NSMenu")]
152        #[unsafe(method(setFontMenu:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn setFontMenu(&self, new_menu: &NSMenu);
155
156        #[cfg(feature = "NSMenu")]
157        #[unsafe(method(fontMenu:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn fontMenu(&self, create: bool) -> Option<Retained<NSMenu>>;
160
161        #[cfg(all(
162            feature = "NSFontPanel",
163            feature = "NSPanel",
164            feature = "NSResponder",
165            feature = "NSWindow"
166        ))]
167        #[unsafe(method(fontPanel:))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn fontPanel(&self, create: bool) -> Option<Retained<NSFontPanel>>;
170
171        #[cfg(all(feature = "NSFont", feature = "objc2-core-foundation"))]
172        #[unsafe(method(fontWithFamily:traits:weight:size:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn fontWithFamily_traits_weight_size(
175            &self,
176            family: &NSString,
177            traits: NSFontTraitMask,
178            weight: NSInteger,
179            size: CGFloat,
180        ) -> Option<Retained<NSFont>>;
181
182        #[cfg(feature = "NSFont")]
183        #[unsafe(method(traitsOfFont:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn traitsOfFont(&self, font_obj: &NSFont) -> NSFontTraitMask;
186
187        #[cfg(feature = "NSFont")]
188        #[unsafe(method(weightOfFont:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn weightOfFont(&self, font_obj: &NSFont) -> NSInteger;
191
192        #[unsafe(method(availableFonts))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn availableFonts(&self) -> Retained<NSArray<NSString>>;
195
196        #[unsafe(method(availableFontFamilies))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn availableFontFamilies(&self) -> Retained<NSArray<NSString>>;
199
200        #[unsafe(method(availableMembersOfFontFamily:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn availableMembersOfFontFamily(
203            &self,
204            fam: &NSString,
205        ) -> Option<Retained<NSArray<NSArray>>>;
206
207        #[cfg(feature = "NSFont")]
208        #[unsafe(method(convertFont:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn convertFont(&self, font_obj: &NSFont) -> Retained<NSFont>;
211
212        #[cfg(all(feature = "NSFont", feature = "objc2-core-foundation"))]
213        #[unsafe(method(convertFont:toSize:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn convertFont_toSize(
216            &self,
217            font_obj: &NSFont,
218            size: CGFloat,
219        ) -> Retained<NSFont>;
220
221        #[cfg(feature = "NSFont")]
222        #[unsafe(method(convertFont:toFace:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn convertFont_toFace(
225            &self,
226            font_obj: &NSFont,
227            typeface: &NSString,
228        ) -> Option<Retained<NSFont>>;
229
230        #[cfg(feature = "NSFont")]
231        #[unsafe(method(convertFont:toFamily:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn convertFont_toFamily(
234            &self,
235            font_obj: &NSFont,
236            family: &NSString,
237        ) -> Retained<NSFont>;
238
239        #[cfg(feature = "NSFont")]
240        #[unsafe(method(convertFont:toHaveTrait:))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn convertFont_toHaveTrait(
243            &self,
244            font_obj: &NSFont,
245            r#trait: NSFontTraitMask,
246        ) -> Retained<NSFont>;
247
248        #[cfg(feature = "NSFont")]
249        #[unsafe(method(convertFont:toNotHaveTrait:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn convertFont_toNotHaveTrait(
252            &self,
253            font_obj: &NSFont,
254            r#trait: NSFontTraitMask,
255        ) -> Retained<NSFont>;
256
257        #[cfg(feature = "NSFont")]
258        #[unsafe(method(convertWeight:ofFont:))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn convertWeight_ofFont(
261            &self,
262            up_flag: bool,
263            font_obj: &NSFont,
264        ) -> Retained<NSFont>;
265
266        #[unsafe(method(isEnabled))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn isEnabled(&self) -> bool;
269
270        /// Setter for [`isEnabled`][Self::isEnabled].
271        #[unsafe(method(setEnabled:))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn setEnabled(&self, enabled: bool);
274
275        #[unsafe(method(action))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn action(&self) -> Sel;
278
279        /// Setter for [`action`][Self::action].
280        #[unsafe(method(setAction:))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn setAction(&self, action: Sel);
283
284        #[deprecated = "NSFontManager doesn't have any delegate method. This property should not be used."]
285        #[unsafe(method(delegate))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
288
289        /// Setter for [`delegate`][Self::delegate].
290        #[deprecated = "NSFontManager doesn't have any delegate method. This property should not be used."]
291        #[unsafe(method(setDelegate:))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
294
295        #[unsafe(method(sendAction))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn sendAction(&self) -> bool;
298
299        #[unsafe(method(localizedNameForFamily:face:))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn localizedNameForFamily_face(
302            &self,
303            family: &NSString,
304            face_key: Option<&NSString>,
305        ) -> Retained<NSString>;
306
307        #[unsafe(method(setSelectedAttributes:isMultiple:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn setSelectedAttributes_isMultiple(
310            &self,
311            attributes: &NSDictionary<NSString, AnyObject>,
312            flag: bool,
313        );
314
315        #[unsafe(method(convertAttributes:))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn convertAttributes(
318            &self,
319            attributes: &NSDictionary<NSString, AnyObject>,
320        ) -> Retained<NSDictionary<NSString, AnyObject>>;
321
322        #[cfg(feature = "NSFontDescriptor")]
323        #[deprecated = "Use -[NSFontDescriptor matchingFontDescriptorsWithMandatoryKeys:] instead"]
324        #[unsafe(method(availableFontNamesMatchingFontDescriptor:))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn availableFontNamesMatchingFontDescriptor(
327            &self,
328            descriptor: &NSFontDescriptor,
329        ) -> Option<Retained<NSArray>>;
330
331        #[deprecated = "Use +[NSFontCollection allFontCollectionNames] instead"]
332        #[unsafe(method(collectionNames))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn collectionNames(&self) -> Retained<NSArray>;
335
336        #[deprecated = "Use -[NSFontCollection matchingDescriptors] instead"]
337        #[unsafe(method(fontDescriptorsInCollection:))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn fontDescriptorsInCollection(
340            &self,
341            collection_names: &NSString,
342        ) -> Option<Retained<NSArray>>;
343
344        #[deprecated = "Use +[NSFontCollection showFontCollection:withName:visibility:name:] instead"]
345        #[unsafe(method(addCollection:options:))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn addCollection_options(
348            &self,
349            collection_name: &NSString,
350            collection_options: NSFontCollectionOptions,
351        ) -> bool;
352
353        #[deprecated = "Use +[NSFontCollection hideFontCollectionWithName:visibility:error:] instead"]
354        #[unsafe(method(removeCollection:))]
355        #[unsafe(method_family = none)]
356        pub unsafe fn removeCollection(&self, collection_name: &NSString) -> bool;
357
358        #[deprecated = "Use -[NSMutableFontCollection addQueryForDescriptors:] instead"]
359        #[unsafe(method(addFontDescriptors:toCollection:))]
360        #[unsafe(method_family = none)]
361        pub unsafe fn addFontDescriptors_toCollection(
362            &self,
363            descriptors: &NSArray,
364            collection_name: &NSString,
365        );
366
367        #[cfg(feature = "NSFontDescriptor")]
368        #[deprecated = "Use -[NSMutableFontCollection removeQueryForDescriptors:] instead"]
369        #[unsafe(method(removeFontDescriptor:fromCollection:))]
370        #[unsafe(method_family = none)]
371        pub unsafe fn removeFontDescriptor_fromCollection(
372            &self,
373            descriptor: &NSFontDescriptor,
374            collection: &NSString,
375        );
376
377        #[unsafe(method(currentFontAction))]
378        #[unsafe(method_family = none)]
379        pub unsafe fn currentFontAction(&self) -> NSFontAction;
380
381        #[unsafe(method(convertFontTraits:))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn convertFontTraits(&self, traits: NSFontTraitMask) -> NSFontTraitMask;
384
385        #[unsafe(method(target))]
386        #[unsafe(method_family = none)]
387        pub unsafe fn target(&self) -> Option<Retained<AnyObject>>;
388
389        /// This is a [weak property][objc2::topics::weak_property].
390        /// Setter for [`target`][Self::target].
391        #[unsafe(method(setTarget:))]
392        #[unsafe(method_family = none)]
393        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
394    );
395}
396
397/// Methods declared on superclass `NSObject`.
398impl NSFontManager {
399    extern_methods!(
400        #[unsafe(method(init))]
401        #[unsafe(method_family = init)]
402        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
403
404        #[unsafe(method(new))]
405        #[unsafe(method_family = new)]
406        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
407    );
408}
409
410/// NSFontManagerMenuActionMethods.
411impl NSFontManager {
412    extern_methods!(
413        #[unsafe(method(fontNamed:hasTraits:))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn fontNamed_hasTraits(
416            &self,
417            f_name: &NSString,
418            some_traits: NSFontTraitMask,
419        ) -> bool;
420
421        #[unsafe(method(availableFontNamesWithTraits:))]
422        #[unsafe(method_family = none)]
423        pub unsafe fn availableFontNamesWithTraits(
424            &self,
425            some_traits: NSFontTraitMask,
426        ) -> Option<Retained<NSArray<NSString>>>;
427
428        #[unsafe(method(addFontTrait:))]
429        #[unsafe(method_family = none)]
430        pub unsafe fn addFontTrait(&self, sender: Option<&AnyObject>);
431
432        #[unsafe(method(removeFontTrait:))]
433        #[unsafe(method_family = none)]
434        pub unsafe fn removeFontTrait(&self, sender: Option<&AnyObject>);
435
436        #[unsafe(method(modifyFontViaPanel:))]
437        #[unsafe(method_family = none)]
438        pub unsafe fn modifyFontViaPanel(&self, sender: Option<&AnyObject>);
439
440        #[unsafe(method(modifyFont:))]
441        #[unsafe(method_family = none)]
442        pub unsafe fn modifyFont(&self, sender: Option<&AnyObject>);
443
444        #[unsafe(method(orderFrontFontPanel:))]
445        #[unsafe(method_family = none)]
446        pub unsafe fn orderFrontFontPanel(&self, sender: Option<&AnyObject>);
447
448        #[unsafe(method(orderFrontStylesPanel:))]
449        #[unsafe(method_family = none)]
450        pub unsafe fn orderFrontStylesPanel(&self, sender: Option<&AnyObject>);
451    );
452}