TextBlock
struct · ferroui-controls · v0.5.0
struct TextBlock
A control that displays a block of text.
Members
TYPEto_refrender_text_layoutcreate_text_layoutbackground_propertypadding_propertyfont_family_propertyfont_size_propertyfont_style_propertyfont_weight_propertyfont_stretch_propertyforeground_propertybaseline_offset_propertytext_line_bounds_propertylayout_rounding_placement_propertyline_height_propertyline_spacing_propertyletter_spacing_propertymax_lines_propertytext_propertytext_alignment_propertytext_wrapping_propertytext_trimming_propertytext_decorations_propertyfont_features_propertyinlines_propertyconstructget_alpha_masknewtext_layoutpaddingset_paddingbackgroundset_backgroundtextset_textfont_familyset_font_familyfont_sizeset_font_sizefont_styleset_font_stylefont_weightset_font_weightfont_stretchset_font_stretchforegroundset_foregroundline_heightset_line_heightline_spacingset_line_spacingletter_spacingset_letter_spacingmax_linesset_max_linestext_wrappingset_text_wrappingtext_trimmingset_text_trimmingtext_alignmentset_text_alignmenttext_decorationsset_text_decorationsfont_featuresset_font_featuresinlinesset_inlineshas_complex_contentget_max_size_from_constraintconstrainttext_runsbaseline_offsetset_baseline_offsetget_baseline_offsetset_baseline_offset_ontext_line_boundsset_text_line_boundsget_text_line_boundsset_text_line_bounds_onlayout_rounding_placementset_layout_rounding_placementget_layout_rounding_placementset_layout_rounding_placement_onlayout_rounding_offsetget_text_alignmentset_text_alignment_onget_text_wrappingset_text_wrapping_onget_text_trimmingset_text_trimming_onget_line_heightset_line_height_onget_letter_spacingset_letter_spacing_onget_max_linesset_max_lines_oninvalidate_text_layoutensure_text_runs
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<TextBlock>
Returns a strong reference to this object.
render_text_layout
fn render_text_layout(self: &Self, context: &mut DrawingContext<'_>, origin: Point)
Renders the text layout to a drawing context.
create_text_layout
fn create_text_layout(self: &Self, text: Option<&str>) -> Rc<TextLayout>
Creates the TextLayout used to render the text.
background_property
fn background_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
Defines the Background property.
padding_property
fn padding_property() -> &'static StyledProperty<Thickness>
Defines the Padding property.
font_family_property
fn font_family_property() -> &'static StyledProperty<FontFamily>
Defines the FontFamily property.
font_size_property
fn font_size_property() -> &'static StyledProperty<f64>
Defines the FontSize property.
font_style_property
fn font_style_property() -> &'static StyledProperty<FontStyle>
Defines the FontStyle property.
font_weight_property
fn font_weight_property() -> &'static StyledProperty<FontWeight>
Defines the FontWeight property.
font_stretch_property
fn font_stretch_property() -> &'static StyledProperty<FontStretch>
Defines the FontStretch property.
foreground_property
fn foreground_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
Defines the Foreground property.
baseline_offset_property
fn baseline_offset_property() -> &'static AttachedProperty<f64>
Defines the BaselineOffset attached property.
text_line_bounds_property
fn text_line_bounds_property() -> &'static AttachedProperty<TextLineBounds>
Defines the TextLineBounds attached property: how the box of each line is bounded
above and below (a FerroUI addition after WinUI's TextBlock.TextLineBounds,
DEVIATIONS.md, Text block). Inherited, as the other attached text properties, so that
a content presenter sets it for the text of its content.
layout_rounding_placement_property
fn layout_rounding_placement_property() -> &'static AttachedProperty<TextLayoutRoundingPlacement>
Defines the LayoutRoundingPlacement attached property: where a text block puts
the height layout rounding adds to it (a FerroUI addition). Inherited, so that a
theme sets it once on the top-level.
line_height_property
fn line_height_property() -> &'static AttachedProperty<f64>
Defines the LineHeight property.
line_spacing_property
fn line_spacing_property() -> &'static AttachedProperty<f64>
Defines the LineSpacing property.
letter_spacing_property
fn letter_spacing_property() -> &'static StyledProperty<f64>
Defines the LetterSpacing property.
max_lines_property
fn max_lines_property() -> &'static AttachedProperty<i32>
Defines the MaxLines property.
text_property
fn text_property() -> &'static StyledProperty<Option<String>>
Defines the Text property.
text_alignment_property
fn text_alignment_property() -> &'static AttachedProperty<TextAlignment>
Defines the TextAlignment property.
text_wrapping_property
fn text_wrapping_property() -> &'static AttachedProperty<TextWrapping>
Defines the TextWrapping property.
text_trimming_property
fn text_trimming_property() -> &'static AttachedProperty<Rc<dyn TextTrimming>>
Defines the TextTrimming property.
text_decorations_property
fn text_decorations_property() -> &'static StyledProperty<Option<TextDecorationCollection>>
Defines the TextDecorations property.
font_features_property
fn font_features_property() -> &'static StyledProperty<Option<FontFeatureCollection>>
Defines the FontFeatures property.
inlines_property
fn inlines_property() -> &'static DirectProperty<TextBlock, Option<InlineCollection>>
Defines the Inlines property.
construct
fn construct() -> Self
Creates the class data; see ferroui_base::FerroObject::construct.
get_alpha_mask
fn get_alpha_mask(self: &Self) -> Option<Rc<ferroui_base::rendering::composition::CompositionBrush>>
TextBlock.GetAlphaMask: a composition brush that shows the alpha of
the text block (its text, and its background when it has one), for
the Mask of a
DropShadow or
another composition effect. The same brush is returned on every call;
it follows the text block as it is drawn again (its text, font, size
and visibility). None when no compositor is available.
See AlphaMask for
how the mask is drawn.
new
fn new() -> Ref<Self>
Initializes a new instance of the TextBlock class.
text_layout
fn text_layout(self: &Self) -> Rc<TextLayout>
The TextLayout used to render the text.
The layout is cached until a property it depends on, the measure of the control or its constraint changes.
padding
fn padding(self: &Self) -> Thickness
The padding to place around the Text.
set_padding
fn set_padding(self: &Self, value: Thickness)
background
fn background(self: &Self) -> Option<Rc<dyn IBrush>>
A brush used to paint the control's background.
set_background
fn set_background(self: &Self, value: Option<Rc<dyn IBrush>>)
text
fn text(self: &Self) -> Option<String>
The text.
set_text
fn set_text(self: &Self, value: Option<&str>)
font_family
fn font_family(self: &Self) -> FontFamily
The font family used to draw the control's text.
set_font_family
fn set_font_family(self: &Self, value: FontFamily)
font_size
fn font_size(self: &Self) -> f64
The size of the control's text in points.
set_font_size
fn set_font_size(self: &Self, value: f64)
font_style
fn font_style(self: &Self) -> FontStyle
The font style used to draw the control's text.
set_font_style
fn set_font_style(self: &Self, value: FontStyle)
font_weight
fn font_weight(self: &Self) -> FontWeight
The font weight used to draw the control's text.
set_font_weight
fn set_font_weight(self: &Self, value: FontWeight)
font_stretch
fn font_stretch(self: &Self) -> FontStretch
The font stretch used to draw the control's text.
set_font_stretch
fn set_font_stretch(self: &Self, value: FontStretch)
foreground
fn foreground(self: &Self) -> Option<Rc<dyn IBrush>>
The brush used to draw the control's text and other foreground elements.
set_foreground
fn set_foreground(self: &Self, value: Option<Rc<dyn IBrush>>)
line_height
fn line_height(self: &Self) -> f64
The height of each line of content.
set_line_height
fn set_line_height(self: &Self, value: f64)
line_spacing
fn line_spacing(self: &Self) -> f64
The extra distance between each line of content.
set_line_spacing
fn set_line_spacing(self: &Self, value: f64)
letter_spacing
fn letter_spacing(self: &Self) -> f64
The letter spacing.
set_letter_spacing
fn set_letter_spacing(self: &Self, value: f64)
max_lines
fn max_lines(self: &Self) -> i32
The maximum number of text lines.
set_max_lines
fn set_max_lines(self: &Self, value: i32)
text_wrapping
fn text_wrapping(self: &Self) -> TextWrapping
The control's text wrapping mode.
set_text_wrapping
fn set_text_wrapping(self: &Self, value: TextWrapping)
text_trimming
fn text_trimming(self: &Self) -> Rc<dyn TextTrimming>
The control's text trimming mode.
set_text_trimming
fn set_text_trimming(self: &Self, value: Rc<dyn TextTrimming>)
text_alignment
fn text_alignment(self: &Self) -> TextAlignment
The text alignment.
set_text_alignment
fn set_text_alignment(self: &Self, value: TextAlignment)
text_decorations
fn text_decorations(self: &Self) -> Option<TextDecorationCollection>
The text decorations.
set_text_decorations
fn set_text_decorations(self: &Self, value: Option<TextDecorationCollection>)
font_features
fn font_features(self: &Self) -> Option<FontFeatureCollection>
The font features.
set_font_features
fn set_font_features(self: &Self, value: Option<FontFeatureCollection>)
inlines
fn inlines(self: &Self) -> Option<InlineCollection>
The inlines.
set_inlines
fn set_inlines(self: &Self, value: Option<InlineCollection>)
has_complex_content
fn has_complex_content(self: &Self) -> bool
Whether the text block displays inlines rather than its Text.
get_max_size_from_constraint
fn get_max_size_from_constraint(self: &Self) -> Size
The constraint of the text layout as a maximum size: an unset constraint is zero.
constraint
fn constraint(self: &Self) -> Size
The constraint the text layout is created for.
text_runs
fn text_runs(self: &Self) -> Option<Rc<Vec<Rc<dyn TextRun>>>>
The text runs of the inlines, when they have been built.
baseline_offset
fn baseline_offset(self: &Self) -> f64
The baseline offset.
set_baseline_offset
fn set_baseline_offset(self: &Self, value: f64)
get_baseline_offset
fn get_baseline_offset(control: &Control) -> f64
Reads the attached BaselineOffset property from the given control.
set_baseline_offset_on
fn set_baseline_offset_on(control: &Control, value: f64)
Writes the attached BaselineOffset property to the given control.
text_line_bounds
fn text_line_bounds(self: &Self) -> TextLineBounds
How the box of each line is bounded: by the ascent and the descent of the font (the
default), or trimmed to the cap height above the baseline, to the baseline below it, or
both. A FerroUI addition after WinUI's TextLineBounds.
set_text_line_bounds
fn set_text_line_bounds(self: &Self, value: TextLineBounds)
get_text_line_bounds
fn get_text_line_bounds(control: &Control) -> TextLineBounds
Reads the attached TextLineBounds property from the given control.
set_text_line_bounds_on
fn set_text_line_bounds_on(control: &Control, value: TextLineBounds)
Writes the attached TextLineBounds property to the given control.
layout_rounding_placement
fn layout_rounding_placement(self: &Self) -> TextLayoutRoundingPlacement
Where the text block puts the height layout rounding adds to it: below its text (the default, as the reference) or above it (as WinUI). A FerroUI addition.
set_layout_rounding_placement
fn set_layout_rounding_placement(self: &Self, value: TextLayoutRoundingPlacement)
get_layout_rounding_placement
fn get_layout_rounding_placement(control: &Control) -> TextLayoutRoundingPlacement
Reads the attached LayoutRoundingPlacement property from the given control.
set_layout_rounding_placement_on
fn set_layout_rounding_placement_on(control: &Control, value: TextLayoutRoundingPlacement)
Writes the attached LayoutRoundingPlacement property to the given control.
layout_rounding_offset
fn layout_rounding_offset(self: &Self) -> f64
How far down the text is drawn from the top of the content (the top padding) because
layout rounding added height to the block: the height of the text and the vertical
padding rounded up to whole device pixels, minus that height, when
layout_rounding_placement is
Above and the block uses layout rounding; zero
otherwise. Rendering, hit testing and the access key underline add it to the top padding
(WinUI's CTextBlock::GetContentRenderingOffset). A FerroUI addition.
get_text_alignment
fn get_text_alignment(control: &Control) -> TextAlignment
Reads the attached TextAlignment property from the given control.
set_text_alignment_on
fn set_text_alignment_on(control: &Control, alignment: TextAlignment)
Writes the attached TextAlignment property to the given control.
get_text_wrapping
fn get_text_wrapping(control: &Control) -> TextWrapping
Reads the attached TextWrapping property from the given control.
set_text_wrapping_on
fn set_text_wrapping_on(control: &Control, wrapping: TextWrapping)
Writes the attached TextWrapping property to the given control.
get_text_trimming
fn get_text_trimming(control: &Control) -> Rc<dyn TextTrimming>
Reads the attached TextTrimming property from the given control.
set_text_trimming_on
fn set_text_trimming_on(control: &Control, trimming: Rc<dyn TextTrimming>)
Writes the attached TextTrimming property to the given control.
get_line_height
fn get_line_height(control: &Control) -> f64
Reads the attached LineHeight property from the given control.
set_line_height_on
fn set_line_height_on(control: &Control, height: f64)
Writes the attached LineHeight property to the given control.
get_letter_spacing
fn get_letter_spacing(control: &Control) -> f64
Reads the attached LetterSpacing property from the given control.
set_letter_spacing_on
fn set_letter_spacing_on(control: &Control, letter_spacing: f64)
Writes the attached LetterSpacing property to the given control.
get_max_lines
fn get_max_lines(control: &Control) -> i32
Reads the attached MaxLines property from the given control.
set_max_lines_on
fn set_max_lines_on(control: &Control, max_lines: i32)
Writes the attached MaxLines property to the given control.
invalidate_text_layout
fn invalidate_text_layout(self: &Self)
Invalidates the text layout and the shaped runs it was built from.
ensure_text_runs
fn ensure_text_runs(self: &Self)
Builds the text runs of the inlines, unless they are up to date.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeControlImplExtTextBlockImplExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyInputElementImplExtInteractiveImplExtLayoutableImplExtFerroObjectImplExtStyledElementImplExtClassDefaultsVisualImplExtErasedDestructorIntoEitherDerefUpcast<T>Upcast<TextBlock>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleInteractiveImplInputElementImplDropControlImplStyledElementImplFerroObjectImplVisualImplLayoutableImplTextBlockImpl
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.