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 =
32        NSCursorFrameResizePosition::Top as usize | NSCursorFrameResizePosition::Left as usize,
33    /// The top right corner of the frame.
34    #[doc(alias = "NSCursorFrameResizePositionTopRight")]
35    TopRight =
36        NSCursorFrameResizePosition::Top as usize | NSCursorFrameResizePosition::Right as usize,
37    /// The bottom left corner of the frame.
38    #[doc(alias = "NSCursorFrameResizePositionBottomLeft")]
39    BottomLeft =
40        NSCursorFrameResizePosition::Bottom as usize | NSCursorFrameResizePosition::Left as usize,
41    /// The bottom right corner of the frame.
42    #[doc(alias = "NSCursorFrameResizePositionBottomRight")]
43    BottomRight =
44        NSCursorFrameResizePosition::Bottom as usize | NSCursorFrameResizePosition::Right as usize,
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
91unsafe impl NSCoding for NSCursor {}
92
93unsafe impl NSObjectProtocol for NSCursor {}
94
95unsafe impl NSSecureCoding for NSCursor {}
96
97impl NSCursor {
98    extern_methods!(
99        #[cfg(feature = "NSImage")]
100        #[unsafe(method(initWithImage:hotSpot:))]
101        #[unsafe(method_family = init)]
102        pub fn initWithImage_hotSpot(
103            this: Allocated<Self>,
104            new_image: &NSImage,
105            point: NSPoint,
106        ) -> Retained<Self>;
107
108        #[unsafe(method(initWithCoder:))]
109        #[unsafe(method_family = init)]
110        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
111
112        #[cfg(feature = "NSImage")]
113        #[unsafe(method(image))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn image(&self) -> Retained<NSImage>;
116
117        #[unsafe(method(hotSpot))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn hotSpot(&self) -> NSPoint;
120
121        #[unsafe(method(hide))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn hide();
124
125        #[unsafe(method(unhide))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn unhide();
128
129        #[unsafe(method(setHiddenUntilMouseMoves:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn setHiddenUntilMouseMoves(flag: bool);
132
133        #[unsafe(method(pop))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn pop_class();
136
137        #[unsafe(method(pop))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn pop(&self);
140
141        #[unsafe(method(push))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn push(&self);
144
145        #[unsafe(method(set))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn set(&self);
148
149        /// Returns the application’s current cursor.
150        /// - Note: This isn’t necessarily the cursor that is currently being displayed, as the system may be showing the cursor for another running application.
151        #[unsafe(method(currentCursor))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn currentCursor() -> Retained<NSCursor>;
154
155        /// Returns the default cursor, the arrow cursor.
156        /// - 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.
157        #[unsafe(method(arrowCursor))]
158        #[unsafe(method_family = none)]
159        pub fn arrowCursor() -> Retained<NSCursor>;
160
161        #[unsafe(method(crosshairCursor))]
162        #[unsafe(method_family = none)]
163        pub fn crosshairCursor() -> Retained<NSCursor>;
164
165        #[unsafe(method(disappearingItemCursor))]
166        #[unsafe(method_family = none)]
167        pub fn disappearingItemCursor() -> Retained<NSCursor>;
168
169        #[unsafe(method(operationNotAllowedCursor))]
170        #[unsafe(method_family = none)]
171        pub fn operationNotAllowedCursor() -> Retained<NSCursor>;
172
173        #[unsafe(method(dragLinkCursor))]
174        #[unsafe(method_family = none)]
175        pub fn dragLinkCursor() -> Retained<NSCursor>;
176
177        #[unsafe(method(dragCopyCursor))]
178        #[unsafe(method_family = none)]
179        pub fn dragCopyCursor() -> Retained<NSCursor>;
180
181        #[unsafe(method(contextualMenuCursor))]
182        #[unsafe(method_family = none)]
183        pub fn contextualMenuCursor() -> Retained<NSCursor>;
184
185        #[unsafe(method(pointingHandCursor))]
186        #[unsafe(method_family = none)]
187        pub fn pointingHandCursor() -> Retained<NSCursor>;
188
189        #[unsafe(method(closedHandCursor))]
190        #[unsafe(method_family = none)]
191        pub fn closedHandCursor() -> Retained<NSCursor>;
192
193        #[unsafe(method(openHandCursor))]
194        #[unsafe(method_family = none)]
195        pub fn openHandCursor() -> Retained<NSCursor>;
196
197        #[unsafe(method(IBeamCursor))]
198        #[unsafe(method_family = none)]
199        pub fn IBeamCursor() -> Retained<NSCursor>;
200
201        #[unsafe(method(IBeamCursorForVerticalLayout))]
202        #[unsafe(method_family = none)]
203        pub fn IBeamCursorForVerticalLayout() -> Retained<NSCursor>;
204
205        /// Returns the zoom-in cursor.
206        /// - Note: This cursor is used to indicate zooming in on (magnifying) a canvas or object.
207        #[unsafe(method(zoomInCursor))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn zoomInCursor() -> Retained<NSCursor>;
210
211        /// Returns the zoom-out cursor.
212        /// - Note: This cursor is used to indicate zooming out of a canvas or object.
213        #[unsafe(method(zoomOutCursor))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn zoomOutCursor() -> Retained<NSCursor>;
216
217        /// Returns the cursor for resizing a column (vertical divider) in either direction.
218        #[unsafe(method(columnResizeCursor))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn columnResizeCursor() -> Retained<NSCursor>;
221
222        #[cfg(feature = "NSDirection")]
223        /// Returns the cursor for resizing a column (vertical divider) in the specified directions.
224        /// - Parameter directions: The direction in which a column can be resized.
225        #[unsafe(method(columnResizeCursorInDirections:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn columnResizeCursorInDirections(
228            directions: NSHorizontalDirections,
229        ) -> Retained<NSCursor>;
230
231        /// Returns the cursor for resizing a row (horizontal divider) in either direction.
232        #[unsafe(method(rowResizeCursor))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn rowResizeCursor() -> Retained<NSCursor>;
235
236        #[cfg(feature = "NSDirection")]
237        /// Returns the cursor for resizing a row (horizontal divider) in the specified directions.
238        /// - Parameter directions: The direction in which a row can be resized.
239        #[unsafe(method(rowResizeCursorInDirections:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn rowResizeCursorInDirections(
242            directions: NSVerticalDirections,
243        ) -> Retained<NSCursor>;
244
245        /// Returns the cursor for resizing a rectangular frame from the specified edge or corner.
246        /// - Parameters:
247        /// - position: The position along the perimeter of a rectangular frame (its edges and corners) from which it’s resized.
248        /// - directions: The directions in which a rectangular frame can be resized.
249        #[unsafe(method(frameResizeCursorFromPosition:inDirections:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn frameResizeCursorFromPosition_inDirections(
252            position: NSCursorFrameResizePosition,
253            directions: NSCursorFrameResizeDirections,
254        ) -> Retained<NSCursor>;
255    );
256}
257
258/// Methods declared on superclass `NSObject`.
259impl NSCursor {
260    extern_methods!(
261        #[unsafe(method(init))]
262        #[unsafe(method_family = init)]
263        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
264
265        #[unsafe(method(new))]
266        #[unsafe(method_family = new)]
267        pub unsafe fn new() -> Retained<Self>;
268    );
269}
270
271/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumberwithcursorsizesupport?language=objc)
272#[cfg(feature = "NSApplication")]
273pub static NSAppKitVersionNumberWithCursorSizeSupport: NSAppKitVersion = 682.0 as _;
274
275/// Deprecated.
276impl NSCursor {
277    extern_methods!(
278        /// This property will always be `nil` in a future version of macOS.
279        #[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."]
280        #[unsafe(method(currentSystemCursor))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn currentSystemCursor() -> Option<Retained<NSCursor>>;
283
284        #[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."]
285        #[unsafe(method(resizeLeftCursor))]
286        #[unsafe(method_family = none)]
287        pub fn resizeLeftCursor() -> Retained<NSCursor>;
288
289        #[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."]
290        #[unsafe(method(resizeRightCursor))]
291        #[unsafe(method_family = none)]
292        pub fn resizeRightCursor() -> Retained<NSCursor>;
293
294        #[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."]
295        #[unsafe(method(resizeLeftRightCursor))]
296        #[unsafe(method_family = none)]
297        pub fn resizeLeftRightCursor() -> Retained<NSCursor>;
298
299        #[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."]
300        #[unsafe(method(resizeUpCursor))]
301        #[unsafe(method_family = none)]
302        pub fn resizeUpCursor() -> Retained<NSCursor>;
303
304        #[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."]
305        #[unsafe(method(resizeDownCursor))]
306        #[unsafe(method_family = none)]
307        pub fn resizeDownCursor() -> Retained<NSCursor>;
308
309        #[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."]
310        #[unsafe(method(resizeUpDownCursor))]
311        #[unsafe(method_family = none)]
312        pub fn resizeUpDownCursor() -> Retained<NSCursor>;
313    );
314}
315
316/// NSDeprecated.
317impl NSCursor {
318    extern_methods!(
319        #[cfg(all(feature = "NSColor", feature = "NSImage"))]
320        #[deprecated = "Color hints are ignored. Use -initWithImage:hotSpot: instead"]
321        #[unsafe(method(initWithImage:foregroundColorHint:backgroundColorHint:hotSpot:))]
322        #[unsafe(method_family = init)]
323        pub unsafe fn initWithImage_foregroundColorHint_backgroundColorHint_hotSpot(
324            this: Allocated<Self>,
325            new_image: &NSImage,
326            fg: Option<&NSColor>,
327            bg: Option<&NSColor>,
328            hot_spot: NSPoint,
329        ) -> Retained<Self>;
330
331        #[deprecated = "setOnMouseExited is unused and should not be called"]
332        #[unsafe(method(setOnMouseExited:))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn setOnMouseExited(&self, flag: bool);
335
336        #[deprecated = "setOnMouseEntered is unused and should not be called"]
337        #[unsafe(method(setOnMouseEntered:))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn setOnMouseEntered(&self, flag: bool);
340
341        #[deprecated = "isSetOnMouseExited is unused"]
342        #[unsafe(method(isSetOnMouseExited))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn isSetOnMouseExited(&self) -> bool;
345
346        #[deprecated = "isSetOnMouseEntered is unused"]
347        #[unsafe(method(isSetOnMouseEntered))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn isSetOnMouseEntered(&self) -> bool;
350
351        #[cfg(feature = "NSEvent")]
352        #[deprecated = "mouseEntered: is unused and should not be called"]
353        #[unsafe(method(mouseEntered:))]
354        #[unsafe(method_family = none)]
355        pub unsafe fn mouseEntered(&self, event: &NSEvent);
356
357        #[cfg(feature = "NSEvent")]
358        #[deprecated = "mouseExited: is unused and should not be called"]
359        #[unsafe(method(mouseExited:))]
360        #[unsafe(method_family = none)]
361        pub unsafe fn mouseExited(&self, event: &NSEvent);
362    );
363}