Trait WidgetBase
pub unsafe trait WidgetBase: WidgetExt {
// Required methods
fn new<'a, T>(x: i32, y: i32, width: i32, height: i32, title: T) -> Self
where T: Into<Option<&'a str>>;
fn default_fill() -> Self;
fn delete(wid: Self)
where Self: Sized;
unsafe fn from_widget_ptr(ptr: *mut Fl_Widget) -> Self;
unsafe fn from_widget<W>(w: W) -> Self
where W: WidgetExt;
fn handle<F>(&mut self, cb: F)
where F: FnMut(&mut Self, Event) -> bool + 'static;
fn draw<F>(&mut self, cb: F)
where F: FnMut(&mut Self) + 'static;
fn resize_callback<F>(&mut self, cb: F)
where F: FnMut(&mut Self, i32, i32, i32, i32) + 'static;
// Provided methods
unsafe fn assume_derived(&mut self) { ... }
fn from_dyn_widget<W>(_w: &W) -> Option<Self> ⓘ
where W: WidgetExt,
Self: Sized { ... }
fn from_dyn_widget_ptr(_w: *mut Fl_Widget) -> Option<Self> ⓘ
where Self: Sized { ... }
}
dep_fltk
only.Expand description
Required Methods§
fn new<'a, T>(x: i32, y: i32, width: i32, height: i32, title: T) -> Self
fn new<'a, T>(x: i32, y: i32, width: i32, height: i32, title: T) -> Self
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 screeny
- The y coordinate in the screenwidth
- The width of the widgetheigth
- The height of the widgettitle
- The title or label of the widget
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.
fn default_fill() -> Self
fn default_fill() -> Self
Constructs a widget with the size of its parent
unsafe fn from_widget_ptr(ptr: *mut Fl_Widget) -> Self
unsafe fn from_widget_ptr(ptr: *mut Fl_Widget) -> Self
unsafe fn from_widget<W>(w: W) -> Selfwhere
W: WidgetExt,
unsafe fn from_widget<W>(w: W) -> Selfwhere
W: WidgetExt,
fn handle<F>(&mut self, cb: F)
fn handle<F>(&mut self, cb: F)
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.
The ability to handle an event might depend on handling other events, as explained here
Provided Methods§
unsafe fn assume_derived(&mut self)
unsafe fn assume_derived(&mut self)
fn from_dyn_widget<W>(_w: &W) -> Option<Self> ⓘ
fn from_dyn_widget<W>(_w: &W) -> Option<Self> ⓘ
Cast a type-erased widget back to its original widget
fn from_dyn_widget_ptr(_w: *mut Fl_Widget) -> Option<Self> ⓘwhere
Self: Sized,
fn from_dyn_widget_ptr(_w: *mut Fl_Widget) -> Option<Self> ⓘwhere
Self: Sized,
Cast a type-erased widget pointer back to its original widget
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.