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")]
115unsafe impl NSMenuItemValidation for NSFontManager {}
116
117unsafe impl NSObjectProtocol for NSFontManager {}
118
119impl NSFontManager {
120    extern_methods!(
121        #[unsafe(method(setFontPanelFactory:))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn setFontPanelFactory(factory_id: Option<&AnyClass>, mtm: MainThreadMarker);
124
125        #[unsafe(method(setFontManagerFactory:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn setFontManagerFactory(factory_id: Option<&AnyClass>, mtm: MainThreadMarker);
128
129        #[unsafe(method(sharedFontManager))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn sharedFontManager(mtm: MainThreadMarker) -> Retained<NSFontManager>;
132
133        #[unsafe(method(isMultiple))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn isMultiple(&self) -> bool;
136
137        #[cfg(feature = "NSFont")]
138        #[unsafe(method(selectedFont))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn selectedFont(&self) -> Option<Retained<NSFont>>;
141
142        #[cfg(feature = "NSFont")]
143        #[unsafe(method(setSelectedFont:isMultiple:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn setSelectedFont_isMultiple(&self, font_obj: &NSFont, flag: bool);
146
147        #[cfg(feature = "NSMenu")]
148        #[unsafe(method(setFontMenu:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn setFontMenu(&self, new_menu: &NSMenu);
151
152        #[cfg(feature = "NSMenu")]
153        #[unsafe(method(fontMenu:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn fontMenu(&self, create: bool) -> Option<Retained<NSMenu>>;
156
157        #[cfg(all(
158            feature = "NSFontPanel",
159            feature = "NSPanel",
160            feature = "NSResponder",
161            feature = "NSWindow"
162        ))]
163        #[unsafe(method(fontPanel:))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn fontPanel(&self, create: bool) -> Option<Retained<NSFontPanel>>;
166
167        #[cfg(all(feature = "NSFont", feature = "objc2-core-foundation"))]
168        #[unsafe(method(fontWithFamily:traits:weight:size:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn fontWithFamily_traits_weight_size(
171            &self,
172            family: &NSString,
173            traits: NSFontTraitMask,
174            weight: NSInteger,
175            size: CGFloat,
176        ) -> Option<Retained<NSFont>>;
177
178        #[cfg(feature = "NSFont")]
179        #[unsafe(method(traitsOfFont:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn traitsOfFont(&self, font_obj: &NSFont) -> NSFontTraitMask;
182
183        #[cfg(feature = "NSFont")]
184        #[unsafe(method(weightOfFont:))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn weightOfFont(&self, font_obj: &NSFont) -> NSInteger;
187
188        #[unsafe(method(availableFonts))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn availableFonts(&self) -> Retained<NSArray<NSString>>;
191
192        #[unsafe(method(availableFontFamilies))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn availableFontFamilies(&self) -> Retained<NSArray<NSString>>;
195
196        #[unsafe(method(availableMembersOfFontFamily:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn availableMembersOfFontFamily(
199            &self,
200            fam: &NSString,
201        ) -> Option<Retained<NSArray<NSArray>>>;
202
203        #[cfg(feature = "NSFont")]
204        #[unsafe(method(convertFont:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn convertFont(&self, font_obj: &NSFont) -> Retained<NSFont>;
207
208        #[cfg(all(feature = "NSFont", feature = "objc2-core-foundation"))]
209        #[unsafe(method(convertFont:toSize:))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn convertFont_toSize(
212            &self,
213            font_obj: &NSFont,
214            size: CGFloat,
215        ) -> Retained<NSFont>;
216
217        #[cfg(feature = "NSFont")]
218        #[unsafe(method(convertFont:toFace:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn convertFont_toFace(
221            &self,
222            font_obj: &NSFont,
223            typeface: &NSString,
224        ) -> Option<Retained<NSFont>>;
225
226        #[cfg(feature = "NSFont")]
227        #[unsafe(method(convertFont:toFamily:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn convertFont_toFamily(
230            &self,
231            font_obj: &NSFont,
232            family: &NSString,
233        ) -> Retained<NSFont>;
234
235        #[cfg(feature = "NSFont")]
236        #[unsafe(method(convertFont:toHaveTrait:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn convertFont_toHaveTrait(
239            &self,
240            font_obj: &NSFont,
241            r#trait: NSFontTraitMask,
242        ) -> Retained<NSFont>;
243
244        #[cfg(feature = "NSFont")]
245        #[unsafe(method(convertFont:toNotHaveTrait:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn convertFont_toNotHaveTrait(
248            &self,
249            font_obj: &NSFont,
250            r#trait: NSFontTraitMask,
251        ) -> Retained<NSFont>;
252
253        #[cfg(feature = "NSFont")]
254        #[unsafe(method(convertWeight:ofFont:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn convertWeight_ofFont(
257            &self,
258            up_flag: bool,
259            font_obj: &NSFont,
260        ) -> Retained<NSFont>;
261
262        #[unsafe(method(isEnabled))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn isEnabled(&self) -> bool;
265
266        /// Setter for [`isEnabled`][Self::isEnabled].
267        #[unsafe(method(setEnabled:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn setEnabled(&self, enabled: bool);
270
271        #[unsafe(method(action))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn action(&self) -> Sel;
274
275        /// Setter for [`action`][Self::action].
276        #[unsafe(method(setAction:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn setAction(&self, action: Sel);
279
280        #[deprecated = "NSFontManager doesn't have any delegate method. This property should not be used."]
281        #[unsafe(method(delegate))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
284
285        /// Setter for [`delegate`][Self::delegate].
286        #[deprecated = "NSFontManager doesn't have any delegate method. This property should not be used."]
287        #[unsafe(method(setDelegate:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
290
291        #[unsafe(method(sendAction))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn sendAction(&self) -> bool;
294
295        #[unsafe(method(localizedNameForFamily:face:))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn localizedNameForFamily_face(
298            &self,
299            family: &NSString,
300            face_key: Option<&NSString>,
301        ) -> Retained<NSString>;
302
303        #[unsafe(method(setSelectedAttributes:isMultiple:))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn setSelectedAttributes_isMultiple(
306            &self,
307            attributes: &NSDictionary<NSString, AnyObject>,
308            flag: bool,
309        );
310
311        #[unsafe(method(convertAttributes:))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn convertAttributes(
314            &self,
315            attributes: &NSDictionary<NSString, AnyObject>,
316        ) -> Retained<NSDictionary<NSString, AnyObject>>;
317
318        #[cfg(feature = "NSFontDescriptor")]
319        #[deprecated = "Use -[NSFontDescriptor matchingFontDescriptorsWithMandatoryKeys:] instead"]
320        #[unsafe(method(availableFontNamesMatchingFontDescriptor:))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn availableFontNamesMatchingFontDescriptor(
323            &self,
324            descriptor: &NSFontDescriptor,
325        ) -> Option<Retained<NSArray>>;
326
327        #[deprecated = "Use +[NSFontCollection allFontCollectionNames] instead"]
328        #[unsafe(method(collectionNames))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn collectionNames(&self) -> Retained<NSArray>;
331
332        #[deprecated = "Use -[NSFontCollection matchingDescriptors] instead"]
333        #[unsafe(method(fontDescriptorsInCollection:))]
334        #[unsafe(method_family = none)]
335        pub unsafe fn fontDescriptorsInCollection(
336            &self,
337            collection_names: &NSString,
338        ) -> Option<Retained<NSArray>>;
339
340        #[deprecated = "Use +[NSFontCollection showFontCollection:withName:visibility:name:] instead"]
341        #[unsafe(method(addCollection:options:))]
342        #[unsafe(method_family = none)]
343        pub unsafe fn addCollection_options(
344            &self,
345            collection_name: &NSString,
346            collection_options: NSFontCollectionOptions,
347        ) -> bool;
348
349        #[deprecated = "Use +[NSFontCollection hideFontCollectionWithName:visibility:error:] instead"]
350        #[unsafe(method(removeCollection:))]
351        #[unsafe(method_family = none)]
352        pub unsafe fn removeCollection(&self, collection_name: &NSString) -> bool;
353
354        #[deprecated = "Use -[NSMutableFontCollection addQueryForDescriptors:] instead"]
355        #[unsafe(method(addFontDescriptors:toCollection:))]
356        #[unsafe(method_family = none)]
357        pub unsafe fn addFontDescriptors_toCollection(
358            &self,
359            descriptors: &NSArray,
360            collection_name: &NSString,
361        );
362
363        #[cfg(feature = "NSFontDescriptor")]
364        #[deprecated = "Use -[NSMutableFontCollection removeQueryForDescriptors:] instead"]
365        #[unsafe(method(removeFontDescriptor:fromCollection:))]
366        #[unsafe(method_family = none)]
367        pub unsafe fn removeFontDescriptor_fromCollection(
368            &self,
369            descriptor: &NSFontDescriptor,
370            collection: &NSString,
371        );
372
373        #[unsafe(method(currentFontAction))]
374        #[unsafe(method_family = none)]
375        pub unsafe fn currentFontAction(&self) -> NSFontAction;
376
377        #[unsafe(method(convertFontTraits:))]
378        #[unsafe(method_family = none)]
379        pub unsafe fn convertFontTraits(&self, traits: NSFontTraitMask) -> NSFontTraitMask;
380
381        #[unsafe(method(target))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn target(&self) -> Option<Retained<AnyObject>>;
384
385        /// This is a [weak property][objc2::topics::weak_property].
386        /// Setter for [`target`][Self::target].
387        #[unsafe(method(setTarget:))]
388        #[unsafe(method_family = none)]
389        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
390    );
391}
392
393/// Methods declared on superclass `NSObject`.
394impl NSFontManager {
395    extern_methods!(
396        #[unsafe(method(init))]
397        #[unsafe(method_family = init)]
398        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
399
400        #[unsafe(method(new))]
401        #[unsafe(method_family = new)]
402        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
403    );
404}
405
406/// NSFontManagerMenuActionMethods.
407impl NSFontManager {
408    extern_methods!(
409        #[unsafe(method(fontNamed:hasTraits:))]
410        #[unsafe(method_family = none)]
411        pub unsafe fn fontNamed_hasTraits(
412            &self,
413            f_name: &NSString,
414            some_traits: NSFontTraitMask,
415        ) -> bool;
416
417        #[unsafe(method(availableFontNamesWithTraits:))]
418        #[unsafe(method_family = none)]
419        pub unsafe fn availableFontNamesWithTraits(
420            &self,
421            some_traits: NSFontTraitMask,
422        ) -> Option<Retained<NSArray<NSString>>>;
423
424        #[unsafe(method(addFontTrait:))]
425        #[unsafe(method_family = none)]
426        pub unsafe fn addFontTrait(&self, sender: Option<&AnyObject>);
427
428        #[unsafe(method(removeFontTrait:))]
429        #[unsafe(method_family = none)]
430        pub unsafe fn removeFontTrait(&self, sender: Option<&AnyObject>);
431
432        #[unsafe(method(modifyFontViaPanel:))]
433        #[unsafe(method_family = none)]
434        pub unsafe fn modifyFontViaPanel(&self, sender: Option<&AnyObject>);
435
436        #[unsafe(method(modifyFont:))]
437        #[unsafe(method_family = none)]
438        pub unsafe fn modifyFont(&self, sender: Option<&AnyObject>);
439
440        #[unsafe(method(orderFrontFontPanel:))]
441        #[unsafe(method_family = none)]
442        pub unsafe fn orderFrontFontPanel(&self, sender: Option<&AnyObject>);
443
444        #[unsafe(method(orderFrontStylesPanel:))]
445        #[unsafe(method_family = none)]
446        pub unsafe fn orderFrontStylesPanel(&self, sender: Option<&AnyObject>);
447    );
448}