pub struct NSBezierPath { /* private fields */ }
NSBezierPath
only.Expand description
Implementations§
Source§impl NSBezierPath
impl NSBezierPath
pub fn bezierPath() -> Retained<NSBezierPath>
pub fn bezierPathWithRect(rect: NSRect) -> Retained<NSBezierPath>
pub fn bezierPathWithOvalInRect(rect: NSRect) -> Retained<NSBezierPath>
pub fn bezierPathWithRoundedRect_xRadius_yRadius( rect: NSRect, x_radius: CGFloat, y_radius: CGFloat, ) -> Retained<NSBezierPath>
objc2-core-foundation
only.pub fn fillRect(rect: NSRect)
pub fn strokeRect(rect: NSRect)
pub fn clipRect(rect: NSRect)
pub fn strokeLineFromPoint_toPoint(point1: NSPoint, point2: NSPoint)
Sourcepub unsafe fn drawPackedGlyphs_atPoint(
packed_glyphs: NonNull<c_char>,
point: NSPoint,
)
pub unsafe fn drawPackedGlyphs_atPoint( packed_glyphs: NonNull<c_char>, point: NSPoint, )
§Safety
packed_glyphs
must be a valid pointer.
pub fn defaultMiterLimit() -> CGFloat
objc2-core-foundation
only.Sourcepub fn setDefaultMiterLimit(default_miter_limit: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setDefaultMiterLimit(default_miter_limit: CGFloat)
objc2-core-foundation
only.Setter for defaultMiterLimit
.
pub fn defaultFlatness() -> CGFloat
objc2-core-foundation
only.Sourcepub fn setDefaultFlatness(default_flatness: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setDefaultFlatness(default_flatness: CGFloat)
objc2-core-foundation
only.Setter for defaultFlatness
.
pub fn defaultWindingRule() -> NSWindingRule
Sourcepub fn setDefaultWindingRule(default_winding_rule: NSWindingRule)
pub fn setDefaultWindingRule(default_winding_rule: NSWindingRule)
Setter for defaultWindingRule
.
pub fn defaultLineCapStyle() -> NSLineCapStyle
Sourcepub fn setDefaultLineCapStyle(default_line_cap_style: NSLineCapStyle)
pub fn setDefaultLineCapStyle(default_line_cap_style: NSLineCapStyle)
Setter for defaultLineCapStyle
.
pub fn defaultLineJoinStyle() -> NSLineJoinStyle
Sourcepub fn setDefaultLineJoinStyle(default_line_join_style: NSLineJoinStyle)
pub fn setDefaultLineJoinStyle(default_line_join_style: NSLineJoinStyle)
Setter for defaultLineJoinStyle
.
pub fn defaultLineWidth() -> CGFloat
objc2-core-foundation
only.Sourcepub fn setDefaultLineWidth(default_line_width: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setDefaultLineWidth(default_line_width: CGFloat)
objc2-core-foundation
only.Setter for defaultLineWidth
.
pub fn moveToPoint(&self, point: NSPoint)
pub fn lineToPoint(&self, point: NSPoint)
pub fn curveToPoint_controlPoint1_controlPoint2( &self, end_point: NSPoint, control_point1: NSPoint, control_point2: NSPoint, )
pub fn curveToPoint_controlPoint( &self, end_point: NSPoint, control_point: NSPoint, )
pub fn closePath(&self)
pub fn removeAllPoints(&self)
pub fn relativeMoveToPoint(&self, point: NSPoint)
pub fn relativeLineToPoint(&self, point: NSPoint)
pub fn relativeCurveToPoint_controlPoint1_controlPoint2( &self, end_point: NSPoint, control_point1: NSPoint, control_point2: NSPoint, )
pub fn relativeCurveToPoint_controlPoint( &self, end_point: NSPoint, control_point: NSPoint, )
pub fn lineWidth(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setLineWidth(&self, line_width: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setLineWidth(&self, line_width: CGFloat)
objc2-core-foundation
only.Setter for lineWidth
.
pub fn lineCapStyle(&self) -> NSLineCapStyle
Sourcepub fn setLineCapStyle(&self, line_cap_style: NSLineCapStyle)
pub fn setLineCapStyle(&self, line_cap_style: NSLineCapStyle)
Setter for lineCapStyle
.
pub fn lineJoinStyle(&self) -> NSLineJoinStyle
Sourcepub fn setLineJoinStyle(&self, line_join_style: NSLineJoinStyle)
pub fn setLineJoinStyle(&self, line_join_style: NSLineJoinStyle)
Setter for lineJoinStyle
.
pub fn windingRule(&self) -> NSWindingRule
Sourcepub fn setWindingRule(&self, winding_rule: NSWindingRule)
pub fn setWindingRule(&self, winding_rule: NSWindingRule)
Setter for windingRule
.
pub fn miterLimit(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setMiterLimit(&self, miter_limit: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setMiterLimit(&self, miter_limit: CGFloat)
objc2-core-foundation
only.Setter for miterLimit
.
pub fn flatness(&self) -> CGFloat
objc2-core-foundation
only.Sourcepub fn setFlatness(&self, flatness: CGFloat)
Available on crate feature objc2-core-foundation
only.
pub fn setFlatness(&self, flatness: CGFloat)
objc2-core-foundation
only.Setter for flatness
.
Sourcepub unsafe fn getLineDash_count_phase(
&self,
pattern: *mut CGFloat,
count: *mut NSInteger,
phase: *mut CGFloat,
)
Available on crate feature objc2-core-foundation
only.
pub unsafe fn getLineDash_count_phase( &self, pattern: *mut CGFloat, count: *mut NSInteger, phase: *mut CGFloat, )
objc2-core-foundation
only.§Safety
pattern
must be a valid pointer or null.count
must be a valid pointer or null.phase
must be a valid pointer or null.
Sourcepub unsafe fn setLineDash_count_phase(
&self,
pattern: *const CGFloat,
count: NSInteger,
phase: CGFloat,
)
Available on crate feature objc2-core-foundation
only.
pub unsafe fn setLineDash_count_phase( &self, pattern: *const CGFloat, count: NSInteger, phase: CGFloat, )
objc2-core-foundation
only.§Safety
pattern
must be a valid pointer or null.
pub fn stroke(&self)
pub fn fill(&self)
pub fn addClip(&self)
pub fn setClip(&self)
pub fn bezierPathByFlatteningPath(&self) -> Retained<NSBezierPath>
pub fn bezierPathByReversingPath(&self) -> Retained<NSBezierPath>
pub fn transformUsingAffineTransform(&self, transform: &NSAffineTransform)
pub fn isEmpty(&self) -> bool
pub fn currentPoint(&self) -> NSPoint
pub fn controlPointBounds(&self) -> NSRect
pub fn bounds(&self) -> NSRect
pub fn elementCount(&self) -> NSInteger
Sourcepub unsafe fn elementAtIndex_associatedPoints(
&self,
index: NSInteger,
points: NSPointArray,
) -> NSBezierPathElement
pub unsafe fn elementAtIndex_associatedPoints( &self, index: NSInteger, points: NSPointArray, ) -> NSBezierPathElement
§Safety
points
must be a valid pointer or null.
pub fn elementAtIndex(&self, index: NSInteger) -> NSBezierPathElement
Sourcepub unsafe fn setAssociatedPoints_atIndex(
&self,
points: NSPointArray,
index: NSInteger,
)
pub unsafe fn setAssociatedPoints_atIndex( &self, points: NSPointArray, index: NSInteger, )
§Safety
points
must be a valid pointer or null.
pub fn appendBezierPath(&self, path: &NSBezierPath)
pub fn appendBezierPathWithRect(&self, rect: NSRect)
Sourcepub unsafe fn appendBezierPathWithPoints_count(
&self,
points: NSPointArray,
count: NSInteger,
)
pub unsafe fn appendBezierPathWithPoints_count( &self, points: NSPointArray, count: NSInteger, )
§Safety
points
must be a valid pointer.
pub fn appendBezierPathWithOvalInRect(&self, rect: NSRect)
pub fn appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise( &self, center: NSPoint, radius: CGFloat, start_angle: CGFloat, end_angle: CGFloat, clockwise: bool, )
objc2-core-foundation
only.pub fn appendBezierPathWithArcWithCenter_radius_startAngle_endAngle( &self, center: NSPoint, radius: CGFloat, start_angle: CGFloat, end_angle: CGFloat, )
objc2-core-foundation
only.pub fn appendBezierPathWithArcFromPoint_toPoint_radius( &self, point1: NSPoint, point2: NSPoint, radius: CGFloat, )
objc2-core-foundation
only.pub fn appendBezierPathWithRoundedRect_xRadius_yRadius( &self, rect: NSRect, x_radius: CGFloat, y_radius: CGFloat, )
objc2-core-foundation
only.pub fn containsPoint(&self, point: NSPoint) -> bool
Source§impl NSBezierPath
Methods declared on superclass NSObject
.
impl NSBezierPath
Methods declared on superclass NSObject
.
Source§impl NSBezierPath
NSBezierPathDeprecated.
impl NSBezierPath
NSBezierPathDeprecated.
pub fn cachesBezierPath(&self) -> bool
pub fn setCachesBezierPath(&self, flag: bool)
pub fn appendBezierPathWithGlyph_inFont(&self, glyph: NSGlyph, font: &NSFont)
NSFont
only.Sourcepub unsafe fn appendBezierPathWithGlyphs_count_inFont(
&self,
glyphs: NonNull<NSGlyph>,
count: NSInteger,
font: &NSFont,
)
👎Deprecated: Use -appendBezierPathWithCGGlyphs:count:inFont: insteadAvailable on crate feature NSFont
only.
pub unsafe fn appendBezierPathWithGlyphs_count_inFont( &self, glyphs: NonNull<NSGlyph>, count: NSInteger, font: &NSFont, )
NSFont
only.§Safety
glyphs
must be a valid pointer.
Sourcepub unsafe fn appendBezierPathWithPackedGlyphs(
&self,
packed_glyphs: NonNull<c_char>,
)
👎Deprecated: Use -appendBezierPathWithCGGlyphs:count:inFont: instead
pub unsafe fn appendBezierPathWithPackedGlyphs( &self, packed_glyphs: NonNull<c_char>, )
§Safety
packed_glyphs
must be a valid pointer.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
Available on crate feature NSAccessibilityConstants
only.
pub fn class(&self) -> &'static AnyClass
NSAccessibilityConstants
only.Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init
/new
methods).
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.Available on crate feature NSAccessibilityConstants
only.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.NSAccessibilityConstants
only.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Available on crate feature NSAccessibilityConstants
only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
NSAccessibilityConstants
only.Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AnyObject> for NSBezierPath
impl AsRef<AnyObject> for NSBezierPath
Source§impl AsRef<NSBezierPath> for NSBezierPath
impl AsRef<NSBezierPath> for NSBezierPath
Source§impl AsRef<NSObject> for NSBezierPath
impl AsRef<NSObject> for NSBezierPath
Source§impl Borrow<AnyObject> for NSBezierPath
impl Borrow<AnyObject> for NSBezierPath
Source§impl Borrow<NSObject> for NSBezierPath
impl Borrow<NSObject> for NSBezierPath
Source§impl ClassType for NSBezierPath
impl ClassType for NSBezierPath
Source§const NAME: &'static str = "NSBezierPath"
const NAME: &'static str = "NSBezierPath"
Source§type ThreadKind = <<NSBezierPath as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<NSBezierPath as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for NSBezierPath
impl CopyingHelper for NSBezierPath
Source§type Result = NSBezierPath
type Result = NSBezierPath
Self
if the type has no
immutable counterpart. Read moreSource§impl Debug for NSBezierPath
impl Debug for NSBezierPath
Source§impl DefaultRetained for NSBezierPath
impl DefaultRetained for NSBezierPath
Source§impl Deref for NSBezierPath
impl Deref for NSBezierPath
Source§impl Hash for NSBezierPath
impl Hash for NSBezierPath
Source§impl Message for NSBezierPath
impl Message for NSBezierPath
Source§impl NSCoding for NSBezierPath
impl NSCoding for NSBezierPath
Source§impl NSCopying for NSBezierPath
impl NSCopying for NSBezierPath
Source§impl NSObjectProtocol for NSBezierPath
impl NSObjectProtocol for NSBezierPath
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref