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-image")]
9#[cfg(target_vendor = "apple")]
10use objc2_core_image::*;
11use objc2_foundation::*;
12#[cfg(feature = "objc2-quartz-core")]
13#[cfg(target_vendor = "apple")]
14use objc2_quartz_core::*;
15
16use crate::*;
17
18#[repr(transparent)]
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub struct NSAutoresizingMaskOptions(pub NSUInteger);
23bitflags::bitflags! {
24 impl NSAutoresizingMaskOptions: NSUInteger {
25 #[doc(alias = "NSViewNotSizable")]
26 const ViewNotSizable = 0;
27 #[doc(alias = "NSViewMinXMargin")]
28 const ViewMinXMargin = 1;
29 #[doc(alias = "NSViewWidthSizable")]
30 const ViewWidthSizable = 2;
31 #[doc(alias = "NSViewMaxXMargin")]
32 const ViewMaxXMargin = 4;
33 #[doc(alias = "NSViewMinYMargin")]
34 const ViewMinYMargin = 8;
35 #[doc(alias = "NSViewHeightSizable")]
36 const ViewHeightSizable = 16;
37 #[doc(alias = "NSViewMaxYMargin")]
38 const ViewMaxYMargin = 32;
39 }
40}
41
42unsafe impl Encode for NSAutoresizingMaskOptions {
43 const ENCODING: Encoding = NSUInteger::ENCODING;
44}
45
46unsafe impl RefEncode for NSAutoresizingMaskOptions {
47 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
48}
49
50#[repr(transparent)]
53#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
54pub struct NSBorderType(pub NSUInteger);
55impl NSBorderType {
56 #[doc(alias = "NSNoBorder")]
57 pub const NoBorder: Self = Self(0);
58 #[doc(alias = "NSLineBorder")]
59 pub const LineBorder: Self = Self(1);
60 #[doc(alias = "NSBezelBorder")]
61 pub const BezelBorder: Self = Self(2);
62 #[doc(alias = "NSGrooveBorder")]
63 pub const GrooveBorder: Self = Self(3);
64}
65
66unsafe impl Encode for NSBorderType {
67 const ENCODING: Encoding = NSUInteger::ENCODING;
68}
69
70unsafe impl RefEncode for NSBorderType {
71 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74#[repr(transparent)]
77#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
78pub struct NSViewLayerContentsRedrawPolicy(pub NSInteger);
79impl NSViewLayerContentsRedrawPolicy {
80 #[doc(alias = "NSViewLayerContentsRedrawNever")]
81 pub const Never: Self = Self(0);
82 #[doc(alias = "NSViewLayerContentsRedrawOnSetNeedsDisplay")]
83 pub const OnSetNeedsDisplay: Self = Self(1);
84 #[doc(alias = "NSViewLayerContentsRedrawDuringViewResize")]
85 pub const DuringViewResize: Self = Self(2);
86 #[doc(alias = "NSViewLayerContentsRedrawBeforeViewResize")]
87 pub const BeforeViewResize: Self = Self(3);
88 #[doc(alias = "NSViewLayerContentsRedrawCrossfade")]
89 pub const Crossfade: Self = Self(4);
90}
91
92unsafe impl Encode for NSViewLayerContentsRedrawPolicy {
93 const ENCODING: Encoding = NSInteger::ENCODING;
94}
95
96unsafe impl RefEncode for NSViewLayerContentsRedrawPolicy {
97 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
98}
99
100#[repr(transparent)]
103#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
104pub struct NSViewLayerContentsPlacement(pub NSInteger);
105impl NSViewLayerContentsPlacement {
106 #[doc(alias = "NSViewLayerContentsPlacementScaleAxesIndependently")]
107 pub const ScaleAxesIndependently: Self = Self(0);
108 #[doc(alias = "NSViewLayerContentsPlacementScaleProportionallyToFit")]
109 pub const ScaleProportionallyToFit: Self = Self(1);
110 #[doc(alias = "NSViewLayerContentsPlacementScaleProportionallyToFill")]
111 pub const ScaleProportionallyToFill: Self = Self(2);
112 #[doc(alias = "NSViewLayerContentsPlacementCenter")]
113 pub const Center: Self = Self(3);
114 #[doc(alias = "NSViewLayerContentsPlacementTop")]
115 pub const Top: Self = Self(4);
116 #[doc(alias = "NSViewLayerContentsPlacementTopRight")]
117 pub const TopRight: Self = Self(5);
118 #[doc(alias = "NSViewLayerContentsPlacementRight")]
119 pub const Right: Self = Self(6);
120 #[doc(alias = "NSViewLayerContentsPlacementBottomRight")]
121 pub const BottomRight: Self = Self(7);
122 #[doc(alias = "NSViewLayerContentsPlacementBottom")]
123 pub const Bottom: Self = Self(8);
124 #[doc(alias = "NSViewLayerContentsPlacementBottomLeft")]
125 pub const BottomLeft: Self = Self(9);
126 #[doc(alias = "NSViewLayerContentsPlacementLeft")]
127 pub const Left: Self = Self(10);
128 #[doc(alias = "NSViewLayerContentsPlacementTopLeft")]
129 pub const TopLeft: Self = Self(11);
130}
131
132unsafe impl Encode for NSViewLayerContentsPlacement {
133 const ENCODING: Encoding = NSInteger::ENCODING;
134}
135
136unsafe impl RefEncode for NSViewLayerContentsPlacement {
137 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
138}
139
140pub type NSTrackingRectTag = NSInteger;
142
143pub type NSToolTipTag = NSInteger;
145
146extern_class!(
147 #[unsafe(super(NSResponder, NSObject))]
149 #[thread_kind = MainThreadOnly]
150 #[derive(Debug, PartialEq, Eq, Hash)]
151 #[cfg(feature = "NSResponder")]
152 pub struct NSView;
153);
154
155#[cfg(all(feature = "NSAccessibilityProtocols", feature = "NSResponder"))]
156extern_conformance!(
157 unsafe impl NSAccessibility for NSView {}
158);
159
160#[cfg(all(feature = "NSAccessibilityProtocols", feature = "NSResponder"))]
161extern_conformance!(
162 unsafe impl NSAccessibilityElementProtocol for NSView {}
163);
164
165#[cfg(all(feature = "NSAnimation", feature = "NSResponder"))]
166extern_conformance!(
167 unsafe impl NSAnimatablePropertyContainer for NSView {}
168);
169
170#[cfg(all(feature = "NSAppearance", feature = "NSResponder"))]
171extern_conformance!(
172 unsafe impl NSAppearanceCustomization for NSView {}
173);
174
175#[cfg(feature = "NSResponder")]
176extern_conformance!(
177 unsafe impl NSCoding for NSView {}
178);
179
180#[cfg(all(feature = "NSDragging", feature = "NSResponder"))]
181extern_conformance!(
182 unsafe impl NSDraggingDestination for NSView {}
183);
184
185#[cfg(feature = "NSResponder")]
186extern_conformance!(
187 unsafe impl NSObjectProtocol for NSView {}
188);
189
190#[cfg(all(feature = "NSResponder", feature = "NSUserInterfaceItemIdentification"))]
191extern_conformance!(
192 unsafe impl NSUserInterfaceItemIdentification for NSView {}
193);
194
195#[cfg(feature = "NSResponder")]
196impl NSView {
197 extern_methods!(
198 #[unsafe(method(initWithFrame:))]
199 #[unsafe(method_family = init)]
200 pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
201
202 #[unsafe(method(initWithCoder:))]
206 #[unsafe(method_family = init)]
207 pub unsafe fn initWithCoder(
208 this: Allocated<Self>,
209 coder: &NSCoder,
210 ) -> Option<Retained<Self>>;
211
212 #[cfg(feature = "NSWindow")]
213 #[unsafe(method(window))]
214 #[unsafe(method_family = none)]
215 pub fn window(&self) -> Option<Retained<NSWindow>>;
216
217 #[unsafe(method(superview))]
221 #[unsafe(method_family = none)]
222 pub unsafe fn superview(&self) -> Option<Retained<NSView>>;
223
224 #[unsafe(method(subviews))]
225 #[unsafe(method_family = none)]
226 pub fn subviews(&self) -> Retained<NSArray<NSView>>;
227
228 #[unsafe(method(setSubviews:))]
232 #[unsafe(method_family = none)]
233 pub fn setSubviews(&self, subviews: &NSArray<NSView>);
234
235 #[unsafe(method(isDescendantOf:))]
236 #[unsafe(method_family = none)]
237 pub fn isDescendantOf(&self, view: &NSView) -> bool;
238
239 #[unsafe(method(ancestorSharedWithView:))]
240 #[unsafe(method_family = none)]
241 pub fn ancestorSharedWithView(&self, view: &NSView) -> Option<Retained<NSView>>;
242
243 #[unsafe(method(opaqueAncestor))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn opaqueAncestor(&self) -> Option<Retained<NSView>>;
249
250 #[unsafe(method(isHidden))]
251 #[unsafe(method_family = none)]
252 pub fn isHidden(&self) -> bool;
253
254 #[unsafe(method(setHidden:))]
256 #[unsafe(method_family = none)]
257 pub fn setHidden(&self, hidden: bool);
258
259 #[unsafe(method(isHiddenOrHasHiddenAncestor))]
260 #[unsafe(method_family = none)]
261 pub fn isHiddenOrHasHiddenAncestor(&self) -> bool;
262
263 #[unsafe(method(getRectsBeingDrawn:count:))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn getRectsBeingDrawn_count(
270 &self,
271 rects: *mut *const NSRect,
272 count: *mut NSInteger,
273 );
274
275 #[unsafe(method(needsToDrawRect:))]
276 #[unsafe(method_family = none)]
277 pub fn needsToDrawRect(&self, rect: NSRect) -> bool;
278
279 #[unsafe(method(wantsDefaultClipping))]
280 #[unsafe(method_family = none)]
281 pub fn wantsDefaultClipping(&self) -> bool;
282
283 #[unsafe(method(viewDidHide))]
284 #[unsafe(method_family = none)]
285 pub fn viewDidHide(&self);
286
287 #[unsafe(method(viewDidUnhide))]
288 #[unsafe(method_family = none)]
289 pub fn viewDidUnhide(&self);
290
291 #[unsafe(method(addSubview:))]
292 #[unsafe(method_family = none)]
293 pub fn addSubview(&self, view: &NSView);
294
295 #[cfg(feature = "NSGraphics")]
296 #[unsafe(method(addSubview:positioned:relativeTo:))]
297 #[unsafe(method_family = none)]
298 pub fn addSubview_positioned_relativeTo(
299 &self,
300 view: &NSView,
301 place: NSWindowOrderingMode,
302 other_view: Option<&NSView>,
303 );
304
305 #[unsafe(method(sortSubviewsUsingFunction:context:))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn sortSubviewsUsingFunction_context(
312 &self,
313 compare: unsafe extern "C-unwind" fn(
314 NonNull<NSView>,
315 NonNull<NSView>,
316 *mut c_void,
317 ) -> NSComparisonResult,
318 context: *mut c_void,
319 );
320
321 #[cfg(feature = "NSWindow")]
322 #[unsafe(method(viewWillMoveToWindow:))]
323 #[unsafe(method_family = none)]
324 pub fn viewWillMoveToWindow(&self, new_window: Option<&NSWindow>);
325
326 #[unsafe(method(viewDidMoveToWindow))]
327 #[unsafe(method_family = none)]
328 pub fn viewDidMoveToWindow(&self);
329
330 #[unsafe(method(viewWillMoveToSuperview:))]
331 #[unsafe(method_family = none)]
332 pub fn viewWillMoveToSuperview(&self, new_superview: Option<&NSView>);
333
334 #[unsafe(method(viewDidMoveToSuperview))]
335 #[unsafe(method_family = none)]
336 pub fn viewDidMoveToSuperview(&self);
337
338 #[unsafe(method(didAddSubview:))]
339 #[unsafe(method_family = none)]
340 pub fn didAddSubview(&self, subview: &NSView);
341
342 #[unsafe(method(willRemoveSubview:))]
343 #[unsafe(method_family = none)]
344 pub fn willRemoveSubview(&self, subview: &NSView);
345
346 #[unsafe(method(removeFromSuperview))]
347 #[unsafe(method_family = none)]
348 pub fn removeFromSuperview(&self);
349
350 #[unsafe(method(replaceSubview:with:))]
351 #[unsafe(method_family = none)]
352 pub fn replaceSubview_with(&self, old_view: &NSView, new_view: &NSView);
353
354 #[unsafe(method(removeFromSuperviewWithoutNeedingDisplay))]
355 #[unsafe(method_family = none)]
356 pub fn removeFromSuperviewWithoutNeedingDisplay(&self);
357
358 #[unsafe(method(viewDidChangeBackingProperties))]
359 #[unsafe(method_family = none)]
360 pub fn viewDidChangeBackingProperties(&self);
361
362 #[unsafe(method(postsFrameChangedNotifications))]
363 #[unsafe(method_family = none)]
364 pub fn postsFrameChangedNotifications(&self) -> bool;
365
366 #[unsafe(method(setPostsFrameChangedNotifications:))]
368 #[unsafe(method_family = none)]
369 pub fn setPostsFrameChangedNotifications(&self, posts_frame_changed_notifications: bool);
370
371 #[unsafe(method(resizeSubviewsWithOldSize:))]
372 #[unsafe(method_family = none)]
373 pub fn resizeSubviewsWithOldSize(&self, old_size: NSSize);
374
375 #[unsafe(method(resizeWithOldSuperviewSize:))]
376 #[unsafe(method_family = none)]
377 pub fn resizeWithOldSuperviewSize(&self, old_size: NSSize);
378
379 #[unsafe(method(autoresizesSubviews))]
380 #[unsafe(method_family = none)]
381 pub fn autoresizesSubviews(&self) -> bool;
382
383 #[unsafe(method(setAutoresizesSubviews:))]
385 #[unsafe(method_family = none)]
386 pub fn setAutoresizesSubviews(&self, autoresizes_subviews: bool);
387
388 #[unsafe(method(autoresizingMask))]
389 #[unsafe(method_family = none)]
390 pub fn autoresizingMask(&self) -> NSAutoresizingMaskOptions;
391
392 #[unsafe(method(setAutoresizingMask:))]
394 #[unsafe(method_family = none)]
395 pub fn setAutoresizingMask(&self, autoresizing_mask: NSAutoresizingMaskOptions);
396
397 #[unsafe(method(setFrameOrigin:))]
398 #[unsafe(method_family = none)]
399 pub fn setFrameOrigin(&self, new_origin: NSPoint);
400
401 #[unsafe(method(setFrameSize:))]
402 #[unsafe(method_family = none)]
403 pub fn setFrameSize(&self, new_size: NSSize);
404
405 #[unsafe(method(frame))]
406 #[unsafe(method_family = none)]
407 pub fn frame(&self) -> NSRect;
408
409 #[unsafe(method(setFrame:))]
411 #[unsafe(method_family = none)]
412 pub fn setFrame(&self, frame: NSRect);
413
414 #[cfg(feature = "objc2-core-foundation")]
415 #[unsafe(method(frameRotation))]
416 #[unsafe(method_family = none)]
417 pub fn frameRotation(&self) -> CGFloat;
418
419 #[cfg(feature = "objc2-core-foundation")]
420 #[unsafe(method(setFrameRotation:))]
422 #[unsafe(method_family = none)]
423 pub fn setFrameRotation(&self, frame_rotation: CGFloat);
424
425 #[cfg(feature = "objc2-core-foundation")]
426 #[unsafe(method(frameCenterRotation))]
427 #[unsafe(method_family = none)]
428 pub fn frameCenterRotation(&self) -> CGFloat;
429
430 #[cfg(feature = "objc2-core-foundation")]
431 #[unsafe(method(setFrameCenterRotation:))]
433 #[unsafe(method_family = none)]
434 pub fn setFrameCenterRotation(&self, frame_center_rotation: CGFloat);
435
436 #[unsafe(method(setBoundsOrigin:))]
437 #[unsafe(method_family = none)]
438 pub fn setBoundsOrigin(&self, new_origin: NSPoint);
439
440 #[unsafe(method(setBoundsSize:))]
441 #[unsafe(method_family = none)]
442 pub fn setBoundsSize(&self, new_size: NSSize);
443
444 #[cfg(feature = "objc2-core-foundation")]
445 #[unsafe(method(boundsRotation))]
446 #[unsafe(method_family = none)]
447 pub fn boundsRotation(&self) -> CGFloat;
448
449 #[cfg(feature = "objc2-core-foundation")]
450 #[unsafe(method(setBoundsRotation:))]
452 #[unsafe(method_family = none)]
453 pub fn setBoundsRotation(&self, bounds_rotation: CGFloat);
454
455 #[unsafe(method(translateOriginToPoint:))]
456 #[unsafe(method_family = none)]
457 pub fn translateOriginToPoint(&self, translation: NSPoint);
458
459 #[unsafe(method(scaleUnitSquareToSize:))]
460 #[unsafe(method_family = none)]
461 pub fn scaleUnitSquareToSize(&self, new_unit_size: NSSize);
462
463 #[cfg(feature = "objc2-core-foundation")]
464 #[unsafe(method(rotateByAngle:))]
465 #[unsafe(method_family = none)]
466 pub fn rotateByAngle(&self, angle: CGFloat);
467
468 #[unsafe(method(bounds))]
469 #[unsafe(method_family = none)]
470 pub fn bounds(&self) -> NSRect;
471
472 #[unsafe(method(setBounds:))]
474 #[unsafe(method_family = none)]
475 pub fn setBounds(&self, bounds: NSRect);
476
477 #[unsafe(method(isFlipped))]
478 #[unsafe(method_family = none)]
479 pub fn isFlipped(&self) -> bool;
480
481 #[unsafe(method(isRotatedFromBase))]
482 #[unsafe(method_family = none)]
483 pub fn isRotatedFromBase(&self) -> bool;
484
485 #[unsafe(method(isRotatedOrScaledFromBase))]
486 #[unsafe(method_family = none)]
487 pub fn isRotatedOrScaledFromBase(&self) -> bool;
488
489 #[unsafe(method(isOpaque))]
490 #[unsafe(method_family = none)]
491 pub fn isOpaque(&self) -> bool;
492
493 #[unsafe(method(convertPoint:fromView:))]
494 #[unsafe(method_family = none)]
495 pub fn convertPoint_fromView(&self, point: NSPoint, view: Option<&NSView>) -> NSPoint;
496
497 #[unsafe(method(convertPoint:toView:))]
498 #[unsafe(method_family = none)]
499 pub fn convertPoint_toView(&self, point: NSPoint, view: Option<&NSView>) -> NSPoint;
500
501 #[unsafe(method(convertSize:fromView:))]
502 #[unsafe(method_family = none)]
503 pub fn convertSize_fromView(&self, size: NSSize, view: Option<&NSView>) -> NSSize;
504
505 #[unsafe(method(convertSize:toView:))]
506 #[unsafe(method_family = none)]
507 pub fn convertSize_toView(&self, size: NSSize, view: Option<&NSView>) -> NSSize;
508
509 #[unsafe(method(convertRect:fromView:))]
510 #[unsafe(method_family = none)]
511 pub fn convertRect_fromView(&self, rect: NSRect, view: Option<&NSView>) -> NSRect;
512
513 #[unsafe(method(convertRect:toView:))]
514 #[unsafe(method_family = none)]
515 pub fn convertRect_toView(&self, rect: NSRect, view: Option<&NSView>) -> NSRect;
516
517 #[unsafe(method(backingAlignedRect:options:))]
518 #[unsafe(method_family = none)]
519 pub fn backingAlignedRect_options(
520 &self,
521 rect: NSRect,
522 options: NSAlignmentOptions,
523 ) -> NSRect;
524
525 #[unsafe(method(centerScanRect:))]
526 #[unsafe(method_family = none)]
527 pub fn centerScanRect(&self, rect: NSRect) -> NSRect;
528
529 #[unsafe(method(convertPointToBacking:))]
530 #[unsafe(method_family = none)]
531 pub fn convertPointToBacking(&self, point: NSPoint) -> NSPoint;
532
533 #[unsafe(method(convertPointFromBacking:))]
534 #[unsafe(method_family = none)]
535 pub fn convertPointFromBacking(&self, point: NSPoint) -> NSPoint;
536
537 #[unsafe(method(convertSizeToBacking:))]
538 #[unsafe(method_family = none)]
539 pub fn convertSizeToBacking(&self, size: NSSize) -> NSSize;
540
541 #[unsafe(method(convertSizeFromBacking:))]
542 #[unsafe(method_family = none)]
543 pub fn convertSizeFromBacking(&self, size: NSSize) -> NSSize;
544
545 #[unsafe(method(convertRectToBacking:))]
546 #[unsafe(method_family = none)]
547 pub fn convertRectToBacking(&self, rect: NSRect) -> NSRect;
548
549 #[unsafe(method(convertRectFromBacking:))]
550 #[unsafe(method_family = none)]
551 pub fn convertRectFromBacking(&self, rect: NSRect) -> NSRect;
552
553 #[unsafe(method(convertPointToLayer:))]
554 #[unsafe(method_family = none)]
555 pub fn convertPointToLayer(&self, point: NSPoint) -> NSPoint;
556
557 #[unsafe(method(convertPointFromLayer:))]
558 #[unsafe(method_family = none)]
559 pub fn convertPointFromLayer(&self, point: NSPoint) -> NSPoint;
560
561 #[unsafe(method(convertSizeToLayer:))]
562 #[unsafe(method_family = none)]
563 pub fn convertSizeToLayer(&self, size: NSSize) -> NSSize;
564
565 #[unsafe(method(convertSizeFromLayer:))]
566 #[unsafe(method_family = none)]
567 pub fn convertSizeFromLayer(&self, size: NSSize) -> NSSize;
568
569 #[unsafe(method(convertRectToLayer:))]
570 #[unsafe(method_family = none)]
571 pub fn convertRectToLayer(&self, rect: NSRect) -> NSRect;
572
573 #[unsafe(method(convertRectFromLayer:))]
574 #[unsafe(method_family = none)]
575 pub fn convertRectFromLayer(&self, rect: NSRect) -> NSRect;
576
577 #[unsafe(method(canDrawConcurrently))]
578 #[unsafe(method_family = none)]
579 pub fn canDrawConcurrently(&self) -> bool;
580
581 #[unsafe(method(setCanDrawConcurrently:))]
583 #[unsafe(method_family = none)]
584 pub unsafe fn setCanDrawConcurrently(&self, can_draw_concurrently: bool);
585
586 #[deprecated = "If a view needs display, -drawRect: or -updateLayer will be called automatically when the view is able to draw. To check whether a view is in a window, call -window. To check whether a view is hidden, call -isHiddenOrHasHiddenAncestor."]
587 #[unsafe(method(canDraw))]
588 #[unsafe(method_family = none)]
589 pub fn canDraw(&self) -> bool;
590
591 #[unsafe(method(setNeedsDisplayInRect:))]
592 #[unsafe(method_family = none)]
593 pub fn setNeedsDisplayInRect(&self, invalid_rect: NSRect);
594
595 #[unsafe(method(needsDisplay))]
596 #[unsafe(method_family = none)]
597 pub fn needsDisplay(&self) -> bool;
598
599 #[unsafe(method(setNeedsDisplay:))]
601 #[unsafe(method_family = none)]
602 pub fn setNeedsDisplay(&self, needs_display: bool);
603
604 #[deprecated = "To draw, subclass NSView and implement -drawRect:; AppKit's automatic deferred display mechanism will call -drawRect: as necessary to display the view."]
605 #[unsafe(method(lockFocus))]
606 #[unsafe(method_family = none)]
607 pub fn lockFocus(&self);
608
609 #[deprecated = "To draw, subclass NSView and implement -drawRect:; AppKit's automatic deferred display mechanism will call -drawRect: as necessary to display the view."]
610 #[unsafe(method(unlockFocus))]
611 #[unsafe(method_family = none)]
612 pub fn unlockFocus(&self);
613
614 #[deprecated = "To draw, subclass NSView and implement -drawRect:; AppKit's automatic deferred display mechanism will call -drawRect: as necessary to display the view."]
615 #[unsafe(method(lockFocusIfCanDraw))]
616 #[unsafe(method_family = none)]
617 pub fn lockFocusIfCanDraw(&self) -> bool;
618
619 #[cfg(feature = "NSGraphicsContext")]
620 #[deprecated = "Use -[NSView displayRectIgnoringOpacity:inContext:] to draw a view subtree into a graphics context."]
621 #[unsafe(method(lockFocusIfCanDrawInContext:))]
622 #[unsafe(method_family = none)]
623 pub fn lockFocusIfCanDrawInContext(&self, context: &NSGraphicsContext) -> bool;
624
625 #[unsafe(method(focusView))]
626 #[unsafe(method_family = none)]
627 pub fn focusView(mtm: MainThreadMarker) -> Option<Retained<NSView>>;
628
629 #[unsafe(method(visibleRect))]
635 #[unsafe(method_family = none)]
636 pub fn visibleRect(&self) -> NSRect;
637
638 #[unsafe(method(display))]
639 #[unsafe(method_family = none)]
640 pub fn display(&self);
641
642 #[unsafe(method(displayIfNeeded))]
643 #[unsafe(method_family = none)]
644 pub fn displayIfNeeded(&self);
645
646 #[unsafe(method(displayIfNeededIgnoringOpacity))]
647 #[unsafe(method_family = none)]
648 pub fn displayIfNeededIgnoringOpacity(&self);
649
650 #[unsafe(method(displayRect:))]
651 #[unsafe(method_family = none)]
652 pub fn displayRect(&self, rect: NSRect);
653
654 #[unsafe(method(displayIfNeededInRect:))]
655 #[unsafe(method_family = none)]
656 pub fn displayIfNeededInRect(&self, rect: NSRect);
657
658 #[unsafe(method(displayRectIgnoringOpacity:))]
659 #[unsafe(method_family = none)]
660 pub fn displayRectIgnoringOpacity(&self, rect: NSRect);
661
662 #[unsafe(method(displayIfNeededInRectIgnoringOpacity:))]
663 #[unsafe(method_family = none)]
664 pub fn displayIfNeededInRectIgnoringOpacity(&self, rect: NSRect);
665
666 #[unsafe(method(drawRect:))]
667 #[unsafe(method_family = none)]
668 pub fn drawRect(&self, dirty_rect: NSRect);
669
670 #[cfg(feature = "NSGraphicsContext")]
671 #[unsafe(method(displayRectIgnoringOpacity:inContext:))]
672 #[unsafe(method_family = none)]
673 pub fn displayRectIgnoringOpacity_inContext(
674 &self,
675 rect: NSRect,
676 context: &NSGraphicsContext,
677 );
678
679 #[cfg(all(feature = "NSBitmapImageRep", feature = "NSImageRep"))]
680 #[unsafe(method(bitmapImageRepForCachingDisplayInRect:))]
681 #[unsafe(method_family = none)]
682 pub fn bitmapImageRepForCachingDisplayInRect(
683 &self,
684 rect: NSRect,
685 ) -> Option<Retained<NSBitmapImageRep>>;
686
687 #[cfg(all(feature = "NSBitmapImageRep", feature = "NSImageRep"))]
688 #[unsafe(method(cacheDisplayInRect:toBitmapImageRep:))]
689 #[unsafe(method_family = none)]
690 pub fn cacheDisplayInRect_toBitmapImageRep(
691 &self,
692 rect: NSRect,
693 bitmap_image_rep: &NSBitmapImageRep,
694 );
695
696 #[unsafe(method(viewWillDraw))]
697 #[unsafe(method_family = none)]
698 pub fn viewWillDraw(&self);
699
700 #[unsafe(method(scrollPoint:))]
701 #[unsafe(method_family = none)]
702 pub fn scrollPoint(&self, point: NSPoint);
703
704 #[unsafe(method(scrollRectToVisible:))]
705 #[unsafe(method_family = none)]
706 pub fn scrollRectToVisible(&self, rect: NSRect) -> bool;
707
708 #[cfg(feature = "NSEvent")]
709 #[unsafe(method(autoscroll:))]
710 #[unsafe(method_family = none)]
711 pub fn autoscroll(&self, event: &NSEvent) -> bool;
712
713 #[unsafe(method(adjustScroll:))]
714 #[unsafe(method_family = none)]
715 pub fn adjustScroll(&self, new_visible: NSRect) -> NSRect;
716
717 #[deprecated = "Use NSScrollView to achieve scrolling views."]
718 #[unsafe(method(scrollRect:by:))]
719 #[unsafe(method_family = none)]
720 pub fn scrollRect_by(&self, rect: NSRect, delta: NSSize);
721
722 #[unsafe(method(translateRectsNeedingDisplayInRect:by:))]
723 #[unsafe(method_family = none)]
724 pub fn translateRectsNeedingDisplayInRect_by(&self, clip_rect: NSRect, delta: NSSize);
725
726 #[unsafe(method(hitTest:))]
727 #[unsafe(method_family = none)]
728 pub fn hitTest(&self, point: NSPoint) -> Option<Retained<NSView>>;
729
730 #[unsafe(method(mouse:inRect:))]
731 #[unsafe(method_family = none)]
732 pub fn mouse_inRect(&self, point: NSPoint, rect: NSRect) -> bool;
733
734 #[unsafe(method(viewWithTag:))]
735 #[unsafe(method_family = none)]
736 pub fn viewWithTag(&self, tag: NSInteger) -> Option<Retained<NSView>>;
737
738 #[unsafe(method(tag))]
739 #[unsafe(method_family = none)]
740 pub fn tag(&self) -> NSInteger;
741
742 #[cfg(feature = "NSEvent")]
743 #[unsafe(method(performKeyEquivalent:))]
744 #[unsafe(method_family = none)]
745 pub fn performKeyEquivalent(&self, event: &NSEvent) -> bool;
746
747 #[cfg(feature = "NSEvent")]
748 #[unsafe(method(acceptsFirstMouse:))]
749 #[unsafe(method_family = none)]
750 pub fn acceptsFirstMouse(&self, event: Option<&NSEvent>) -> bool;
751
752 #[cfg(feature = "NSEvent")]
753 #[unsafe(method(shouldDelayWindowOrderingForEvent:))]
754 #[unsafe(method_family = none)]
755 pub fn shouldDelayWindowOrderingForEvent(&self, event: &NSEvent) -> bool;
756
757 #[unsafe(method(needsPanelToBecomeKey))]
758 #[unsafe(method_family = none)]
759 pub fn needsPanelToBecomeKey(&self) -> bool;
760
761 #[unsafe(method(mouseDownCanMoveWindow))]
762 #[unsafe(method_family = none)]
763 pub fn mouseDownCanMoveWindow(&self) -> bool;
764
765 #[deprecated = "Use allowedTouchTypes instead"]
766 #[unsafe(method(acceptsTouchEvents))]
767 #[unsafe(method_family = none)]
768 pub fn acceptsTouchEvents(&self) -> bool;
769
770 #[deprecated = "Use allowedTouchTypes instead"]
772 #[unsafe(method(setAcceptsTouchEvents:))]
773 #[unsafe(method_family = none)]
774 pub fn setAcceptsTouchEvents(&self, accepts_touch_events: bool);
775
776 #[unsafe(method(wantsRestingTouches))]
777 #[unsafe(method_family = none)]
778 pub fn wantsRestingTouches(&self) -> bool;
779
780 #[unsafe(method(setWantsRestingTouches:))]
782 #[unsafe(method_family = none)]
783 pub fn setWantsRestingTouches(&self, wants_resting_touches: bool);
784
785 #[cfg(feature = "objc2-quartz-core")]
786 #[cfg(target_vendor = "apple")]
787 #[unsafe(method(makeBackingLayer))]
788 #[unsafe(method_family = none)]
789 pub fn makeBackingLayer(&self) -> Retained<CALayer>;
790
791 #[unsafe(method(layerContentsRedrawPolicy))]
792 #[unsafe(method_family = none)]
793 pub fn layerContentsRedrawPolicy(&self) -> NSViewLayerContentsRedrawPolicy;
794
795 #[unsafe(method(setLayerContentsRedrawPolicy:))]
797 #[unsafe(method_family = none)]
798 pub fn setLayerContentsRedrawPolicy(
799 &self,
800 layer_contents_redraw_policy: NSViewLayerContentsRedrawPolicy,
801 );
802
803 #[unsafe(method(layerContentsPlacement))]
804 #[unsafe(method_family = none)]
805 pub fn layerContentsPlacement(&self) -> NSViewLayerContentsPlacement;
806
807 #[unsafe(method(setLayerContentsPlacement:))]
809 #[unsafe(method_family = none)]
810 pub fn setLayerContentsPlacement(
811 &self,
812 layer_contents_placement: NSViewLayerContentsPlacement,
813 );
814
815 #[unsafe(method(wantsLayer))]
816 #[unsafe(method_family = none)]
817 pub fn wantsLayer(&self) -> bool;
818
819 #[unsafe(method(setWantsLayer:))]
821 #[unsafe(method_family = none)]
822 pub fn setWantsLayer(&self, wants_layer: bool);
823
824 #[cfg(feature = "objc2-quartz-core")]
825 #[cfg(target_vendor = "apple")]
826 #[unsafe(method(layer))]
827 #[unsafe(method_family = none)]
828 pub fn layer(&self) -> Option<Retained<CALayer>>;
829
830 #[cfg(feature = "objc2-quartz-core")]
831 #[cfg(target_vendor = "apple")]
832 #[unsafe(method(setLayer:))]
834 #[unsafe(method_family = none)]
835 pub fn setLayer(&self, layer: Option<&CALayer>);
836
837 #[unsafe(method(wantsUpdateLayer))]
838 #[unsafe(method_family = none)]
839 pub fn wantsUpdateLayer(&self) -> bool;
840
841 #[unsafe(method(updateLayer))]
842 #[unsafe(method_family = none)]
843 pub fn updateLayer(&self);
844
845 #[unsafe(method(canDrawSubviewsIntoLayer))]
846 #[unsafe(method_family = none)]
847 pub fn canDrawSubviewsIntoLayer(&self) -> bool;
848
849 #[unsafe(method(setCanDrawSubviewsIntoLayer:))]
851 #[unsafe(method_family = none)]
852 pub fn setCanDrawSubviewsIntoLayer(&self, can_draw_subviews_into_layer: bool);
853
854 #[unsafe(method(layoutSubtreeIfNeeded))]
855 #[unsafe(method_family = none)]
856 pub fn layoutSubtreeIfNeeded(&self);
857
858 #[unsafe(method(layout))]
859 #[unsafe(method_family = none)]
860 pub fn layout(&self);
861
862 #[unsafe(method(needsLayout))]
863 #[unsafe(method_family = none)]
864 pub fn needsLayout(&self) -> bool;
865
866 #[unsafe(method(setNeedsLayout:))]
868 #[unsafe(method_family = none)]
869 pub fn setNeedsLayout(&self, needs_layout: bool);
870
871 #[cfg(feature = "objc2-core-foundation")]
872 #[unsafe(method(alphaValue))]
873 #[unsafe(method_family = none)]
874 pub fn alphaValue(&self) -> CGFloat;
875
876 #[cfg(feature = "objc2-core-foundation")]
877 #[unsafe(method(setAlphaValue:))]
879 #[unsafe(method_family = none)]
880 pub fn setAlphaValue(&self, alpha_value: CGFloat);
881
882 #[unsafe(method(layerUsesCoreImageFilters))]
883 #[unsafe(method_family = none)]
884 pub fn layerUsesCoreImageFilters(&self) -> bool;
885
886 #[unsafe(method(setLayerUsesCoreImageFilters:))]
888 #[unsafe(method_family = none)]
889 pub fn setLayerUsesCoreImageFilters(&self, layer_uses_core_image_filters: bool);
890
891 #[cfg(feature = "objc2-core-image")]
892 #[cfg(target_vendor = "apple")]
893 #[unsafe(method(backgroundFilters))]
894 #[unsafe(method_family = none)]
895 pub fn backgroundFilters(&self) -> Retained<NSArray<CIFilter>>;
896
897 #[cfg(feature = "objc2-core-image")]
898 #[cfg(target_vendor = "apple")]
899 #[unsafe(method(setBackgroundFilters:))]
903 #[unsafe(method_family = none)]
904 pub fn setBackgroundFilters(&self, background_filters: &NSArray<CIFilter>);
905
906 #[cfg(feature = "objc2-core-image")]
907 #[cfg(target_vendor = "apple")]
908 #[unsafe(method(compositingFilter))]
909 #[unsafe(method_family = none)]
910 pub fn compositingFilter(&self) -> Option<Retained<CIFilter>>;
911
912 #[cfg(feature = "objc2-core-image")]
913 #[cfg(target_vendor = "apple")]
914 #[unsafe(method(setCompositingFilter:))]
916 #[unsafe(method_family = none)]
917 pub fn setCompositingFilter(&self, compositing_filter: Option<&CIFilter>);
918
919 #[cfg(feature = "objc2-core-image")]
920 #[cfg(target_vendor = "apple")]
921 #[unsafe(method(contentFilters))]
922 #[unsafe(method_family = none)]
923 pub fn contentFilters(&self) -> Retained<NSArray<CIFilter>>;
924
925 #[cfg(feature = "objc2-core-image")]
926 #[cfg(target_vendor = "apple")]
927 #[unsafe(method(setContentFilters:))]
931 #[unsafe(method_family = none)]
932 pub fn setContentFilters(&self, content_filters: &NSArray<CIFilter>);
933
934 #[cfg(feature = "NSShadow")]
935 #[unsafe(method(shadow))]
936 #[unsafe(method_family = none)]
937 pub fn shadow(&self) -> Option<Retained<NSShadow>>;
938
939 #[cfg(feature = "NSShadow")]
940 #[unsafe(method(setShadow:))]
944 #[unsafe(method_family = none)]
945 pub fn setShadow(&self, shadow: Option<&NSShadow>);
946
947 #[unsafe(method(clipsToBounds))]
948 #[unsafe(method_family = none)]
949 pub fn clipsToBounds(&self) -> bool;
950
951 #[unsafe(method(setClipsToBounds:))]
953 #[unsafe(method_family = none)]
954 pub fn setClipsToBounds(&self, clips_to_bounds: bool);
955
956 #[unsafe(method(postsBoundsChangedNotifications))]
957 #[unsafe(method_family = none)]
958 pub fn postsBoundsChangedNotifications(&self) -> bool;
959
960 #[unsafe(method(setPostsBoundsChangedNotifications:))]
962 #[unsafe(method_family = none)]
963 pub fn setPostsBoundsChangedNotifications(&self, posts_bounds_changed_notifications: bool);
964
965 #[cfg(feature = "NSScrollView")]
966 #[unsafe(method(enclosingScrollView))]
967 #[unsafe(method_family = none)]
968 pub fn enclosingScrollView(&self) -> Option<Retained<NSScrollView>>;
969
970 #[cfg(all(feature = "NSEvent", feature = "NSMenu"))]
971 #[unsafe(method(menuForEvent:))]
972 #[unsafe(method_family = none)]
973 pub fn menuForEvent(&self, event: &NSEvent) -> Option<Retained<NSMenu>>;
974
975 #[cfg(feature = "NSMenu")]
976 #[unsafe(method(defaultMenu))]
977 #[unsafe(method_family = none)]
978 pub fn defaultMenu(mtm: MainThreadMarker) -> Option<Retained<NSMenu>>;
979
980 #[cfg(all(feature = "NSEvent", feature = "NSMenu"))]
981 #[unsafe(method(willOpenMenu:withEvent:))]
988 #[unsafe(method_family = none)]
989 pub fn willOpenMenu_withEvent(&self, menu: &NSMenu, event: &NSEvent);
990
991 #[cfg(all(feature = "NSEvent", feature = "NSMenu"))]
992 #[unsafe(method(didCloseMenu:withEvent:))]
999 #[unsafe(method_family = none)]
1000 pub fn didCloseMenu_withEvent(&self, menu: &NSMenu, event: Option<&NSEvent>);
1001
1002 #[unsafe(method(toolTip))]
1003 #[unsafe(method_family = none)]
1004 pub fn toolTip(&self) -> Option<Retained<NSString>>;
1005
1006 #[unsafe(method(setToolTip:))]
1010 #[unsafe(method_family = none)]
1011 pub fn setToolTip(&self, tool_tip: Option<&NSString>);
1012
1013 #[unsafe(method(addToolTipRect:owner:userData:))]
1018 #[unsafe(method_family = none)]
1019 pub unsafe fn addToolTipRect_owner_userData(
1020 &self,
1021 rect: NSRect,
1022 owner: &AnyObject,
1023 data: *mut c_void,
1024 ) -> NSToolTipTag;
1025
1026 #[unsafe(method(removeToolTip:))]
1027 #[unsafe(method_family = none)]
1028 pub fn removeToolTip(&self, tag: NSToolTipTag);
1029
1030 #[unsafe(method(removeAllToolTips))]
1031 #[unsafe(method_family = none)]
1032 pub fn removeAllToolTips(&self);
1033
1034 #[unsafe(method(viewWillStartLiveResize))]
1035 #[unsafe(method_family = none)]
1036 pub fn viewWillStartLiveResize(&self);
1037
1038 #[unsafe(method(viewDidEndLiveResize))]
1039 #[unsafe(method_family = none)]
1040 pub fn viewDidEndLiveResize(&self);
1041
1042 #[unsafe(method(inLiveResize))]
1043 #[unsafe(method_family = none)]
1044 pub fn inLiveResize(&self) -> bool;
1045
1046 #[unsafe(method(preservesContentDuringLiveResize))]
1047 #[unsafe(method_family = none)]
1048 pub fn preservesContentDuringLiveResize(&self) -> bool;
1049
1050 #[unsafe(method(rectPreservedDuringLiveResize))]
1051 #[unsafe(method_family = none)]
1052 pub fn rectPreservedDuringLiveResize(&self) -> NSRect;
1053
1054 #[cfg(feature = "NSTextInputContext")]
1055 #[unsafe(method(inputContext))]
1056 #[unsafe(method_family = none)]
1057 pub fn inputContext(&self) -> Option<Retained<NSTextInputContext>>;
1058
1059 #[unsafe(method(rectForSmartMagnificationAtPoint:inRect:))]
1060 #[unsafe(method_family = none)]
1061 pub fn rectForSmartMagnificationAtPoint_inRect(
1062 &self,
1063 location: NSPoint,
1064 visible_rect: NSRect,
1065 ) -> NSRect;
1066
1067 #[cfg(feature = "NSUserInterfaceLayout")]
1068 #[unsafe(method(userInterfaceLayoutDirection))]
1069 #[unsafe(method_family = none)]
1070 pub fn userInterfaceLayoutDirection(&self) -> NSUserInterfaceLayoutDirection;
1071
1072 #[cfg(feature = "NSUserInterfaceLayout")]
1073 #[unsafe(method(setUserInterfaceLayoutDirection:))]
1075 #[unsafe(method_family = none)]
1076 pub fn setUserInterfaceLayoutDirection(
1077 &self,
1078 user_interface_layout_direction: NSUserInterfaceLayoutDirection,
1079 );
1080
1081 #[unsafe(method(prepareForReuse))]
1082 #[unsafe(method_family = none)]
1083 pub fn prepareForReuse(&self);
1084
1085 #[unsafe(method(isCompatibleWithResponsiveScrolling))]
1086 #[unsafe(method_family = none)]
1087 pub fn isCompatibleWithResponsiveScrolling(mtm: MainThreadMarker) -> bool;
1088
1089 #[unsafe(method(prepareContentInRect:))]
1090 #[unsafe(method_family = none)]
1091 pub fn prepareContentInRect(&self, rect: NSRect);
1092
1093 #[unsafe(method(preparedContentRect))]
1094 #[unsafe(method_family = none)]
1095 pub fn preparedContentRect(&self) -> NSRect;
1096
1097 #[unsafe(method(setPreparedContentRect:))]
1099 #[unsafe(method_family = none)]
1100 pub fn setPreparedContentRect(&self, prepared_content_rect: NSRect);
1101
1102 #[unsafe(method(allowsVibrancy))]
1103 #[unsafe(method_family = none)]
1104 pub fn allowsVibrancy(&self) -> bool;
1105
1106 #[unsafe(method(viewDidChangeEffectiveAppearance))]
1108 #[unsafe(method_family = none)]
1109 pub fn viewDidChangeEffectiveAppearance(&self);
1110 );
1111}
1112
1113#[cfg(feature = "NSResponder")]
1115impl NSView {
1116 extern_methods!(
1117 #[unsafe(method(init))]
1118 #[unsafe(method_family = init)]
1119 pub fn init(this: Allocated<Self>) -> Retained<Self>;
1120 );
1121}
1122
1123#[cfg(feature = "NSResponder")]
1125impl NSView {
1126 extern_methods!(
1127 #[unsafe(method(new))]
1128 #[unsafe(method_family = new)]
1129 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
1130 );
1131}
1132
1133extern_protocol!(
1134 pub unsafe trait NSViewLayerContentScaleDelegate: NSObjectProtocol {
1136 #[cfg(all(
1137 feature = "NSResponder",
1138 feature = "NSWindow",
1139 feature = "objc2-core-foundation",
1140 feature = "objc2-quartz-core"
1141 ))]
1142 #[cfg(target_vendor = "apple")]
1143 #[optional]
1144 #[unsafe(method(layer:shouldInheritContentsScale:fromWindow:))]
1145 #[unsafe(method_family = none)]
1146 fn layer_shouldInheritContentsScale_fromWindow(
1147 &self,
1148 layer: &CALayer,
1149 new_scale: CGFloat,
1150 window: &NSWindow,
1151 ) -> bool;
1152 }
1153);
1154
1155extern_protocol!(
1156 pub unsafe trait NSViewToolTipOwner: NSObjectProtocol + MainThreadOnly {
1158 #[cfg(feature = "NSResponder")]
1159 #[unsafe(method(view:stringForToolTip:point:userData:))]
1163 #[unsafe(method_family = none)]
1164 unsafe fn view_stringForToolTip_point_userData(
1165 &self,
1166 view: &NSView,
1167 tag: NSToolTipTag,
1168 point: NSPoint,
1169 data: *mut c_void,
1170 ) -> Retained<NSString>;
1171 }
1172);
1173
1174extern_protocol!(
1175 pub unsafe trait NSViewContentSelectionInfo: NSObjectProtocol {
1179 #[optional]
1180 #[unsafe(method(selectionAnchorRect))]
1181 #[unsafe(method_family = none)]
1182 fn selectionAnchorRect(&self) -> NSRect;
1183 }
1184);
1185
1186#[cfg(feature = "NSResponder")]
1188impl NSView {
1189 extern_methods!(
1190 #[unsafe(method(nextKeyView))]
1194 #[unsafe(method_family = none)]
1195 pub unsafe fn nextKeyView(&self) -> Option<Retained<NSView>>;
1196
1197 #[unsafe(method(setNextKeyView:))]
1203 #[unsafe(method_family = none)]
1204 pub unsafe fn setNextKeyView(&self, next_key_view: Option<&NSView>);
1205
1206 #[unsafe(method(previousKeyView))]
1210 #[unsafe(method_family = none)]
1211 pub unsafe fn previousKeyView(&self) -> Option<Retained<NSView>>;
1212
1213 #[unsafe(method(nextValidKeyView))]
1217 #[unsafe(method_family = none)]
1218 pub unsafe fn nextValidKeyView(&self) -> Option<Retained<NSView>>;
1219
1220 #[unsafe(method(previousValidKeyView))]
1224 #[unsafe(method_family = none)]
1225 pub unsafe fn previousValidKeyView(&self) -> Option<Retained<NSView>>;
1226
1227 #[unsafe(method(canBecomeKeyView))]
1228 #[unsafe(method_family = none)]
1229 pub fn canBecomeKeyView(&self) -> bool;
1230
1231 #[unsafe(method(setKeyboardFocusRingNeedsDisplayInRect:))]
1232 #[unsafe(method_family = none)]
1233 pub fn setKeyboardFocusRingNeedsDisplayInRect(&self, rect: NSRect);
1234
1235 #[cfg(feature = "NSGraphics")]
1236 #[unsafe(method(focusRingType))]
1237 #[unsafe(method_family = none)]
1238 pub fn focusRingType(&self) -> NSFocusRingType;
1239
1240 #[cfg(feature = "NSGraphics")]
1241 #[unsafe(method(setFocusRingType:))]
1243 #[unsafe(method_family = none)]
1244 pub fn setFocusRingType(&self, focus_ring_type: NSFocusRingType);
1245
1246 #[cfg(feature = "NSGraphics")]
1247 #[unsafe(method(defaultFocusRingType))]
1248 #[unsafe(method_family = none)]
1249 pub fn defaultFocusRingType(mtm: MainThreadMarker) -> NSFocusRingType;
1250
1251 #[unsafe(method(drawFocusRingMask))]
1252 #[unsafe(method_family = none)]
1253 pub fn drawFocusRingMask(&self);
1254
1255 #[unsafe(method(focusRingMaskBounds))]
1256 #[unsafe(method_family = none)]
1257 pub fn focusRingMaskBounds(&self) -> NSRect;
1258
1259 #[unsafe(method(noteFocusRingMaskChanged))]
1260 #[unsafe(method_family = none)]
1261 pub fn noteFocusRingMaskChanged(&self);
1262 );
1263}
1264
1265#[cfg(feature = "NSResponder")]
1267impl NSView {
1268 extern_methods!(
1269 #[cfg(feature = "NSPasteboard")]
1270 #[unsafe(method(writeEPSInsideRect:toPasteboard:))]
1271 #[unsafe(method_family = none)]
1272 pub fn writeEPSInsideRect_toPasteboard(&self, rect: NSRect, pasteboard: &NSPasteboard);
1273
1274 #[unsafe(method(dataWithEPSInsideRect:))]
1275 #[unsafe(method_family = none)]
1276 pub fn dataWithEPSInsideRect(&self, rect: NSRect) -> Retained<NSData>;
1277
1278 #[cfg(feature = "NSPasteboard")]
1279 #[unsafe(method(writePDFInsideRect:toPasteboard:))]
1280 #[unsafe(method_family = none)]
1281 pub fn writePDFInsideRect_toPasteboard(&self, rect: NSRect, pasteboard: &NSPasteboard);
1282
1283 #[unsafe(method(dataWithPDFInsideRect:))]
1284 #[unsafe(method_family = none)]
1285 pub fn dataWithPDFInsideRect(&self, rect: NSRect) -> Retained<NSData>;
1286
1287 #[unsafe(method(print:))]
1291 #[unsafe(method_family = none)]
1292 pub unsafe fn print(&self, sender: Option<&AnyObject>);
1293
1294 #[unsafe(method(knowsPageRange:))]
1298 #[unsafe(method_family = none)]
1299 pub unsafe fn knowsPageRange(&self, range: NSRangePointer) -> bool;
1300
1301 #[cfg(feature = "objc2-core-foundation")]
1302 #[unsafe(method(heightAdjustLimit))]
1303 #[unsafe(method_family = none)]
1304 pub fn heightAdjustLimit(&self) -> CGFloat;
1305
1306 #[cfg(feature = "objc2-core-foundation")]
1307 #[unsafe(method(widthAdjustLimit))]
1308 #[unsafe(method_family = none)]
1309 pub fn widthAdjustLimit(&self) -> CGFloat;
1310
1311 #[cfg(feature = "objc2-core-foundation")]
1312 #[unsafe(method(adjustPageWidthNew:left:right:limit:))]
1316 #[unsafe(method_family = none)]
1317 pub unsafe fn adjustPageWidthNew_left_right_limit(
1318 &self,
1319 new_right: NonNull<CGFloat>,
1320 old_left: CGFloat,
1321 old_right: CGFloat,
1322 right_limit: CGFloat,
1323 );
1324
1325 #[cfg(feature = "objc2-core-foundation")]
1326 #[unsafe(method(adjustPageHeightNew:top:bottom:limit:))]
1330 #[unsafe(method_family = none)]
1331 pub unsafe fn adjustPageHeightNew_top_bottom_limit(
1332 &self,
1333 new_bottom: NonNull<CGFloat>,
1334 old_top: CGFloat,
1335 old_bottom: CGFloat,
1336 bottom_limit: CGFloat,
1337 );
1338
1339 #[unsafe(method(rectForPage:))]
1340 #[unsafe(method_family = none)]
1341 pub fn rectForPage(&self, page: NSInteger) -> NSRect;
1342
1343 #[unsafe(method(locationOfPrintRect:))]
1344 #[unsafe(method_family = none)]
1345 pub fn locationOfPrintRect(&self, rect: NSRect) -> NSPoint;
1346
1347 #[unsafe(method(drawPageBorderWithSize:))]
1348 #[unsafe(method_family = none)]
1349 pub fn drawPageBorderWithSize(&self, border_size: NSSize);
1350
1351 #[unsafe(method(pageHeader))]
1352 #[unsafe(method_family = none)]
1353 pub fn pageHeader(&self) -> Retained<NSAttributedString>;
1354
1355 #[unsafe(method(pageFooter))]
1356 #[unsafe(method_family = none)]
1357 pub fn pageFooter(&self) -> Retained<NSAttributedString>;
1358
1359 #[deprecated = "This is never invoked and the NSView implementation does nothing"]
1361 #[unsafe(method(drawSheetBorderWithSize:))]
1362 #[unsafe(method_family = none)]
1363 pub fn drawSheetBorderWithSize(&self, border_size: NSSize);
1364
1365 #[unsafe(method(printJobTitle))]
1366 #[unsafe(method_family = none)]
1367 pub fn printJobTitle(&self) -> Retained<NSString>;
1368
1369 #[unsafe(method(beginDocument))]
1370 #[unsafe(method_family = none)]
1371 pub fn beginDocument(&self);
1372
1373 #[unsafe(method(endDocument))]
1374 #[unsafe(method_family = none)]
1375 pub fn endDocument(&self);
1376
1377 #[unsafe(method(beginPageInRect:atPlacement:))]
1378 #[unsafe(method_family = none)]
1379 pub fn beginPageInRect_atPlacement(&self, rect: NSRect, location: NSPoint);
1380
1381 #[unsafe(method(endPage))]
1382 #[unsafe(method_family = none)]
1383 pub fn endPage(&self);
1384 );
1385}
1386
1387#[cfg(feature = "NSResponder")]
1389impl NSView {
1390 extern_methods!(
1391 #[cfg(all(
1392 feature = "NSDragging",
1393 feature = "NSDraggingItem",
1394 feature = "NSDraggingSession",
1395 feature = "NSEvent"
1396 ))]
1397 #[unsafe(method(beginDraggingSessionWithItems:event:source:))]
1398 #[unsafe(method_family = none)]
1399 pub fn beginDraggingSessionWithItems_event_source(
1400 &self,
1401 items: &NSArray<NSDraggingItem>,
1402 event: &NSEvent,
1403 source: &ProtocolObject<dyn NSDraggingSource>,
1404 ) -> Retained<NSDraggingSession>;
1405
1406 #[cfg(feature = "NSPasteboard")]
1407 #[unsafe(method(registeredDraggedTypes))]
1408 #[unsafe(method_family = none)]
1409 pub fn registeredDraggedTypes(&self) -> Retained<NSArray<NSPasteboardType>>;
1410
1411 #[cfg(feature = "NSPasteboard")]
1412 #[unsafe(method(registerForDraggedTypes:))]
1413 #[unsafe(method_family = none)]
1414 pub fn registerForDraggedTypes(&self, new_types: &NSArray<NSPasteboardType>);
1415
1416 #[unsafe(method(unregisterDraggedTypes))]
1417 #[unsafe(method_family = none)]
1418 pub fn unregisterDraggedTypes(&self);
1419 );
1420}
1421
1422pub type NSViewFullScreenModeOptionKey = NSString;
1425
1426extern "C" {
1427 pub static NSFullScreenModeAllScreens: &'static NSViewFullScreenModeOptionKey;
1429}
1430
1431extern "C" {
1432 pub static NSFullScreenModeSetting: &'static NSViewFullScreenModeOptionKey;
1434}
1435
1436extern "C" {
1437 pub static NSFullScreenModeWindowLevel: &'static NSViewFullScreenModeOptionKey;
1439}
1440
1441extern "C" {
1442 pub static NSFullScreenModeApplicationPresentationOptions:
1444 &'static NSViewFullScreenModeOptionKey;
1445}
1446
1447#[cfg(feature = "NSResponder")]
1449impl NSView {
1450 extern_methods!(
1451 #[cfg(feature = "NSScreen")]
1452 #[unsafe(method(enterFullScreenMode:withOptions:))]
1456 #[unsafe(method_family = none)]
1457 pub unsafe fn enterFullScreenMode_withOptions(
1458 &self,
1459 screen: &NSScreen,
1460 options: Option<&NSDictionary<NSViewFullScreenModeOptionKey, AnyObject>>,
1461 ) -> bool;
1462
1463 #[unsafe(method(exitFullScreenModeWithOptions:))]
1467 #[unsafe(method_family = none)]
1468 pub unsafe fn exitFullScreenModeWithOptions(
1469 &self,
1470 options: Option<&NSDictionary<NSViewFullScreenModeOptionKey, AnyObject>>,
1471 );
1472
1473 #[unsafe(method(isInFullScreenMode))]
1474 #[unsafe(method_family = none)]
1475 pub fn isInFullScreenMode(&self) -> bool;
1476 );
1477}
1478
1479pub type NSDefinitionOptionKey = NSString;
1482
1483extern "C" {
1484 pub static NSDefinitionPresentationTypeKey: &'static NSDefinitionOptionKey;
1486}
1487
1488pub type NSDefinitionPresentationType = NSString;
1491
1492extern "C" {
1493 pub static NSDefinitionPresentationTypeOverlay: &'static NSDefinitionPresentationType;
1495}
1496
1497extern "C" {
1498 pub static NSDefinitionPresentationTypeDictionaryApplication:
1500 &'static NSDefinitionPresentationType;
1501}
1502
1503#[cfg(feature = "NSResponder")]
1505impl NSView {
1506 extern_methods!(
1507 #[unsafe(method(showDefinitionForAttributedString:atPoint:))]
1508 #[unsafe(method_family = none)]
1509 pub fn showDefinitionForAttributedString_atPoint(
1510 &self,
1511 attr_string: Option<&NSAttributedString>,
1512 text_baseline_origin: NSPoint,
1513 );
1514
1515 #[cfg(feature = "block2")]
1516 #[unsafe(method(showDefinitionForAttributedString:range:options:baselineOriginProvider:))]
1520 #[unsafe(method_family = none)]
1521 pub unsafe fn showDefinitionForAttributedString_range_options_baselineOriginProvider(
1522 &self,
1523 attr_string: Option<&NSAttributedString>,
1524 target_range: NSRange,
1525 options: Option<&NSDictionary<NSDefinitionOptionKey, AnyObject>>,
1526 origin_provider: Option<&block2::DynBlock<dyn Fn(NSRange) -> NSPoint>>,
1527 );
1528 );
1529}
1530
1531#[cfg(feature = "NSResponder")]
1533impl NSView {
1534 extern_methods!(
1535 #[unsafe(method(isDrawingFindIndicator))]
1536 #[unsafe(method_family = none)]
1537 pub fn isDrawingFindIndicator(&self) -> bool;
1538 );
1539}
1540
1541#[cfg(feature = "NSResponder")]
1543impl NSView {
1544 extern_methods!(
1545 #[cfg(feature = "NSGestureRecognizer")]
1546 #[unsafe(method(gestureRecognizers))]
1547 #[unsafe(method_family = none)]
1548 pub fn gestureRecognizers(&self) -> Retained<NSArray<NSGestureRecognizer>>;
1549
1550 #[cfg(feature = "NSGestureRecognizer")]
1551 #[unsafe(method(setGestureRecognizers:))]
1555 #[unsafe(method_family = none)]
1556 pub fn setGestureRecognizers(&self, gesture_recognizers: &NSArray<NSGestureRecognizer>);
1557
1558 #[cfg(feature = "NSGestureRecognizer")]
1559 #[unsafe(method(addGestureRecognizer:))]
1560 #[unsafe(method_family = none)]
1561 pub fn addGestureRecognizer(&self, gesture_recognizer: &NSGestureRecognizer);
1562
1563 #[cfg(feature = "NSGestureRecognizer")]
1564 #[unsafe(method(removeGestureRecognizer:))]
1565 #[unsafe(method_family = none)]
1566 pub fn removeGestureRecognizer(&self, gesture_recognizer: &NSGestureRecognizer);
1567 );
1568}
1569
1570#[cfg(feature = "NSResponder")]
1572impl NSView {
1573 extern_methods!(
1574 #[cfg(feature = "NSTouch")]
1575 #[unsafe(method(allowedTouchTypes))]
1576 #[unsafe(method_family = none)]
1577 pub fn allowedTouchTypes(&self) -> NSTouchTypeMask;
1578
1579 #[cfg(feature = "NSTouch")]
1580 #[unsafe(method(setAllowedTouchTypes:))]
1582 #[unsafe(method_family = none)]
1583 pub fn setAllowedTouchTypes(&self, allowed_touch_types: NSTouchTypeMask);
1584 );
1585}
1586
1587#[cfg(feature = "NSResponder")]
1589impl NSView {
1590 extern_methods!(
1591 #[unsafe(method(safeAreaInsets))]
1592 #[unsafe(method_family = none)]
1593 pub fn safeAreaInsets(&self) -> NSEdgeInsets;
1594
1595 #[unsafe(method(additionalSafeAreaInsets))]
1596 #[unsafe(method_family = none)]
1597 pub fn additionalSafeAreaInsets(&self) -> NSEdgeInsets;
1598
1599 #[unsafe(method(setAdditionalSafeAreaInsets:))]
1601 #[unsafe(method_family = none)]
1602 pub fn setAdditionalSafeAreaInsets(&self, additional_safe_area_insets: NSEdgeInsets);
1603
1604 #[cfg(feature = "NSLayoutGuide")]
1605 #[unsafe(method(safeAreaLayoutGuide))]
1606 #[unsafe(method_family = none)]
1607 pub fn safeAreaLayoutGuide(&self) -> Retained<NSLayoutGuide>;
1608
1609 #[unsafe(method(safeAreaRect))]
1610 #[unsafe(method_family = none)]
1611 pub fn safeAreaRect(&self) -> NSRect;
1612
1613 #[cfg(feature = "NSLayoutGuide")]
1614 #[unsafe(method(layoutMarginsGuide))]
1615 #[unsafe(method_family = none)]
1616 pub fn layoutMarginsGuide(&self) -> Retained<NSLayoutGuide>;
1617 );
1618}
1619
1620#[cfg(feature = "NSResponder")]
1622impl NSView {
1623 extern_methods!(
1624 #[unsafe(method(prefersCompactControlSizeMetrics))]
1628 #[unsafe(method_family = none)]
1629 pub fn prefersCompactControlSizeMetrics(&self) -> bool;
1630
1631 #[unsafe(method(setPrefersCompactControlSizeMetrics:))]
1633 #[unsafe(method_family = none)]
1634 pub fn setPrefersCompactControlSizeMetrics(
1635 &self,
1636 prefers_compact_control_size_metrics: bool,
1637 );
1638 );
1639}
1640
1641#[cfg(feature = "NSResponder")]
1643impl NSView {
1644 extern_methods!(
1645 #[cfg(feature = "NSTrackingArea")]
1646 #[unsafe(method(addTrackingArea:))]
1647 #[unsafe(method_family = none)]
1648 pub fn addTrackingArea(&self, tracking_area: &NSTrackingArea);
1649
1650 #[cfg(feature = "NSTrackingArea")]
1651 #[unsafe(method(removeTrackingArea:))]
1652 #[unsafe(method_family = none)]
1653 pub fn removeTrackingArea(&self, tracking_area: &NSTrackingArea);
1654
1655 #[cfg(feature = "NSTrackingArea")]
1656 #[unsafe(method(trackingAreas))]
1657 #[unsafe(method_family = none)]
1658 pub fn trackingAreas(&self) -> Retained<NSArray<NSTrackingArea>>;
1659
1660 #[unsafe(method(updateTrackingAreas))]
1661 #[unsafe(method_family = none)]
1662 pub fn updateTrackingAreas(&self);
1663
1664 #[cfg(feature = "NSCursor")]
1665 #[unsafe(method(addCursorRect:cursor:))]
1666 #[unsafe(method_family = none)]
1667 pub fn addCursorRect_cursor(&self, rect: NSRect, object: &NSCursor);
1668
1669 #[cfg(feature = "NSCursor")]
1670 #[unsafe(method(removeCursorRect:cursor:))]
1671 #[unsafe(method_family = none)]
1672 pub fn removeCursorRect_cursor(&self, rect: NSRect, object: &NSCursor);
1673
1674 #[unsafe(method(discardCursorRects))]
1675 #[unsafe(method_family = none)]
1676 pub fn discardCursorRects(&self);
1677
1678 #[unsafe(method(resetCursorRects))]
1679 #[unsafe(method_family = none)]
1680 pub fn resetCursorRects(&self);
1681
1682 #[unsafe(method(addTrackingRect:owner:userData:assumeInside:))]
1687 #[unsafe(method_family = none)]
1688 pub unsafe fn addTrackingRect_owner_userData_assumeInside(
1689 &self,
1690 rect: NSRect,
1691 owner: &AnyObject,
1692 data: *mut c_void,
1693 flag: bool,
1694 ) -> NSTrackingRectTag;
1695
1696 #[unsafe(method(removeTrackingRect:))]
1697 #[unsafe(method_family = none)]
1698 pub fn removeTrackingRect(&self, tag: NSTrackingRectTag);
1699 );
1700}
1701
1702#[cfg(feature = "NSResponder")]
1704impl NSView {
1705 extern_methods!(
1706 #[cfg(feature = "objc2-quartz-core")]
1707 #[cfg(target_vendor = "apple")]
1708 #[unsafe(method(displayLinkWithTarget:selector:))]
1713 #[unsafe(method_family = none)]
1714 pub unsafe fn displayLinkWithTarget_selector(
1715 &self,
1716 target: &AnyObject,
1717 selector: Sel,
1718 ) -> Retained<CADisplayLink>;
1719 );
1720}
1721
1722#[cfg(feature = "NSResponder")]
1724impl NSView {
1725 extern_methods!(
1726 #[cfg(all(feature = "NSEvent", feature = "NSImage", feature = "NSPasteboard"))]
1727 #[deprecated = "Use -beginDraggingSessionWithItems:event:source: instead"]
1731 #[unsafe(method(dragImage:at:offset:event:pasteboard:source:slideBack:))]
1732 #[unsafe(method_family = none)]
1733 pub unsafe fn dragImage_at_offset_event_pasteboard_source_slideBack(
1734 &self,
1735 image: &NSImage,
1736 view_location: NSPoint,
1737 initial_offset: NSSize,
1738 event: &NSEvent,
1739 pboard: &NSPasteboard,
1740 source_obj: &AnyObject,
1741 slide_flag: bool,
1742 );
1743
1744 #[cfg(feature = "NSEvent")]
1745 #[deprecated = "Use -beginDraggingSessionWithItems:event:source: instead"]
1746 #[unsafe(method(dragFile:fromRect:slideBack:event:))]
1747 #[unsafe(method_family = none)]
1748 pub fn dragFile_fromRect_slideBack_event(
1749 &self,
1750 filename: &NSString,
1751 rect: NSRect,
1752 flag: bool,
1753 event: &NSEvent,
1754 ) -> bool;
1755
1756 #[cfg(feature = "NSEvent")]
1757 #[deprecated = "Use -beginDraggingSessionWithItems:event:source: with an NSFilePromiseProvider instead"]
1761 #[unsafe(method(dragPromisedFilesOfTypes:fromRect:source:slideBack:event:))]
1762 #[unsafe(method_family = none)]
1763 pub unsafe fn dragPromisedFilesOfTypes_fromRect_source_slideBack_event(
1764 &self,
1765 type_array: &NSArray<NSString>,
1766 rect: NSRect,
1767 source_object: &AnyObject,
1768 flag: bool,
1769 event: &NSEvent,
1770 ) -> bool;
1771
1772 #[deprecated]
1773 #[unsafe(method(convertPointToBase:))]
1774 #[unsafe(method_family = none)]
1775 pub fn convertPointToBase(&self, point: NSPoint) -> NSPoint;
1776
1777 #[deprecated]
1778 #[unsafe(method(convertPointFromBase:))]
1779 #[unsafe(method_family = none)]
1780 pub fn convertPointFromBase(&self, point: NSPoint) -> NSPoint;
1781
1782 #[deprecated]
1783 #[unsafe(method(convertSizeToBase:))]
1784 #[unsafe(method_family = none)]
1785 pub fn convertSizeToBase(&self, size: NSSize) -> NSSize;
1786
1787 #[deprecated]
1788 #[unsafe(method(convertSizeFromBase:))]
1789 #[unsafe(method_family = none)]
1790 pub fn convertSizeFromBase(&self, size: NSSize) -> NSSize;
1791
1792 #[deprecated]
1793 #[unsafe(method(convertRectToBase:))]
1794 #[unsafe(method_family = none)]
1795 pub fn convertRectToBase(&self, rect: NSRect) -> NSRect;
1796
1797 #[deprecated]
1798 #[unsafe(method(convertRectFromBase:))]
1799 #[unsafe(method_family = none)]
1800 pub fn convertRectFromBase(&self, rect: NSRect) -> NSRect;
1801
1802 #[deprecated = "This has always returned NO and had no effect on macOS"]
1803 #[unsafe(method(performMnemonic:))]
1804 #[unsafe(method_family = none)]
1805 pub fn performMnemonic(&self, string: &NSString) -> bool;
1806
1807 #[deprecated = "This method no longer does anything"]
1808 #[unsafe(method(shouldDrawColor))]
1809 #[unsafe(method_family = none)]
1810 pub fn shouldDrawColor(&self) -> bool;
1811
1812 #[deprecated]
1813 #[unsafe(method(gState))]
1814 #[unsafe(method_family = none)]
1815 pub fn gState(&self) -> NSInteger;
1816
1817 #[deprecated]
1818 #[unsafe(method(allocateGState))]
1819 #[unsafe(method_family = none)]
1820 pub fn allocateGState(&self);
1821
1822 #[deprecated]
1823 #[unsafe(method(setUpGState))]
1824 #[unsafe(method_family = none)]
1825 pub fn setUpGState(&self);
1826
1827 #[deprecated]
1828 #[unsafe(method(renewGState))]
1829 #[unsafe(method_family = none)]
1830 pub fn renewGState(&self);
1831 );
1832}
1833
1834#[cfg(feature = "NSResponder")]
1836impl NSView {
1837 extern_methods!(
1838 #[cfg(feature = "NSWritingToolsCoordinator")]
1839 #[unsafe(method(writingToolsCoordinator))]
1840 #[unsafe(method_family = none)]
1841 pub fn writingToolsCoordinator(&self) -> Option<Retained<NSWritingToolsCoordinator>>;
1842
1843 #[cfg(feature = "NSWritingToolsCoordinator")]
1844 #[unsafe(method(setWritingToolsCoordinator:))]
1846 #[unsafe(method_family = none)]
1847 pub fn setWritingToolsCoordinator(
1848 &self,
1849 writing_tools_coordinator: Option<&NSWritingToolsCoordinator>,
1850 );
1851 );
1852}
1853
1854extern "C" {
1855 pub static NSViewFrameDidChangeNotification: &'static NSNotificationName;
1857}
1858
1859extern "C" {
1860 #[deprecated]
1862 pub static NSViewFocusDidChangeNotification: &'static NSNotificationName;
1863}
1864
1865extern "C" {
1866 pub static NSViewBoundsDidChangeNotification: &'static NSNotificationName;
1868}
1869
1870extern "C" {
1871 #[deprecated = "Use NSOpenGLView instead."]
1873 pub static NSViewGlobalFrameDidChangeNotification: &'static NSNotificationName;
1874}
1875
1876extern "C" {
1877 pub static NSViewDidUpdateTrackingAreasNotification: &'static NSNotificationName;
1879}