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: WidgetExt>(&self, widget: &W) -> i32
where Self: Sized;
fn add<W: WidgetExt>(&mut self, widget: &W)
where Self: Sized;
fn insert<W: WidgetExt>(&mut self, widget: &W, index: i32)
where Self: Sized;
fn remove<W: WidgetExt>(&mut self, widget: &W)
where Self: Sized;
fn remove_by_index(&mut self, idx: i32);
fn resizable<W: WidgetExt>(&self, widget: &W)
where Self: Sized;
fn make_resizable(&mut self, val: bool);
fn add_resizable<W: WidgetExt>(&mut self, widget: &W)
where Self: Sized;
fn set_clip_children(&mut self, flag: bool);
fn clip_children(&self) -> bool;
fn draw_child<W: WidgetExt>(&self, w: &mut W)
where Self: Sized;
fn update_child<W: WidgetExt>(&self, w: &mut W)
where Self: Sized;
fn draw_outside_label<W: WidgetExt>(&self, w: &mut W)
where 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;
}
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§
sourcefn find<W: WidgetExt>(&self, widget: &W) -> i32where
Self: Sized,
fn find<W: WidgetExt>(&self, widget: &W) -> i32where
Self: Sized,
Find a widget within a group and return its index
sourcefn insert<W: WidgetExt>(&mut self, widget: &W, index: i32)where
Self: Sized,
fn insert<W: WidgetExt>(&mut self, widget: &W, index: i32)where
Self: Sized,
Insert a widget to a group at a certain index
sourcefn remove<W: WidgetExt>(&mut self, widget: &W)where
Self: Sized,
fn remove<W: WidgetExt>(&mut self, widget: &W)where
Self: Sized,
Remove a widget from a group, but does not delete it
sourcefn remove_by_index(&mut self, idx: i32)
fn remove_by_index(&mut self, idx: i32)
Remove a child widget by its index
sourcefn resizable<W: WidgetExt>(&self, widget: &W)where
Self: Sized,
fn resizable<W: WidgetExt>(&self, widget: &W)where
Self: Sized,
The resizable widget defines both the resizing frame and the resizing behavior of the group and its children.
sourcefn 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
sourcefn add_resizable<W: WidgetExt>(&mut self, widget: &W)where
Self: Sized,
fn add_resizable<W: WidgetExt>(&mut self, widget: &W)where
Self: Sized,
Adds a widget to the group and makes it the resizable widget
sourcefn set_clip_children(&mut self, flag: bool)
fn set_clip_children(&mut self, flag: bool)
Clips children outside the group boundaries
sourcefn clip_children(&self) -> bool
fn clip_children(&self) -> bool
Get whether clip_children
is set
sourcefn draw_child<W: WidgetExt>(&self, w: &mut W)where
Self: Sized,
fn draw_child<W: WidgetExt>(&self, w: &mut W)where
Self: Sized,
Draw a child widget, the call should be in a WidgetBase::draw
method
sourcefn update_child<W: WidgetExt>(&self, w: &mut W)where
Self: Sized,
fn update_child<W: WidgetExt>(&self, w: &mut W)where
Self: Sized,
Update a child widget, the call should be in a WidgetBase::draw
method
sourcefn draw_outside_label<W: WidgetExt>(&self, w: &mut W)where
Self: Sized,
fn draw_outside_label<W: WidgetExt>(&self, w: &mut W)where
Self: Sized,
Draw the outside label, the call should be in a WidgetBase::draw
method
sourcefn draw_children(&mut self)
fn draw_children(&mut self)
Draw children, the call should be in a WidgetBase::draw
method
sourcefn init_sizes(&mut self)
fn init_sizes(&mut self)
Resets the internal array of widget sizes and positions
sourcefn 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)
sourceunsafe 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)