pub struct NSTextLayoutManager { /* private fields */ }
NSTextLayoutManager
only.Expand description
Implementations§
Source§impl NSTextLayoutManager
impl NSTextLayoutManager
pub fn init(this: Allocated<Self>) -> Retained<Self>
Sourcepub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>
pub unsafe fn initWithCoder( this: Allocated<Self>, coder: &NSCoder, ) -> Option<Retained<Self>>
§Safety
coder
possibly has further requirements.
pub fn delegate( &self, ) -> Option<Retained<ProtocolObject<dyn NSTextLayoutManagerDelegate>>>
Sourcepub fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn NSTextLayoutManagerDelegate>>,
)
pub fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn NSTextLayoutManagerDelegate>>, )
Setter for delegate
.
This is a weak property.
pub fn usesFontLeading(&self) -> bool
Sourcepub fn setUsesFontLeading(&self, uses_font_leading: bool)
pub fn setUsesFontLeading(&self, uses_font_leading: bool)
Setter for usesFontLeading
.
pub fn limitsLayoutForSuspiciousContents(&self) -> bool
Sourcepub fn setLimitsLayoutForSuspiciousContents(
&self,
limits_layout_for_suspicious_contents: bool,
)
pub fn setLimitsLayoutForSuspiciousContents( &self, limits_layout_for_suspicious_contents: bool, )
Setter for limitsLayoutForSuspiciousContents
.
pub fn usesHyphenation(&self) -> bool
Sourcepub fn setUsesHyphenation(&self, uses_hyphenation: bool)
pub fn setUsesHyphenation(&self, uses_hyphenation: bool)
Setter for usesHyphenation
.
Sourcepub fn resolvesNaturalAlignmentWithBaseWritingDirection(&self) -> bool
pub fn resolvesNaturalAlignmentWithBaseWritingDirection(&self) -> bool
Specifies the behavior for resolving NSTextAlignment.natural
to the visual alignment.
When set to true
, the resolved visual alignment is determined by the resolved base writing direction; otherwise, it is using the user’s preferred language.
The default value is true
.
Sourcepub fn setResolvesNaturalAlignmentWithBaseWritingDirection(
&self,
resolves_natural_alignment_with_base_writing_direction: bool,
)
pub fn setResolvesNaturalAlignmentWithBaseWritingDirection( &self, resolves_natural_alignment_with_base_writing_direction: bool, )
Setter for resolvesNaturalAlignmentWithBaseWritingDirection
.
pub fn textContentManager(&self) -> Option<Retained<NSTextContentManager>>
NSTextContentManager
only.pub fn replaceTextContentManager( &self, text_content_manager: &NSTextContentManager, )
NSTextContentManager
only.pub fn textContainer(&self) -> Option<Retained<NSTextContainer>>
NSTextContainer
only.Sourcepub fn setTextContainer(&self, text_container: Option<&NSTextContainer>)
Available on crate feature NSTextContainer
only.
pub fn setTextContainer(&self, text_container: Option<&NSTextContainer>)
NSTextContainer
only.Setter for textContainer
.
pub fn usageBoundsForTextContainer(&self) -> CGRect
objc2-core-foundation
only.pub fn textViewportLayoutController( &self, ) -> Retained<NSTextViewportLayoutController>
NSTextViewportLayoutController
only.pub fn layoutQueue(&self) -> Option<Retained<NSOperationQueue>>
Sourcepub unsafe fn setLayoutQueue(&self, layout_queue: Option<&NSOperationQueue>)
pub unsafe fn setLayoutQueue(&self, layout_queue: Option<&NSOperationQueue>)
pub fn ensureLayoutForRange(&self, range: &NSTextRange)
NSTextRange
only.pub fn ensureLayoutForBounds(&self, bounds: CGRect)
objc2-core-foundation
only.pub fn invalidateLayoutForRange(&self, range: &NSTextRange)
NSTextRange
only.pub fn textLayoutFragmentForPosition( &self, position: CGPoint, ) -> Option<Retained<NSTextLayoutFragment>>
NSTextLayoutFragment
and objc2-core-foundation
only.pub fn textLayoutFragmentForLocation( &self, location: &ProtocolObject<dyn NSTextLocation>, ) -> Option<Retained<NSTextLayoutFragment>>
NSTextLayoutFragment
and NSTextRange
only.pub fn enumerateTextLayoutFragmentsFromLocation_options_usingBlock( &self, location: Option<&ProtocolObject<dyn NSTextLocation>>, options: NSTextLayoutFragmentEnumerationOptions, block: &DynBlock<dyn Fn(NonNull<NSTextLayoutFragment>) -> Bool + '_>, ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>
NSTextLayoutFragment
and NSTextRange
and block2
only.pub fn textSelections(&self) -> Retained<NSArray<NSTextSelection>>
NSTextSelection
only.Sourcepub fn setTextSelections(&self, text_selections: &NSArray<NSTextSelection>)
Available on crate feature NSTextSelection
only.
pub fn setTextSelections(&self, text_selections: &NSArray<NSTextSelection>)
NSTextSelection
only.Setter for textSelections
.
NSTextSelectionNavigation
only.Available on crate feature NSTextSelectionNavigation
only.
NSTextSelectionNavigation
only.Setter for textSelectionNavigation
.
pub fn enumerateRenderingAttributesFromLocation_reverse_usingBlock( &self, location: &ProtocolObject<dyn NSTextLocation>, reverse: bool, block: &DynBlock<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSDictionary<NSAttributedStringKey, AnyObject>>, NonNull<NSTextRange>) -> Bool + '_>, )
NSTextRange
and block2
only.Sourcepub unsafe fn setRenderingAttributes_forTextRange(
&self,
rendering_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
text_range: &NSTextRange,
)
Available on crate feature NSTextRange
only.
pub unsafe fn setRenderingAttributes_forTextRange( &self, rendering_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>, text_range: &NSTextRange, )
NSTextRange
only.§Safety
rendering_attributes
generic should be of the correct type.
Sourcepub unsafe fn addRenderingAttribute_value_forTextRange(
&self,
rendering_attribute: &NSAttributedStringKey,
value: Option<&AnyObject>,
text_range: &NSTextRange,
)
Available on crate feature NSTextRange
only.
pub unsafe fn addRenderingAttribute_value_forTextRange( &self, rendering_attribute: &NSAttributedStringKey, value: Option<&AnyObject>, text_range: &NSTextRange, )
NSTextRange
only.§Safety
value
should be of the correct type.
pub fn removeRenderingAttribute_forTextRange( &self, rendering_attribute: &NSAttributedStringKey, text_range: &NSTextRange, )
NSTextRange
only.pub fn invalidateRenderingAttributesForTextRange( &self, text_range: &NSTextRange, )
NSTextRange
only.Sourcepub unsafe fn renderingAttributesValidator(
&self,
) -> *mut DynBlock<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSTextLayoutFragment>)>
Available on crate features NSTextLayoutFragment
and block2
only.
pub unsafe fn renderingAttributesValidator( &self, ) -> *mut DynBlock<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSTextLayoutFragment>)>
NSTextLayoutFragment
and block2
only.§Safety
- The returned block’s argument 1 must be a valid pointer.
- The returned block’s argument 2 must be a valid pointer.
Sourcepub fn setRenderingAttributesValidator(
&self,
rendering_attributes_validator: Option<&DynBlock<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSTextLayoutFragment>)>>,
)
Available on crate features NSTextLayoutFragment
and block2
only.
pub fn setRenderingAttributesValidator( &self, rendering_attributes_validator: Option<&DynBlock<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSTextLayoutFragment>)>>, )
NSTextLayoutFragment
and block2
only.Setter for renderingAttributesValidator
.
This is copied when set.
pub fn linkRenderingAttributes() -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>
Sourcepub unsafe fn renderingAttributesForLink_atLocation(
&self,
link: &AnyObject,
location: &ProtocolObject<dyn NSTextLocation>,
) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>
Available on crate feature NSTextRange
only.
pub unsafe fn renderingAttributesForLink_atLocation( &self, link: &AnyObject, location: &ProtocolObject<dyn NSTextLocation>, ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>
NSTextRange
only.§Safety
link
should be of the correct type.
pub fn enumerateTextSegmentsInRange_type_options_usingBlock( &self, text_range: &NSTextRange, type: NSTextLayoutManagerSegmentType, options: NSTextLayoutManagerSegmentOptions, block: &DynBlock<dyn Fn(*mut NSTextRange, CGRect, CGFloat, NonNull<NSTextContainer>) -> Bool + '_>, )
NSTextContainer
and NSTextRange
and block2
and objc2-core-foundation
only.pub fn replaceContentsInRange_withTextElements( &self, range: &NSTextRange, text_elements: &NSArray<NSTextElement>, )
NSTextElement
and NSTextRange
only.pub fn replaceContentsInRange_withAttributedString( &self, range: &NSTextRange, attributed_string: &NSAttributedString, )
NSTextRange
only.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 NSTextLayoutManager
impl AsRef<AnyObject> for NSTextLayoutManager
Source§impl AsRef<NSObject> for NSTextLayoutManager
impl AsRef<NSObject> for NSTextLayoutManager
Source§impl Borrow<AnyObject> for NSTextLayoutManager
impl Borrow<AnyObject> for NSTextLayoutManager
Source§impl Borrow<NSObject> for NSTextLayoutManager
impl Borrow<NSObject> for NSTextLayoutManager
Source§impl ClassType for NSTextLayoutManager
impl ClassType for NSTextLayoutManager
Source§const NAME: &'static str = "NSTextLayoutManager"
const NAME: &'static str = "NSTextLayoutManager"
Source§type ThreadKind = <<NSTextLayoutManager as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<NSTextLayoutManager as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for NSTextLayoutManager
impl Debug for NSTextLayoutManager
Source§impl Deref for NSTextLayoutManager
impl Deref for NSTextLayoutManager
Source§impl Hash for NSTextLayoutManager
impl Hash for NSTextLayoutManager
Source§impl Message for NSTextLayoutManager
impl Message for NSTextLayoutManager
Source§impl NSCoding for NSTextLayoutManager
impl NSCoding for NSTextLayoutManager
Source§impl NSObjectProtocol for NSTextLayoutManager
impl NSObjectProtocol for NSTextLayoutManager
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
Source§fn isMemberOfClass(&self, cls: &AnyClass) -> bool
fn isMemberOfClass(&self, cls: &AnyClass) -> bool
Source§fn respondsToSelector(&self, aSelector: Sel) -> bool
fn respondsToSelector(&self, aSelector: Sel) -> bool
Source§fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
Source§fn debugDescription(&self) -> Retained<NSObject>
fn debugDescription(&self) -> Retained<NSObject>
Source§impl NSSecureCoding for NSTextLayoutManager
impl NSSecureCoding for NSTextLayoutManager
Source§impl NSTextSelectionDataSource for NSTextLayoutManager
impl NSTextSelectionDataSource for NSTextLayoutManager
Source§fn documentRange(&self) -> Retained<NSTextRange>
fn documentRange(&self) -> Retained<NSTextRange>
NSTextSelectionNavigation
and NSTextRange
only.Source§fn enumerateSubstringsFromLocation_options_usingBlock(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
options: NSStringEnumerationOptions,
block: &DynBlock<dyn Fn(*mut NSString, NonNull<NSTextRange>, *mut NSTextRange, NonNull<Bool>) + '_>,
)
fn enumerateSubstringsFromLocation_options_usingBlock( &self, location: &ProtocolObject<dyn NSTextLocation>, options: NSStringEnumerationOptions, block: &DynBlock<dyn Fn(*mut NSString, NonNull<NSTextRange>, *mut NSTextRange, NonNull<Bool>) + '_>, )
NSTextRange
and block2
and NSTextSelectionNavigation
only.Source§fn textRangeForSelectionGranularity_enclosingLocation(
&self,
selection_granularity: NSTextSelectionGranularity,
location: &ProtocolObject<dyn NSTextLocation>,
) -> Option<Retained<NSTextRange>>
fn textRangeForSelectionGranularity_enclosingLocation( &self, selection_granularity: NSTextSelectionGranularity, location: &ProtocolObject<dyn NSTextLocation>, ) -> Option<Retained<NSTextRange>>
NSTextRange
and NSTextSelection
and NSTextSelectionNavigation
only.Source§fn locationFromLocation_withOffset(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
offset: NSInteger,
) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>
fn locationFromLocation_withOffset( &self, location: &ProtocolObject<dyn NSTextLocation>, offset: NSInteger, ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>
NSTextSelectionNavigation
and NSTextRange
only.Source§fn offsetFromLocation_toLocation(
&self,
from: &ProtocolObject<dyn NSTextLocation>,
to: &ProtocolObject<dyn NSTextLocation>,
) -> NSInteger
fn offsetFromLocation_toLocation( &self, from: &ProtocolObject<dyn NSTextLocation>, to: &ProtocolObject<dyn NSTextLocation>, ) -> NSInteger
NSTextSelectionNavigation
and NSTextRange
only.Source§fn baseWritingDirectionAtLocation(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
) -> NSTextSelectionNavigationWritingDirection
fn baseWritingDirectionAtLocation( &self, location: &ProtocolObject<dyn NSTextLocation>, ) -> NSTextSelectionNavigationWritingDirection
NSTextSelectionNavigation
and NSTextRange
only.Source§fn enumerateCaretOffsetsInLineFragmentAtLocation_usingBlock(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
block: &DynBlock<dyn Fn(CGFloat, NonNull<ProtocolObject<dyn NSTextLocation>>, Bool, NonNull<Bool>) + '_>,
)
fn enumerateCaretOffsetsInLineFragmentAtLocation_usingBlock( &self, location: &ProtocolObject<dyn NSTextLocation>, block: &DynBlock<dyn Fn(CGFloat, NonNull<ProtocolObject<dyn NSTextLocation>>, Bool, NonNull<Bool>) + '_>, )
NSTextRange
and block2
and objc2-core-foundation
and NSTextSelectionNavigation
only.Source§fn lineFragmentRangeForPoint_inContainerAtLocation(
&self,
point: CGPoint,
location: &ProtocolObject<dyn NSTextLocation>,
) -> Option<Retained<NSTextRange>>
fn lineFragmentRangeForPoint_inContainerAtLocation( &self, point: CGPoint, location: &ProtocolObject<dyn NSTextLocation>, ) -> Option<Retained<NSTextRange>>
NSTextRange
and objc2-core-foundation
and NSTextSelectionNavigation
only.Source§fn enumerateContainerBoundariesFromLocation_reverse_usingBlock(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
reverse: bool,
block: &DynBlock<dyn Fn(NonNull<ProtocolObject<dyn NSTextLocation>>, NonNull<Bool>) + '_>,
)
fn enumerateContainerBoundariesFromLocation_reverse_usingBlock( &self, location: &ProtocolObject<dyn NSTextLocation>, reverse: bool, block: &DynBlock<dyn Fn(NonNull<ProtocolObject<dyn NSTextLocation>>, NonNull<Bool>) + '_>, )
NSTextRange
and block2
and NSTextSelectionNavigation
only.Source§fn textLayoutOrientationAtLocation(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
) -> NSTextSelectionNavigationLayoutOrientation
fn textLayoutOrientationAtLocation( &self, location: &ProtocolObject<dyn NSTextLocation>, ) -> NSTextSelectionNavigationLayoutOrientation
NSTextSelectionNavigation
and NSTextRange
only.