pub struct Tabs { /* private fields */ }
Expand description
Creates a tab which can contain widgets
Implementations§
Source§impl Tabs
impl Tabs
Sourcepub fn new<'a, T: Into<Option<&'a str>>>(
x: i32,
y: i32,
width: i32,
height: i32,
title: T,
) -> Tabs
pub fn new<'a, T: Into<Option<&'a str>>>( x: i32, y: i32, width: i32, height: i32, title: T, ) -> Tabs
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 screeny
- The y coordinate in the screenwidth
- The width of the widgetheigth
- The height of the widgettitle
- The title or label of the widget
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.
Sourcepub fn default_fill() -> Self
pub fn default_fill() -> Self
Constructs a widget with the size of its parent
Examples found in repository?
12fn draw_gallery() {
13 let mut tab = Tabs::default_fill();
14
15 let mut grp1 = Flex::default_fill().with_label("Tab1\t\t").row();
16 let mut col = Flex::default().column();
17 grp1.fixed(&col, 160);
18 col.set_pad(10);
19 col.set_margin(10);
20 let _but1 = Button::default().with_label("Button");
21 let _but2 = RoundButton::default().with_label("Round");
22 let _but3 = CheckButton::default().with_label("Check");
23 let _but4 = LightButton::default().with_label("Light");
24 let mut but5 = MenuButton::default().with_label("Menu");
25 but5.add_choice("Hello|World|From|Rust");
26 let _but6 = ReturnButton::default().with_label("Return");
27 let mut chce = Choice::default();
28 chce.add_choice("Hello");
29 let _inp = Input::default();
30 let mut out = Output::default();
31 out.set_value("output");
32 col.end();
33 grp1.end();
34
35 let grp2 = Flex::default_fill().with_label("Tab2\t\t").row();
36 grp2.end();
37 tab.end();
38 tab.auto_layout();
39}
Source§impl Tabs
impl Tabs
Sourcepub fn push(&self) -> Option<impl GroupExt>
pub fn push(&self) -> Option<impl GroupExt>
Returns the tab group for the tab the user has currently down-clicked
Sourcepub fn set_push<Grp: GroupExt>(&mut self, w: &Grp) -> Result<(), FltkError>
pub fn set_push<Grp: GroupExt>(&mut self, w: &Grp) -> Result<(), FltkError>
This is called by the tab widget’s handle()
method to set the tab group widget the user last pushed
§Errors
Errors if set_push
can’t be set for the group widget
Sourcepub fn client_area(&self) -> (i32, i32, i32, i32)
pub fn client_area(&self) -> (i32, i32, i32, i32)
Returns the position and size available to be used by its children
Sourcepub fn set_tab_align(&mut self, a: Align)
pub fn set_tab_align(&mut self, a: Align)
Sets the tab label alignment
Examples found in repository?
11fn main() {
12 let app = app::App::default();
13 let mut win = window::Window::default().with_size(800, 600);
14 let row = group::Flex::default_fill().row();
15 let mut tabs = group::Tabs::default();
16 tabs.set_tab_align(enums::Align::Right);
17 tabs.handle_overflow(group::TabsOverflow::Compress);
18 // first tab
19 {
20 let mut col1 = group::Flex::default().with_label("\t\ttab1").column();
21 col1.set_when(When::Closed);
22 col1.set_callback(tab_close_cb);
23 // widgets
24 col1.end();
25 }
26 // end first tab
27
28 // second tab
29 {
30 let mut col2 = group::Flex::default().with_label("\t\ttab2").column();
31 col2.set_when(When::Closed);
32 col2.set_callback(tab_close_cb);
33 // widgets
34 col2.end();
35 }
36 // end second tab
37 tabs.end();
38 tabs.auto_layout();
39 row.end();
40 win.end();
41 win.show();
42 app.run().unwrap();
43}
Sourcepub fn auto_layout(&mut self)
pub fn auto_layout(&mut self)
Auto layout a tabs widget
Examples found in repository?
11fn main() {
12 let app = app::App::default();
13 let mut win = window::Window::default().with_size(800, 600);
14 let row = group::Flex::default_fill().row();
15 let mut tabs = group::Tabs::default();
16 tabs.set_tab_align(enums::Align::Right);
17 tabs.handle_overflow(group::TabsOverflow::Compress);
18 // first tab
19 {
20 let mut col1 = group::Flex::default().with_label("\t\ttab1").column();
21 col1.set_when(When::Closed);
22 col1.set_callback(tab_close_cb);
23 // widgets
24 col1.end();
25 }
26 // end first tab
27
28 // second tab
29 {
30 let mut col2 = group::Flex::default().with_label("\t\ttab2").column();
31 col2.set_when(When::Closed);
32 col2.set_callback(tab_close_cb);
33 // widgets
34 col2.end();
35 }
36 // end second tab
37 tabs.end();
38 tabs.auto_layout();
39 row.end();
40 win.end();
41 win.show();
42 app.run().unwrap();
43}
More examples
12fn draw_gallery() {
13 let mut tab = Tabs::default_fill();
14
15 let mut grp1 = Flex::default_fill().with_label("Tab1\t\t").row();
16 let mut col = Flex::default().column();
17 grp1.fixed(&col, 160);
18 col.set_pad(10);
19 col.set_margin(10);
20 let _but1 = Button::default().with_label("Button");
21 let _but2 = RoundButton::default().with_label("Round");
22 let _but3 = CheckButton::default().with_label("Check");
23 let _but4 = LightButton::default().with_label("Light");
24 let mut but5 = MenuButton::default().with_label("Menu");
25 but5.add_choice("Hello|World|From|Rust");
26 let _but6 = ReturnButton::default().with_label("Return");
27 let mut chce = Choice::default();
28 chce.add_choice("Hello");
29 let _inp = Input::default();
30 let mut out = Output::default();
31 out.set_value("output");
32 col.end();
33 grp1.end();
34
35 let grp2 = Flex::default_fill().with_label("Tab2\t\t").row();
36 grp2.end();
37 tab.end();
38 tab.auto_layout();
39}
Sourcepub fn handle_overflow(&mut self, ov: TabsOverflow)
pub fn handle_overflow(&mut self, ov: TabsOverflow)
Sets how the Tabs handles overflow
Examples found in repository?
11fn main() {
12 let app = app::App::default();
13 let mut win = window::Window::default().with_size(800, 600);
14 let row = group::Flex::default_fill().row();
15 let mut tabs = group::Tabs::default();
16 tabs.set_tab_align(enums::Align::Right);
17 tabs.handle_overflow(group::TabsOverflow::Compress);
18 // first tab
19 {
20 let mut col1 = group::Flex::default().with_label("\t\ttab1").column();
21 col1.set_when(When::Closed);
22 col1.set_callback(tab_close_cb);
23 // widgets
24 col1.end();
25 }
26 // end first tab
27
28 // second tab
29 {
30 let mut col2 = group::Flex::default().with_label("\t\ttab2").column();
31 col2.set_when(When::Closed);
32 col2.set_callback(tab_close_cb);
33 // widgets
34 col2.end();
35 }
36 // end second tab
37 tabs.end();
38 tabs.auto_layout();
39 row.end();
40 win.end();
41 win.show();
42 app.run().unwrap();
43}
Trait Implementations§
Source§impl GroupExt for Tabs
impl GroupExt for Tabs
Source§fn find<W: WidgetExt>(&self, widget: &W) -> i32
fn find<W: WidgetExt>(&self, widget: &W) -> i32
Source§fn insert<W: WidgetExt>(&mut self, widget: &W, index: i32)
fn insert<W: WidgetExt>(&mut self, widget: &W, index: i32)
Source§fn remove<W: WidgetExt>(&mut self, widget: &W)
fn remove<W: WidgetExt>(&mut self, widget: &W)
Source§fn remove_by_index(&mut self, idx: i32)
fn remove_by_index(&mut self, idx: i32)
Source§fn resizable<W: WidgetExt>(&self, widget: &W)
fn resizable<W: WidgetExt>(&self, widget: &W)
Source§fn make_resizable(&mut self, val: bool)
fn make_resizable(&mut self, val: bool)
Source§fn add_resizable<W: WidgetExt>(&mut self, widget: &W)
fn add_resizable<W: WidgetExt>(&mut self, widget: &W)
Source§fn set_clip_children(&mut self, flag: bool)
fn set_clip_children(&mut self, flag: bool)
Source§fn clip_children(&self) -> bool
fn clip_children(&self) -> bool
clip_children
is setSource§fn draw_child<W: WidgetExt>(&self, w: &mut W)
fn draw_child<W: WidgetExt>(&self, w: &mut W)
WidgetBase::draw
methodSource§fn update_child<W: WidgetExt>(&self, w: &mut W)
fn update_child<W: WidgetExt>(&self, w: &mut W)
WidgetBase::draw
methodSource§fn draw_outside_label<W: WidgetExt>(&self, w: &mut W)
fn draw_outside_label<W: WidgetExt>(&self, w: &mut W)
WidgetBase::draw
methodSource§fn draw_children(&mut self)
fn draw_children(&mut self)
WidgetBase::draw
methodSource§fn init_sizes(&mut self)
fn init_sizes(&mut self)
Source§impl IntoIterator for Tabs
impl IntoIterator for Tabs
Source§impl WidgetBase for Tabs
impl WidgetBase for Tabs
Source§unsafe fn from_widget_ptr(ptr: *mut Fl_Widget) -> Self
unsafe fn from_widget_ptr(ptr: *mut Fl_Widget) -> Self
Source§unsafe fn from_widget<W: WidgetExt>(w: W) -> Self
unsafe fn from_widget<W: WidgetExt>(w: W) -> Self
Source§fn handle<F: FnMut(&mut Self, Event) -> bool + 'static>(&mut self, cb: F)
fn handle<F: FnMut(&mut Self, Event) -> bool + 'static>(&mut self, cb: F)
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 hereSource§fn draw<F: FnMut(&mut Self) + 'static>(&mut self, cb: F)
fn draw<F: FnMut(&mut Self) + 'static>(&mut self, cb: F)
WidgetBase::draw
actually calls drawing functionsSource§fn resize_callback<F: FnMut(&mut Self, i32, i32, i32, i32) + 'static>(
&mut self,
cb: F,
)
fn resize_callback<F: FnMut(&mut Self, i32, i32, i32, i32) + 'static>( &mut self, cb: F, )
Source§unsafe fn assume_derived(&mut self)
unsafe fn assume_derived(&mut self)
Source§impl WidgetExt for Tabs
impl WidgetExt for Tabs
Source§fn set_label(&mut self, title: &str)
fn set_label(&mut self, title: &str)
@
sign.
and for the associated formatting.Source§fn unset_label(&mut self)
fn unset_label(&mut self)
Source§fn measure_label(&self) -> (i32, i32)
fn measure_label(&self) -> (i32, i32)
Source§fn as_widget_ptr(&self) -> *mut Fl_Widget
fn as_widget_ptr(&self) -> *mut Fl_Widget
Fl_Widget
, for internal useSource§fn deactivate(&mut self)
fn deactivate(&mut self)
Source§fn redraw_label(&mut self)
fn redraw_label(&mut self)
Source§fn resize(&mut self, x: i32, y: i32, width: i32, height: i32)
fn resize(&mut self, x: i32, y: i32, width: i32, height: i32)
Source§fn widget_resize(&mut self, x: i32, y: i32, width: i32, height: i32)
fn widget_resize(&mut self, x: i32, y: i32, width: i32, height: i32)
Source§fn set_tooltip(&mut self, txt: &str)
fn set_tooltip(&mut self, txt: &str)
Source§fn label_color(&self) -> Color
fn label_color(&self) -> Color
Source§fn set_label_color(&mut self, color: Color)
fn set_label_color(&mut self, color: Color)
Source§fn label_font(&self) -> Font
fn label_font(&self) -> Font
Source§fn set_label_font(&mut self, font: Font)
fn set_label_font(&mut self, font: Font)
Source§fn label_size(&self) -> i32
fn label_size(&self) -> i32
Source§fn set_label_size(&mut self, sz: i32)
fn set_label_size(&mut self, sz: i32)
Source§fn label_type(&self) -> LabelType
fn label_type(&self) -> LabelType
Source§fn set_label_type(&mut self, typ: LabelType)
fn set_label_type(&mut self, typ: LabelType)
Source§fn set_changed(&mut self)
fn set_changed(&mut self)
Source§fn clear_changed(&mut self)
fn clear_changed(&mut self)
Source§fn set_when(&mut self, trigger: When)
fn set_when(&mut self, trigger: When)
when()
Source§fn selection_color(&self) -> Color
fn selection_color(&self) -> Color
Source§fn set_selection_color(&mut self, color: Color)
fn set_selection_color(&mut self, color: Color)
Source§fn do_callback(&mut self)
fn do_callback(&mut self)
Source§fn top_window(&self) -> Option<Box<dyn WindowExt>>
fn top_window(&self) -> Option<Box<dyn WindowExt>>
Source§fn takes_events(&self) -> bool
fn takes_events(&self) -> bool
Source§fn set_visible_focus(&mut self)
fn set_visible_focus(&mut self)
Source§fn clear_visible_focus(&mut self)
fn clear_visible_focus(&mut self)
Source§fn visible_focus(&mut self, v: bool)
fn visible_focus(&mut self, v: bool)
Source§fn has_visible_focus(&self) -> bool
fn has_visible_focus(&self) -> bool
Source§fn was_deleted(&self) -> bool
fn was_deleted(&self) -> bool
Source§fn set_damage(&mut self, flag: bool)
fn set_damage(&mut self, flag: bool)
Source§fn damage_type(&self) -> Damage
fn damage_type(&self) -> Damage
Source§fn set_damage_type(&mut self, mask: Damage)
fn set_damage_type(&mut self, mask: Damage)
Source§fn set_damage_area(&mut self, mask: Damage, x: i32, y: i32, w: i32, h: i32)
fn set_damage_area(&mut self, mask: Damage, x: i32, y: i32, w: i32, h: i32)
Source§fn clear_damage(&mut self)
fn clear_damage(&mut self)
Source§fn as_window(&self) -> Option<Box<dyn WindowExt>>
fn as_window(&self) -> Option<Box<dyn WindowExt>>
Source§fn as_group(&self) -> Option<Group>
fn as_group(&self) -> Option<Group>
Source§fn inside<W: WidgetExt>(&self, wid: &W) -> bool
fn inside<W: WidgetExt>(&self, wid: &W) -> bool
Source§fn get_type<T: WidgetType>(&self) -> T
fn get_type<T: WidgetType>(&self) -> T
Source§fn set_type<T: WidgetType>(&mut self, typ: T)
fn set_type<T: WidgetType>(&mut self, typ: T)
Source§fn set_image_scaled<I: ImageExt>(&mut self, image: Option<I>)
fn set_image_scaled<I: ImageExt>(&mut self, image: Option<I>)
Source§fn set_deimage<I: ImageExt>(&mut self, image: Option<I>)
fn set_deimage<I: ImageExt>(&mut self, image: Option<I>)
Source§fn set_deimage_scaled<I: ImageExt>(&mut self, image: Option<I>)
fn set_deimage_scaled<I: ImageExt>(&mut self, image: Option<I>)
Source§fn deimage(&self) -> Option<Box<dyn ImageExt>>
fn deimage(&self) -> Option<Box<dyn ImageExt>>
Source§fn set_callback<F: FnMut(&mut Self) + 'static>(&mut self, cb: F)
fn set_callback<F: FnMut(&mut Self) + 'static>(&mut self, cb: F)
Source§fn emit<T: 'static + Clone + Send + Sync>(&mut self, sender: Sender<T>, msg: T)
fn emit<T: 'static + Clone + Send + Sync>(&mut self, sender: Sender<T>, msg: T)
Source§unsafe fn as_widget<W: WidgetBase>(&self) -> W
unsafe fn as_widget<W: WidgetBase>(&self) -> W
WidgetExt
to some widget type Read moreSource§fn visible_r(&self) -> bool
fn visible_r(&self) -> bool
Source§fn is_same<W: WidgetExt>(&self, other: &W) -> bool
fn is_same<W: WidgetExt>(&self, other: &W) -> bool
Source§fn active_r(&self) -> bool
fn active_r(&self) -> bool
Source§fn handle_event(&mut self, event: Event) -> bool
fn handle_event(&mut self, event: Event) -> bool
Source§fn is_derived(&self) -> bool
fn is_derived(&self) -> bool
Source§fn as_base_widget(&self) -> Widgetwhere
Self: Sized,
fn as_base_widget(&self) -> Widgetwhere
Self: Sized,
WidgetExt
to a WidgetSource§impl WidgetProps for Tabs
impl WidgetProps for Tabs
Source§fn with_label(self, title: &str) -> Self
fn with_label(self, title: &str) -> Self
Initialize with a label
Source§fn with_align(self, align: Align) -> Self
fn with_align(self, align: Align) -> Self
Initialize with alignment
Source§fn with_type<T: WidgetType>(self, typ: T) -> Self
fn with_type<T: WidgetType>(self, typ: T) -> Self
Initialize with type
Source§fn below_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
fn below_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize at bottom of another widget
Source§fn above_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
fn above_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize above of another widget
Source§fn right_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
fn right_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize right of another widget
Source§fn left_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
fn left_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize left of another widget
Source§fn center_x<W: WidgetExt>(self, w: &W) -> Self
fn center_x<W: WidgetExt>(self, w: &W) -> Self
Initialize center of another widget on the x axis
Source§fn center_y<W: WidgetExt>(self, w: &W) -> Self
fn center_y<W: WidgetExt>(self, w: &W) -> Self
Initialize center of another widget on the y axis
Source§fn center_of_parent(self) -> Self
fn center_of_parent(self) -> Self
Initialize center of parent
Source§fn size_of_parent(self) -> Self
fn size_of_parent(self) -> Self
Initialize to the size of the parent
impl Eq for Tabs
impl Send for Tabs
single-threaded
only.impl Sync for Tabs
single-threaded
only.