1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9#[cfg(target_vendor = "apple")]
10use objc2_core_graphics::*;
11#[cfg(feature = "objc2-core-image")]
12#[cfg(target_vendor = "apple")]
13use objc2_core_image::*;
14use objc2_foundation::*;
15
16use crate::*;
17
18#[cfg(feature = "NSApplication")]
20pub static NSAppKitVersionNumberWithPatternColorLeakFix: NSAppKitVersion = 641.0 as _;
21
22#[repr(transparent)]
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
26pub struct NSColorType(pub NSInteger);
27impl NSColorType {
28 #[doc(alias = "NSColorTypeComponentBased")]
29 pub const ComponentBased: Self = Self(0);
30 #[doc(alias = "NSColorTypePattern")]
31 pub const Pattern: Self = Self(1);
32 #[doc(alias = "NSColorTypeCatalog")]
33 pub const Catalog: Self = Self(2);
34}
35
36unsafe impl Encode for NSColorType {
37 const ENCODING: Encoding = NSInteger::ENCODING;
38}
39
40unsafe impl RefEncode for NSColorType {
41 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44#[repr(transparent)]
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct NSColorSystemEffect(pub NSInteger);
49impl NSColorSystemEffect {
50 #[doc(alias = "NSColorSystemEffectNone")]
51 pub const None: Self = Self(0);
52 #[doc(alias = "NSColorSystemEffectPressed")]
53 pub const Pressed: Self = Self(1);
54 #[doc(alias = "NSColorSystemEffectDeepPressed")]
55 pub const DeepPressed: Self = Self(2);
56 #[doc(alias = "NSColorSystemEffectDisabled")]
57 pub const Disabled: Self = Self(3);
58 #[doc(alias = "NSColorSystemEffectRollover")]
59 pub const Rollover: Self = Self(4);
60}
61
62unsafe impl Encode for NSColorSystemEffect {
63 const ENCODING: Encoding = NSInteger::ENCODING;
64}
65
66unsafe impl RefEncode for NSColorSystemEffect {
67 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
68}
69
70extern_class!(
71 #[unsafe(super(NSObject))]
73 #[derive(Debug, PartialEq, Eq, Hash)]
74 pub struct NSColor;
75);
76
77unsafe impl Send for NSColor {}
78
79unsafe impl Sync for NSColor {}
80
81extern_conformance!(
82 unsafe impl NSCoding for NSColor {}
83);
84
85extern_conformance!(
86 unsafe impl NSCopying for NSColor {}
87);
88
89unsafe impl CopyingHelper for NSColor {
90 type Result = Self;
91}
92
93extern_conformance!(
94 unsafe impl NSObjectProtocol for NSColor {}
95);
96
97#[cfg(feature = "NSPasteboard")]
98extern_conformance!(
99 unsafe impl NSPasteboardReading for NSColor {}
100);
101
102#[cfg(feature = "NSPasteboard")]
103extern_conformance!(
104 unsafe impl NSPasteboardWriting for NSColor {}
105);
106
107extern_conformance!(
108 unsafe impl NSSecureCoding for NSColor {}
109);
110
111impl NSColor {
112 extern_methods!(
113 #[unsafe(method(init))]
114 #[unsafe(method_family = init)]
115 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
116
117 #[unsafe(method(initWithCoder:))]
118 #[unsafe(method_family = init)]
119 pub unsafe fn initWithCoder(
120 this: Allocated<Self>,
121 coder: &NSCoder,
122 ) -> Option<Retained<Self>>;
123
124 #[cfg(all(feature = "NSColorSpace", feature = "objc2-core-foundation"))]
125 #[unsafe(method(colorWithColorSpace:components:count:))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn colorWithColorSpace_components_count(
128 space: &NSColorSpace,
129 components: NonNull<CGFloat>,
130 number_of_components: NSInteger,
131 ) -> Retained<NSColor>;
132
133 #[cfg(feature = "objc2-core-foundation")]
134 #[unsafe(method(colorWithSRGBRed:green:blue:alpha:))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn colorWithSRGBRed_green_blue_alpha(
137 red: CGFloat,
138 green: CGFloat,
139 blue: CGFloat,
140 alpha: CGFloat,
141 ) -> Retained<NSColor>;
142
143 #[cfg(feature = "objc2-core-foundation")]
144 #[unsafe(method(colorWithGenericGamma22White:alpha:))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn colorWithGenericGamma22White_alpha(
147 white: CGFloat,
148 alpha: CGFloat,
149 ) -> Retained<NSColor>;
150
151 #[cfg(feature = "objc2-core-foundation")]
152 #[unsafe(method(colorWithDisplayP3Red:green:blue:alpha:))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn colorWithDisplayP3Red_green_blue_alpha(
155 red: CGFloat,
156 green: CGFloat,
157 blue: CGFloat,
158 alpha: CGFloat,
159 ) -> Retained<NSColor>;
160
161 #[cfg(feature = "objc2-core-foundation")]
162 #[unsafe(method(colorWithWhite:alpha:))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn colorWithWhite_alpha(white: CGFloat, alpha: CGFloat) -> Retained<NSColor>;
165
166 #[cfg(feature = "objc2-core-foundation")]
167 #[unsafe(method(colorWithRed:green:blue:alpha:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn colorWithRed_green_blue_alpha(
170 red: CGFloat,
171 green: CGFloat,
172 blue: CGFloat,
173 alpha: CGFloat,
174 ) -> Retained<NSColor>;
175
176 #[cfg(feature = "objc2-core-foundation")]
177 #[unsafe(method(colorWithHue:saturation:brightness:alpha:))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn colorWithHue_saturation_brightness_alpha(
180 hue: CGFloat,
181 saturation: CGFloat,
182 brightness: CGFloat,
183 alpha: CGFloat,
184 ) -> Retained<NSColor>;
185
186 #[cfg(all(feature = "NSColorSpace", feature = "objc2-core-foundation"))]
187 #[unsafe(method(colorWithColorSpace:hue:saturation:brightness:alpha:))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn colorWithColorSpace_hue_saturation_brightness_alpha(
190 space: &NSColorSpace,
191 hue: CGFloat,
192 saturation: CGFloat,
193 brightness: CGFloat,
194 alpha: CGFloat,
195 ) -> Retained<NSColor>;
196
197 #[cfg(feature = "NSColorList")]
198 #[unsafe(method(colorWithCatalogName:colorName:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn colorWithCatalogName_colorName(
201 list_name: &NSColorListName,
202 color_name: &NSColorName,
203 ) -> Option<Retained<NSColor>>;
204
205 #[cfg(feature = "NSColorList")]
206 #[unsafe(method(colorNamed:bundle:))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn colorNamed_bundle(
209 name: &NSColorName,
210 bundle: Option<&NSBundle>,
211 ) -> Option<Retained<NSColor>>;
212
213 #[cfg(feature = "NSColorList")]
214 #[unsafe(method(colorNamed:))]
215 #[unsafe(method_family = none)]
216 pub unsafe fn colorNamed(name: &NSColorName) -> Option<Retained<NSColor>>;
217
218 #[cfg(all(feature = "NSAppearance", feature = "NSColorList", feature = "block2"))]
219 #[unsafe(method(colorWithName:dynamicProvider:))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn colorWithName_dynamicProvider(
222 color_name: Option<&NSColorName>,
223 dynamic_provider: &block2::DynBlock<dyn Fn(NonNull<NSAppearance>) -> NonNull<NSColor>>,
224 ) -> Retained<NSColor>;
225
226 #[cfg(feature = "objc2-core-foundation")]
227 #[unsafe(method(colorWithDeviceWhite:alpha:))]
228 #[unsafe(method_family = none)]
229 pub unsafe fn colorWithDeviceWhite_alpha(
230 white: CGFloat,
231 alpha: CGFloat,
232 ) -> Retained<NSColor>;
233
234 #[cfg(feature = "objc2-core-foundation")]
235 #[unsafe(method(colorWithDeviceRed:green:blue:alpha:))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn colorWithDeviceRed_green_blue_alpha(
238 red: CGFloat,
239 green: CGFloat,
240 blue: CGFloat,
241 alpha: CGFloat,
242 ) -> Retained<NSColor>;
243
244 #[cfg(feature = "objc2-core-foundation")]
245 #[unsafe(method(colorWithDeviceHue:saturation:brightness:alpha:))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn colorWithDeviceHue_saturation_brightness_alpha(
248 hue: CGFloat,
249 saturation: CGFloat,
250 brightness: CGFloat,
251 alpha: CGFloat,
252 ) -> Retained<NSColor>;
253
254 #[cfg(feature = "objc2-core-foundation")]
255 #[unsafe(method(colorWithDeviceCyan:magenta:yellow:black:alpha:))]
256 #[unsafe(method_family = none)]
257 pub unsafe fn colorWithDeviceCyan_magenta_yellow_black_alpha(
258 cyan: CGFloat,
259 magenta: CGFloat,
260 yellow: CGFloat,
261 black: CGFloat,
262 alpha: CGFloat,
263 ) -> Retained<NSColor>;
264
265 #[cfg(feature = "objc2-core-foundation")]
266 #[unsafe(method(colorWithCalibratedWhite:alpha:))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn colorWithCalibratedWhite_alpha(
269 white: CGFloat,
270 alpha: CGFloat,
271 ) -> Retained<NSColor>;
272
273 #[cfg(feature = "objc2-core-foundation")]
274 #[unsafe(method(colorWithCalibratedRed:green:blue:alpha:))]
275 #[unsafe(method_family = none)]
276 pub unsafe fn colorWithCalibratedRed_green_blue_alpha(
277 red: CGFloat,
278 green: CGFloat,
279 blue: CGFloat,
280 alpha: CGFloat,
281 ) -> Retained<NSColor>;
282
283 #[cfg(feature = "objc2-core-foundation")]
284 #[unsafe(method(colorWithCalibratedHue:saturation:brightness:alpha:))]
285 #[unsafe(method_family = none)]
286 pub unsafe fn colorWithCalibratedHue_saturation_brightness_alpha(
287 hue: CGFloat,
288 saturation: CGFloat,
289 brightness: CGFloat,
290 alpha: CGFloat,
291 ) -> Retained<NSColor>;
292
293 #[cfg(feature = "NSImage")]
294 #[unsafe(method(colorWithPatternImage:))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn colorWithPatternImage(image: &NSImage) -> Retained<NSColor>;
297
298 #[unsafe(method(type))]
299 #[unsafe(method_family = none)]
300 pub unsafe fn r#type(&self) -> NSColorType;
301
302 #[unsafe(method(colorUsingType:))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn colorUsingType(&self, r#type: NSColorType) -> Option<Retained<NSColor>>;
305
306 #[cfg(feature = "NSColorSpace")]
307 #[unsafe(method(colorUsingColorSpace:))]
308 #[unsafe(method_family = none)]
309 pub unsafe fn colorUsingColorSpace(
310 &self,
311 space: &NSColorSpace,
312 ) -> Option<Retained<NSColor>>;
313
314 #[unsafe(method(blackColor))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn blackColor() -> Retained<NSColor>;
317
318 #[unsafe(method(darkGrayColor))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn darkGrayColor() -> Retained<NSColor>;
321
322 #[unsafe(method(lightGrayColor))]
323 #[unsafe(method_family = none)]
324 pub unsafe fn lightGrayColor() -> Retained<NSColor>;
325
326 #[unsafe(method(whiteColor))]
327 #[unsafe(method_family = none)]
328 pub unsafe fn whiteColor() -> Retained<NSColor>;
329
330 #[unsafe(method(grayColor))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn grayColor() -> Retained<NSColor>;
333
334 #[unsafe(method(redColor))]
335 #[unsafe(method_family = none)]
336 pub unsafe fn redColor() -> Retained<NSColor>;
337
338 #[unsafe(method(greenColor))]
339 #[unsafe(method_family = none)]
340 pub unsafe fn greenColor() -> Retained<NSColor>;
341
342 #[unsafe(method(blueColor))]
343 #[unsafe(method_family = none)]
344 pub unsafe fn blueColor() -> Retained<NSColor>;
345
346 #[unsafe(method(cyanColor))]
347 #[unsafe(method_family = none)]
348 pub unsafe fn cyanColor() -> Retained<NSColor>;
349
350 #[unsafe(method(yellowColor))]
351 #[unsafe(method_family = none)]
352 pub unsafe fn yellowColor() -> Retained<NSColor>;
353
354 #[unsafe(method(magentaColor))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn magentaColor() -> Retained<NSColor>;
357
358 #[unsafe(method(orangeColor))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn orangeColor() -> Retained<NSColor>;
361
362 #[unsafe(method(purpleColor))]
363 #[unsafe(method_family = none)]
364 pub unsafe fn purpleColor() -> Retained<NSColor>;
365
366 #[unsafe(method(brownColor))]
367 #[unsafe(method_family = none)]
368 pub unsafe fn brownColor() -> Retained<NSColor>;
369
370 #[unsafe(method(clearColor))]
371 #[unsafe(method_family = none)]
372 pub unsafe fn clearColor() -> Retained<NSColor>;
373
374 #[unsafe(method(labelColor))]
375 #[unsafe(method_family = none)]
376 pub unsafe fn labelColor() -> Retained<NSColor>;
377
378 #[unsafe(method(secondaryLabelColor))]
379 #[unsafe(method_family = none)]
380 pub unsafe fn secondaryLabelColor() -> Retained<NSColor>;
381
382 #[unsafe(method(tertiaryLabelColor))]
383 #[unsafe(method_family = none)]
384 pub unsafe fn tertiaryLabelColor() -> Retained<NSColor>;
385
386 #[unsafe(method(quaternaryLabelColor))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn quaternaryLabelColor() -> Retained<NSColor>;
389
390 #[unsafe(method(quinaryLabelColor))]
391 #[unsafe(method_family = none)]
392 pub unsafe fn quinaryLabelColor() -> Retained<NSColor>;
393
394 #[unsafe(method(linkColor))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn linkColor() -> Retained<NSColor>;
398
399 #[unsafe(method(placeholderTextColor))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn placeholderTextColor() -> Retained<NSColor>;
402
403 #[unsafe(method(windowFrameTextColor))]
404 #[unsafe(method_family = none)]
405 pub unsafe fn windowFrameTextColor() -> Retained<NSColor>;
406
407 #[unsafe(method(selectedMenuItemTextColor))]
408 #[unsafe(method_family = none)]
409 pub unsafe fn selectedMenuItemTextColor() -> Retained<NSColor>;
410
411 #[unsafe(method(alternateSelectedControlTextColor))]
412 #[unsafe(method_family = none)]
413 pub unsafe fn alternateSelectedControlTextColor() -> Retained<NSColor>;
414
415 #[unsafe(method(headerTextColor))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn headerTextColor() -> Retained<NSColor>;
418
419 #[unsafe(method(separatorColor))]
420 #[unsafe(method_family = none)]
421 pub unsafe fn separatorColor() -> Retained<NSColor>;
422
423 #[unsafe(method(gridColor))]
424 #[unsafe(method_family = none)]
425 pub unsafe fn gridColor() -> Retained<NSColor>;
426
427 #[unsafe(method(windowBackgroundColor))]
428 #[unsafe(method_family = none)]
429 pub unsafe fn windowBackgroundColor() -> Retained<NSColor>;
430
431 #[unsafe(method(underPageBackgroundColor))]
432 #[unsafe(method_family = none)]
433 pub unsafe fn underPageBackgroundColor() -> Retained<NSColor>;
434
435 #[unsafe(method(controlBackgroundColor))]
436 #[unsafe(method_family = none)]
437 pub unsafe fn controlBackgroundColor() -> Retained<NSColor>;
438
439 #[unsafe(method(selectedContentBackgroundColor))]
440 #[unsafe(method_family = none)]
441 pub unsafe fn selectedContentBackgroundColor() -> Retained<NSColor>;
442
443 #[unsafe(method(unemphasizedSelectedContentBackgroundColor))]
444 #[unsafe(method_family = none)]
445 pub unsafe fn unemphasizedSelectedContentBackgroundColor() -> Retained<NSColor>;
446
447 #[unsafe(method(alternatingContentBackgroundColors))]
448 #[unsafe(method_family = none)]
449 pub unsafe fn alternatingContentBackgroundColors() -> Retained<NSArray<NSColor>>;
450
451 #[unsafe(method(findHighlightColor))]
452 #[unsafe(method_family = none)]
453 pub unsafe fn findHighlightColor() -> Retained<NSColor>;
454
455 #[unsafe(method(textColor))]
456 #[unsafe(method_family = none)]
457 pub unsafe fn textColor() -> Retained<NSColor>;
458
459 #[unsafe(method(textBackgroundColor))]
460 #[unsafe(method_family = none)]
461 pub unsafe fn textBackgroundColor() -> Retained<NSColor>;
462
463 #[unsafe(method(textInsertionPointColor))]
464 #[unsafe(method_family = none)]
465 pub unsafe fn textInsertionPointColor() -> Retained<NSColor>;
466
467 #[unsafe(method(selectedTextColor))]
468 #[unsafe(method_family = none)]
469 pub unsafe fn selectedTextColor() -> Retained<NSColor>;
470
471 #[unsafe(method(selectedTextBackgroundColor))]
472 #[unsafe(method_family = none)]
473 pub unsafe fn selectedTextBackgroundColor() -> Retained<NSColor>;
474
475 #[unsafe(method(unemphasizedSelectedTextBackgroundColor))]
476 #[unsafe(method_family = none)]
477 pub unsafe fn unemphasizedSelectedTextBackgroundColor() -> Retained<NSColor>;
478
479 #[unsafe(method(unemphasizedSelectedTextColor))]
480 #[unsafe(method_family = none)]
481 pub unsafe fn unemphasizedSelectedTextColor() -> Retained<NSColor>;
482
483 #[unsafe(method(controlColor))]
484 #[unsafe(method_family = none)]
485 pub unsafe fn controlColor() -> Retained<NSColor>;
486
487 #[unsafe(method(controlTextColor))]
488 #[unsafe(method_family = none)]
489 pub unsafe fn controlTextColor() -> Retained<NSColor>;
490
491 #[unsafe(method(selectedControlColor))]
492 #[unsafe(method_family = none)]
493 pub unsafe fn selectedControlColor() -> Retained<NSColor>;
494
495 #[unsafe(method(selectedControlTextColor))]
496 #[unsafe(method_family = none)]
497 pub unsafe fn selectedControlTextColor() -> Retained<NSColor>;
498
499 #[unsafe(method(disabledControlTextColor))]
500 #[unsafe(method_family = none)]
501 pub unsafe fn disabledControlTextColor() -> Retained<NSColor>;
502
503 #[unsafe(method(keyboardFocusIndicatorColor))]
504 #[unsafe(method_family = none)]
505 pub unsafe fn keyboardFocusIndicatorColor() -> Retained<NSColor>;
506
507 #[unsafe(method(scrubberTexturedBackgroundColor))]
508 #[unsafe(method_family = none)]
509 pub unsafe fn scrubberTexturedBackgroundColor() -> Retained<NSColor>;
510
511 #[unsafe(method(systemRedColor))]
512 #[unsafe(method_family = none)]
513 pub unsafe fn systemRedColor() -> Retained<NSColor>;
514
515 #[unsafe(method(systemGreenColor))]
516 #[unsafe(method_family = none)]
517 pub unsafe fn systemGreenColor() -> Retained<NSColor>;
518
519 #[unsafe(method(systemBlueColor))]
520 #[unsafe(method_family = none)]
521 pub unsafe fn systemBlueColor() -> Retained<NSColor>;
522
523 #[unsafe(method(systemOrangeColor))]
524 #[unsafe(method_family = none)]
525 pub unsafe fn systemOrangeColor() -> Retained<NSColor>;
526
527 #[unsafe(method(systemYellowColor))]
528 #[unsafe(method_family = none)]
529 pub unsafe fn systemYellowColor() -> Retained<NSColor>;
530
531 #[unsafe(method(systemBrownColor))]
532 #[unsafe(method_family = none)]
533 pub unsafe fn systemBrownColor() -> Retained<NSColor>;
534
535 #[unsafe(method(systemPinkColor))]
536 #[unsafe(method_family = none)]
537 pub unsafe fn systemPinkColor() -> Retained<NSColor>;
538
539 #[unsafe(method(systemPurpleColor))]
540 #[unsafe(method_family = none)]
541 pub unsafe fn systemPurpleColor() -> Retained<NSColor>;
542
543 #[unsafe(method(systemGrayColor))]
544 #[unsafe(method_family = none)]
545 pub unsafe fn systemGrayColor() -> Retained<NSColor>;
546
547 #[unsafe(method(systemTealColor))]
548 #[unsafe(method_family = none)]
549 pub unsafe fn systemTealColor() -> Retained<NSColor>;
550
551 #[unsafe(method(systemIndigoColor))]
552 #[unsafe(method_family = none)]
553 pub unsafe fn systemIndigoColor() -> Retained<NSColor>;
554
555 #[unsafe(method(systemMintColor))]
556 #[unsafe(method_family = none)]
557 pub unsafe fn systemMintColor() -> Retained<NSColor>;
558
559 #[unsafe(method(systemCyanColor))]
560 #[unsafe(method_family = none)]
561 pub unsafe fn systemCyanColor() -> Retained<NSColor>;
562
563 #[unsafe(method(systemFillColor))]
568 #[unsafe(method_family = none)]
569 pub unsafe fn systemFillColor() -> Retained<NSColor>;
570
571 #[unsafe(method(secondarySystemFillColor))]
573 #[unsafe(method_family = none)]
574 pub unsafe fn secondarySystemFillColor() -> Retained<NSColor>;
575
576 #[unsafe(method(tertiarySystemFillColor))]
578 #[unsafe(method_family = none)]
579 pub unsafe fn tertiarySystemFillColor() -> Retained<NSColor>;
580
581 #[unsafe(method(quaternarySystemFillColor))]
583 #[unsafe(method_family = none)]
584 pub unsafe fn quaternarySystemFillColor() -> Retained<NSColor>;
585
586 #[unsafe(method(quinarySystemFillColor))]
588 #[unsafe(method_family = none)]
589 pub unsafe fn quinarySystemFillColor() -> Retained<NSColor>;
590
591 #[unsafe(method(controlAccentColor))]
593 #[unsafe(method_family = none)]
594 pub unsafe fn controlAccentColor() -> Retained<NSColor>;
595
596 #[cfg(feature = "NSCell")]
597 #[unsafe(method(currentControlTint))]
598 #[unsafe(method_family = none)]
599 pub unsafe fn currentControlTint() -> NSControlTint;
600
601 #[cfg(feature = "NSCell")]
602 #[deprecated = "NSControlTint does not describe the full range of available control accent colors. Use +[NSColor controlAccentColor] instead."]
603 #[unsafe(method(colorForControlTint:))]
604 #[unsafe(method_family = none)]
605 pub unsafe fn colorForControlTint(control_tint: NSControlTint) -> Retained<NSColor>;
606
607 #[unsafe(method(highlightColor))]
608 #[unsafe(method_family = none)]
609 pub unsafe fn highlightColor() -> Retained<NSColor>;
610
611 #[unsafe(method(shadowColor))]
612 #[unsafe(method_family = none)]
613 pub unsafe fn shadowColor() -> Retained<NSColor>;
614
615 #[cfg(feature = "objc2-core-foundation")]
616 #[unsafe(method(highlightWithLevel:))]
617 #[unsafe(method_family = none)]
618 pub unsafe fn highlightWithLevel(&self, val: CGFloat) -> Option<Retained<NSColor>>;
619
620 #[cfg(feature = "objc2-core-foundation")]
621 #[unsafe(method(shadowWithLevel:))]
622 #[unsafe(method_family = none)]
623 pub unsafe fn shadowWithLevel(&self, val: CGFloat) -> Option<Retained<NSColor>>;
624
625 #[unsafe(method(colorWithSystemEffect:))]
627 #[unsafe(method_family = none)]
628 pub unsafe fn colorWithSystemEffect(
629 &self,
630 system_effect: NSColorSystemEffect,
631 ) -> Retained<NSColor>;
632
633 #[unsafe(method(set))]
634 #[unsafe(method_family = none)]
635 pub unsafe fn set(&self);
636
637 #[unsafe(method(setFill))]
638 #[unsafe(method_family = none)]
639 pub unsafe fn setFill(&self);
640
641 #[unsafe(method(setStroke))]
642 #[unsafe(method_family = none)]
643 pub unsafe fn setStroke(&self);
644
645 #[cfg(feature = "objc2-core-foundation")]
646 #[unsafe(method(blendedColorWithFraction:ofColor:))]
647 #[unsafe(method_family = none)]
648 pub unsafe fn blendedColorWithFraction_ofColor(
649 &self,
650 fraction: CGFloat,
651 color: &NSColor,
652 ) -> Option<Retained<NSColor>>;
653
654 #[cfg(feature = "objc2-core-foundation")]
655 #[unsafe(method(colorWithAlphaComponent:))]
656 #[unsafe(method_family = none)]
657 pub unsafe fn colorWithAlphaComponent(&self, alpha: CGFloat) -> Retained<NSColor>;
658
659 #[cfg(feature = "NSColorList")]
660 #[unsafe(method(catalogNameComponent))]
662 #[unsafe(method_family = none)]
663 pub unsafe fn catalogNameComponent(&self) -> Retained<NSColorListName>;
664
665 #[cfg(feature = "NSColorList")]
666 #[unsafe(method(colorNameComponent))]
667 #[unsafe(method_family = none)]
668 pub unsafe fn colorNameComponent(&self) -> Retained<NSColorName>;
669
670 #[unsafe(method(localizedCatalogNameComponent))]
671 #[unsafe(method_family = none)]
672 pub unsafe fn localizedCatalogNameComponent(&self) -> Retained<NSString>;
673
674 #[unsafe(method(localizedColorNameComponent))]
675 #[unsafe(method_family = none)]
676 pub unsafe fn localizedColorNameComponent(&self) -> Retained<NSString>;
677
678 #[cfg(feature = "objc2-core-foundation")]
679 #[unsafe(method(redComponent))]
680 #[unsafe(method_family = none)]
681 pub unsafe fn redComponent(&self) -> CGFloat;
682
683 #[cfg(feature = "objc2-core-foundation")]
684 #[unsafe(method(greenComponent))]
685 #[unsafe(method_family = none)]
686 pub unsafe fn greenComponent(&self) -> CGFloat;
687
688 #[cfg(feature = "objc2-core-foundation")]
689 #[unsafe(method(blueComponent))]
690 #[unsafe(method_family = none)]
691 pub unsafe fn blueComponent(&self) -> CGFloat;
692
693 #[cfg(feature = "objc2-core-foundation")]
694 #[unsafe(method(getRed:green:blue:alpha:))]
695 #[unsafe(method_family = none)]
696 pub unsafe fn getRed_green_blue_alpha(
697 &self,
698 red: *mut CGFloat,
699 green: *mut CGFloat,
700 blue: *mut CGFloat,
701 alpha: *mut CGFloat,
702 );
703
704 #[cfg(feature = "objc2-core-foundation")]
705 #[unsafe(method(hueComponent))]
706 #[unsafe(method_family = none)]
707 pub unsafe fn hueComponent(&self) -> CGFloat;
708
709 #[cfg(feature = "objc2-core-foundation")]
710 #[unsafe(method(saturationComponent))]
711 #[unsafe(method_family = none)]
712 pub unsafe fn saturationComponent(&self) -> CGFloat;
713
714 #[cfg(feature = "objc2-core-foundation")]
715 #[unsafe(method(brightnessComponent))]
716 #[unsafe(method_family = none)]
717 pub unsafe fn brightnessComponent(&self) -> CGFloat;
718
719 #[cfg(feature = "objc2-core-foundation")]
720 #[unsafe(method(getHue:saturation:brightness:alpha:))]
721 #[unsafe(method_family = none)]
722 pub unsafe fn getHue_saturation_brightness_alpha(
723 &self,
724 hue: *mut CGFloat,
725 saturation: *mut CGFloat,
726 brightness: *mut CGFloat,
727 alpha: *mut CGFloat,
728 );
729
730 #[cfg(feature = "objc2-core-foundation")]
731 #[unsafe(method(whiteComponent))]
732 #[unsafe(method_family = none)]
733 pub unsafe fn whiteComponent(&self) -> CGFloat;
734
735 #[cfg(feature = "objc2-core-foundation")]
736 #[unsafe(method(getWhite:alpha:))]
737 #[unsafe(method_family = none)]
738 pub unsafe fn getWhite_alpha(&self, white: *mut CGFloat, alpha: *mut CGFloat);
739
740 #[cfg(feature = "objc2-core-foundation")]
741 #[unsafe(method(cyanComponent))]
742 #[unsafe(method_family = none)]
743 pub unsafe fn cyanComponent(&self) -> CGFloat;
744
745 #[cfg(feature = "objc2-core-foundation")]
746 #[unsafe(method(magentaComponent))]
747 #[unsafe(method_family = none)]
748 pub unsafe fn magentaComponent(&self) -> CGFloat;
749
750 #[cfg(feature = "objc2-core-foundation")]
751 #[unsafe(method(yellowComponent))]
752 #[unsafe(method_family = none)]
753 pub unsafe fn yellowComponent(&self) -> CGFloat;
754
755 #[cfg(feature = "objc2-core-foundation")]
756 #[unsafe(method(blackComponent))]
757 #[unsafe(method_family = none)]
758 pub unsafe fn blackComponent(&self) -> CGFloat;
759
760 #[cfg(feature = "objc2-core-foundation")]
761 #[unsafe(method(getCyan:magenta:yellow:black:alpha:))]
762 #[unsafe(method_family = none)]
763 pub unsafe fn getCyan_magenta_yellow_black_alpha(
764 &self,
765 cyan: *mut CGFloat,
766 magenta: *mut CGFloat,
767 yellow: *mut CGFloat,
768 black: *mut CGFloat,
769 alpha: *mut CGFloat,
770 );
771
772 #[cfg(feature = "NSColorSpace")]
773 #[unsafe(method(colorSpace))]
774 #[unsafe(method_family = none)]
775 pub unsafe fn colorSpace(&self) -> Retained<NSColorSpace>;
776
777 #[unsafe(method(numberOfComponents))]
778 #[unsafe(method_family = none)]
779 pub unsafe fn numberOfComponents(&self) -> NSInteger;
780
781 #[cfg(feature = "objc2-core-foundation")]
782 #[unsafe(method(getComponents:))]
783 #[unsafe(method_family = none)]
784 pub unsafe fn getComponents(&self, components: NonNull<CGFloat>);
785
786 #[cfg(feature = "NSImage")]
787 #[unsafe(method(patternImage))]
788 #[unsafe(method_family = none)]
789 pub unsafe fn patternImage(&self) -> Retained<NSImage>;
790
791 #[cfg(feature = "objc2-core-foundation")]
792 #[unsafe(method(alphaComponent))]
793 #[unsafe(method_family = none)]
794 pub unsafe fn alphaComponent(&self) -> CGFloat;
795
796 #[cfg(feature = "NSPasteboard")]
797 #[unsafe(method(colorFromPasteboard:))]
798 #[unsafe(method_family = none)]
799 pub unsafe fn colorFromPasteboard(paste_board: &NSPasteboard) -> Option<Retained<NSColor>>;
800
801 #[cfg(feature = "NSPasteboard")]
802 #[unsafe(method(writeToPasteboard:))]
803 #[unsafe(method_family = none)]
804 pub unsafe fn writeToPasteboard(&self, paste_board: &NSPasteboard);
805
806 #[unsafe(method(drawSwatchInRect:))]
807 #[unsafe(method_family = none)]
808 pub unsafe fn drawSwatchInRect(&self, rect: NSRect);
809
810 #[cfg(feature = "objc2-core-graphics")]
811 #[cfg(target_vendor = "apple")]
812 #[unsafe(method(colorWithCGColor:))]
813 #[unsafe(method_family = none)]
814 pub unsafe fn colorWithCGColor(cg_color: &CGColor) -> Option<Retained<NSColor>>;
815
816 #[cfg(feature = "objc2-core-graphics")]
817 #[cfg(target_vendor = "apple")]
818 #[unsafe(method(CGColor))]
819 #[unsafe(method_family = none)]
820 pub unsafe fn CGColor(&self) -> Retained<CGColor>;
821
822 #[deprecated = "Use `showsAlpha` in `NSColorPanel` and `supportsAlpha` in `NSColorWell` to control alpha behavior for individual controls."]
823 #[unsafe(method(ignoresAlpha))]
824 #[unsafe(method_family = none)]
825 pub unsafe fn ignoresAlpha(mtm: MainThreadMarker) -> bool;
826
827 #[deprecated = "Use `showsAlpha` in `NSColorPanel` and `supportsAlpha` in `NSColorWell` to control alpha behavior for individual controls."]
829 #[unsafe(method(setIgnoresAlpha:))]
830 #[unsafe(method_family = none)]
831 pub unsafe fn setIgnoresAlpha(ignores_alpha: bool, mtm: MainThreadMarker);
832 );
833}
834
835impl NSColor {
837 extern_methods!(
838 #[unsafe(method(new))]
839 #[unsafe(method_family = new)]
840 pub unsafe fn new() -> Retained<Self>;
841 );
842}
843
844impl NSColor {
846 extern_methods!(
847 #[deprecated = "Use a color that matches the semantics being used, such as `separatorColor`"]
849 #[unsafe(method(controlHighlightColor))]
850 #[unsafe(method_family = none)]
851 pub unsafe fn controlHighlightColor() -> Retained<NSColor>;
852
853 #[deprecated = "Use a color that matches the semantics being used, such as `separatorColor`"]
855 #[unsafe(method(controlLightHighlightColor))]
856 #[unsafe(method_family = none)]
857 pub unsafe fn controlLightHighlightColor() -> Retained<NSColor>;
858
859 #[deprecated = "Use a color that matches the semantics being used, such as `separatorColor`"]
861 #[unsafe(method(controlShadowColor))]
862 #[unsafe(method_family = none)]
863 pub unsafe fn controlShadowColor() -> Retained<NSColor>;
864
865 #[deprecated = "Use a color that matches the semantics being used, such as `separatorColor`"]
867 #[unsafe(method(controlDarkShadowColor))]
868 #[unsafe(method_family = none)]
869 pub unsafe fn controlDarkShadowColor() -> Retained<NSColor>;
870
871 #[deprecated = "Use NSScroller instead"]
873 #[unsafe(method(scrollBarColor))]
874 #[unsafe(method_family = none)]
875 pub unsafe fn scrollBarColor() -> Retained<NSColor>;
876
877 #[deprecated = "Use NSScroller instead"]
879 #[unsafe(method(knobColor))]
880 #[unsafe(method_family = none)]
881 pub unsafe fn knobColor() -> Retained<NSColor>;
882
883 #[deprecated = "Use NSScroller instead"]
885 #[unsafe(method(selectedKnobColor))]
886 #[unsafe(method_family = none)]
887 pub unsafe fn selectedKnobColor() -> Retained<NSColor>;
888
889 #[deprecated = "Use NSVisualEffectMaterialTitlebar"]
891 #[unsafe(method(windowFrameColor))]
892 #[unsafe(method_family = none)]
893 pub unsafe fn windowFrameColor() -> Retained<NSColor>;
894
895 #[deprecated = "Use NSVisualEffectMaterialSelection"]
897 #[unsafe(method(selectedMenuItemColor))]
898 #[unsafe(method_family = none)]
899 pub unsafe fn selectedMenuItemColor() -> Retained<NSColor>;
900
901 #[deprecated = "Use NSVisualEffectMaterialHeaderView"]
903 #[unsafe(method(headerColor))]
904 #[unsafe(method_family = none)]
905 pub unsafe fn headerColor() -> Retained<NSColor>;
906
907 #[deprecated]
909 #[unsafe(method(secondarySelectedControlColor))]
910 #[unsafe(method_family = none)]
911 pub unsafe fn secondarySelectedControlColor() -> Retained<NSColor>;
912
913 #[deprecated]
915 #[unsafe(method(alternateSelectedControlColor))]
916 #[unsafe(method_family = none)]
917 pub unsafe fn alternateSelectedControlColor() -> Retained<NSColor>;
918
919 #[deprecated]
921 #[unsafe(method(controlAlternatingRowBackgroundColors))]
922 #[unsafe(method_family = none)]
923 pub unsafe fn controlAlternatingRowBackgroundColors() -> Retained<NSArray<NSColor>>;
924
925 #[cfg(feature = "NSGraphics")]
926 #[deprecated = "Use -type and NSColorType instead"]
927 #[unsafe(method(colorSpaceName))]
928 #[unsafe(method_family = none)]
929 pub unsafe fn colorSpaceName(&self) -> Retained<NSColorSpaceName>;
930
931 #[cfg(feature = "NSGraphics")]
932 #[deprecated = "Use -colorUsingType: or -colorUsingColorSpace: instead"]
933 #[unsafe(method(colorUsingColorSpaceName:device:))]
934 #[unsafe(method_family = none)]
935 pub unsafe fn colorUsingColorSpaceName_device(
936 &self,
937 name: Option<&NSColorSpaceName>,
938 device_description: Option<&NSDictionary<NSDeviceDescriptionKey, AnyObject>>,
939 ) -> Option<Retained<NSColor>>;
940
941 #[cfg(feature = "NSGraphics")]
942 #[deprecated = "Use -colorUsingType: or -colorUsingColorSpace: instead"]
943 #[unsafe(method(colorUsingColorSpaceName:))]
944 #[unsafe(method_family = none)]
945 pub unsafe fn colorUsingColorSpaceName(
946 &self,
947 name: &NSColorSpaceName,
948 ) -> Option<Retained<NSColor>>;
949 );
950}
951
952impl NSColor {
954 extern_methods!(
955 #[cfg(feature = "objc2-core-image")]
956 #[cfg(target_vendor = "apple")]
957 #[unsafe(method(colorWithCIColor:))]
958 #[unsafe(method_family = none)]
959 pub unsafe fn colorWithCIColor(color: &CIColor) -> Retained<NSColor>;
960 );
961}
962
963mod private_CIColorNSAppKitAdditions {
964 pub trait Sealed {}
965}
966
967#[doc(alias = "NSAppKitAdditions")]
969pub unsafe trait CIColorNSAppKitAdditions:
970 ClassType + Sized + private_CIColorNSAppKitAdditions::Sealed
971{
972 extern_methods!(
973 #[unsafe(method(initWithColor:))]
974 #[unsafe(method_family = init)]
975 unsafe fn initWithColor(this: Allocated<Self>, color: &NSColor) -> Option<Retained<Self>>;
976 );
977}
978
979#[cfg(feature = "objc2-core-image")]
980#[cfg(target_vendor = "apple")]
981impl private_CIColorNSAppKitAdditions::Sealed for CIColor {}
982#[cfg(feature = "objc2-core-image")]
983#[cfg(target_vendor = "apple")]
984unsafe impl CIColorNSAppKitAdditions for CIColor {}
985
986extern "C" {
987 pub static NSSystemColorsDidChangeNotification: &'static NSNotificationName;
989}