Trait fltk::prelude::WidgetBase[][src]

pub unsafe trait WidgetBase: WidgetExt {
    fn new<T: Into<Option<&'static str>>>(
        x: i32,
        y: i32,
        width: i32,
        height: i32,
        title: T
    ) -> Self;
fn delete(wid: Self)
    where
        Self: Sized
;
unsafe fn from_widget_ptr(ptr: *mut Fl_Widget) -> Self;
unsafe fn from_widget<W: WidgetExt>(w: W) -> Self;
fn handle<F: FnMut(&mut Self, Event) -> bool + 'static>(&mut self, cb: F);
fn draw<F: FnMut(&mut Self) + 'static>(&mut self, cb: F);
unsafe fn draw_data(&mut self) -> Option<Box<dyn FnMut()>>;
unsafe fn handle_data(&mut self) -> Option<Box<dyn FnMut(Event) -> bool>>; }
Expand description

Defines the extended methods implemented by all widgets

Required methods

Creates a new widget, takes an x, y coordinates, as well as a width and height, plus a title

Arguments

  • x - The x coordinate in the screen
  • y - The y coordinate in the screen
  • width - The width of the widget
  • heigth - The height of the widget
  • title - The title or label of the widget The title is expected to be a static str or None. To use dynamic strings use with_label(self, &str) or set_label(&mut self, &str) labels support special symbols preceded by an @ sign. and for the associated formatting.

Deletes widgets and their children.

transforms a widget pointer to a Widget, for internal use

Safety

The pointer must be valid

Get a widget from base widget

Safety

The underlying object must be valid

Set a custom handler, where events are managed manually, akin to Fl_Widget::handle(int). Handled or ignored events should return true, unhandled events should return false. takes the widget as a closure argument

Set a custom draw method. takes the widget as a closure argument. macOS requires that WidgetBase::draw actually calls drawing functions

INTERNAL: Retrieve the draw data

Safety

Can return multiple mutable references to the draw_data

INTERNAL: Retrieve the handle data

Safety

Can return multiple mutable references to the handle_data

Implementors