using CPF.Mac.CoreGraphics; using CPF.Mac.Foundation; using CPF.Mac.ObjCRuntime; using System; using System.ComponentModel; namespace CPF.Mac.AppKit { [Register("NSPathControl", true)] public class NSPathControl : NSControl { private static readonly IntPtr selURLHandle = Selector.GetHandle("URL"); private static readonly IntPtr selSetURL_Handle = Selector.GetHandle("setURL:"); private static readonly IntPtr selClickedPathComponentCellHandle = Selector.GetHandle("clickedPathComponentCell"); private static readonly IntPtr selDoubleActionHandle = Selector.GetHandle("doubleAction"); private static readonly IntPtr selSetDoubleAction_Handle = Selector.GetHandle("setDoubleAction:"); private static readonly IntPtr selPathStyleHandle = Selector.GetHandle("pathStyle"); private static readonly IntPtr selSetPathStyle_Handle = Selector.GetHandle("setPathStyle:"); private static readonly IntPtr selPathComponentCellsHandle = Selector.GetHandle("pathComponentCells"); private static readonly IntPtr selSetPathComponentCells_Handle = Selector.GetHandle("setPathComponentCells:"); private static readonly IntPtr selBackgroundColorHandle = Selector.GetHandle("backgroundColor"); private static readonly IntPtr selSetBackgroundColor_Handle = Selector.GetHandle("setBackgroundColor:"); private static readonly IntPtr selDelegateHandle = Selector.GetHandle("delegate"); private static readonly IntPtr selSetDelegate_Handle = Selector.GetHandle("setDelegate:"); private static readonly IntPtr selMenuHandle = Selector.GetHandle("menu"); private static readonly IntPtr selSetMenu_Handle = Selector.GetHandle("setMenu:"); private static readonly IntPtr selInitWithFrame_Handle = Selector.GetHandle("initWithFrame:"); private static readonly IntPtr selSetDraggingSourceOperationMaskForLocal_Handle = Selector.GetHandle("setDraggingSourceOperationMask:forLocal:"); private static readonly IntPtr class_ptr = Class.GetHandle("NSPathControl"); private object __mt_Url_var; private object __mt_ClickedPathComponentCell_var; private object __mt_PathComponentCells_var; private object __mt_BackgroundColor_var; private object __mt_WeakDelegate_var; private object __mt_Menu_var; public override IntPtr ClassHandle => class_ptr; public virtual NSUrl Url { [Export("URL")] get { NSApplication.EnsureUIThread(); return (NSUrl)(__mt_Url_var = ((!IsDirectBinding) ? ((NSUrl)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selURLHandle))) : ((NSUrl)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend(base.Handle, selURLHandle))))); } [Export("setURL:")] set { NSApplication.EnsureUIThread(); if (value == null) { throw new ArgumentNullException("value"); } if (IsDirectBinding) { Messaging.void_objc_msgSend_IntPtr(base.Handle, selSetURL_Handle, value.Handle); } else { Messaging.void_objc_msgSendSuper_IntPtr(base.SuperHandle, selSetURL_Handle, value.Handle); } __mt_Url_var = value; } } public virtual NSPathComponentCell ClickedPathComponentCell { [Export("clickedPathComponentCell")] get { NSApplication.EnsureUIThread(); return (NSPathComponentCell)(__mt_ClickedPathComponentCell_var = ((!IsDirectBinding) ? ((NSPathComponentCell)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selClickedPathComponentCellHandle))) : ((NSPathComponentCell)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend(base.Handle, selClickedPathComponentCellHandle))))); } } public virtual Selector DoubleAction { [Export("doubleAction")] get { NSApplication.EnsureUIThread(); if (IsDirectBinding) { return Selector.FromHandle(Messaging.IntPtr_objc_msgSend(base.Handle, selDoubleActionHandle)); } return Selector.FromHandle(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selDoubleActionHandle)); } [Export("setDoubleAction:")] set { NSApplication.EnsureUIThread(); if (value == null) { throw new ArgumentNullException("value"); } if (IsDirectBinding) { Messaging.void_objc_msgSend_IntPtr(base.Handle, selSetDoubleAction_Handle, value.Handle); } else { Messaging.void_objc_msgSendSuper_IntPtr(base.SuperHandle, selSetDoubleAction_Handle, value.Handle); } } } public virtual NSPathStyle PathStyle { [Export("pathStyle")] get { NSApplication.EnsureUIThread(); if (IsDirectBinding) { return (NSPathStyle)Messaging.Int64_objc_msgSend(base.Handle, selPathStyleHandle); } return (NSPathStyle)Messaging.Int64_objc_msgSendSuper(base.SuperHandle, selPathStyleHandle); } [Export("setPathStyle:")] set { NSApplication.EnsureUIThread(); if (IsDirectBinding) { Messaging.void_objc_msgSend_Int64(base.Handle, selSetPathStyle_Handle, (long)value); } else { Messaging.void_objc_msgSendSuper_Int64(base.SuperHandle, selSetPathStyle_Handle, (long)value); } } } public virtual NSPathComponentCell[] PathComponentCells { [Export("pathComponentCells")] get { NSApplication.EnsureUIThread(); return (NSPathComponentCell[])(__mt_PathComponentCells_var = ((!IsDirectBinding) ? NSArray.ArrayFromHandle(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selPathComponentCellsHandle)) : NSArray.ArrayFromHandle(Messaging.IntPtr_objc_msgSend(base.Handle, selPathComponentCellsHandle)))); } [Export("setPathComponentCells:")] set { NSApplication.EnsureUIThread(); if (value == null) { throw new ArgumentNullException("value"); } NSArray nSArray = NSArray.FromNSObjects(value); if (IsDirectBinding) { Messaging.void_objc_msgSend_IntPtr(base.Handle, selSetPathComponentCells_Handle, nSArray.Handle); } else { Messaging.void_objc_msgSendSuper_IntPtr(base.SuperHandle, selSetPathComponentCells_Handle, nSArray.Handle); } nSArray.Dispose(); __mt_PathComponentCells_var = value; } } public virtual NSColor BackgroundColor { [Export("backgroundColor")] get { NSApplication.EnsureUIThread(); return (NSColor)(__mt_BackgroundColor_var = ((!IsDirectBinding) ? ((NSColor)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selBackgroundColorHandle))) : ((NSColor)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend(base.Handle, selBackgroundColorHandle))))); } [Export("setBackgroundColor:")] set { NSApplication.EnsureUIThread(); if (IsDirectBinding) { Messaging.void_objc_msgSend_IntPtr(base.Handle, selSetBackgroundColor_Handle, value?.Handle ?? IntPtr.Zero); } else { Messaging.void_objc_msgSendSuper_IntPtr(base.SuperHandle, selSetBackgroundColor_Handle, value?.Handle ?? IntPtr.Zero); } __mt_BackgroundColor_var = value; } } public virtual NSObject WeakDelegate { [Export("delegate")] get { NSApplication.EnsureUIThread(); return (NSObject)(__mt_WeakDelegate_var = ((!IsDirectBinding) ? Runtime.GetNSObject(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selDelegateHandle)) : Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend(base.Handle, selDelegateHandle)))); } [Export("setDelegate:")] set { NSApplication.EnsureUIThread(); if (IsDirectBinding) { Messaging.void_objc_msgSend_IntPtr(base.Handle, selSetDelegate_Handle, value?.Handle ?? IntPtr.Zero); } else { Messaging.void_objc_msgSendSuper_IntPtr(base.SuperHandle, selSetDelegate_Handle, value?.Handle ?? IntPtr.Zero); } __mt_WeakDelegate_var = value; } } public NSPathControlDelegate Delegate { get { return WeakDelegate as NSPathControlDelegate; } set { WeakDelegate = value; } } public new virtual NSMenu Menu { [Export("menu")] get { NSApplication.EnsureUIThread(); return (NSMenu)(__mt_Menu_var = ((!IsDirectBinding) ? ((NSMenu)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selMenuHandle))) : ((NSMenu)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend(base.Handle, selMenuHandle))))); } [Export("setMenu:")] set { NSApplication.EnsureUIThread(); if (value == null) { throw new ArgumentNullException("value"); } if (IsDirectBinding) { Messaging.void_objc_msgSend_IntPtr(base.Handle, selSetMenu_Handle, value.Handle); } else { Messaging.void_objc_msgSendSuper_IntPtr(base.SuperHandle, selSetMenu_Handle, value.Handle); } __mt_Menu_var = value; } } public event EventHandler DoubleClick { add { Target = ActionDispatcher.SetupDoubleAction(Target, value); DoubleAction = ActionDispatcher.DoubleAction; } remove { ActionDispatcher.RemoveDoubleAction(Target, value); } } [EditorBrowsable(EditorBrowsableState.Advanced)] [Export("init")] public NSPathControl() : base(NSObjectFlag.Empty) { if (IsDirectBinding) { base.Handle = Messaging.IntPtr_objc_msgSend(base.Handle, Selector.Init); } else { base.Handle = Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, Selector.Init); } } [EditorBrowsable(EditorBrowsableState.Advanced)] [Export("initWithCoder:")] public NSPathControl(NSCoder coder) : base(NSObjectFlag.Empty) { if (IsDirectBinding) { base.Handle = Messaging.IntPtr_objc_msgSend_IntPtr(base.Handle, Selector.InitWithCoder, coder.Handle); } else { base.Handle = Messaging.IntPtr_objc_msgSendSuper_IntPtr(base.SuperHandle, Selector.InitWithCoder, coder.Handle); } } [EditorBrowsable(EditorBrowsableState.Advanced)] public NSPathControl(NSObjectFlag t) : base(t) { } [EditorBrowsable(EditorBrowsableState.Advanced)] public NSPathControl(IntPtr handle) : base(handle) { } [Export("initWithFrame:")] public NSPathControl(CGRect frameRect) : base(NSObjectFlag.Empty) { NSApplication.EnsureUIThread(); if (IsDirectBinding) { base.Handle = Messaging.IntPtr_objc_msgSend_CGRect(base.Handle, selInitWithFrame_Handle, frameRect); } else { base.Handle = Messaging.IntPtr_objc_msgSendSuper_CGRect(base.SuperHandle, selInitWithFrame_Handle, frameRect); } } [Export("setDraggingSourceOperationMask:forLocal:")] public virtual void SetDraggingSource(NSDragOperation operationMask, bool isLocal) { NSApplication.EnsureUIThread(); if (IsDirectBinding) { Messaging.void_objc_msgSend_UInt64_bool(base.Handle, selSetDraggingSourceOperationMaskForLocal_Handle, (ulong)operationMask, isLocal); } else { Messaging.void_objc_msgSendSuper_UInt64_bool(base.SuperHandle, selSetDraggingSourceOperationMaskForLocal_Handle, (ulong)operationMask, isLocal); } } protected override void Dispose(bool disposing) { base.Dispose(disposing); if (base.Handle == IntPtr.Zero) { __mt_Url_var = null; __mt_ClickedPathComponentCell_var = null; __mt_PathComponentCells_var = null; __mt_BackgroundColor_var = null; __mt_WeakDelegate_var = null; __mt_Menu_var = null; } } } }