[][src]Trait pushrod::widget::widget::Widget

pub trait Widget {
    fn config(&mut self) -> &mut Configurable;
fn set_widget_id(&mut self, widget_id: i32);
fn get_widget_id(&mut self) -> i32;
fn get_injectable_custom_events(
        &mut self
    ) -> &mut dyn InjectableCustomEvents;
fn get_drawable(&mut self) -> &mut dyn Drawable;
fn get_injectable_system_events(
        &mut self
    ) -> &mut dyn InjectableSystemEvents; fn invalidate(&mut self) { ... }
fn clear_invalidate(&mut self) { ... }
fn is_invalidated(&mut self) -> bool { ... }
fn set_config(&mut self, config: u8, config_value: Config) { ... }
fn get_config(&mut self, config: u8) -> Option<&Config> { ... }
fn set_point(&mut self, config: u8, x: i32, y: i32) { ... }
fn set_size(&mut self, config: u8, w: i32, h: i32) { ... }
fn set_color(&mut self, config: u8, color: Color) { ... }
fn set_numeric(&mut self, config: u8, value: u64) { ... }
fn set_text(&mut self, config: u8, text: String) { ... }
fn set_toggle(&mut self, config: u8, flag: bool) { ... }
fn handle_event(
        &mut self,
        _injected: bool,
        _event: CallbackEvent,
        _widget_store: Option<&Vec<WidgetContainer>>
    ) -> Option<CallbackEvent> { ... }
fn handles_events(&mut self) -> bool { ... }
fn injects_custom_events(&mut self) -> bool { ... }
fn is_drawable(&mut self) -> bool { ... }
fn injects_system_events(&mut self) -> bool { ... } }

Master level trait object for describing a Widget. A Widget is a GUI element that can be interacted with and can receive and generate events.

Required methods

fn config(&mut self) -> &mut Configurable

Retrieves the Configurable object for this Widget. All Widget implementations must provide this. (See the CanvasWidget implementation.)

fn set_widget_id(&mut self, widget_id: i32)

fn get_widget_id(&mut self) -> i32

fn get_injectable_custom_events(&mut self) -> &mut dyn InjectableCustomEvents

Retrieves the InjectableCustomEvents trait of this class, which is responsible for injecting custom events when appropriate. Injecting system events is used with the InjectableSystemEvents, and things like mouse clicks and widget clicks are used with the handle_event block. This code is used to inject events that are not triggered by other events in the system.

fn get_drawable(&mut self) -> &mut dyn Drawable

Retrieves the Drawable functionality of this Widget.

fn get_injectable_system_events(&mut self) -> &mut dyn InjectableSystemEvents

Retrieves the trait for injecting system events. Only use this if your Widget injects custom system-level events that the top-level application needs to use. Anything other than that should be ignored completely.

Loading content...

Provided methods

fn invalidate(&mut self)

Indicates that a Widget object needs to be repainted.

fn clear_invalidate(&mut self)

Clears the invalidation flag. Set this when the draw function completes. Otherwise, this Widget object may be continuously repainted.

fn is_invalidated(&mut self) -> bool

Indicates whether or not a Widget needs to be repainted.

fn set_config(&mut self, config: u8, config_value: Config)

Master config setter - use convenience methods.

fn get_config(&mut self, config: u8) -> Option<&Config>

Master config getter - use convenience methods.

fn set_point(&mut self, config: u8, x: i32, y: i32)

Sets a point value for a configuration key.

fn set_size(&mut self, config: u8, w: i32, h: i32)

Sets a size value for a configuration key.

fn set_color(&mut self, config: u8, color: Color)

Sets a color for a configuration key.

fn set_numeric(&mut self, config: u8, value: u64)

Sets a numeric value for a configuration key.

fn set_text(&mut self, config: u8, text: String)

Sets a text value for a configuration key.

fn set_toggle(&mut self, config: u8, flag: bool)

Sets a toggle value for a configuration key.

fn handle_event(
    &mut self,
    _injected: bool,
    _event: CallbackEvent,
    _widget_store: Option<&Vec<WidgetContainer>>
) -> Option<CallbackEvent>

Custom handler to receive an event. Any Widget that implements this does so to handle top-level GUI events, such as a mouse entering or exiting the bounds of this Widget. If the injected flag is set, it indicates that the event supplied was generate by a Widget, and not by the run loop.

fn handles_events(&mut self) -> bool

Indicates to the run loop whether or not the Widget handles system-generated events.

fn injects_custom_events(&mut self) -> bool

If this Widget provides custom injected events that are generated outside of the handle_event loop, indicate true. Only override if necessary. (See TimerWidget for reference.)

fn is_drawable(&mut self) -> bool

Describes whether or not the Widget returns a Drawable trait. This function is called each time a frame is refreshed, so if there is no Drawable available, this function could serve as a way to indicate a frame tick. Only override this to set it to false if your Widget does not draw anything on the screen.

fn injects_system_events(&mut self) -> bool

Indicates to the run loop whether or not a Widget injects system-level events.

Loading content...

Implementors

impl Widget for BoxWidget[src]

impl Widget for CheckboxWidget[src]

impl Widget for ImageButtonWidget[src]

impl Widget for ImageWidget[src]

impl Widget for ProgressWidget[src]

impl Widget for PushButtonWidget[src]

impl Widget for RadioButtonWidget[src]

impl Widget for TextWidget[src]

impl Widget for TimerWidget[src]

impl Widget for ToggleButtonWidget[src]

impl Widget for CanvasWidget[src]

Loading content...