FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    TextBlock

    struct · ferroui-controls · v0.5.0

    struct TextBlock
    

    A control that displays a block of text.

    View source

    Members

    TYPE

    const TYPE: &'static $crate::TypeInfo
    

    The runtime type of this class.

    Source

    to_ref

    fn to_ref(self: &Self) -> $crate::Ref<TextBlock>
    

    Returns a strong reference to this object.

    Source

    render_text_layout

    fn render_text_layout(self: &Self, context: &mut DrawingContext<'_>, origin: Point)
    

    Renders the text layout to a drawing context.

    Source

    create_text_layout

    fn create_text_layout(self: &Self, text: Option<&str>) -> Rc<TextLayout>
    

    Creates the TextLayout used to render the text.

    Source

    background_property

    fn background_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
    

    Defines the Background property.

    Source

    padding_property

    fn padding_property() -> &'static StyledProperty<Thickness>
    

    Defines the Padding property.

    Source

    font_family_property

    fn font_family_property() -> &'static StyledProperty<FontFamily>
    

    Defines the FontFamily property.

    Source

    font_size_property

    fn font_size_property() -> &'static StyledProperty<f64>
    

    Defines the FontSize property.

    Source

    font_style_property

    fn font_style_property() -> &'static StyledProperty<FontStyle>
    

    Defines the FontStyle property.

    Source

    font_weight_property

    fn font_weight_property() -> &'static StyledProperty<FontWeight>
    

    Defines the FontWeight property.

    Source

    font_stretch_property

    fn font_stretch_property() -> &'static StyledProperty<FontStretch>
    

    Defines the FontStretch property.

    Source

    foreground_property

    fn foreground_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
    

    Defines the Foreground property.

    Source

    baseline_offset_property

    fn baseline_offset_property() -> &'static AttachedProperty<f64>
    

    Defines the BaselineOffset attached property.

    Source

    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.

    Source

    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.

    Source

    line_height_property

    fn line_height_property() -> &'static AttachedProperty<f64>
    

    Defines the LineHeight property.

    Source

    line_spacing_property

    fn line_spacing_property() -> &'static AttachedProperty<f64>
    

    Defines the LineSpacing property.

    Source

    letter_spacing_property

    fn letter_spacing_property() -> &'static StyledProperty<f64>
    

    Defines the LetterSpacing property.

    Source

    max_lines_property

    fn max_lines_property() -> &'static AttachedProperty<i32>
    

    Defines the MaxLines property.

    Source

    text_property

    fn text_property() -> &'static StyledProperty<Option<String>>
    

    Defines the Text property.

    Source

    text_alignment_property

    fn text_alignment_property() -> &'static AttachedProperty<TextAlignment>
    

    Defines the TextAlignment property.

    Source

    text_wrapping_property

    fn text_wrapping_property() -> &'static AttachedProperty<TextWrapping>
    

    Defines the TextWrapping property.

    Source

    text_trimming_property

    fn text_trimming_property() -> &'static AttachedProperty<Rc<dyn TextTrimming>>
    

    Defines the TextTrimming property.

    Source

    text_decorations_property

    fn text_decorations_property() -> &'static StyledProperty<Option<TextDecorationCollection>>
    

    Defines the TextDecorations property.

    Source

    font_features_property

    fn font_features_property() -> &'static StyledProperty<Option<FontFeatureCollection>>
    

    Defines the FontFeatures property.

    Source

    inlines_property

    fn inlines_property() -> &'static DirectProperty<TextBlock, Option<InlineCollection>>
    

    Defines the Inlines property.

    Source

    construct

    fn construct() -> Self
    

    Creates the class data; see ferroui_base::FerroObject::construct.

    Source

    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.

    Source

    new

    fn new() -> Ref<Self>
    

    Initializes a new instance of the TextBlock class.

    Source

    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.

    Source

    padding

    fn padding(self: &Self) -> Thickness
    

    The padding to place around the Text.

    Source

    set_padding

    fn set_padding(self: &Self, value: Thickness)
    

    Source

    background

    fn background(self: &Self) -> Option<Rc<dyn IBrush>>
    

    A brush used to paint the control's background.

    Source

    set_background

    fn set_background(self: &Self, value: Option<Rc<dyn IBrush>>)
    

    Source

    text

    fn text(self: &Self) -> Option<String>
    

    The text.

    Source

    set_text

    fn set_text(self: &Self, value: Option<&str>)
    

    Source

    font_family

    fn font_family(self: &Self) -> FontFamily
    

    The font family used to draw the control's text.

    Source

    set_font_family

    fn set_font_family(self: &Self, value: FontFamily)
    

    Source

    font_size

    fn font_size(self: &Self) -> f64
    

    The size of the control's text in points.

    Source

    set_font_size

    fn set_font_size(self: &Self, value: f64)
    

    Source

    font_style

    fn font_style(self: &Self) -> FontStyle
    

    The font style used to draw the control's text.

    Source

    set_font_style

    fn set_font_style(self: &Self, value: FontStyle)
    

    Source

    font_weight

    fn font_weight(self: &Self) -> FontWeight
    

    The font weight used to draw the control's text.

    Source

    set_font_weight

    fn set_font_weight(self: &Self, value: FontWeight)
    

    Source

    font_stretch

    fn font_stretch(self: &Self) -> FontStretch
    

    The font stretch used to draw the control's text.

    Source

    set_font_stretch

    fn set_font_stretch(self: &Self, value: FontStretch)
    

    Source

    foreground

    fn foreground(self: &Self) -> Option<Rc<dyn IBrush>>
    

    The brush used to draw the control's text and other foreground elements.

    Source

    set_foreground

    fn set_foreground(self: &Self, value: Option<Rc<dyn IBrush>>)
    

    Source

    line_height

    fn line_height(self: &Self) -> f64
    

    The height of each line of content.

    Source

    set_line_height

    fn set_line_height(self: &Self, value: f64)
    

    Source

    line_spacing

    fn line_spacing(self: &Self) -> f64
    

    The extra distance between each line of content.

    Source

    set_line_spacing

    fn set_line_spacing(self: &Self, value: f64)
    

    Source

    letter_spacing

    fn letter_spacing(self: &Self) -> f64
    

    The letter spacing.

    Source

    set_letter_spacing

    fn set_letter_spacing(self: &Self, value: f64)
    

    Source

    max_lines

    fn max_lines(self: &Self) -> i32
    

    The maximum number of text lines.

    Source

    set_max_lines

    fn set_max_lines(self: &Self, value: i32)
    

    Source

    text_wrapping

    fn text_wrapping(self: &Self) -> TextWrapping
    

    The control's text wrapping mode.

    Source

    set_text_wrapping

    fn set_text_wrapping(self: &Self, value: TextWrapping)
    

    Source

    text_trimming

    fn text_trimming(self: &Self) -> Rc<dyn TextTrimming>
    

    The control's text trimming mode.

    Source

    set_text_trimming

    fn set_text_trimming(self: &Self, value: Rc<dyn TextTrimming>)
    

    Source

    text_alignment

    fn text_alignment(self: &Self) -> TextAlignment
    

    The text alignment.

    Source

    set_text_alignment

    fn set_text_alignment(self: &Self, value: TextAlignment)
    

    Source

    text_decorations

    fn text_decorations(self: &Self) -> Option<TextDecorationCollection>
    

    The text decorations.

    Source

    set_text_decorations

    fn set_text_decorations(self: &Self, value: Option<TextDecorationCollection>)
    

    Source

    font_features

    fn font_features(self: &Self) -> Option<FontFeatureCollection>
    

    The font features.

    Source

    set_font_features

    fn set_font_features(self: &Self, value: Option<FontFeatureCollection>)
    

    Source

    inlines

    fn inlines(self: &Self) -> Option<InlineCollection>
    

    The inlines.

    Source

    set_inlines

    fn set_inlines(self: &Self, value: Option<InlineCollection>)
    

    Source

    has_complex_content

    fn has_complex_content(self: &Self) -> bool
    

    Whether the text block displays inlines rather than its Text.

    Source

    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.

    Source

    constraint

    fn constraint(self: &Self) -> Size
    

    The constraint the text layout is created for.

    Source

    text_runs

    fn text_runs(self: &Self) -> Option<Rc<Vec<Rc<dyn TextRun>>>>
    

    The text runs of the inlines, when they have been built.

    Source

    baseline_offset

    fn baseline_offset(self: &Self) -> f64
    

    The baseline offset.

    Source

    set_baseline_offset

    fn set_baseline_offset(self: &Self, value: f64)
    

    Source

    get_baseline_offset

    fn get_baseline_offset(control: &Control) -> f64
    

    Reads the attached BaselineOffset property from the given control.

    Source

    set_baseline_offset_on

    fn set_baseline_offset_on(control: &Control, value: f64)
    

    Writes the attached BaselineOffset property to the given control.

    Source

    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.

    Source

    set_text_line_bounds

    fn set_text_line_bounds(self: &Self, value: TextLineBounds)
    

    Source

    get_text_line_bounds

    fn get_text_line_bounds(control: &Control) -> TextLineBounds
    

    Reads the attached TextLineBounds property from the given control.

    Source

    set_text_line_bounds_on

    fn set_text_line_bounds_on(control: &Control, value: TextLineBounds)
    

    Writes the attached TextLineBounds property to the given control.

    Source

    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.

    Source

    set_layout_rounding_placement

    fn set_layout_rounding_placement(self: &Self, value: TextLayoutRoundingPlacement)
    

    Source

    get_layout_rounding_placement

    fn get_layout_rounding_placement(control: &Control) -> TextLayoutRoundingPlacement
    

    Reads the attached LayoutRoundingPlacement property from the given control.

    Source

    set_layout_rounding_placement_on

    fn set_layout_rounding_placement_on(control: &Control, value: TextLayoutRoundingPlacement)
    

    Writes the attached LayoutRoundingPlacement property to the given control.

    Source

    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.

    Source

    get_text_alignment

    fn get_text_alignment(control: &Control) -> TextAlignment
    

    Reads the attached TextAlignment property from the given control.

    Source

    set_text_alignment_on

    fn set_text_alignment_on(control: &Control, alignment: TextAlignment)
    

    Writes the attached TextAlignment property to the given control.

    Source

    get_text_wrapping

    fn get_text_wrapping(control: &Control) -> TextWrapping
    

    Reads the attached TextWrapping property from the given control.

    Source

    set_text_wrapping_on

    fn set_text_wrapping_on(control: &Control, wrapping: TextWrapping)
    

    Writes the attached TextWrapping property to the given control.

    Source

    get_text_trimming

    fn get_text_trimming(control: &Control) -> Rc<dyn TextTrimming>
    

    Reads the attached TextTrimming property from the given control.

    Source

    set_text_trimming_on

    fn set_text_trimming_on(control: &Control, trimming: Rc<dyn TextTrimming>)
    

    Writes the attached TextTrimming property to the given control.

    Source

    get_line_height

    fn get_line_height(control: &Control) -> f64
    

    Reads the attached LineHeight property from the given control.

    Source

    set_line_height_on

    fn set_line_height_on(control: &Control, height: f64)
    

    Writes the attached LineHeight property to the given control.

    Source

    get_letter_spacing

    fn get_letter_spacing(control: &Control) -> f64
    

    Reads the attached LetterSpacing property from the given control.

    Source

    set_letter_spacing_on

    fn set_letter_spacing_on(control: &Control, letter_spacing: f64)
    

    Writes the attached LetterSpacing property to the given control.

    Source

    get_max_lines

    fn get_max_lines(control: &Control) -> i32
    

    Reads the attached MaxLines property from the given control.

    Source

    set_max_lines_on

    fn set_max_lines_on(control: &Control, max_lines: i32)
    

    Writes the attached MaxLines property to the given control.

    Source

    invalidate_text_layout

    fn invalidate_text_layout(self: &Self)
    

    Invalidates the text layout and the shaped runs it was built from.

    Source

    ensure_text_runs

    fn ensure_text_runs(self: &Self)
    

    Builds the text runs of the inlines, unless they are up to date.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.