objc2_app_kit/generated/
NSCursor.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// The position along the perimeter of a rectangular frame (its edges and corners) from which it’s resized.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nscursorframeresizeposition?language=objc)
13// NS_CLOSED_ENUM
14#[repr(usize)] // NSUInteger
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub enum NSCursorFrameResizePosition {
17    /// The top edge of the frame.
18    #[doc(alias = "NSCursorFrameResizePositionTop")]
19    Top = 1 << 0,
20    /// The left edge of the frame.
21    #[doc(alias = "NSCursorFrameResizePositionLeft")]
22    Left = 1 << 1,
23    /// The bottom edge of the frame.
24    #[doc(alias = "NSCursorFrameResizePositionBottom")]
25    Bottom = 1 << 2,
26    /// The right edge of the frame.
27    #[doc(alias = "NSCursorFrameResizePositionRight")]
28    Right = 1 << 3,
29    /// The top left corner of the frame.
30    #[doc(alias = "NSCursorFrameResizePositionTopLeft")]
31    TopLeft = NSCursorFrameResizePosition::Top as NSUInteger
32        | NSCursorFrameResizePosition::Left as NSUInteger,
33    /// The top right corner of the frame.
34    #[doc(alias = "NSCursorFrameResizePositionTopRight")]
35    TopRight = NSCursorFrameResizePosition::Top as NSUInteger
36        | NSCursorFrameResizePosition::Right as NSUInteger,
37    /// The bottom left corner of the frame.
38    #[doc(alias = "NSCursorFrameResizePositionBottomLeft")]
39    BottomLeft = NSCursorFrameResizePosition::Bottom as NSUInteger
40        | NSCursorFrameResizePosition::Left as NSUInteger,
41    /// The bottom right corner of the frame.
42    #[doc(alias = "NSCursorFrameResizePositionBottomRight")]
43    BottomRight = NSCursorFrameResizePosition::Bottom as NSUInteger
44        | NSCursorFrameResizePosition::Right as NSUInteger,
45}
46
47unsafe impl Encode for NSCursorFrameResizePosition {
48    const ENCODING: Encoding = NSUInteger::ENCODING;
49}
50
51unsafe impl RefEncode for NSCursorFrameResizePosition {
52    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
53}
54
55/// The directions in which a rectangular frame can be resized.
56///
57/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nscursorframeresizedirections?language=objc)
58// NS_OPTIONS
59#[repr(transparent)]
60#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
61pub struct NSCursorFrameResizeDirections(pub NSUInteger);
62bitflags::bitflags! {
63    impl NSCursorFrameResizeDirections: NSUInteger {
64/// Indicates that the shape can be resized inwards to be smaller.
65        #[doc(alias = "NSCursorFrameResizeDirectionsInward")]
66        const Inward = 1<<0;
67/// Indicates that the shape can be resized outwards to be larger.
68        #[doc(alias = "NSCursorFrameResizeDirectionsOutward")]
69        const Outward = 1<<1;
70/// Indicates that the shape can be resized inwards or wards to be either smaller or larger, respectively.
71        #[doc(alias = "NSCursorFrameResizeDirectionsAll")]
72        const All = NSCursorFrameResizeDirections::Inward.0|NSCursorFrameResizeDirections::Outward.0;
73    }
74}
75
76unsafe impl Encode for NSCursorFrameResizeDirections {
77    const ENCODING: Encoding = NSUInteger::ENCODING;
78}
79
80unsafe impl RefEncode for NSCursorFrameResizeDirections {
81    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
82}
83
84extern_class!(
85    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscursor?language=objc)
86    #[unsafe(super(NSObject))]
87    #[derive(Debug, PartialEq, Eq, Hash)]
88    pub struct NSCursor;
89);
90
91extern_conformance!(
92    unsafe impl NSCoding for NSCursor {}
93);
94
95extern_conformance!(
96    unsafe impl NSObjectProtocol for NSCursor {}
97);
98
99extern_conformance!(
100    unsafe impl NSSecureCoding for NSCursor {}
101);
102
103impl NSCursor {
104    extern_methods!(
105        #[cfg(feature = "NSImage")]
106        #[unsafe(method(initWithImage:hotSpot:))]
107        #[unsafe(method_family = init)]
108        pub fn initWithImage_hotSpot(
109            this: Allocated<Self>,
110            new_image: &NSImage,
111            point: NSPoint,
112        ) -> Retained<Self>;
113
114        #[unsafe(method(initWithCoder:))]
115        #[unsafe(method_family = init)]
116        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
117
118        #[cfg(feature = "NSImage")]
119        #[unsafe(method(image))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn image(&self) -> Retained<NSImage>;
122
123        #[unsafe(method(hotSpot))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn hotSpot(&self) -> NSPoint;
126
127        #[unsafe(method(hide))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn hide();
130
131        #[unsafe(method(unhide))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn unhide();
134
135        #[unsafe(method(setHiddenUntilMouseMoves:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setHiddenUntilMouseMoves(flag: bool);
138
139        #[unsafe(method(pop))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn pop_class();
142
143        #[unsafe(method(pop))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn pop(&self);
146
147        #[unsafe(method(push))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn push(&self);
150
151        #[unsafe(method(set))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn set(&self);
154
155        /// Returns the application’s current cursor.
156        /// - Note: This isn’t necessarily the cursor that is currently being displayed, as the system may be showing the cursor for another running application.
157        #[unsafe(method(currentCursor))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn currentCursor() -> Retained<NSCursor>;
160
161        /// Returns the default cursor, the arrow cursor.
162        /// - Discussion: The default cursor, a slanted arrow with its hot spot at the tip. The arrow cursor is the one you’re used to seeing over buttons, scrollers, and many other objects in the window system.
163        #[unsafe(method(arrowCursor))]
164        #[unsafe(method_family = none)]
165        pub fn arrowCursor() -> Retained<NSCursor>;
166
167        #[unsafe(method(crosshairCursor))]
168        #[unsafe(method_family = none)]
169        pub fn crosshairCursor() -> Retained<NSCursor>;
170
171        #[unsafe(method(disappearingItemCursor))]
172        #[unsafe(method_family = none)]
173        pub fn disappearingItemCursor() -> Retained<NSCursor>;
174
175        #[unsafe(method(operationNotAllowedCursor))]
176        #[unsafe(method_family = none)]
177        pub fn operationNotAllowedCursor() -> Retained<NSCursor>;
178
179        #[unsafe(method(dragLinkCursor))]
180        #[unsafe(method_family = none)]
181        pub fn dragLinkCursor() -> Retained<NSCursor>;
182
183        #[unsafe(method(dragCopyCursor))]
184        #[unsafe(method_family = none)]
185        pub fn dragCopyCursor() -> Retained<NSCursor>;
186
187        #[unsafe(method(contextualMenuCursor))]
188        #[unsafe(method_family = none)]
189        pub fn contextualMenuCursor() -> Retained<NSCursor>;
190
191        #[unsafe(method(pointingHandCursor))]
192        #[unsafe(method_family = none)]
193        pub fn pointingHandCursor() -> Retained<NSCursor>;
194
195        #[unsafe(method(closedHandCursor))]
196        #[unsafe(method_family = none)]
197        pub fn closedHandCursor() -> Retained<NSCursor>;
198
199        #[unsafe(method(openHandCursor))]
200        #[unsafe(method_family = none)]
201        pub fn openHandCursor() -> Retained<NSCursor>;
202
203        #[unsafe(method(IBeamCursor))]
204        #[unsafe(method_family = none)]
205        pub fn IBeamCursor() -> Retained<NSCursor>;
206
207        #[unsafe(method(IBeamCursorForVerticalLayout))]
208        #[unsafe(method_family = none)]
209        pub fn IBeamCursorForVerticalLayout() -> Retained<NSCursor>;
210
211        /// Returns the zoom-in cursor.
212        /// - Note: This cursor is used to indicate zooming in on (magnifying) a canvas or object.
213        #[unsafe(method(zoomInCursor))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn zoomInCursor() -> Retained<NSCursor>;
216
217        /// Returns the zoom-out cursor.
218        /// - Note: This cursor is used to indicate zooming out of a canvas or object.
219        #[unsafe(method(zoomOutCursor))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn zoomOutCursor() -> Retained<NSCursor>;
222
223        /// Returns the cursor for resizing a column (vertical divider) in either direction.
224        #[unsafe(method(columnResizeCursor))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn columnResizeCursor() -> Retained<NSCursor>;
227
228        #[cfg(feature = "NSDirection")]
229        /// Returns the cursor for resizing a column (vertical divider) in the specified directions.
230        /// - Parameter directions: The direction in which a column can be resized.
231        #[unsafe(method(columnResizeCursorInDirections:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn columnResizeCursorInDirections(
234            directions: NSHorizontalDirections,
235        ) -> Retained<NSCursor>;
236
237        /// Returns the cursor for resizing a row (horizontal divider) in either direction.
238        #[unsafe(method(rowResizeCursor))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn rowResizeCursor() -> Retained<NSCursor>;
241
242        #[cfg(feature = "NSDirection")]
243        /// Returns the cursor for resizing a row (horizontal divider) in the specified directions.
244        /// - Parameter directions: The direction in which a row can be resized.
245        #[unsafe(method(rowResizeCursorInDirections:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn rowResizeCursorInDirections(
248            directions: NSVerticalDirections,
249        ) -> Retained<NSCursor>;
250
251        /// Returns the cursor for resizing a rectangular frame from the specified edge or corner.
252        /// - Parameters:
253        /// - position: The position along the perimeter of a rectangular frame (its edges and corners) from which it’s resized.
254        /// - directions: The directions in which a rectangular frame can be resized.
255        #[unsafe(method(frameResizeCursorFromPosition:inDirections:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn frameResizeCursorFromPosition_inDirections(
258            position: NSCursorFrameResizePosition,
259            directions: NSCursorFrameResizeDirections,
260        ) -> Retained<NSCursor>;
261    );
262}
263
264/// Methods declared on superclass `NSObject`.
265impl NSCursor {
266    extern_methods!(
267        #[unsafe(method(init))]
268        #[unsafe(method_family = init)]
269        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
270
271        #[unsafe(method(new))]
272        #[unsafe(method_family = new)]
273        pub unsafe fn new() -> Retained<Self>;
274    );
275}
276
277/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumberwithcursorsizesupport?language=objc)
278#[cfg(feature = "NSApplication")]
279pub static NSAppKitVersionNumberWithCursorSizeSupport: NSAppKitVersion = 682.0 as _;
280
281/// Deprecated.
282impl NSCursor {
283    extern_methods!(
284        /// This property will always be `nil` in a future version of macOS.
285        #[deprecated = "No longer recommended. Use ScreenCaptureKit to capture the screen. Use the `showsCursor` property on `SCStreamConfiguration` to control whether or not to include the cursor in the capture. Or, use `NSCursor.currentCursor` if needing to just get the current cursor for this application."]
286        #[unsafe(method(currentSystemCursor))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn currentSystemCursor() -> Option<Retained<NSCursor>>;
289
290        #[deprecated = "Use either `+[NSCursor columnResizeCursorInDirections:]` or `+[NSCursor frameResizeCursorFromPosition:inDirections:]` instead, depending on whether a divider is being re-positioned or a rectangular frame is being resized."]
291        #[unsafe(method(resizeLeftCursor))]
292        #[unsafe(method_family = none)]
293        pub fn resizeLeftCursor() -> Retained<NSCursor>;
294
295        #[deprecated = "Use either `+[NSCursor columnResizeCursorInDirections:]` or `+[NSCursor frameResizeCursorFromPosition:inDirections:]` instead, depending on whether a divider is being re-positioned or a rectangular frame is being resized."]
296        #[unsafe(method(resizeRightCursor))]
297        #[unsafe(method_family = none)]
298        pub fn resizeRightCursor() -> Retained<NSCursor>;
299
300        #[deprecated = "Use either `+[NSCursor columnResizeCursorInDirections:]` or `+[NSCursor frameResizeCursorFromPosition:inDirections:]` instead, depending on whether a divider is being re-positioned or a rectangular frame is being resized."]
301        #[unsafe(method(resizeLeftRightCursor))]
302        #[unsafe(method_family = none)]
303        pub fn resizeLeftRightCursor() -> Retained<NSCursor>;
304
305        #[deprecated = "Use either `+[NSCursor rowResizeCursorInDirections:]` or `+[NSCursor frameResizeCursorFromPosition:inDirections:]` instead, depending on whether a divider is being re-positioned or a rectangular frame is being resized."]
306        #[unsafe(method(resizeUpCursor))]
307        #[unsafe(method_family = none)]
308        pub fn resizeUpCursor() -> Retained<NSCursor>;
309
310        #[deprecated = "Use either `+[NSCursor rowResizeCursorInDirections:]` or `+[NSCursor frameResizeCursorFromPosition:inDirections:]` instead, depending on whether a divider is being re-positioned or a rectangular frame is being resized."]
311        #[unsafe(method(resizeDownCursor))]
312        #[unsafe(method_family = none)]
313        pub fn resizeDownCursor() -> Retained<NSCursor>;
314
315        #[deprecated = "Use either `+[NSCursor rowResizeCursorInDirections:]` or `+[NSCursor frameResizeCursorFromPosition:inDirections:]` instead, depending on whether a divider is being re-positioned or a rectangular frame is being resized."]
316        #[unsafe(method(resizeUpDownCursor))]
317        #[unsafe(method_family = none)]
318        pub fn resizeUpDownCursor() -> Retained<NSCursor>;
319    );
320}
321
322/// NSDeprecated.
323impl NSCursor {
324    extern_methods!(
325        #[cfg(all(feature = "NSColor", feature = "NSImage"))]
326        #[deprecated = "Color hints are ignored. Use -initWithImage:hotSpot: instead"]
327        #[unsafe(method(initWithImage:foregroundColorHint:backgroundColorHint:hotSpot:))]
328        #[unsafe(method_family = init)]
329        pub unsafe fn initWithImage_foregroundColorHint_backgroundColorHint_hotSpot(
330            this: Allocated<Self>,
331            new_image: &NSImage,
332            fg: Option<&NSColor>,
333            bg: Option<&NSColor>,
334            hot_spot: NSPoint,
335        ) -> Retained<Self>;
336
337        #[deprecated = "setOnMouseExited is unused and should not be called"]
338        #[unsafe(method(setOnMouseExited:))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn setOnMouseExited(&self, flag: bool);
341
342        #[deprecated = "setOnMouseEntered is unused and should not be called"]
343        #[unsafe(method(setOnMouseEntered:))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn setOnMouseEntered(&self, flag: bool);
346
347        #[deprecated = "isSetOnMouseExited is unused"]
348        #[unsafe(method(isSetOnMouseExited))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn isSetOnMouseExited(&self) -> bool;
351
352        #[deprecated = "isSetOnMouseEntered is unused"]
353        #[unsafe(method(isSetOnMouseEntered))]
354        #[unsafe(method_family = none)]
355        pub unsafe fn isSetOnMouseEntered(&self) -> bool;
356
357        #[cfg(feature = "NSEvent")]
358        #[deprecated = "mouseEntered: is unused and should not be called"]
359        #[unsafe(method(mouseEntered:))]
360        #[unsafe(method_family = none)]
361        pub unsafe fn mouseEntered(&self, event: &NSEvent);
362
363        #[cfg(feature = "NSEvent")]
364        #[deprecated = "mouseExited: is unused and should not be called"]
365        #[unsafe(method(mouseExited:))]
366        #[unsafe(method_family = none)]
367        pub unsafe fn mouseExited(&self, event: &NSEvent);
368    );
369}