Struct MenuBar

Source
pub struct MenuBar { /* private fields */ }
Expand description

Creates a menu bar

Implementations§

Source§

impl MenuBar

Source

pub fn new<'a, T: Into<Option<&'a str>>>( x: i32, y: i32, width: i32, height: i32, title: T, ) -> MenuBar

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 screen
  • y - The y coordinate in the screen
  • width - The width of the widget
  • heigth - The height of the widget
  • title - 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.

Examples found in repository?
examples/terminal.rs (line 42)
20fn main() {
21    let app = fltk::app::App::default();
22
23    // Set panic handler for main thread (will become UI thread)
24    std::panic::set_hook(Box::new({
25        |e| {
26            eprintln!("!!!!PANIC!!!!{:#?}", e);
27            error_box(e.to_string()); // Only works from the UI thread
28            std::process::exit(2);
29        }
30    }));
31
32    let mut main_win = Window::new(
33        2285,
34        180,
35        WIN_WIDTH,
36        WIN_HEIGHT,
37        "FLTK/Terminal Rust wrapper test",
38    );
39    main_win.set_type(WindowType::Double);
40    main_win.make_resizable(true);
41
42    let mut menu_bar = MenuBar::new(0, 0, WIN_WIDTH, 30, None);
43
44    let mut term = Terminal::new(0, 30, WIN_WIDTH, WIN_HEIGHT - 30, None);
45    term.set_label("term");
46    main_win.resizable(&term);
47    term.set_label_type(LabelType::None);
48
49    let idx = menu_bar.add_choice("Test&1");
50    menu_bar.at(idx).unwrap().set_callback({
51        let mut term1 = term.clone();
52        move |c| mb_test1_cb(c, &mut term1)
53    });
54    menu_bar
55        .at(idx)
56        .unwrap()
57        .set_shortcut(unsafe { std::mem::transmute(0x80031) }); // Alt-1
58
59    let idx = menu_bar.add_choice("Test&2");
60    menu_bar.at(idx).unwrap().set_callback({
61        let mut term1 = term.clone();
62        move |c| mb_test2_cb(c, &mut term1)
63    });
64    menu_bar
65        .at(idx)
66        .unwrap()
67        .set_shortcut(unsafe { std::mem::transmute(0x80032) }); // Alt-2
68
69    let idx = menu_bar.add_choice("Test&3");
70    menu_bar.at(idx).unwrap().set_callback({
71        let mut term1 = term.clone();
72        move |c| mb_test3_cb(c, &mut term1)
73    });
74    menu_bar
75        .at(idx)
76        .unwrap()
77        .set_shortcut(unsafe { std::mem::transmute(0x80033) }); // Alt-3
78
79    let idx = menu_bar.add_choice("Test&4");
80    menu_bar.at(idx).unwrap().set_callback({
81        let mut term1 = term.clone();
82        move |c| mb_test4_cb(c, &mut term1)
83    });
84    menu_bar
85        .at(idx)
86        .unwrap()
87        .set_shortcut(unsafe { std::mem::transmute(0x80034) }); // Alt-4
88
89    let idx = menu_bar.add_choice("Test&5");
90    menu_bar.at(idx).unwrap().set_callback({
91        let mut term1 = term.clone();
92        move |c| mb_test5_cb(c, &mut term1)
93    });
94    menu_bar
95        .at(idx)
96        .unwrap()
97        .set_shortcut(unsafe { std::mem::transmute(0x80035) }); // Alt-5
98
99    menu_bar.end();
100
101    main_win.end();
102    main_win.show();
103
104    // Worker thread that drives the startup tests
105    let _worker_thread: std::thread::JoinHandle<_> = std::thread::spawn({
106        let mut term = term.clone();
107        move || {
108            println!("Startup tests\n");
109            term.append("Startup tests\n\n");
110            term.append("<tmp>\n"); // This line will be overwritten later
111
112            term.cursor_up(2, false);
113            assert_eq!(term.text(false), "Startup tests\n\n"); // Ignores lines below cursor
114            assert_eq!(
115                term.text(true),
116                "Startup tests\n\n<tmp>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
117            );
118
119            // Testing ansi() and set_ansi() methods
120            assert!(term.ansi(), "Default ANSI mode should be ON at startup");
121            term.append("ANSI mode is \x1b[4mON\x1b[0m\n");
122            term.set_ansi(false);
123            assert!(!term.ansi());
124            term.append("ANSI mode is \x1b[4mOFF\x1b[0m\n");
125            // append() method is already being used/tested. Test the u8, ascii, and utf8 variants
126            term.append_u8(b"Appending u8 array\n");
127            term.append_ascii("Appending ASCII array ↑ (up-arrow is dropped)\n");
128            term.set_ansi(true); // Restore ANSI state
129
130            // Play with the horizontal scrollbar
131            assert_eq!(term.hscrollbar_style(), ScrollbarStyle::AUTO);
132            term.set_hscrollbar_style(ScrollbarStyle::ON);
133            assert_eq!(term.hscrollbar_style(), ScrollbarStyle::ON);
134
135            // Test show_unknown() as incidental part of testing append methods
136            term.set_show_unknown(true);
137            assert!(term.show_unknown());
138            term.append_ascii(
139                "Appending ASCII array with show_unknown() ↑ (up-arrow is three unknown bytes)\n",
140            );
141            term.set_show_unknown(false);
142            assert!(!term.show_unknown());
143
144            term.append_utf8("Appending UTF8 array ↑ (up-arrow is visible)\n");
145            term.append_utf8_u8(b"Appending UTF8 array as u8 \xe2\x86\x91 (up-arrow is visible)\n");
146
147            let r = term.cursor_row();
148            assert_eq!(term.cursor_col(), 0);
149            term.append(&format!("Testing cursor row/col {r}"));
150            assert_eq!(term.cursor_col(), 24);
151            assert_eq!(term.cursor_row(), r);
152
153            // Test cursor color methods
154            assert_eq!(
155                term.cursor_bg_color(),
156                Color::XtermGreen,
157                "Default cursor bg at startup"
158            );
159            term.set_cursor_bg_color(Color::Red);
160            assert_eq!(term.cursor_bg_color(), Color::Red);
161            term.set_cursor_fg_color(Color::Blue);
162            assert_eq!(term.cursor_bg_color(), Color::Red);
163            assert_eq!(term.cursor_fg_color(), Color::Blue);
164            term.set_cursor_bg_color(Color::XtermGreen); // Restore the defaults
165            term.set_cursor_fg_color(Color::from_hex(0xff_ff_f0));
166            assert_eq!(term.cursor_bg_color(), Color::XtermGreen);
167            assert_eq!(term.cursor_fg_color(), Color::from_hex(0xff_ff_f0));
168
169            // The default display_rows() will derive from the window size
170            let dr = term.display_rows();
171            let height = term.h();
172            assert_eq!(height, term.h());
173            assert!(dr > 20, "Default display_rows at startup");
174            term.resize(term.x(), term.y(), term.w(), height * 2);
175            assert_eq!(term.h(), height * 2);
176            assert_eq!(height * 2, term.h());
177            assert!(term.display_rows() > dr);
178            term.resize(term.x(), term.y(), term.w(), height);
179
180            // The default display_columns() will derive from the window size
181            let dc = term.display_columns();
182            assert!(dc > 80, "Default display_rows at startup");
183            term.set_display_columns(200);
184            assert_eq!(term.display_columns(), 200);
185            term.append("\n         1         2         3         4         5         6         7         8         9");
186            term.append("\n123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
187            term.append("[This text should be truncated by display_columns() call below.]\n"); // We shouldn't see this on screen
188            term.set_display_columns(90);
189            assert_eq!(term.display_columns(), 90);
190            term.set_display_columns(dc); // Set back to default
191            assert_eq!(term.display_columns(), dc);
192
193            assert_eq!(term.history_rows(), 100, "Default history_rows at startup");
194            term.set_history_rows(50);
195            assert_eq!(term.history_rows(), 50);
196            term.set_history_rows(100); // Set back to default
197            assert_eq!(term.history_rows(), 100);
198
199            let hu = term.history_use();
200            term.append(&format!(
201                "history_use = {hu} (it's not clear what this means)\n"
202            ));
203            // assert_eq!(term.history_use(), hu+1);
204
205            term.append(&format!(
206                "margins = b:{} l:{} r:{} t{}\n",
207                term.margin_bottom(),
208                term.margin_left(),
209                term.margin_right(),
210                term.margin_top()
211            ));
212            assert_eq!(term.margin_bottom(), 3);
213            assert_eq!(term.margin_left(), 3);
214            assert_eq!(term.margin_right(), 3);
215            assert_eq!(term.margin_top(), 3);
216
217            term.set_margin_bottom(5);
218            term.set_margin_left(10);
219            term.set_margin_right(15);
220            term.set_margin_top(20);
221            assert_eq!(term.margin_bottom(), 5);
222            assert_eq!(term.margin_left(), 10);
223            assert_eq!(term.margin_right(), 15);
224            assert_eq!(term.margin_top(), 20);
225
226            term.append("Single character: '");
227            term.print_char('X');
228            term.append("', single UTF-8 character: '");
229            term.print_char_utf8('↑');
230            term.append("'\n");
231
232            let rr = term.redraw_rate();
233            assert_eq!(rr, 0.1, "Default redraw rate at startup");
234            term.append(&format!("Redraw rate {rr}\n"));
235            term.set_redraw_rate(1.0);
236            assert_eq!(term.redraw_rate(), 1.0);
237            term.set_redraw_rate(rr);
238            assert_eq!(term.redraw_rate(), rr);
239
240            let rs = term.redraw_style();
241            term.append(&format!("Redraw style {rs:?}\n"));
242            assert_eq!(
243                rs,
244                RedrawStyle::RateLimited,
245                "Default redraw style at startup"
246            );
247            term.set_redraw_style(RedrawStyle::NoRedraw);
248            assert_eq!(term.redraw_style(), RedrawStyle::NoRedraw);
249            term.set_redraw_style(rs);
250            assert_eq!(term.redraw_style(), rs);
251
252            // Sanity checks: enum values are implicitly assigned in the C++ code so could change unexpectedly
253            assert_eq!(
254                RedrawStyle::NoRedraw.bits(),
255                0x0000,
256                "RedrawStyle enum values have been reassigned"
257            );
258            assert_eq!(
259                RedrawStyle::RateLimited.bits(),
260                0x0001,
261                "RedrawStyle enum values have been reassigned"
262            );
263            assert_eq!(
264                RedrawStyle::PerWrite.bits(),
265                0x0002,
266                "RedrawStyle enum values have been reassigned"
267            );
268
269            let sb = term.scrollbar();
270            let hsb = term.hscrollbar();
271            // Both vertical and horizontal scrollbars are at zero
272            assert_eq!(sb.value(), 0.0);
273            assert_eq!(hsb.value(), 0.0);
274            term.set_hscrollbar_style(ScrollbarStyle::AUTO);
275
276            term.append(&format!(
277                "Scrollbar actual size {}\n",
278                term.scrollbar_actual_size()
279            ));
280            assert_eq!(term.scrollbar_actual_size(), 16);
281            term.append(&format!("Scrollbar size {}\n", term.scrollbar_size()));
282            assert_eq!(
283                term.scrollbar_size(),
284                0,
285                "Default scrollbar size at startup"
286            );
287            term.set_scrollbar_size(40);
288            assert_eq!(term.scrollbar_size(), 40);
289            assert_eq!(term.scrollbar_actual_size(), 40);
290            term.append(&format!(
291                "Scrollbar actual size {}\n",
292                term.scrollbar_actual_size()
293            ));
294            term.set_scrollbar_size(0); // Restore default
295            assert_eq!(term.scrollbar_size(), 0);
296            assert_eq!(term.scrollbar_actual_size(), 16);
297
298            let sfc = term.selection_fg_color();
299            let sbc = term.selection_bg_color();
300            assert_eq!(sfc, Color::Black);
301            assert_eq!(sbc, Color::White);
302            term.append(&format!("Selection colors: {sfc} {sbc}\n"));
303            term.set_selection_fg_color(Color::Green);
304            term.set_selection_bg_color(Color::DarkBlue);
305            assert_eq!(term.selection_fg_color(), Color::Green);
306            assert_eq!(term.selection_bg_color(), Color::DarkBlue);
307            term.set_selection_fg_color(sfc);
308            term.set_selection_bg_color(sbc);
309            assert_eq!(term.selection_fg_color(), Color::Black);
310            assert_eq!(term.selection_bg_color(), Color::White);
311
312            let tfcd = term.text_fg_color_default();
313            let tbcd = term.text_bg_color_default();
314            assert_eq!(tfcd, Color::XtermWhite);
315            assert_eq!(tbcd, Color::TransparentBg);
316            term.append(&format!("Default text colors: {sfc} {sbc}\n"));
317            term.set_text_fg_color_default(Color::Green);
318            term.set_text_bg_color_default(Color::DarkBlue);
319            assert_eq!(term.text_fg_color_default(), Color::Green);
320            assert_eq!(term.text_bg_color_default(), Color::DarkBlue);
321            term.set_text_fg_color_default(tfcd);
322            term.set_text_bg_color_default(tbcd);
323            assert_eq!(term.text_fg_color_default(), Color::XtermWhite);
324            assert_eq!(term.text_bg_color_default(), Color::TransparentBg);
325
326            let tfc = term.text_fg_color();
327            let tbc = term.text_bg_color();
328            assert_eq!(tfc, Color::XtermWhite);
329            assert_eq!(tbc, Color::TransparentBg);
330            term.append(&format!("Text colors: {sfc} {sbc}\n"));
331            term.set_text_fg_color(Color::Green);
332            term.set_text_bg_color(Color::DarkBlue);
333            assert_eq!(term.text_fg_color(), Color::Green);
334            assert_eq!(term.text_bg_color(), Color::DarkBlue);
335            term.set_text_fg_color(tfc);
336            term.set_text_bg_color(tbc);
337            assert_eq!(term.text_fg_color(), Color::XtermWhite);
338            assert_eq!(term.text_bg_color(), Color::TransparentBg);
339
340            let tf = term.text_font();
341            term.append(&format!("Text font: {tf:?}\n"));
342            assert_eq!(tf, Font::Courier);
343            term.set_text_font(Font::Screen);
344            assert_eq!(term.text_font(), Font::Screen);
345            term.set_text_font(tf);
346            assert_eq!(term.text_font(), Font::Courier);
347
348            let ts = term.text_size();
349            let r = term.h_to_row(100);
350            let c = term.w_to_col(100);
351            term.append(&format!(
352                "Text size: {ts}, h_to_row(100): {r}, w_to_col(100): {c}\n"
353            ));
354            assert_eq!(ts, 14);
355            term.set_text_size(30);
356            assert_eq!(term.text_size(), 30);
357            term.append(&format!(
358                "Text size: {}, h_to_row(100): {}, w_to_col(100): {}\n",
359                term.text_size(),
360                term.h_to_row(100),
361                term.w_to_col(100)
362            ));
363            term.set_text_size(ts);
364            assert_eq!(term.text_size(), ts);
365            term.append(&format!(
366                "Text size: {}, h_to_row(100): {}, w_to_col(100): {}\n",
367                term.text_size(),
368                term.h_to_row(100),
369                term.w_to_col(100)
370            ));
371
372            // Keyboard handler
373            term.handle({
374                move |term, e| {
375                    match e {
376                        fltk::enums::Event::KeyDown
377                            if fltk::app::event_key() == fltk::enums::Key::Escape =>
378                        {
379                            // false to let FLTK handle ESC. true to hide ESC
380                            false
381                        }
382
383                        fltk::enums::Event::KeyDown
384                            if fltk::app::event_length() == 1 && fltk::app::is_event_ctrl() =>
385                        {
386                            // We handle control keystroke
387                            let k = fltk::app::event_text().unwrap();
388                            term.append_utf8(&k);
389                            true
390                        }
391
392                        fltk::enums::Event::KeyDown
393                            if fltk::app::event_length() == 1 && !fltk::app::is_event_alt() =>
394                        {
395                            // We handle normal printable keystroke
396                            let k = fltk::app::event_text().unwrap();
397                            term.take_focus().unwrap();
398                            term.append(&k);
399                            true
400                        }
401
402                        // fltk docs say that keyboard handler should always claim Focus and Unfocus events
403                        // We can do this, or else ignore them (return false)
404                        // fltk::enums::Event::Focus | fltk::enums::Event::Unfocus => {
405                        //     term.redraw();
406                        //     true
407                        // }
408                        _ => false, // Let FLTK handle everything else
409                    }
410                }
411            });
412
413            let attr_save = term.text_attrib();
414            term.set_text_attrib(Attrib::Inverse | Attrib::Italic);
415            term.append("\nStartup tests complete. Keyboard is live.\n");
416            assert_eq!(term.text_attrib(), Attrib::Inverse | Attrib::Italic);
417            term.set_text_attrib(attr_save);
418            assert_eq!(term.text_attrib(), attr_save);
419            term.redraw();
420        }
421    });
422
423    app.run().unwrap();
424}
Source

pub fn default_fill() -> Self

Constructs a widget with the size of its parent

Trait Implementations§

Source§

impl Clone for MenuBar

Source§

fn clone(&self) -> MenuBar

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MenuBar

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MenuBar

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl IntoIterator for MenuBar

Source§

type Item = MenuItem

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<MenuBar as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl MenuExt for MenuBar

Source§

fn add<F: FnMut(&mut Self) + 'static>( &mut self, name: &str, shortcut: Shortcut, flag: MenuFlag, cb: F, ) -> i32

Add a menu item along with its callback. The characters “&”, “/”, “\”, and “_” (underscore) are treated as special characters in the label string. The “&” character specifies that the following character is an accelerator and will be underlined. The “\” character is used to escape the next character in the string. Labels starting with the “_” (underscore) character cause a divider to be placed after that menu item. Takes the menu item as a closure argument
Source§

fn insert<F: FnMut(&mut Self) + 'static>( &mut self, idx: i32, name: &str, shortcut: Shortcut, flag: MenuFlag, cb: F, ) -> i32

Inserts a menu item at an index along with its callback. The characters “&”, “/”, “\”, and “_” (underscore) are treated as special characters in the label string. The “&” character specifies that the following character is an accelerator and will be underlined. The “\” character is used to escape the next character in the string. Labels starting with the “_” (underscore) character cause a divider to be placed after that menu item. Takes the menu item as a closure argument
Source§

fn add_emit<T: 'static + Clone + Send + Sync>( &mut self, label: &str, shortcut: Shortcut, flag: MenuFlag, sender: Sender<T>, msg: T, ) -> i32

Add a menu item along with an emit (sender and message). The characters “&”, “/”, “\”, and “_” (underscore) are treated as special characters in the label string. The “&” character specifies that the following character is an accelerator and will be underlined. The “\” character is used to escape the next character in the string. Labels starting with the “_” (underscore) character cause a divider to be placed after that menu item.
Source§

fn insert_emit<T: 'static + Clone + Send + Sync>( &mut self, idx: i32, label: &str, shortcut: Shortcut, flag: MenuFlag, sender: Sender<T>, msg: T, ) -> i32

Inserts a menu item along with an emit (sender and message). The characters “&”, “/”, “\”, and “_” (underscore) are treated as special characters in the label string. The “&” character specifies that the following character is an accelerator and will be underlined. The “\” character is used to escape the next character in the string. Labels starting with the “_” (underscore) character cause a divider to be placed after that menu item.
Source§

fn remove(&mut self, idx: i32)

Remove a menu item by index
Source§

fn find_item(&self, name: &str) -> Option<MenuItem>

Get a menu item by name
Source§

fn set_item(&mut self, item: &MenuItem) -> bool

Set selected item
Source§

fn find_index(&self, label: &str) -> i32

Find an item’s index by its label
Source§

fn text_font(&self) -> Font

Return the text font
Source§

fn set_text_font(&mut self, c: Font)

Sets the text font
Source§

fn text_size(&self) -> i32

Return the text size
Source§

fn set_text_size(&mut self, c: i32)

Sets the text size
Source§

fn text_color(&self) -> Color

Return the text color
Source§

fn set_text_color(&mut self, c: Color)

Sets the text color
Source§

fn add_choice(&mut self, text: &str) -> i32

Adds a simple text option to the Choice and MenuButton widgets. The characters “&”, “/”, “\”, “|”, and “_” (underscore) are treated as special characters in the label string. The “&” character specifies that the following character is an accelerator and will be underlined. The “\” character is used to escape the next character in the string. Labels starting with the “_” (underscore) character cause a divider to be placed after that menu item.
Source§

fn choice(&self) -> Option<String>

Gets the user choice from the Choice and MenuButton widgets
Source§

fn value(&self) -> i32

Get index into menu of the last item chosen, returns -1 if no item was chosen
Source§

fn set_value(&mut self, v: i32) -> bool

Set index into menu of the last item chosen,return true if the new value is different than the old one
Source§

fn clear(&mut self)

Clears the items in a menu, effectively deleting them.
Source§

unsafe fn unsafe_clear(&mut self)

Clears the items in a menu, effectively deleting them, and recursively force-cleans capturing callbacks Read more
Source§

fn clear_submenu(&mut self, idx: i32) -> Result<(), FltkError>

Clears a submenu by index Read more
Source§

fn size(&self) -> i32

Get the size of the menu widget
Source§

fn text(&self, idx: i32) -> Option<String>

Get the text label of the menu item at index idx
Source§

fn at(&self, idx: i32) -> Option<MenuItem>

Get the menu item at an index
Source§

fn mode(&self, idx: i32) -> MenuFlag

Get the mode of a menu item by index and flag
Source§

fn set_mode(&mut self, idx: i32, flag: MenuFlag)

Set the mode of a menu item
Source§

fn end(&mut self)

End the menu
Source§

fn set_down_frame(&mut self, f: FrameType)

Set the down_box of the widget
Source§

fn down_frame(&self) -> FrameType

Get the down frame type of the widget
Source§

fn global(&mut self)

Make a menu globally accessible from any window
Source§

fn menu(&self) -> Option<MenuItem>

Get the menu element
Source§

unsafe fn set_menu(&mut self, item: MenuItem)

Set the menu element Read more
Source§

fn item_pathname(&self, item: Option<&MenuItem>) -> Result<String, FltkError>

Get an item’s pathname
Source§

fn set_menu_frame(&mut self, f: FrameType)

Set the menu’s popup frame type
Source§

fn menu_frame(&self) -> FrameType

Get the menu’s popup frame type
Source§

fn mvalue(&self) -> Option<MenuItem>

Get the selected menu item
Source§

fn prev_mvalue(&self) -> Option<MenuItem>

Get the previously selected menu item
Source§

impl PartialEq for MenuBar

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl WidgetBase for MenuBar

Source§

fn delete(wid: Self)

Deletes widgets and their children.
Source§

unsafe fn from_widget_ptr(ptr: *mut Fl_Widget) -> Self

transforms a widget pointer to a Widget, for internal use Read more
Source§

unsafe fn from_widget<W: WidgetExt>(w: W) -> Self

Get a widget from base widget Read more
Source§

fn handle<F: FnMut(&mut Self, Event) -> bool + 'static>(&mut self, cb: F)

Set a custom handler, where events are managed manually, akin to 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 here
Source§

fn draw<F: FnMut(&mut Self) + 'static>(&mut self, cb: F)

Set a custom draw method. takes the widget as a closure argument. macOS requires that WidgetBase::draw actually calls drawing functions
Source§

fn resize_callback<F: FnMut(&mut Self, i32, i32, i32, i32) + 'static>( &mut self, cb: F, )

Perform a callback on resize. Avoid resizing the parent or the same widget to avoid infinite recursion
Source§

unsafe fn assume_derived(&mut self)

Makes the widget derived Read more
Source§

fn from_dyn_widget<W: WidgetExt>(w: &W) -> Option<Self>

Cast a type-erased widget back to its original widget
Source§

fn from_dyn_widget_ptr(w: *mut Fl_Widget) -> Option<Self>

Cast a type-erased widget pointer back to its original widget
Source§

impl WidgetExt for MenuBar

Source§

fn set_label(&mut self, title: &str)

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

fn unset_label(&mut self)

Unset a widget’s label
Source§

fn redraw(&mut self)

Redraws a widget, necessary for resizing and changing positions
Source§

fn show(&mut self)

Shows the widget
Source§

fn hide(&mut self)

Hides the widget
Source§

fn x(&self) -> i32

Returns the x coordinate of the widget
Source§

fn y(&self) -> i32

Returns the y coordinate of the widget
Source§

fn w(&self) -> i32

Returns the width of the widget
Source§

fn h(&self) -> i32

Returns the height of the widget
Source§

fn label(&self) -> Option<String>

Returns the label of the widget
Source§

fn measure_label(&self) -> (i32, i32)

Measures the label’s width and height
Source§

fn as_widget_ptr(&self) -> *mut Fl_Widget

transforms a widget to a base Fl_Widget, for internal use
Source§

fn activate(&mut self)

Activates the widget
Source§

fn deactivate(&mut self)

Deactivates the widget
Source§

fn redraw_label(&mut self)

Redraws the label of the widget
Source§

fn resize(&mut self, x: i32, y: i32, width: i32, height: i32)

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

fn widget_resize(&mut self, x: i32, y: i32, width: i32, height: i32)

Does a simple resize ignoring class-specific resize functionality
Source§

fn tooltip(&self) -> Option<String>

Returns the tooltip text
Source§

fn set_tooltip(&mut self, txt: &str)

Sets the tooltip text
Source§

fn color(&self) -> Color

Returns the widget color
Source§

fn set_color(&mut self, color: Color)

Sets the widget’s color
Source§

fn label_color(&self) -> Color

Returns the widget label’s color
Source§

fn set_label_color(&mut self, color: Color)

Sets the widget label’s color
Source§

fn label_font(&self) -> Font

Returns the widget label’s font
Source§

fn set_label_font(&mut self, font: Font)

Sets the widget label’s font
Source§

fn label_size(&self) -> i32

Returns the widget label’s size
Source§

fn set_label_size(&mut self, sz: i32)

Sets the widget label’s size
Source§

fn label_type(&self) -> LabelType

Returns the widget label’s type
Source§

fn set_label_type(&mut self, typ: LabelType)

Sets the widget label’s type
Source§

fn frame(&self) -> FrameType

Returns the widget’s frame type
Source§

fn set_frame(&mut self, typ: FrameType)

Sets the widget’s frame type
Source§

fn changed(&self) -> bool

Returns whether the widget was changed
Source§

fn set_changed(&mut self)

Mark the widget as changed
Source§

fn clear_changed(&mut self)

Clears the changed status of the widget
Source§

fn align(&self) -> Align

Returns the alignment of the widget
Source§

fn set_align(&mut self, align: Align)

Sets the alignment of the widget
Source§

fn set_when(&mut self, trigger: When)

Sets the default callback trigger for a widget, equivalent to when()
Source§

fn when(&self) -> When

Return the callback trigger, equivalent to when()
Source§

fn parent(&self) -> Option<Group>

Returns the parent of the widget
Source§

fn selection_color(&self) -> Color

Gets the selection color of the widget
Source§

fn set_selection_color(&mut self, color: Color)

Sets the selection color of the widget
Source§

fn do_callback(&mut self)

Runs the already registered callback
Source§

fn window(&self) -> Option<Box<dyn WindowExt>>

Returns the direct window holding the widget
Source§

fn top_window(&self) -> Option<Box<dyn WindowExt>>

Returns the topmost window holding the widget
Source§

fn takes_events(&self) -> bool

Checks whether a widget is capable of taking events
Source§

fn take_focus(&mut self) -> Result<(), FltkError>

Make the widget take focus Read more
Source§

fn set_visible_focus(&mut self)

Set the widget to have visible focus
Source§

fn clear_visible_focus(&mut self)

Clear visible focus
Source§

fn visible_focus(&mut self, v: bool)

Set the visible focus using a flag
Source§

fn has_visible_focus(&self) -> bool

Return whether the widget has visible focus
Source§

fn has_focus(&self) -> bool

Return whether the widget has focus
Source§

fn was_deleted(&self) -> bool

Check if a widget was deleted
Source§

fn damage(&self) -> bool

Return whether the widget was damaged
Source§

fn set_damage(&mut self, flag: bool)

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

fn damage_type(&self) -> Damage

Return the damage mask
Source§

fn set_damage_type(&mut self, mask: Damage)

Signal the type of damage a widget received
Source§

fn set_damage_area(&mut self, mask: Damage, x: i32, y: i32, w: i32, h: i32)

Signal damage for an area inside the widget
Source§

fn clear_damage(&mut self)

Clear the damaged flag
Source§

fn as_window(&self) -> Option<Box<dyn WindowExt>>

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

fn as_group(&self) -> Option<Group>

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

fn inside<W: WidgetExt>(&self, wid: &W) -> bool

Checks whether the self widget is inside another widget
Source§

fn get_type<T: WidgetType>(&self) -> T

Returns the widget type when applicable
Source§

fn set_type<T: WidgetType>(&mut self, typ: T)

Sets the widget type
Source§

fn set_image<I: ImageExt>(&mut self, image: Option<I>)

Sets the image of the widget
Source§

fn set_image_scaled<I: ImageExt>(&mut self, image: Option<I>)

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

fn image(&self) -> Option<Box<dyn ImageExt>>

Gets the image associated with the widget
Source§

fn set_deimage<I: ImageExt>(&mut self, image: Option<I>)

Sets the deactivated image of the widget
Source§

fn set_deimage_scaled<I: ImageExt>(&mut self, image: Option<I>)

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

fn deimage(&self) -> Option<Box<dyn ImageExt>>

Gets the deactivated image associated with the widget
Source§

fn set_callback<F: FnMut(&mut Self) + 'static>(&mut self, cb: F)

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

fn emit<T: 'static + Clone + Send + Sync>(&mut self, sender: Sender<T>, msg: T)

Emits a message on callback using a sender
Source§

unsafe fn as_widget<W: WidgetBase>(&self) -> W

Upcast a WidgetExt to some widget type Read more
Source§

fn visible(&self) -> bool

Returns whether a widget is visible
Source§

fn visible_r(&self) -> bool

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

fn is_same<W: WidgetExt>(&self, other: &W) -> bool

Return whether two widgets object point to the same widget
Source§

fn active(&self) -> bool

Returns whether a widget is active
Source§

fn active_r(&self) -> bool

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

fn handle_event(&mut self, event: Event) -> bool

Handle a specific event
Source§

fn is_derived(&self) -> bool

Check whether a widget is derived
Source§

fn as_base_widget(&self) -> Widget
where Self: Sized,

Upcast a WidgetExt to a Widget
Source§

impl WidgetProps for MenuBar

Source§

fn with_pos(self, x: i32, y: i32) -> Self

Initialize to position x, y

Source§

fn with_size(self, width: i32, height: i32) -> Self

Initialize to size width, height

Source§

fn with_label(self, title: &str) -> Self

Initialize with a label

Source§

fn with_align(self, align: Align) -> Self

Initialize with alignment

Source§

fn with_type<T: WidgetType>(self, typ: T) -> Self

Initialize with type

Source§

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

Initialize above of another widget

Source§

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

Initialize left of another widget

Source§

fn center_of<W: WidgetExt>(self, w: &W) -> Self

Initialize center of another widget

Source§

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

Initialize center of another widget on the y axis

Source§

fn center_of_parent(self) -> Self

Initialize center of parent

Source§

fn size_of<W: WidgetExt>(self, w: &W) -> Self

Initialize to the size of another widget

Source§

fn size_of_parent(self) -> Self

Initialize to the size of the parent

Source§

impl Eq for MenuBar

Source§

impl Send for MenuBar

Available on non-crate feature single-threaded only.
Source§

impl Sync for MenuBar

Available on non-crate feature single-threaded only.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<W> WidgetId<W> for W
where W: WidgetExt + Clone + Send + Sync + 'static,

Source§

fn set_id(&mut self, id: &str)

Set the widget’s Id
Source§

fn with_id(self, id: &str) -> W

Construct a widget with an Id