Trait fltk::prelude::GroupExt

source ·
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 ending 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§

source

fn begin(&self)

Begins a group, used for widgets implementing the group trait

source

fn end(&self)

Ends a group, used for widgets implementing the group trait

source

fn clear(&mut self)

Clear a group from all widgets

source

fn children(&self) -> i32

Return the number of children in a group

source

fn child(&self, idx: i32) -> Option<Widget>

Return child widget by index

source

fn find<W: WidgetExt>(&self, widget: &W) -> i32
where Self: Sized,

Find a widget within a group and return its index

source

fn add<W: WidgetExt>(&mut self, widget: &W)
where Self: Sized,

Add a widget to a group

source

fn insert<W: WidgetExt>(&mut self, widget: &W, index: i32)
where Self: Sized,

Insert a widget to a group at a certain index

source

fn remove<W: WidgetExt>(&mut self, widget: &W)
where Self: Sized,

Remove a widget from a group, but does not delete it

source

fn remove_by_index(&mut self, idx: i32)

Remove a child widget by its index

source

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.

source

fn make_resizable(&mut self, val: bool)

Make the group itself resizable, should be called before the widget is shown

source

fn add_resizable<W: WidgetExt>(&mut self, widget: &W)
where Self: Sized,

Adds a widget to the group and makes it the resizable widget

source

fn set_clip_children(&mut self, flag: bool)

Clips children outside the group boundaries

source

fn clip_children(&self) -> bool

Get whether clip_children is set

source

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

source

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

source

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

source

fn draw_children(&mut self)

Draw children, the call should be in a WidgetBase::draw method

source

fn init_sizes(&mut self)

Resets the internal array of widget sizes and positions

source

fn bounds(&self) -> Vec<(i32, i32, i32, i32)>

Get the bounds of all children widgets (left, upper, right, bottom)

source

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)

Implementors§