use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
#[unsafe(super(NSTouchBarItem, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "NSTouchBarItem")]
pub struct NSCandidateListTouchBarItem<CandidateType: ?Sized = AnyObject>;
);
#[cfg(feature = "NSTouchBarItem")]
impl<CandidateType: ?Sized + Message> NSCandidateListTouchBarItem<CandidateType> {
#[inline]
pub unsafe fn cast_unchecked<NewCandidateType: ?Sized + Message>(
&self,
) -> &NSCandidateListTouchBarItem<NewCandidateType> {
unsafe { &*((self as *const Self).cast()) }
}
}
#[cfg(feature = "NSTouchBarItem")]
extern_conformance!(
unsafe impl<CandidateType: ?Sized + NSCoding> NSCoding
for NSCandidateListTouchBarItem<CandidateType>
{
}
);
#[cfg(feature = "NSTouchBarItem")]
extern_conformance!(
unsafe impl<CandidateType: ?Sized> NSObjectProtocol for NSCandidateListTouchBarItem<CandidateType> {}
);
#[cfg(feature = "NSTouchBarItem")]
impl<CandidateType: Message> NSCandidateListTouchBarItem<CandidateType> {
extern_methods!(
#[cfg(all(
feature = "NSResponder",
feature = "NSTextInputClient",
feature = "NSView"
))]
#[unsafe(method(client))]
#[unsafe(method_family = none)]
pub fn client(&self) -> Option<Retained<NSView>>;
#[cfg(all(
feature = "NSResponder",
feature = "NSTextInputClient",
feature = "NSView"
))]
#[unsafe(method(setClient:))]
#[unsafe(method_family = none)]
pub unsafe fn setClient(&self, client: Option<&NSView>);
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn NSCandidateListTouchBarItemDelegate>>>;
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn NSCandidateListTouchBarItemDelegate>>,
);
#[unsafe(method(isCollapsed))]
#[unsafe(method_family = none)]
pub fn isCollapsed(&self) -> bool;
#[unsafe(method(setCollapsed:))]
#[unsafe(method_family = none)]
pub fn setCollapsed(&self, collapsed: bool);
#[unsafe(method(allowsCollapsing))]
#[unsafe(method_family = none)]
pub fn allowsCollapsing(&self) -> bool;
#[unsafe(method(setAllowsCollapsing:))]
#[unsafe(method_family = none)]
pub fn setAllowsCollapsing(&self, allows_collapsing: bool);
#[unsafe(method(isCandidateListVisible))]
#[unsafe(method_family = none)]
pub fn isCandidateListVisible(&self) -> bool;
#[unsafe(method(updateWithInsertionPointVisibility:))]
#[unsafe(method_family = none)]
pub fn updateWithInsertionPointVisibility(&self, is_visible: bool);
#[unsafe(method(allowsTextInputContextCandidates))]
#[unsafe(method_family = none)]
pub fn allowsTextInputContextCandidates(&self) -> bool;
#[unsafe(method(setAllowsTextInputContextCandidates:))]
#[unsafe(method_family = none)]
pub fn setAllowsTextInputContextCandidates(
&self,
allows_text_input_context_candidates: bool,
);
#[cfg(feature = "block2")]
#[unsafe(method(attributedStringForCandidate))]
#[unsafe(method_family = none)]
pub unsafe fn attributedStringForCandidate(
&self,
) -> *mut block2::DynBlock<
dyn Fn(NonNull<CandidateType>, NSInteger) -> NonNull<NSAttributedString>,
>;
#[cfg(feature = "block2")]
#[unsafe(method(setAttributedStringForCandidate:))]
#[unsafe(method_family = none)]
pub unsafe fn setAttributedStringForCandidate(
&self,
attributed_string_for_candidate: Option<
&block2::DynBlock<
dyn Fn(NonNull<CandidateType>, NSInteger) -> NonNull<NSAttributedString>,
>,
>,
);
#[unsafe(method(candidates))]
#[unsafe(method_family = none)]
pub fn candidates(&self) -> Retained<NSArray<CandidateType>>;
#[unsafe(method(setCandidates:forSelectedRange:inString:))]
#[unsafe(method_family = none)]
pub fn setCandidates_forSelectedRange_inString(
&self,
candidates: &NSArray<CandidateType>,
selected_range: NSRange,
original_string: Option<&NSString>,
);
#[unsafe(method(customizationLabel))]
#[unsafe(method_family = none)]
pub fn customizationLabel(&self) -> Retained<NSString>;
#[unsafe(method(setCustomizationLabel:))]
#[unsafe(method_family = none)]
pub fn setCustomizationLabel(&self, customization_label: Option<&NSString>);
);
}
#[cfg(feature = "NSTouchBarItem")]
impl<CandidateType: Message> NSCandidateListTouchBarItem<CandidateType> {
extern_methods!(
#[unsafe(method(initWithIdentifier:))]
#[unsafe(method_family = init)]
pub fn initWithIdentifier(
this: Allocated<Self>,
identifier: &NSTouchBarItemIdentifier,
) -> Retained<Self>;
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
#[cfg(feature = "NSTouchBarItem")]
impl<CandidateType: Message> NSCandidateListTouchBarItem<CandidateType> {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
extern_protocol!(
pub unsafe trait NSCandidateListTouchBarItemDelegate:
NSObjectProtocol + MainThreadOnly
{
#[cfg(feature = "NSTouchBarItem")]
#[optional]
#[unsafe(method(candidateListTouchBarItem:beginSelectingCandidateAtIndex:))]
#[unsafe(method_family = none)]
unsafe fn candidateListTouchBarItem_beginSelectingCandidateAtIndex(
&self,
an_item: &NSCandidateListTouchBarItem,
index: NSInteger,
);
#[cfg(feature = "NSTouchBarItem")]
#[optional]
#[unsafe(method(candidateListTouchBarItem:changeSelectionFromCandidateAtIndex:toIndex:))]
#[unsafe(method_family = none)]
unsafe fn candidateListTouchBarItem_changeSelectionFromCandidateAtIndex_toIndex(
&self,
an_item: &NSCandidateListTouchBarItem,
previous_index: NSInteger,
index: NSInteger,
);
#[cfg(feature = "NSTouchBarItem")]
#[optional]
#[unsafe(method(candidateListTouchBarItem:endSelectingCandidateAtIndex:))]
#[unsafe(method_family = none)]
unsafe fn candidateListTouchBarItem_endSelectingCandidateAtIndex(
&self,
an_item: &NSCandidateListTouchBarItem,
index: NSInteger,
);
#[cfg(feature = "NSTouchBarItem")]
#[optional]
#[unsafe(method(candidateListTouchBarItem:changedCandidateListVisibility:))]
#[unsafe(method_family = none)]
unsafe fn candidateListTouchBarItem_changedCandidateListVisibility(
&self,
an_item: &NSCandidateListTouchBarItem,
is_visible: bool,
);
}
);
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSView {
extern_methods!(
#[cfg(feature = "NSTouchBarItem")]
#[unsafe(method(candidateListTouchBarItem))]
#[unsafe(method_family = none)]
pub fn candidateListTouchBarItem(&self) -> Option<Retained<NSCandidateListTouchBarItem>>;
);
}
extern "C" {
#[cfg(feature = "NSTouchBarItem")]
pub static NSTouchBarItemIdentifierCandidateList: &'static NSTouchBarItemIdentifier;
}