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