#[repr(C)]pub struct NSTextLayoutManager { /* private fields */ }NSTextLayoutManager only.Expand description
Implementations§
Source§impl NSTextLayoutManager
impl NSTextLayoutManager
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
pub unsafe fn initWithCoder( this: Allocated<Self>, coder: &NSCoder, ) -> Option<Retained<Self>>
pub unsafe fn delegate( &self, ) -> Option<Retained<ProtocolObject<dyn NSTextLayoutManagerDelegate>>>
Sourcepub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn NSTextLayoutManagerDelegate>>,
)
pub unsafe fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn NSTextLayoutManagerDelegate>>, )
This is a weak property.
Setter for delegate.
pub unsafe fn usesFontLeading(&self) -> bool
Sourcepub unsafe fn setUsesFontLeading(&self, uses_font_leading: bool)
pub unsafe fn setUsesFontLeading(&self, uses_font_leading: bool)
Setter for usesFontLeading.
pub unsafe fn limitsLayoutForSuspiciousContents(&self) -> bool
Sourcepub unsafe fn setLimitsLayoutForSuspiciousContents(
&self,
limits_layout_for_suspicious_contents: bool,
)
pub unsafe fn setLimitsLayoutForSuspiciousContents( &self, limits_layout_for_suspicious_contents: bool, )
Setter for limitsLayoutForSuspiciousContents.
pub unsafe fn usesHyphenation(&self) -> bool
Sourcepub unsafe fn setUsesHyphenation(&self, uses_hyphenation: bool)
pub unsafe fn setUsesHyphenation(&self, uses_hyphenation: bool)
Setter for usesHyphenation.
pub unsafe fn textContentManager( &self, ) -> Option<Retained<NSTextContentManager>>
NSTextContentManager only.pub unsafe fn replaceTextContentManager( &self, text_content_manager: &NSTextContentManager, )
NSTextContentManager only.pub unsafe fn textContainer(&self) -> Option<Retained<NSTextContainer>>
NSTextContainer only.Sourcepub unsafe fn setTextContainer(&self, text_container: Option<&NSTextContainer>)
Available on crate feature NSTextContainer only.
pub unsafe fn setTextContainer(&self, text_container: Option<&NSTextContainer>)
NSTextContainer only.Setter for textContainer.
pub unsafe fn usageBoundsForTextContainer(&self) -> CGRect
objc2-core-foundation only.pub unsafe fn textViewportLayoutController( &self, ) -> Retained<NSTextViewportLayoutController>
NSTextViewportLayoutController only.pub unsafe fn layoutQueue(&self) -> Option<Retained<NSOperationQueue>>
Sourcepub unsafe fn setLayoutQueue(&self, layout_queue: Option<&NSOperationQueue>)
pub unsafe fn setLayoutQueue(&self, layout_queue: Option<&NSOperationQueue>)
Setter for layoutQueue.
pub unsafe fn ensureLayoutForRange(&self, range: &NSTextRange)
NSTextRange only.pub unsafe fn ensureLayoutForBounds(&self, bounds: CGRect)
objc2-core-foundation only.pub unsafe fn invalidateLayoutForRange(&self, range: &NSTextRange)
NSTextRange only.pub unsafe fn textLayoutFragmentForPosition( &self, position: CGPoint, ) -> Option<Retained<NSTextLayoutFragment>>
NSTextLayoutFragment and objc2-core-foundation only.pub unsafe fn textLayoutFragmentForLocation( &self, location: &ProtocolObject<dyn NSTextLocation>, ) -> Option<Retained<NSTextLayoutFragment>>
NSTextLayoutFragment and NSTextRange only.pub unsafe fn enumerateTextLayoutFragmentsFromLocation_options_usingBlock( &self, location: Option<&ProtocolObject<dyn NSTextLocation>>, options: NSTextLayoutFragmentEnumerationOptions, block: &Block<dyn Fn(NonNull<NSTextLayoutFragment>) -> Bool + '_>, ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>
NSTextLayoutFragment and NSTextRange and block2 only.pub unsafe fn textSelections(&self) -> Retained<NSArray<NSTextSelection>>
NSTextSelection only.Sourcepub unsafe fn setTextSelections(
&self,
text_selections: &NSArray<NSTextSelection>,
)
Available on crate feature NSTextSelection only.
pub unsafe 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 unsafe fn enumerateRenderingAttributesFromLocation_reverse_usingBlock( &self, location: &ProtocolObject<dyn NSTextLocation>, reverse: bool, block: &Block<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSDictionary<NSAttributedStringKey, AnyObject>>, NonNull<NSTextRange>) -> Bool + '_>, )
NSTextRange and block2 only.pub unsafe fn setRenderingAttributes_forTextRange( &self, rendering_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>, text_range: &NSTextRange, )
NSTextRange only.pub unsafe fn addRenderingAttribute_value_forTextRange( &self, rendering_attribute: &NSAttributedStringKey, value: Option<&AnyObject>, text_range: &NSTextRange, )
NSTextRange only.pub unsafe fn removeRenderingAttribute_forTextRange( &self, rendering_attribute: &NSAttributedStringKey, text_range: &NSTextRange, )
NSTextRange only.pub unsafe fn invalidateRenderingAttributesForTextRange( &self, text_range: &NSTextRange, )
NSTextRange only.pub unsafe fn renderingAttributesValidator( &self, ) -> *mut Block<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSTextLayoutFragment>)>
NSTextLayoutFragment and block2 only.Sourcepub unsafe fn setRenderingAttributesValidator(
&self,
rendering_attributes_validator: Option<&Block<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSTextLayoutFragment>)>>,
)
Available on crate features NSTextLayoutFragment and block2 only.
pub unsafe fn setRenderingAttributesValidator( &self, rendering_attributes_validator: Option<&Block<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSTextLayoutFragment>)>>, )
NSTextLayoutFragment and block2 only.Setter for renderingAttributesValidator.
pub unsafe fn linkRenderingAttributes() -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>
pub unsafe fn renderingAttributesForLink_atLocation( &self, link: &AnyObject, location: &ProtocolObject<dyn NSTextLocation>, ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>
NSTextRange only.pub unsafe fn enumerateTextSegmentsInRange_type_options_usingBlock( &self, text_range: &NSTextRange, type: NSTextLayoutManagerSegmentType, options: NSTextLayoutManagerSegmentOptions, block: &Block<dyn Fn(*mut NSTextRange, CGRect, CGFloat, NonNull<NSTextContainer>) -> Bool + '_>, )
NSTextContainer and NSTextRange and block2 and objc2-core-foundation only.pub unsafe fn replaceContentsInRange_withTextElements( &self, range: &NSTextRange, text_elements: &NSArray<NSTextElement>, )
NSTextElement and NSTextRange only.pub unsafe 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.
§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_refSource§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
Available on crate feature NSTextSelectionNavigation only.
impl NSTextSelectionDataSource for NSTextLayoutManager
NSTextSelectionNavigation only.Source§unsafe fn documentRange(&self) -> Retained<NSTextRange>
unsafe fn documentRange(&self) -> Retained<NSTextRange>
NSTextRange only.Source§unsafe fn enumerateSubstringsFromLocation_options_usingBlock(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
options: NSStringEnumerationOptions,
block: &Block<dyn Fn(*mut NSString, NonNull<NSTextRange>, *mut NSTextRange, NonNull<Bool>) + '_>,
)
unsafe fn enumerateSubstringsFromLocation_options_usingBlock( &self, location: &ProtocolObject<dyn NSTextLocation>, options: NSStringEnumerationOptions, block: &Block<dyn Fn(*mut NSString, NonNull<NSTextRange>, *mut NSTextRange, NonNull<Bool>) + '_>, )
NSTextRange and block2 only.Source§unsafe fn textRangeForSelectionGranularity_enclosingLocation(
&self,
selection_granularity: NSTextSelectionGranularity,
location: &ProtocolObject<dyn NSTextLocation>,
) -> Option<Retained<NSTextRange>>
unsafe fn textRangeForSelectionGranularity_enclosingLocation( &self, selection_granularity: NSTextSelectionGranularity, location: &ProtocolObject<dyn NSTextLocation>, ) -> Option<Retained<NSTextRange>>
NSTextRange and NSTextSelection only.Source§unsafe fn locationFromLocation_withOffset(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
offset: NSInteger,
) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>
unsafe fn locationFromLocation_withOffset( &self, location: &ProtocolObject<dyn NSTextLocation>, offset: NSInteger, ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>
NSTextRange only.Source§unsafe fn offsetFromLocation_toLocation(
&self,
from: &ProtocolObject<dyn NSTextLocation>,
to: &ProtocolObject<dyn NSTextLocation>,
) -> NSInteger
unsafe fn offsetFromLocation_toLocation( &self, from: &ProtocolObject<dyn NSTextLocation>, to: &ProtocolObject<dyn NSTextLocation>, ) -> NSInteger
NSTextRange only.Source§unsafe fn baseWritingDirectionAtLocation(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
) -> NSTextSelectionNavigationWritingDirection
unsafe fn baseWritingDirectionAtLocation( &self, location: &ProtocolObject<dyn NSTextLocation>, ) -> NSTextSelectionNavigationWritingDirection
NSTextRange only.Source§unsafe fn enumerateCaretOffsetsInLineFragmentAtLocation_usingBlock(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
block: &Block<dyn Fn(CGFloat, NonNull<ProtocolObject<dyn NSTextLocation>>, Bool, NonNull<Bool>) + '_>,
)
unsafe fn enumerateCaretOffsetsInLineFragmentAtLocation_usingBlock( &self, location: &ProtocolObject<dyn NSTextLocation>, block: &Block<dyn Fn(CGFloat, NonNull<ProtocolObject<dyn NSTextLocation>>, Bool, NonNull<Bool>) + '_>, )
NSTextRange and block2 and objc2-core-foundation only.Source§unsafe fn lineFragmentRangeForPoint_inContainerAtLocation(
&self,
point: CGPoint,
location: &ProtocolObject<dyn NSTextLocation>,
) -> Option<Retained<NSTextRange>>
unsafe fn lineFragmentRangeForPoint_inContainerAtLocation( &self, point: CGPoint, location: &ProtocolObject<dyn NSTextLocation>, ) -> Option<Retained<NSTextRange>>
NSTextRange and objc2-core-foundation only.Source§unsafe fn enumerateContainerBoundariesFromLocation_reverse_usingBlock(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
reverse: bool,
block: &Block<dyn Fn(NonNull<ProtocolObject<dyn NSTextLocation>>, NonNull<Bool>) + '_>,
)
unsafe fn enumerateContainerBoundariesFromLocation_reverse_usingBlock( &self, location: &ProtocolObject<dyn NSTextLocation>, reverse: bool, block: &Block<dyn Fn(NonNull<ProtocolObject<dyn NSTextLocation>>, NonNull<Bool>) + '_>, )
NSTextRange and block2 only.Source§unsafe fn textLayoutOrientationAtLocation(
&self,
location: &ProtocolObject<dyn NSTextLocation>,
) -> NSTextSelectionNavigationLayoutOrientation
unsafe fn textLayoutOrientationAtLocation( &self, location: &ProtocolObject<dyn NSTextLocation>, ) -> NSTextSelectionNavigationLayoutOrientation
NSTextRange only.