Trait fltk::prelude::WidgetBase

source ·
pub unsafe trait WidgetBase: WidgetExt {
    // Required methods
    fn new<T: Into<Option<&'static str>>>(
        x: i32,
        y: i32,
        width: i32,
        height: i32,
        title: T
    ) -> Self;
    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: 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);
    fn resize_callback<F: FnMut(&mut Self, i32, i32, i32, i32) + 'static>(
        &mut self,
        cb: F
    );

    // Provided methods
    unsafe fn assume_derived(&mut self) { ... }
    fn from_dyn_widget<W: WidgetExt>(_w: &W) -> Option<Self>
       where Self: Sized { ... }
    fn from_dyn_widget_ptr(_w: *mut Fl_Widget) -> Option<Self>
       where Self: Sized { ... }
}
Expand description

Defines the extended methods implemented by all widgets

Safety

fltk-rs traits depend on some FLTK internal code

Warning

fltk-rs traits are non-exhaustive, to avoid future breakage if you try to implement them manually, use the Deref and DerefMut pattern or the widget_extends! macro

Required Methods§

source

fn new<T: Into<Option<&'static str>>>( 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 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.
source

fn default_fill() -> Self

Constructs a widget with the size of its parent

source

fn delete(wid: Self)where Self: Sized,

Deletes widgets and their children.

source

unsafe fn from_widget_ptr(ptr: *mut Fl_Widget) -> Self

transforms a widget pointer to a Widget, for internal use

Safety

The pointer must be valid

source

unsafe fn from_widget<W: WidgetExt>(w: W) -> Self

Get a widget from base widget

Safety

The underlying object must be valid

source

fn handle<F: FnMut(&mut Self, Event) -> bool + 'static>(&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

source

fn draw<F: FnMut(&mut Self) + 'static>(&mut self, cb: F)

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

source

fn resize_callback<F: FnMut(&mut Self, i32, i32, i32, i32) + 'static>( &mut self, cb: F )

Perform a callback on resize. Avoid resizing the parent or the same widget to avoid infinite recursion

Provided Methods§

source

unsafe fn assume_derived(&mut self)

Makes the widget derived

Safety

Calling this on a non-derived widget can cause undefined behavior

source

fn from_dyn_widget<W: WidgetExt>(_w: &W) -> Option<Self>where Self: Sized,

Cast a type-erased widget back to its original widget

source

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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl WidgetBase for Browser

source§

impl WidgetBase for CheckBrowser

source§

impl WidgetBase for FileBrowser

source§

impl WidgetBase for HoldBrowser

source§

impl WidgetBase for MultiBrowser

source§

impl WidgetBase for SelectBrowser

source§

impl WidgetBase for Button

source§

impl WidgetBase for CheckButton

source§

impl WidgetBase for LightButton

source§

impl WidgetBase for RadioButton

source§

impl WidgetBase for RadioLightButton

source§

impl WidgetBase for RadioRoundButton

source§

impl WidgetBase for RepeatButton

source§

impl WidgetBase for ReturnButton

source§

impl WidgetBase for RoundButton

source§

impl WidgetBase for ShortcutButton

source§

impl WidgetBase for ToggleButton

source§

impl WidgetBase for Frame

source§

impl WidgetBase for Grid

source§

impl WidgetBase for ColorChooser

source§

impl WidgetBase for Flex

source§

impl WidgetBase for Group

source§

impl WidgetBase for Pack

source§

impl WidgetBase for Scroll

source§

impl WidgetBase for Tabs

source§

impl WidgetBase for Tile

source§

impl WidgetBase for Wizard

source§

impl WidgetBase for FileInput

source§

impl WidgetBase for FloatInput

source§

impl WidgetBase for Input

source§

impl WidgetBase for IntInput

source§

impl WidgetBase for MultilineInput

source§

impl WidgetBase for SecretInput

source§

impl WidgetBase for Choice

source§

impl WidgetBase for MenuBar

source§

impl WidgetBase for MenuButton

source§

impl WidgetBase for SysMenuBar

source§

impl WidgetBase for Chart

source§

impl WidgetBase for Clock

source§

impl WidgetBase for HelpView

source§

impl WidgetBase for InputChoice

source§

impl WidgetBase for Progress

source§

impl WidgetBase for Spinner

source§

impl WidgetBase for MultilineOutput

source§

impl WidgetBase for Output

source§

impl WidgetBase for Table

source§

impl WidgetBase for TableRow

source§

impl WidgetBase for SimpleTerminal

source§

impl WidgetBase for TextDisplay

source§

impl WidgetBase for TextEditor

source§

impl WidgetBase for Tree

source§

impl WidgetBase for Adjuster

source§

impl WidgetBase for Counter

source§

impl WidgetBase for Dial

source§

impl WidgetBase for FillDial

source§

impl WidgetBase for FillSlider

source§

impl WidgetBase for HorFillSlider

source§

impl WidgetBase for HorNiceSlider

source§

impl WidgetBase for HorSlider

source§

impl WidgetBase for HorValueSlider

source§

impl WidgetBase for LineDial

source§

impl WidgetBase for NiceSlider

source§

impl WidgetBase for Roller

source§

impl WidgetBase for Scrollbar

source§

impl WidgetBase for Slider

source§

impl WidgetBase for ValueInput

source§

impl WidgetBase for ValueOutput

source§

impl WidgetBase for ValueSlider

source§

impl WidgetBase for Widget

source§

impl WidgetBase for DoubleWindow

source§

impl WidgetBase for GlutWindow

source§

impl WidgetBase for MenuWindow

source§

impl WidgetBase for OverlayWindow

source§

impl WidgetBase for SingleWindow