Skip to main content

MessageBox

Struct MessageBox 

Source
pub struct MessageBox {
    pub style: Style,
    pub text_color: Color,
    pub button_text_color: Color,
    /* private fields */
}
Expand description

LVGL-parity message-box dialog (LPAR-14 §5.H).

Combines a title header, a wrapped body message, and a button row into a single widget. The button row is implemented as an internal ButtonMatrix.

§Button IDs

Buttons are assigned sequential ButtonId values in the order supplied to new. Use those IDs with active_button and [activate_button].

Fields§

§style: Style

Style for the outer container.

§text_color: Color

Text colour for the title and body.

§button_text_color: Color

Text colour for the button labels (forwarded to the inner matrix).

Implementations§

Source§

impl MessageBox

Source

pub fn new( bounds: Rect, title: &str, text: &str, buttons: &[&str], ) -> MessageBox

Create a MessageBox with the given bounds, title, body text, and button labels.

buttons is a slice of label strings. An empty slice creates a message-box with no footer buttons.

Source

pub fn set_font(&mut self, font: &'static dyn FontMetrics)

Assign the font used to render this widget (FONT-00 §5); resolves to FONT_6X10 when unset.

Source

pub fn title(&self) -> &str

Return the current title string.

Source

pub fn set_title(&mut self, title: &str)

Replace the title string.

Source

pub fn text(&self) -> &str

Return the current body text.

Source

pub fn set_text(&mut self, text: &str)

Replace the body text.

Source

pub fn active_button(&self) -> ButtonId

Return the most-recently activated button, or BUTTON_NONE if no button has been activated yet.

Source

pub fn activate_button(&mut self, id: ButtonId)

Programmatically activate button id, recording it as the active button. Equivalent to the user pressing a button.

Source

pub fn button_text(&self, id: ButtonId) -> Option<&str>

Return the label of button id, or None if id is out of range.

Source

pub fn button_count(&self) -> usize

Return the total number of buttons in the footer row.

Source

pub fn close(&mut self) -> ButtonId

Signal that the dialog should be dismissed.

Records closed = true and returns the currently active_button. The caller must detach or hide the widget; no z-order or tree manipulation is performed.

Source

pub fn is_closed(&self) -> bool

Return true after close has been called.

Trait Implementations§

Source§

impl StyleProps for MessageBox

Source§

fn style_mut(&mut self) -> &mut Style

Return the mutable style used by this widget’s main visual part.
Source§

fn with_style(self, style: Style) -> Self

Replace the complete main style.
Source§

fn bg(self, color: Color) -> Self

Set the background color.
Source§

fn bg_color(self, color: Color) -> Self

Set the background color.
Source§

fn border_color(self, color: Color) -> Self

Set the border color.
Source§

fn border_width(self, width: u8) -> Self

Set the border width in pixels.
Source§

fn radius(self, radius: u8) -> Self

Set the corner radius in pixels.
Source§

fn rounded(self, radius: u8) -> Self

Set the corner radius in pixels.
Source§

fn opacity(self, alpha: u8) -> Self

Set widget opacity as 0..=255.
Source§

fn alpha(self, alpha: u8) -> Self

Set widget opacity as 0..=255.
Source§

impl ThemedPartsProps for MessageBox

Source§

fn themed_parts( self, theme: &Theme, scheme: ColorScheme, variant: Variant, size: ComponentSize, ) -> Self

Apply the theme to the main style and direct widget-specific part colors.
Source§

impl Widget for MessageBox

Source§

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.
Source§

fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>

Expose this widget’s font slot for cascade-driven font resolution (FONT-05 §5.B). Read more
Source§

fn set_bounds(&mut self, new_bounds: Rect)

Called by the LPAR-10 layout pass to notify this widget of its layout-computed bounds. Read more
Source§

fn draw(&self, renderer: &mut dyn Renderer)

Render the widget using the provided Renderer.
Source§

fn handle_event(&mut self, event: &Event) -> bool

Handle an event and return true if it was consumed. Read more
Source§

fn clear_region(&mut self) -> Option<Rect>

Return a region (in draw/landscape coordinates) that should be restored from the pristine background copy, or None. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> BoundsProps for T
where T: Widget,

Source§

fn bounds(self, bounds: Rect) -> Self

Apply a new bounding rectangle and return the widget.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ThemeProps for T
where T: StyleProps,

Source§

fn themed( self, theme: &Theme, scheme: ColorScheme, variant: Variant, size: ComponentSize, ) -> Self

Apply a complete themed style.
Source§

fn variant(self, theme: &Theme, scheme: ColorScheme, variant: Variant) -> Self

Apply a themed variant with medium sizing.
Source§

fn component_size(self, theme: &Theme, size: ComponentSize) -> Self

Apply only the sizing-affecting style fields.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.