mirror of
https://gitee.com/csharpui/CPF.git
synced 2025-04-05 17:37:51 +08:00
231 lines
5.8 KiB
C#
231 lines
5.8 KiB
C#
using CPF.Mac.CoreGraphics;
|
|
using CPF.Mac.Foundation;
|
|
using CPF.Mac.ObjCRuntime;
|
|
using System;
|
|
using System.ComponentModel;
|
|
|
|
namespace CPF.Mac.AppKit
|
|
{
|
|
[Register("NSStepper", true)]
|
|
public class NSStepper : NSControl
|
|
{
|
|
private static readonly IntPtr selMinValueHandle = Selector.GetHandle("minValue");
|
|
|
|
private static readonly IntPtr selSetMinValue_Handle = Selector.GetHandle("setMinValue:");
|
|
|
|
private static readonly IntPtr selMaxValueHandle = Selector.GetHandle("maxValue");
|
|
|
|
private static readonly IntPtr selSetMaxValue_Handle = Selector.GetHandle("setMaxValue:");
|
|
|
|
private static readonly IntPtr selIncrementHandle = Selector.GetHandle("increment");
|
|
|
|
private static readonly IntPtr selSetIncrement_Handle = Selector.GetHandle("setIncrement:");
|
|
|
|
private static readonly IntPtr selValueWrapsHandle = Selector.GetHandle("valueWraps");
|
|
|
|
private static readonly IntPtr selSetValueWraps_Handle = Selector.GetHandle("setValueWraps:");
|
|
|
|
private static readonly IntPtr selAutorepeatHandle = Selector.GetHandle("autorepeat");
|
|
|
|
private static readonly IntPtr selSetAutorepeat_Handle = Selector.GetHandle("setAutorepeat:");
|
|
|
|
private static readonly IntPtr selInitWithFrame_Handle = Selector.GetHandle("initWithFrame:");
|
|
|
|
private static readonly IntPtr class_ptr = Class.GetHandle("NSStepper");
|
|
|
|
public override IntPtr ClassHandle => class_ptr;
|
|
|
|
public virtual double MinValue
|
|
{
|
|
[Export("minValue")]
|
|
get
|
|
{
|
|
NSApplication.EnsureUIThread();
|
|
if (IsDirectBinding)
|
|
{
|
|
return Messaging.Double_objc_msgSend(base.Handle, selMinValueHandle);
|
|
}
|
|
return Messaging.Double_objc_msgSendSuper(base.SuperHandle, selMinValueHandle);
|
|
}
|
|
[Export("setMinValue:")]
|
|
set
|
|
{
|
|
NSApplication.EnsureUIThread();
|
|
if (IsDirectBinding)
|
|
{
|
|
Messaging.void_objc_msgSend_Double(base.Handle, selSetMinValue_Handle, value);
|
|
}
|
|
else
|
|
{
|
|
Messaging.void_objc_msgSendSuper_Double(base.SuperHandle, selSetMinValue_Handle, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual double MaxValue
|
|
{
|
|
[Export("maxValue")]
|
|
get
|
|
{
|
|
NSApplication.EnsureUIThread();
|
|
if (IsDirectBinding)
|
|
{
|
|
return Messaging.Double_objc_msgSend(base.Handle, selMaxValueHandle);
|
|
}
|
|
return Messaging.Double_objc_msgSendSuper(base.SuperHandle, selMaxValueHandle);
|
|
}
|
|
[Export("setMaxValue:")]
|
|
set
|
|
{
|
|
NSApplication.EnsureUIThread();
|
|
if (IsDirectBinding)
|
|
{
|
|
Messaging.void_objc_msgSend_Double(base.Handle, selSetMaxValue_Handle, value);
|
|
}
|
|
else
|
|
{
|
|
Messaging.void_objc_msgSendSuper_Double(base.SuperHandle, selSetMaxValue_Handle, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual double Increment
|
|
{
|
|
[Export("increment")]
|
|
get
|
|
{
|
|
NSApplication.EnsureUIThread();
|
|
if (IsDirectBinding)
|
|
{
|
|
return Messaging.Double_objc_msgSend(base.Handle, selIncrementHandle);
|
|
}
|
|
return Messaging.Double_objc_msgSendSuper(base.SuperHandle, selIncrementHandle);
|
|
}
|
|
[Export("setIncrement:")]
|
|
set
|
|
{
|
|
NSApplication.EnsureUIThread();
|
|
if (IsDirectBinding)
|
|
{
|
|
Messaging.void_objc_msgSend_Double(base.Handle, selSetIncrement_Handle, value);
|
|
}
|
|
else
|
|
{
|
|
Messaging.void_objc_msgSendSuper_Double(base.SuperHandle, selSetIncrement_Handle, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual bool ValueWraps
|
|
{
|
|
[Export("valueWraps")]
|
|
get
|
|
{
|
|
NSApplication.EnsureUIThread();
|
|
if (IsDirectBinding)
|
|
{
|
|
return Messaging.bool_objc_msgSend(base.Handle, selValueWrapsHandle);
|
|
}
|
|
return Messaging.bool_objc_msgSendSuper(base.SuperHandle, selValueWrapsHandle);
|
|
}
|
|
[Export("setValueWraps:")]
|
|
set
|
|
{
|
|
NSApplication.EnsureUIThread();
|
|
if (IsDirectBinding)
|
|
{
|
|
Messaging.void_objc_msgSend_bool(base.Handle, selSetValueWraps_Handle, value);
|
|
}
|
|
else
|
|
{
|
|
Messaging.void_objc_msgSendSuper_bool(base.SuperHandle, selSetValueWraps_Handle, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual bool Autorepeat
|
|
{
|
|
[Export("autorepeat")]
|
|
get
|
|
{
|
|
NSApplication.EnsureUIThread();
|
|
if (IsDirectBinding)
|
|
{
|
|
return Messaging.bool_objc_msgSend(base.Handle, selAutorepeatHandle);
|
|
}
|
|
return Messaging.bool_objc_msgSendSuper(base.SuperHandle, selAutorepeatHandle);
|
|
}
|
|
[Export("setAutorepeat:")]
|
|
set
|
|
{
|
|
NSApplication.EnsureUIThread();
|
|
if (IsDirectBinding)
|
|
{
|
|
Messaging.void_objc_msgSend_bool(base.Handle, selSetAutorepeat_Handle, value);
|
|
}
|
|
else
|
|
{
|
|
Messaging.void_objc_msgSendSuper_bool(base.SuperHandle, selSetAutorepeat_Handle, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
|
[Export("init")]
|
|
public NSStepper()
|
|
: 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 NSStepper(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 NSStepper(NSObjectFlag t)
|
|
: base(t)
|
|
{
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
|
public NSStepper(IntPtr handle)
|
|
: base(handle)
|
|
{
|
|
}
|
|
|
|
[Export("initWithFrame:")]
|
|
public NSStepper(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);
|
|
}
|
|
}
|
|
}
|
|
}
|