use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
use objc2_quartz_core::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIControlEvents(pub NSUInteger);
bitflags::bitflags! {
impl UIControlEvents: NSUInteger {
#[doc(alias = "UIControlEventTouchDown")]
const TouchDown = 1<<0;
#[doc(alias = "UIControlEventTouchDownRepeat")]
const TouchDownRepeat = 1<<1;
#[doc(alias = "UIControlEventTouchDragInside")]
const TouchDragInside = 1<<2;
#[doc(alias = "UIControlEventTouchDragOutside")]
const TouchDragOutside = 1<<3;
#[doc(alias = "UIControlEventTouchDragEnter")]
const TouchDragEnter = 1<<4;
#[doc(alias = "UIControlEventTouchDragExit")]
const TouchDragExit = 1<<5;
#[doc(alias = "UIControlEventTouchUpInside")]
const TouchUpInside = 1<<6;
#[doc(alias = "UIControlEventTouchUpOutside")]
const TouchUpOutside = 1<<7;
#[doc(alias = "UIControlEventTouchCancel")]
const TouchCancel = 1<<8;
#[doc(alias = "UIControlEventValueChanged")]
const ValueChanged = 1<<12;
#[doc(alias = "UIControlEventPrimaryActionTriggered")]
const PrimaryActionTriggered = 1<<13;
#[doc(alias = "UIControlEventMenuActionTriggered")]
const MenuActionTriggered = 1<<14;
#[doc(alias = "UIControlEventEditingDidBegin")]
const EditingDidBegin = 1<<16;
#[doc(alias = "UIControlEventEditingChanged")]
const EditingChanged = 1<<17;
#[doc(alias = "UIControlEventEditingDidEnd")]
const EditingDidEnd = 1<<18;
#[doc(alias = "UIControlEventEditingDidEndOnExit")]
const EditingDidEndOnExit = 1<<19;
#[doc(alias = "UIControlEventAllTouchEvents")]
const AllTouchEvents = 0x00000FFF;
#[doc(alias = "UIControlEventAllEditingEvents")]
const AllEditingEvents = 0x000F0000;
#[doc(alias = "UIControlEventApplicationReserved")]
const ApplicationReserved = 0x0F000000;
#[doc(alias = "UIControlEventSystemReserved")]
const SystemReserved = 0xF0000000;
#[doc(alias = "UIControlEventAllEvents")]
const AllEvents = 0xFFFFFFFF;
}
}
unsafe impl Encode for UIControlEvents {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for UIControlEvents {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIControlContentVerticalAlignment(pub NSInteger);
impl UIControlContentVerticalAlignment {
#[doc(alias = "UIControlContentVerticalAlignmentCenter")]
pub const Center: Self = Self(0);
#[doc(alias = "UIControlContentVerticalAlignmentTop")]
pub const Top: Self = Self(1);
#[doc(alias = "UIControlContentVerticalAlignmentBottom")]
pub const Bottom: Self = Self(2);
#[doc(alias = "UIControlContentVerticalAlignmentFill")]
pub const Fill: Self = Self(3);
}
unsafe impl Encode for UIControlContentVerticalAlignment {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UIControlContentVerticalAlignment {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIControlContentHorizontalAlignment(pub NSInteger);
impl UIControlContentHorizontalAlignment {
#[doc(alias = "UIControlContentHorizontalAlignmentCenter")]
pub const Center: Self = Self(0);
#[doc(alias = "UIControlContentHorizontalAlignmentLeft")]
pub const Left: Self = Self(1);
#[doc(alias = "UIControlContentHorizontalAlignmentRight")]
pub const Right: Self = Self(2);
#[doc(alias = "UIControlContentHorizontalAlignmentFill")]
pub const Fill: Self = Self(3);
#[doc(alias = "UIControlContentHorizontalAlignmentLeading")]
pub const Leading: Self = Self(4);
#[doc(alias = "UIControlContentHorizontalAlignmentTrailing")]
pub const Trailing: Self = Self(5);
}
unsafe impl Encode for UIControlContentHorizontalAlignment {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UIControlContentHorizontalAlignment {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIControlState(pub NSUInteger);
bitflags::bitflags! {
impl UIControlState: NSUInteger {
#[doc(alias = "UIControlStateNormal")]
const Normal = 0;
#[doc(alias = "UIControlStateHighlighted")]
const Highlighted = 1<<0;
#[doc(alias = "UIControlStateDisabled")]
const Disabled = 1<<1;
#[doc(alias = "UIControlStateSelected")]
const Selected = 1<<2;
#[doc(alias = "UIControlStateFocused")]
const Focused = 1<<3;
#[doc(alias = "UIControlStateApplication")]
const Application = 0x00FF0000;
#[doc(alias = "UIControlStateReserved")]
const Reserved = 0xFF000000;
}
}
unsafe impl Encode for UIControlState {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for UIControlState {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(UIView, UIResponder, NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
pub struct UIControl;
);
#[cfg(all(
feature = "UIResponder",
feature = "UIView",
feature = "objc2-quartz-core"
))]
#[cfg(not(target_os = "watchos"))]
extern_conformance!(
unsafe impl CALayerDelegate for UIControl {}
);
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
unsafe impl NSCoding for UIControl {}
);
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
unsafe impl NSObjectProtocol for UIControl {}
);
#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
unsafe impl UIAppearance for UIControl {}
);
#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
unsafe impl UIAppearanceContainer for UIControl {}
);
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
unsafe impl UICoordinateSpace for UIControl {}
);
#[cfg(all(
feature = "UIDynamicBehavior",
feature = "UIResponder",
feature = "UIView"
))]
extern_conformance!(
unsafe impl UIDynamicItem for UIControl {}
);
#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
unsafe impl UIFocusEnvironment for UIControl {}
);
#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
unsafe impl UIFocusItem for UIControl {}
);
#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
unsafe impl UIFocusItemContainer for UIControl {}
);
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
extern_conformance!(
unsafe impl UIResponderStandardEditActions for UIControl {}
);
#[cfg(all(
feature = "UIResponder",
feature = "UITraitCollection",
feature = "UIView"
))]
extern_conformance!(
unsafe impl UITraitEnvironment for UIControl {}
);
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
impl UIControl {
extern_methods!(
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(initWithFrame:))]
#[unsafe(method_family = init)]
pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
#[cfg(all(
feature = "UIAction",
feature = "UIMenuElement",
feature = "objc2-core-foundation"
))]
#[unsafe(method(initWithFrame:primaryAction:))]
#[unsafe(method_family = init)]
pub fn initWithFrame_primaryAction(
this: Allocated<Self>,
frame: CGRect,
primary_action: Option<&UIAction>,
) -> Retained<Self>;
#[unsafe(method(isEnabled))]
#[unsafe(method_family = none)]
pub fn isEnabled(&self) -> bool;
#[unsafe(method(setEnabled:))]
#[unsafe(method_family = none)]
pub fn setEnabled(&self, enabled: bool);
#[unsafe(method(isSelected))]
#[unsafe(method_family = none)]
pub fn isSelected(&self) -> bool;
#[unsafe(method(setSelected:))]
#[unsafe(method_family = none)]
pub fn setSelected(&self, selected: bool);
#[unsafe(method(isHighlighted))]
#[unsafe(method_family = none)]
pub fn isHighlighted(&self) -> bool;
#[unsafe(method(setHighlighted:))]
#[unsafe(method_family = none)]
pub fn setHighlighted(&self, highlighted: bool);
#[unsafe(method(contentVerticalAlignment))]
#[unsafe(method_family = none)]
pub fn contentVerticalAlignment(&self) -> UIControlContentVerticalAlignment;
#[unsafe(method(setContentVerticalAlignment:))]
#[unsafe(method_family = none)]
pub fn setContentVerticalAlignment(
&self,
content_vertical_alignment: UIControlContentVerticalAlignment,
);
#[unsafe(method(contentHorizontalAlignment))]
#[unsafe(method_family = none)]
pub fn contentHorizontalAlignment(&self) -> UIControlContentHorizontalAlignment;
#[unsafe(method(setContentHorizontalAlignment:))]
#[unsafe(method_family = none)]
pub fn setContentHorizontalAlignment(
&self,
content_horizontal_alignment: UIControlContentHorizontalAlignment,
);
#[unsafe(method(effectiveContentHorizontalAlignment))]
#[unsafe(method_family = none)]
pub fn effectiveContentHorizontalAlignment(&self) -> UIControlContentHorizontalAlignment;
#[unsafe(method(state))]
#[unsafe(method_family = none)]
pub fn state(&self) -> UIControlState;
#[unsafe(method(isTracking))]
#[unsafe(method_family = none)]
pub fn isTracking(&self) -> bool;
#[unsafe(method(isTouchInside))]
#[unsafe(method_family = none)]
pub fn isTouchInside(&self) -> bool;
#[cfg(all(feature = "UIEvent", feature = "UITouch"))]
#[unsafe(method(beginTrackingWithTouch:withEvent:))]
#[unsafe(method_family = none)]
pub fn beginTrackingWithTouch_withEvent(
&self,
touch: &UITouch,
event: Option<&UIEvent>,
) -> bool;
#[cfg(all(feature = "UIEvent", feature = "UITouch"))]
#[unsafe(method(continueTrackingWithTouch:withEvent:))]
#[unsafe(method_family = none)]
pub fn continueTrackingWithTouch_withEvent(
&self,
touch: &UITouch,
event: Option<&UIEvent>,
) -> bool;
#[cfg(all(feature = "UIEvent", feature = "UITouch"))]
#[unsafe(method(endTrackingWithTouch:withEvent:))]
#[unsafe(method_family = none)]
pub fn endTrackingWithTouch_withEvent(
&self,
touch: Option<&UITouch>,
event: Option<&UIEvent>,
);
#[cfg(feature = "UIEvent")]
#[unsafe(method(cancelTrackingWithEvent:))]
#[unsafe(method_family = none)]
pub fn cancelTrackingWithEvent(&self, event: Option<&UIEvent>);
#[unsafe(method(addTarget:action:forControlEvents:))]
#[unsafe(method_family = none)]
pub unsafe fn addTarget_action_forControlEvents(
&self,
target: Option<&AnyObject>,
action: Sel,
control_events: UIControlEvents,
);
#[unsafe(method(removeTarget:action:forControlEvents:))]
#[unsafe(method_family = none)]
pub unsafe fn removeTarget_action_forControlEvents(
&self,
target: Option<&AnyObject>,
action: Option<Sel>,
control_events: UIControlEvents,
);
#[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
#[unsafe(method(addAction:forControlEvents:))]
#[unsafe(method_family = none)]
pub fn addAction_forControlEvents(
&self,
action: &UIAction,
control_events: UIControlEvents,
);
#[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
#[unsafe(method(removeAction:forControlEvents:))]
#[unsafe(method_family = none)]
pub fn removeAction_forControlEvents(
&self,
action: &UIAction,
control_events: UIControlEvents,
);
#[cfg(feature = "UIAction")]
#[unsafe(method(removeActionForIdentifier:forControlEvents:))]
#[unsafe(method_family = none)]
pub fn removeActionForIdentifier_forControlEvents(
&self,
action_identifier: &UIActionIdentifier,
control_events: UIControlEvents,
);
#[unsafe(method(performPrimaryAction))]
#[unsafe(method_family = none)]
pub fn performPrimaryAction(&self);
#[unsafe(method(allTargets))]
#[unsafe(method_family = none)]
pub fn allTargets(&self) -> Retained<NSSet>;
#[unsafe(method(allControlEvents))]
#[unsafe(method_family = none)]
pub fn allControlEvents(&self) -> UIControlEvents;
#[unsafe(method(actionsForTarget:forControlEvent:))]
#[unsafe(method_family = none)]
pub unsafe fn actionsForTarget_forControlEvent(
&self,
target: Option<&AnyObject>,
control_event: UIControlEvents,
) -> Option<Retained<NSArray<NSString>>>;
#[cfg(all(feature = "UIAction", feature = "UIMenuElement", feature = "block2"))]
#[unsafe(method(enumerateEventHandlers:))]
#[unsafe(method_family = none)]
pub fn enumerateEventHandlers(
&self,
iterator: &block2::DynBlock<
dyn Fn(*mut UIAction, *mut AnyObject, Option<Sel>, UIControlEvents, NonNull<Bool>)
+ '_,
>,
);
#[cfg(feature = "UIEvent")]
#[unsafe(method(sendAction:to:forEvent:))]
#[unsafe(method_family = none)]
pub unsafe fn sendAction_to_forEvent(
&self,
action: Sel,
target: Option<&AnyObject>,
event: Option<&UIEvent>,
);
#[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
#[unsafe(method(sendAction:))]
#[unsafe(method_family = none)]
pub fn sendAction(&self, action: &UIAction);
#[unsafe(method(sendActionsForControlEvents:))]
#[unsafe(method_family = none)]
pub fn sendActionsForControlEvents(&self, control_events: UIControlEvents);
#[cfg(feature = "UIContextMenuInteraction")]
#[unsafe(method(contextMenuInteraction))]
#[unsafe(method_family = none)]
pub fn contextMenuInteraction(&self) -> Option<Retained<UIContextMenuInteraction>>;
#[unsafe(method(isContextMenuInteractionEnabled))]
#[unsafe(method_family = none)]
pub fn isContextMenuInteractionEnabled(&self) -> bool;
#[unsafe(method(setContextMenuInteractionEnabled:))]
#[unsafe(method_family = none)]
pub fn setContextMenuInteractionEnabled(&self, context_menu_interaction_enabled: bool);
#[unsafe(method(showsMenuAsPrimaryAction))]
#[unsafe(method_family = none)]
pub fn showsMenuAsPrimaryAction(&self) -> bool;
#[unsafe(method(setShowsMenuAsPrimaryAction:))]
#[unsafe(method_family = none)]
pub fn setShowsMenuAsPrimaryAction(&self, shows_menu_as_primary_action: bool);
#[cfg(all(
feature = "UIContextMenuConfiguration",
feature = "objc2-core-foundation"
))]
#[unsafe(method(menuAttachmentPointForConfiguration:))]
#[unsafe(method_family = none)]
pub fn menuAttachmentPointForConfiguration(
&self,
configuration: &UIContextMenuConfiguration,
) -> CGPoint;
#[unsafe(method(toolTip))]
#[unsafe(method_family = none)]
pub fn toolTip(&self) -> Option<Retained<NSString>>;
#[unsafe(method(setToolTip:))]
#[unsafe(method_family = none)]
pub fn setToolTip(&self, tool_tip: Option<&NSString>);
#[cfg(feature = "UIToolTipInteraction")]
#[unsafe(method(toolTipInteraction))]
#[unsafe(method_family = none)]
pub fn toolTipInteraction(&self) -> Option<Retained<UIToolTipInteraction>>;
#[unsafe(method(isSymbolAnimationEnabled))]
#[unsafe(method_family = none)]
pub fn isSymbolAnimationEnabled(&self) -> bool;
#[unsafe(method(setSymbolAnimationEnabled:))]
#[unsafe(method_family = none)]
pub fn setSymbolAnimationEnabled(&self, symbol_animation_enabled: bool);
);
}
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
impl UIControl {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
impl UIControl {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
impl UIControl {
extern_methods!(
#[cfg(all(
feature = "UIContextMenuConfiguration",
feature = "UIContextMenuInteraction",
feature = "objc2-core-foundation"
))]
#[unsafe(method(contextMenuInteraction:configurationForMenuAtLocation:))]
#[unsafe(method_family = none)]
pub fn contextMenuInteraction_configurationForMenuAtLocation(
&self,
interaction: &UIContextMenuInteraction,
location: CGPoint,
) -> Option<Retained<UIContextMenuConfiguration>>;
#[cfg(all(
feature = "UIContextMenuConfiguration",
feature = "UIContextMenuInteraction",
feature = "UITargetedPreview"
))]
#[unsafe(method(contextMenuInteraction:previewForHighlightingMenuWithConfiguration:))]
#[unsafe(method_family = none)]
pub fn contextMenuInteraction_previewForHighlightingMenuWithConfiguration(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
) -> Option<Retained<UITargetedPreview>>;
#[cfg(all(
feature = "UIContextMenuConfiguration",
feature = "UIContextMenuInteraction",
feature = "UITargetedPreview"
))]
#[unsafe(method(contextMenuInteraction:previewForDismissingMenuWithConfiguration:))]
#[unsafe(method_family = none)]
pub fn contextMenuInteraction_previewForDismissingMenuWithConfiguration(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
) -> Option<Retained<UITargetedPreview>>;
#[cfg(all(
feature = "UIContextMenuConfiguration",
feature = "UIContextMenuInteraction"
))]
#[unsafe(method(contextMenuInteraction:willDisplayMenuForConfiguration:animator:))]
#[unsafe(method_family = none)]
pub fn contextMenuInteraction_willDisplayMenuForConfiguration_animator(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
animator: Option<&ProtocolObject<dyn UIContextMenuInteractionAnimating>>,
);
#[cfg(all(
feature = "UIContextMenuConfiguration",
feature = "UIContextMenuInteraction"
))]
#[unsafe(method(contextMenuInteraction:willEndForConfiguration:animator:))]
#[unsafe(method_family = none)]
pub fn contextMenuInteraction_willEndForConfiguration_animator(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
animator: Option<&ProtocolObject<dyn UIContextMenuInteractionAnimating>>,
);
#[cfg(all(
feature = "UIContextMenuConfiguration",
feature = "UIContextMenuInteraction"
))]
#[unsafe(method(contextMenuInteraction:willPerformPreviewActionForMenuWithConfiguration:animator:))]
#[unsafe(method_family = none)]
pub unsafe fn contextMenuInteraction_willPerformPreviewActionForMenuWithConfiguration_animator(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
animator: &ProtocolObject<dyn UIContextMenuInteractionCommitAnimating>,
);
);
}
#[cfg(all(
feature = "UIContextMenuInteraction",
feature = "UIResponder",
feature = "UIView"
))]
extern_conformance!(
unsafe impl UIContextMenuInteractionDelegate for UIControl {}
);