Trait GroupExt
pub unsafe trait GroupExt: WidgetExt {
Show 22 methods
// Required methods
fn begin(&self);
fn end(&self);
fn clear(&mut self);
fn children(&self) -> i32;
fn child(&self, idx: i32) -> Option<Widget> ⓘ;
fn find<W>(&self, widget: &W) -> i32
where W: WidgetExt,
Self: Sized;
fn add<W>(&mut self, widget: &W)
where W: WidgetExt,
Self: Sized;
fn insert<W>(&mut self, widget: &W, index: i32)
where W: WidgetExt,
Self: Sized;
fn remove<W>(&mut self, widget: &W)
where W: WidgetExt,
Self: Sized;
fn remove_by_index(&mut self, idx: i32);
fn resizable<W>(&self, widget: &W)
where W: WidgetExt,
Self: Sized;
fn make_resizable(&mut self, val: bool);
fn add_resizable<W>(&mut self, widget: &W)
where W: WidgetExt,
Self: Sized;
fn set_clip_children(&mut self, flag: bool);
fn clip_children(&self) -> bool;
fn draw_child<W>(&self, w: &mut W)
where W: WidgetExt,
Self: Sized;
fn update_child<W>(&self, w: &mut W)
where W: WidgetExt,
Self: Sized;
fn draw_outside_label<W>(&self, w: &mut W)
where W: WidgetExt,
Self: Sized;
fn draw_children(&mut self);
fn init_sizes(&mut self);
fn bounds(&self) -> Vec<(i32, i32, i32, i32)> ⓘ;
unsafe fn into_group(&self) -> Group;
}
dep_fltk
only.Expand description
Defines the methods implemented by all group widgets.
These widgets include Window types and others found in the group module: Group, Scroll, Pack, Tile, Flex …etc.
Widgets implementing the GroupExt trait, are characterized by having to call ::end()
method to basically close them.
More details can be found in the wiki.
use fltk::{app, button::Button, window::Window, prelude::GroupExt};
let a = app::App::default();
let win = Window::default();
let btn = Button::default();
// Instantiate other widgets
win.end();
In the above example, the button btn
will be parented by the window.
After end
ing such GroupExt widgets, any other widgets instantiated after the end
call, will be instantiated outside.
These can still be added using the ::add(&other_widget)
method (or using ::insert
):
use fltk::{app, button::Button, window::Window, prelude::GroupExt};
let a = app::App::default();
let mut win = Window::default();
win.end();
let btn = Button::default();
win.add(&btn);
Another option is to reopen the widget:
use fltk::{app, button::Button, window::Window, prelude::GroupExt};
let a = app::App::default();
let win = Window::default();
win.end();
win.begin();
let btn = Button::default();
// other widgets
win.end();
§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§
fn begin(&self)
fn begin(&self)
Begins a group, used for widgets implementing the group trait
fn end(&self)
fn end(&self)
Ends a group, used for widgets implementing the group trait
fn clear(&mut self)
fn clear(&mut self)
Clear a group from all widgets
fn remove_by_index(&mut self, idx: i32)
fn remove_by_index(&mut self, idx: i32)
Remove a child widget by its index
fn resizable<W>(&self, widget: &W)
fn resizable<W>(&self, widget: &W)
The resizable widget defines both the resizing frame and the resizing behavior of the group and its children.
fn make_resizable(&mut self, val: bool)
fn make_resizable(&mut self, val: bool)
Make the group itself resizable, should be called before the widget is shown
fn add_resizable<W>(&mut self, widget: &W)
fn add_resizable<W>(&mut self, widget: &W)
Adds a widget to the group and makes it the resizable widget
fn set_clip_children(&mut self, flag: bool)
fn set_clip_children(&mut self, flag: bool)
Clips children outside the group boundaries
fn clip_children(&self) -> bool
fn clip_children(&self) -> bool
Get whether clip_children
is set
fn draw_child<W>(&self, w: &mut W)
fn draw_child<W>(&self, w: &mut W)
Draw a child widget, the call should be in a WidgetBase::draw
method
fn update_child<W>(&self, w: &mut W)
fn update_child<W>(&self, w: &mut W)
Update a child widget, the call should be in a WidgetBase::draw
method
fn draw_outside_label<W>(&self, w: &mut W)
fn draw_outside_label<W>(&self, w: &mut W)
Draw the outside label, the call should be in a WidgetBase::draw
method
fn draw_children(&mut self)
fn draw_children(&mut self)
Draw children, the call should be in a WidgetBase::draw
method
fn init_sizes(&mut self)
fn init_sizes(&mut self)
Resets the internal array of widget sizes and positions
fn bounds(&self) -> Vec<(i32, i32, i32, i32)> ⓘ
fn bounds(&self) -> Vec<(i32, i32, i32, i32)> ⓘ
Get the bounds of all children widgets (left, upper, right, bottom)
unsafe fn into_group(&self) -> Group
unsafe fn into_group(&self) -> Group
Converts a widget implementing GroupExt into a Group widget
§Safety
If the widget wasn’t created by fltk-rs, vtable differences mean certain methods can’t be overridden (e.g. handle & draw)