rust_macios/appkit/
enums.rs

1use objc::Encode;
2
3use crate::foundation::UInt;
4
5/// Constants that indicate whether a copy or print operation was successful,
6/// was canceled, or failed.
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8#[repr(u64)]
9pub enum NSApplicationDelegateReply {
10    /// Indicates the operation succeeded.
11    Success = 0,
12    /// Indicates the user cancelled the operation.
13    Cancel = 1,
14    /// Indicates an error occurred processing the operation.
15    Failure = 2,
16}
17
18/// Constants for the types of events that responder objects can handle.
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20#[repr(u64)]
21pub enum NSEventType {
22    /// The user pressed the left mouse button.
23    LeftMouseDown = 1,
24    /// The user released the left mouse button.
25    LeftMouseUp = 2,
26    /// The user pressed the right mouse button.
27    RightMouseDown = 3,
28    /// The user released the right mouse button.
29    RightMouseUp = 4,
30    /// The user moved the mouse in a way that caused the cursor to move onscreen.
31    MouseMoved = 5,
32    /// The user moved the mouse while holding down the left mouse button.
33    LeftMouseDragged = 6,
34    /// The user moved the mouse while holding down the right mouse button.
35    RightMouseDragged = 7,
36    /// The cursor entered a well-defined area, such as a view.
37    MouseEntered = 8,
38    /// The cursor exited a well-defined area, such as a view.
39    MouseExited = 9,
40    /// The user pressed a key on the keyboard.
41    KeyDown = 10,
42    /// The user released a key on the keyboard.
43    KeyUp = 11,
44    /// The event flags changed.
45    FlagsChanged = 12,
46    /// An AppKit-related event occurred.
47    AppKitDefined = 13,
48    /// A system-related event occurred.
49    SystemDefined = 14,
50    /// An app-defined event occurred.
51    ApplicationDefined = 15,
52    /// An event that provides execution time to periodic tasks.
53    Periodic = 16,
54    /// An event that updates the cursor.
55    CursorUpdate = 17,
56
57    /// The scroll wheel position changed.
58    ScrollWheel = 22,
59
60    /// The user touched a point on a tablet.
61    TabletPoint = 23,
62    /// A pointing device is near, but not touching, the associated tablet.
63    TabletProximity = 24,
64
65    /// The user pressed a tertiary mouse button.
66    OtherMouseDown = 25,
67    /// The user released a tertiary mouse button.
68    OtherMouseUp = 26,
69    /// The user moved the mouse while holding down a tertiary mouse button.
70    OtherMouseDragged = 27,
71
72    /// The user performed a nonspecific type of gesture.
73    Gesture = 29,
74    /// The user performed a pinch-open or pinch-close gesture.
75    Magnify = 30,
76    /// The user performed a swipe gesture.
77    Swipe = 31,
78    /// The user performed a rotate gesture.
79    Rotate = 18,
80    /// An event marking the beginning of a gesture.
81    BeginGesture = 19,
82    /// An event that marks the end of a gesture.
83    EndGesture = 20,
84
85    /// The user performed a smart-zoom gesture.
86    SmartMagnify = 32,
87    /// An event that initiates a Quick Look request.
88    QuickLook = 33,
89    /// An event that reports a change in pressure on a pressure-sensitive device.
90    Pressure = 34, // 10.10.3, 64-bit-only
91    /// The user touched a portion of the touch bar.
92    DirectTouch = 37, // 10.10
93    /// The user changed the mode of a connected device.
94    ChangeMode = 38,
95}
96
97/// Constants that you use to filter out specific event types from the stream
98/// of incoming events.
99#[derive(Debug, Clone, Copy, PartialEq, Eq)]
100#[repr(u64)]
101pub enum NSEventMask {
102    /// A mask for left mouse-down events.
103    LeftMouseDown = 1 << NSEventType::LeftMouseDown as u64,
104    /// A mask for left mouse-up events.
105    LeftMouseUp = 1 << NSEventType::LeftMouseUp as u64,
106    /// A mask for right mouse-down events.
107    RightMouseDown = 1 << NSEventType::RightMouseDown as u64,
108    /// A mask for right mouse-up events.
109    RightMouseUp = 1 << NSEventType::RightMouseUp as u64,
110    /// A mask for mouse-moved events.
111    MouseMoved = 1 << NSEventType::MouseMoved as u64,
112    /// A mask for left mouse-dragged events.
113    LeftMouseDragged = 1 << NSEventType::LeftMouseDragged as u64,
114    /// A mask for right mouse-dragged events.
115    RightMouseDragged = 1 << NSEventType::RightMouseDragged as u64,
116    /// A mask for mouse-entered events.
117    MouseEntered = 1 << NSEventType::MouseEntered as u64,
118    /// A mask for mouse-exited events.
119    MouseExited = 1 << NSEventType::MouseExited as u64,
120    /// A mask for key-down events.
121    KeyDown = 1 << NSEventType::KeyDown as u64,
122    /// A mask for key-up events.
123    KeyUp = 1 << NSEventType::KeyUp as u64,
124    /// A mask for flags-changed events.
125    FlagsChanged = 1 << NSEventType::FlagsChanged as u64,
126    /// A mask for AppKit–defined events.
127    AppKitDefined = 1 << NSEventType::AppKitDefined as u64,
128    /// A mask for system-defined events.
129    SystemDefined = 1 << NSEventType::SystemDefined as u64,
130    /// A mask for app-defined events.
131    ApplicationDefined = 1 << NSEventType::ApplicationDefined as u64,
132    /// A mask for periodic events.
133    Periodic = 1 << NSEventType::Periodic as u64,
134    /// A mask for cursor-update events.
135    CursorUpdate = 1 << NSEventType::CursorUpdate as u64,
136    /// A mask for scroll-wheel events.
137    ScrollWheel = 1 << NSEventType::ScrollWheel as u64,
138    /// A mask for tablet-point events.
139    TabletPoint = 1 << NSEventType::TabletPoint as u64,
140    /// A mask for tablet-proximity events.
141    TabletProximity = 1 << NSEventType::TabletProximity as u64,
142    /// A mask for tertiary mouse-down events.
143    OtherMouseDown = 1 << NSEventType::OtherMouseDown as u64,
144    /// A mask for right mouse-up events.
145    OtherMouseUp = 1 << NSEventType::OtherMouseUp as u64,
146    /// A mask for tertiary mouse-dragged events.
147    OtherMouseDragged = 1 << NSEventType::OtherMouseDragged as u64,
148    /// A mask for generic gesture events.
149    Gesture = 1 << NSEventType::Gesture as u64,
150    /// A mask for magnify-gesture events.
151    Magnify = 1 << NSEventType::Magnify as u64,
152    /// A mask for swipe-gesture events.
153    Swipe = 1 << NSEventType::Swipe as u64,
154    /// A mask for rotate-gesture events.
155    Rotate = 1 << NSEventType::Rotate as u64,
156    /// A mask for begin-gesture events.
157    BeginGesture = 1 << NSEventType::BeginGesture as u64,
158    /// A mask for end-gesture events.
159    EndGesture = 1 << NSEventType::EndGesture as u64,
160    /// A mask for smart-zoom gesture events.
161    SmartMagnify = 1 << NSEventType::SmartMagnify as u64,
162    /// A mask for pressure-change events.
163    Pressure = 1 << NSEventType::Pressure as u64, // 10.10.3, 64-bit-only
164    /// A mask for touch events.
165    DirectTouch = 1 << NSEventType::DirectTouch as u64, // 10.10
166    /// A mask for change-mode events.
167    ChangeMode = 1 << NSEventType::ChangeMode as u64,
168    /// A mask that matches any type of event.
169    AnyEvent = UInt::max_value(),
170}
171
172#[derive(Debug, Clone, Copy, PartialEq, Eq)]
173#[repr(i64)]
174/// Activation policies (used by `activationPolicy`) that control whether and how an app may be activated.
175pub enum NSApplicationActivationPolicy {
176    /// The application is an ordinary app that appears in the Dock and may have a user interface.
177    Regular,
178    /// The application doesn’t appear in the Dock and doesn’t have a menu bar, but it may be activated programmatically or by clicking on one of its windows.
179    Accessory,
180    /// The application doesn’t appear in the Dock and may not create windows or be activated.
181    Prohibited,
182}
183
184/// The following flags are for `activateWithOptions`
185#[derive(Debug, Clone, Copy, PartialEq, Eq)]
186#[repr(u64)]
187pub enum NSApplicationActivationOptions {
188    /// By default, activation brings only the main and key windows forward.
189    /// If you specify NSApplicationActivateAllWindows, all of the
190    /// application's windows are brought forward.
191    AllWindows = 1 << 0,
192    /// The application is activated regardless of the currently active app.
193    IgnoringOtherWindows = 1 << 1,
194}
195
196/// Constants that determine whether an app should terminate.
197#[derive(Debug, Clone, Copy, PartialEq, Eq)]
198#[repr(u64)]
199pub enum NSApplicationTerminateReply {
200    /// The app should not be terminated.
201    Cancel,
202    /// It is OK to proceed with termination.
203    Now,
204    /// The app should be terminated, but the user should be asked first.
205    Later,
206}
207
208unsafe impl Encode for NSApplicationTerminateReply {
209    fn encode() -> objc::Encoding {
210        unsafe { objc::Encoding::from_str("q") }
211    }
212}
213
214/// Constants that specify the style of a window, and that you can combine
215/// with the C bitwise OR operator.
216#[derive(Debug, Clone, Copy, PartialEq, Eq)]
217#[repr(u64)]
218pub enum NSWindowStyleMask {
219    /// The window displays none of the usual peripheral elements. Useful only
220    /// for display or caching purposes. A window that uses
221    /// NSWindowStyleMaskBorderless can’t become key or main, unless the
222    /// value of canBecomeKeyWindow or canBecomeMainWindow is YES. Note that
223    /// you can set a window’s or panel’s style mask to
224    /// NSWindowStyleMaskBorderless in Interface Builder by deselecting Title
225    /// Bar in the Appearance section of the Attributes inspector.
226    Borderless = 0,
227    /// The window displays a title bar.
228    Titled = 1 << 0,
229    /// The window displays a close button.
230    Closable = 1 << 1,
231    /// The window displays a minimize button.
232    Miniaturizable = 1 << 2,
233    /// The window can be resized by the user.
234    Resizable = 1 << 3,
235    /// The window is a panel or a subclass of NSPanel.
236    Utility = 1 << 4,
237    /// The window is a document-modal panel (or a subclass of NSPanel).
238    DocModal = 1 << 6,
239    /// The window is a panel or a subclass of NSPanel that does not activate
240    /// the owning app.
241    NonactivatingPanel = 1 << 7,
242    /// The window uses a textured background that darkens when the window is
243    /// key or main and lightens when it is inactive, and may have a second
244    /// gradient in the section below the window content.
245    #[deprecated]
246    TexturedBackground = 1 << 8,
247    ///
248    Unscaled = 1 << 11,
249    /// This constant has no effect, because all windows that include a
250    /// toolbar use the unified style.
251    UnifiedTitleAndToolbar = 1 << 12,
252    /// The window is a HUD panel.
253    Hud = 1 << 13,
254    /// The window can appear full screen. A fullscreen window does not
255    /// draw its title bar, and may have special handling for its toolbar.
256    /// (This mask is automatically toggled when toggleFullScreen: is called.)
257    FullScreenWindow = 1 << 14,
258    /// When set, the window’s contentView consumes the full size of the
259    /// window. Although you can combine this constant with other window
260    /// style masks, it is respected only for windows with a title bar.
261    /// Note that using this mask opts in to layer-backing. Use the
262    /// contentLayoutRect or the contentLayoutGuide to lay out views
263    /// underneath the title bar–toolbar area.
264    FullSizeContentView = 1 << 15,
265}
266
267/// Styles that determine the appearance and location of the toolbar in
268/// relation to the title bar.
269#[derive(Debug, Clone, Copy, PartialEq, Eq)]
270#[repr(i64)]
271pub enum NSWindowToolbarStyle {
272    /// A style indicating that the system determines the toolbar’s appearance
273    /// and location.
274    Automatic,
275    /// A style indicating that the toolbar appears below the window title.
276    Expanded,
277    /// A style indicating that the toolbar appears below the window title with
278    /// toolbar items centered in the toolbar.
279    Preference,
280    /// A style indicating that the toolbar appears next to the window title.
281    Unified,
282    /// A style indicating that the toolbar appears next to the window title
283    /// and with reduced margins to allow more focus on the window’s contents.
284    UnifiedCompact,
285}
286
287/// Specifies the appearance of the window’s title bar area.
288#[derive(Debug, Clone, Copy, PartialEq, Eq)]
289#[repr(i64)]
290pub enum NSWindowTitleVisibility {
291    /// The window has the regular window title and title bar buttons.
292    Visible = 0,
293    /// The window has no title bar buttons.
294    Hidden = 1,
295}
296
297#[derive(Debug, Clone, Copy, PartialEq, Eq)]
298#[repr(u64)]
299/// Constants that specify how the window device buffers the drawing done in a window.
300pub enum NSBackingStoreType {
301    /// The window uses a buffer, but draws directly to the screen where possible and to the buffer for obscured portions.
302    #[deprecated]
303    Retained = 0,
304    /// The window draws directly to the screen without using any buffer.
305    #[deprecated]
306    Nonretained = 1,
307    /// The window renders all drawing into a display buffer and then flushes it to the screen.
308    Buffered = 2,
309}
310
311/// Window collection behaviors related to Exposé and Spaces.
312#[derive(Debug, Clone, Copy, PartialEq, Eq)]
313#[repr(u64)]
314pub enum NSWindowCollectionBehavior {
315    /// The window appears in only one space at a time.
316    Default = 0,
317    /// The window appears in all spaces.
318    CanJoinAllSpaces = 1 << 0,
319    /// When the window becomes active, move it to the active space instead of switching spaces.
320    MoveToActiveSpace = 1 << 1,
321    /// The window participates in Spaces and Exposé.
322    Managed = 1 << 2,
323    /// The window floats in Spaces and hides in Exposé.
324    Transient = 1 << 3,
325    /// Exposé doesn’t affect the window, so it stays visible and stationary, like the desktop window.
326    Stationary = 1 << 4,
327    /// The window participates in the window cycle for use with the Cycle Through Windows menu item.
328    ParticipatesInCycle = 1 << 5,
329    /// The window isn’t part of the window cycle for use with the Cycle Through Windows menu item.
330    IgnoresCycle = 1 << 6,
331    /// The window can enter full-screen mode.
332    FullScreenPrimary = 1 << 7,
333    /// The window can display on the same space as the full-screen window.
334    FullScreenAuxiliary = 1 << 8,
335    /// The window doesn’t support full-screen mode.
336    FullScreenNone = 1 << 9,
337    /// The window can be a secondary full screen tile even if it can’t be a full screen window itself.
338    FullScreenAllowsTiling = 1 << 11,
339    /// The window doesn’t support being a full-screen tile window, but may support being a full-screen window.
340    FullScreenDisallowsTiling = 1 << 12,
341}
342
343#[derive(Debug, Clone, Copy, PartialEq, Eq)]
344#[repr(i32)]
345/// A type that represents the depth, or amount of memory, for a single pixel in a window or screen.
346pub enum NSWindowDepth {
347    /// Twenty four bit RGB depth limit.
348    TwentyfourBitRgb = 0x208,
349    /// Sixty four bit RGB depth limit.
350    SixtyfourBitRgb = 0x210,
351    /// One hundred and twenty eight bit RGB depth limit.
352    OneHundredTwentyEightBitRgb = 0x220,
353}
354
355/// Options to use when retrieving window numbers from the system.
356#[derive(Debug, Clone, Copy, PartialEq, Eq)]
357#[repr(u64)]
358pub enum NSWindowNumberListOptions {
359    ///
360    AllApplication = 1 << 0,
361    ///
362    AllSpaces = 1 << 4,
363}
364
365/// Constants that represent the access levels other processes can have to a window’s content.
366#[derive(Debug, Clone, Copy, PartialEq, Eq)]
367#[repr(u64)]
368pub enum NSWindowSharingType {
369    /// The window’s contents cannot be read by another process.
370    None,
371    ///
372    ReadOnly,
373    ///
374    ReadWrite,
375}
376
377/// Constants that let you specify how a window is ordered relative to another window.
378#[derive(Debug, Clone, Copy, PartialEq, Eq)]
379#[repr(i64)]
380pub enum NSWindowOrderingMode {
381    /// Moves the window below the indicated window.
382    Below = -1,
383    /// Moves the window off the screen.
384    Out,
385    /// Moves the window above the indicated window.
386    Above,
387}
388
389/// Specifies whether the window is occluded.
390#[derive(Debug, Clone, Copy, PartialEq, Eq)]
391#[repr(u64)]
392pub enum NSWindowOcclusionState {
393    /// If set, at least part of the window is visible; if not set, the entire window is occluded. A window that has a nonrectangular shape can be entirely occluded onscreen, but if its bounding box falls into a visible region, the window is considered to be visible. Note that a completely transparent window may also be considered visible.
394    Visible = 1 << 1,
395}
396
397/// Constants that provide a way to access standard title bar buttons.
398#[derive(Debug, Clone, Copy, PartialEq, Eq)]
399#[repr(u64)]
400pub enum NSWindowButton {
401    /// The close button.
402    CloseButton,
403    /// The minimize button.
404    MiniaturizeButton,
405    /// The zoom button.
406    ZoomButton,
407    /// The toolbar button.
408    ToolbarButton,
409    /// The document icon button.
410    DocumentIconButton,
411    /// The document versions button.
412    DocumentVersionsButton = 6,
413    /// The fullscreen icon button.
414    #[deprecated = "The standard window button for FullScreenButton is always null; use ZoomButton instead."]
415    FullScreenButton,
416}
417
418/// Styles that determine the type of separator displayed between the title bar and content of a window.
419#[derive(Debug, Clone, Copy, PartialEq, Eq)]
420#[repr(i64)]
421pub enum NSTitlebarSeparatorStyle {
422    /// A style indicating that the system determines the type of separator.
423    Automatic,
424    /// A style indicating that there’s no title bar separator.
425    None,
426    /// A style indicating that there’s no title bar separator.
427    Line,
428    /// A style indicating that the title bar separator is a shadow.
429    Shadow,
430}
431
432/// Specifies the directional flow of the user interface.
433#[derive(Debug, Clone, Copy, PartialEq, Eq)]
434#[repr(i64)]
435pub enum NSUserInterfaceLayoutDirection {
436    /// Layout direction is left to right.
437    LeftToRight,
438    /// Layout direction is right to left.
439    RightToLeft,
440}
441
442/// The appearance and disappearance behavior of a popover.
443#[derive(Debug, Clone, Copy, PartialEq, Eq)]
444#[repr(i64)]
445pub enum NSPopoverBehavior {
446    /// Your application assumes responsibility for closing the popover.
447    ApplicationDefined = 0,
448    /// The system will close the popover when the user interacts with a user interface element outside the popover.
449    Transient = 1,
450    /// The system will close the popover when the user interacts with user interface elements in the window containing the popover's positioning view.
451    Semitransient = 2,
452}
453
454/// A set of optional status item behaviors.
455#[derive(Debug, Clone, Copy, PartialEq, Eq)]
456pub enum NSStatusItemBehavior {
457    /// A status item that allows interactive removal.
458    RemovalAllowed = (1 << 1),
459    /// A status item that quits the application upon removal.
460    TerminationOnRemoval = (1 << 2),
461}