Trait fltk::prelude::WidgetExt[][src]

pub unsafe trait WidgetExt {
Show methods fn set_pos(&mut self, x: i32, y: i32);
fn set_size(&mut self, width: i32, height: i32);
fn set_label(&mut self, title: &str);
fn redraw(&mut self);
fn show(&mut self);
fn hide(&mut self);
fn x(&self) -> i32;
fn y(&self) -> i32;
fn width(&self) -> i32;
fn height(&self) -> i32;
fn w(&self) -> i32;
fn h(&self) -> i32;
fn label(&self) -> String;
fn measure_label(&self) -> (i32, i32);
unsafe fn as_widget_ptr(&self) -> *mut Fl_Widget;
fn with_pos(self, x: i32, y: i32) -> Self
    where
        Self: Sized
;
fn with_size(self, width: i32, height: i32) -> Self
    where
        Self: Sized
;
fn with_label(self, title: &str) -> Self
    where
        Self: Sized
;
fn with_align(self, align: Align) -> Self
    where
        Self: Sized
;
fn below_of<W: WidgetExt>(self, w: &W, padding: i32) -> Self
    where
        Self: Sized
;
fn above_of<W: WidgetExt>(self, w: &W, padding: i32) -> Self
    where
        Self: Sized
;
fn right_of<W: WidgetExt>(self, w: &W, padding: i32) -> Self
    where
        Self: Sized
;
fn left_of<W: WidgetExt>(self, w: &W, padding: i32) -> Self
    where
        Self: Sized
;
fn center_of<W: WidgetExt>(self, w: &W) -> Self
    where
        Self: Sized
;
fn center_of_parent(self) -> Self
    where
        Self: Sized
;
fn size_of<W: WidgetExt>(self, w: &W) -> Self
    where
        Self: Sized
;
fn size_of_parent(self) -> Self
    where
        Self: Sized
;
fn inside<W: WidgetExt>(&self, wid: &W) -> bool
    where
        Self: Sized
;
fn get_type<T: WidgetType>(&self) -> T
    where
        Self: Sized
;
fn set_type<T: WidgetType>(&mut self, typ: T)
    where
        Self: Sized
;
fn with_type<T: WidgetType>(self, typ: T) -> Self
    where
        Self: Sized
;
fn set_image<I: ImageExt>(&mut self, image: Option<I>)
    where
        Self: Sized
;
fn set_image_scaled<I: ImageExt>(&mut self, image: Option<I>)
    where
        Self: Sized
;
fn image(&self) -> Option<Box<dyn ImageExt>>
    where
        Self: Sized
;
fn set_deimage<I: ImageExt>(&mut self, image: Option<I>)
    where
        Self: Sized
;
fn set_deimage_scaled<I: ImageExt>(&mut self, image: Option<I>)
    where
        Self: Sized
;
fn deimage(&self) -> Option<Box<dyn ImageExt>>
    where
        Self: Sized
;
fn set_callback<F: FnMut(&mut Self) + 'static>(&mut self, cb: F)
    where
        Self: Sized
;
fn emit<T: 'static + Clone + Send + Sync>(
        &mut self,
        sender: Sender<T>,
        msg: T
    )
    where
        Self: Sized
;
fn activate(&mut self);
fn deactivate(&mut self);
fn redraw_label(&mut self);
fn resize(&mut self, x: i32, y: i32, width: i32, height: i32);
fn tooltip(&self) -> Option<String>;
fn set_tooltip(&mut self, txt: &str);
fn color(&self) -> Color;
fn set_color(&mut self, color: Color);
fn label_color(&self) -> Color;
fn set_label_color(&mut self, color: Color);
fn label_font(&self) -> Font;
fn set_label_font(&mut self, font: Font);
fn label_size(&self) -> i32;
fn set_label_size(&mut self, sz: i32);
fn label_type(&self) -> LabelType;
fn set_label_type(&mut self, typ: LabelType);
fn frame(&self) -> FrameType;
fn set_frame(&mut self, typ: FrameType);
fn changed(&self) -> bool;
fn set_changed(&mut self);
fn clear_changed(&mut self);
fn align(&self) -> Align;
fn set_align(&mut self, align: Align);
fn parent(&self) -> Option<Group>;
fn selection_color(&mut self) -> Color;
fn set_selection_color(&mut self, color: Color);
fn do_callback(&mut self);
fn window(&self) -> Option<Box<dyn WindowExt>>;
fn top_window(&self) -> Option<Box<dyn WindowExt>>;
fn takes_events(&self) -> bool;
fn take_focus(&mut self) -> Result<(), FltkError>;
fn set_visible_focus(&mut self);
fn clear_visible_focus(&mut self);
fn visible_focus(&mut self, v: bool);
fn has_visible_focus(&mut self) -> bool;
fn was_deleted(&self) -> bool;
fn damage(&self) -> bool;
fn set_damage(&mut self, flag: bool);
fn damage_type(&self) -> Damage;
fn set_damage_type(&mut self, mask: Damage);
fn clear_damage(&mut self);
fn set_trigger(&mut self, trigger: CallbackTrigger);
fn trigger(&self) -> CallbackTrigger;
fn as_window(&self) -> Option<Box<dyn WindowExt>>;
fn as_group(&self) -> Option<Group>;
unsafe fn user_data(&self) -> Option<Box<dyn FnMut()>>;
unsafe fn into_widget<W: WidgetBase>(&self) -> W
    where
        Self: Sized
;
fn visible(&self) -> bool;
fn visible_r(&self) -> bool;
fn is_same<W: WidgetExt>(&self, other: &W) -> bool
    where
        Self: Sized
;
fn active(&self) -> bool;
fn active_r(&self) -> bool;
fn callback(&self) -> Option<Box<dyn FnMut()>>;
fn widget_resize(&mut self, x: i32, y: i32, w: i32, h: i32);
}
Expand description

Defines the methods implemented by all widgets

Required methods

Set to position x, y

Set to dimensions width and height

Sets the widget’s label. labels support special symbols preceded by an @ sign. and for the associated formatting.

Redraws a widget, necessary for resizing and changing positions

Shows the widget

Hides the widget

Returns the x coordinate of the widget

Returns the y coordinate of the widget

Returns the width of the widget

Returns the height of the widget

Returns the width of the widget

Returns the height of the widget

Returns the label of the widget

Measures the label’s width and height

transforms a widget to a base Fl_Widget, for internal use

Safety

Can return multiple mutable pointers to the same widget

Initialize to position x, y, (should only be called on initialization)

Initialilze to dimensions width and height, (should only be called on initialization)

Initialize with label/title, (should only be called on initialization)

Sets the initial alignment of the widget, (should only be called on initialization)

Positions the widget below w, the size of w should be known

Positions the widget above w, the size of w should be known

Positions the widget to the right of w, the size of w should be known

Positions the widget to the left of w, the size of w should be known

Positions the widget to the center of w, the size of w should be known

Positions the widget to the center of its parent

Takes the size of w, the size of w should be known

Takes the size of the parent group or window

Checks whether the self widget is inside another widget

Returns the widget type when applicable

Sets the widget type

Set the type of the widget at construction

Sets the image of the widget

Sets the image of the widget scaled to the widget’s size

Gets the image associated with the widget

Sets the deactived image of the widget

Sets the deactivated image of the widget scaled to the widget’s size

Gets the deactivated image associated with the widget

Sets the callback when the widget is triggered (clicks for example) takes the widget as a closure argument

Emits a message on callback using a sender

Activates the widget

Deactivates the widget

Redraws the label of the widget

Resizes and/or moves the widget, takes x, y, width and height

Returns the tooltip text

Sets the tooltip text

Returns the widget color

Sets the widget’s color

Returns the widget label’s color

Sets the widget label’s color

Returns the widget label’s font

Sets the widget label’s font

Returns the widget label’s size

Sets the widget label’s size

Returns the widget label’s type

Sets the widget label’s type

Returns the widget’s frame type

Sets the widget’s frame type

Returns whether the widget was changed

Mark the widget as changed

Clears the changed status of the widget

Returns the alignment of the widget

Sets the alignment of the widget

Returns the parent of the widget

Gets the selection color of the widget

Sets the selection color of the widget

Runs the already registered callback

Returns the direct window holding the widget

Returns the topmost window holding the widget

Checks whether a widget is capable of taking events

Make the widget take focus

Errors

Errors on failure to take focus

Set the widget to have visible focus

Clear visible focus

Set the visible focus using a flag

Return whether the widget has visible focus

Check if a widget was deleted

Return whether the widget was damaged

Signal the widget as damaged and it should be redrawn in the next event loop cycle

Return the damage mask

Signal the type of damage a widget received

Clear the damaged flag

Sets the default callback trigger for a widget

Return the callback trigger

Return the widget as a window if it’s a window

Return the widget as a group widget if it’s a group widget

INTERNAL: Retakes ownership of the user callback data

Safety

Can return multiple mutable references to the user_data

Upcast a WidgetExt to a Widget

Safety

Allows for potentially unsafe casts between incompatible widget types

Returns whether a widget is visible

Returns whether a widget or any of its parents are visible (recursively)

Return whether two widgets object point to the same widget

Returns whether a widget is active

Returns whether a widget or any of its parents are active (recursively)

Return the default callback function, this allows storing then running within the overriden callback

    use fltk::{prelude::*, *};
    let scroll = group::Scroll::default();
    let mut scrollbar = scroll.scrollbar();
    scrollbar.set_callback({
    let mut cb = scrollbar.callback();
        move |_| {
            println!("print something, and also run the default callback");
            if let Some(cb) = cb.as_mut() {
                (*cb)();
            }
        }
    });

Does a simple resize ignoring class-specific resize functionality

Implementors