Struct DoubleWindow

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

Creates a double (buffered) window widget

Implementations§

Source§

impl DoubleWindow

Source

pub unsafe fn find_by_handle(handle: RawHandle) -> Option<impl WindowExt>

Find an Fl_Window through a raw handle. The window must have been instantiated by the app. void * to: (Windows: HWND, X11: Xid (u64), macOS: NSWindow)

§Safety

The data must be valid and is OS-dependent.

Source

pub fn show_with_env_args(&mut self)

Use FLTK specific arguments for the application: More info here. The options are:

  • -bg2 color
  • -bg color
  • -di[splay] host:n.n
  • -dn[d]
  • -fg color
  • -g[eometry] WxH+X+Y
  • -i[conic]
  • -k[bd]
  • -na[me] classname
  • -nod[nd]
  • -nok[bd]
  • -not[ooltips]
  • -s[cheme] scheme
  • -ti[tle] windowtitle
  • -to[oltips]
Examples found in repository?
examples/animations.rs (line 66)
56fn main() {
57    let app = app::App::default();
58    let mut wind = Window::default().with_label("timeout").with_size(720, 486);
59    wind.set_center_screen();
60    let mut frame = Frame::new(-200, 150, 200, 200, "");
61    let mut pxm = Pixmap::new(PXM).unwrap();
62    pxm.scale(200, 200, true, true);
63    frame.set_image_scaled(Some(pxm));
64    wind.set_color(enums::Color::White);
65    wind.end();
66    wind.show_with_env_args();
67
68    app::add_timeout(0.016, move |handle| {
69        let frame = frame.clone();
70        move_image(frame, handle);
71    });
72    app.run().unwrap();
73}
Source

pub fn show_with_args(&mut self, args: &[&str])

Use FLTK specific arguments for the application: More info here. The options are:

  • -bg2 color
  • -bg color
  • -di[splay] host:n.n
  • -dn[d]
  • -fg color
  • -g[eometry] WxH+X+Y
  • -i[conic]
  • -k[bd]
  • -na[me] classname
  • -nod[nd]
  • -nok[bd]
  • -not[ooltips]
  • -s[cheme] scheme
  • -ti[tle] windowtitle
  • -to[oltips]
Examples found in repository?
examples/calculator.rs (line 156)
89fn main() {
90    let app = app::App::default();
91    let win_w = 400;
92    let win_h = 500;
93    let border = 20;
94    let but_row = 180;
95
96    let mut operation = Ops::None;
97    let mut txt = String::from("0");
98    let mut old_val = String::from("0");
99    let mut new_val: String;
100
101    let mut wind = Window::default()
102        .with_label("FLTK Calc")
103        .with_size(win_w, win_h);
104    wind.set_center_screen();
105    wind.set_color(Color::Light3);
106
107    let mut out = Output::new(border, border, win_w - 40, 140, "");
108    out.set_text_size(36);
109    out.set_value("0");
110
111    let vpack = Pack::new(border, but_row, win_w - 40, 300, "");
112
113    let mut hpack = Pack::new(0, 0, win_w - 40, 60, "");
114    let but_ce = MyButton::new("CE");
115    let but_c = MyButton::new("C");
116    let but_back = MyButton::new("@<-");
117    let but_div = MyButton::new("/");
118    hpack.end();
119    hpack.set_type(PackType::Horizontal);
120
121    let mut hpack = Pack::new(0, 0, win_w - 40, 60, "");
122    let mut but7 = MyButton::new("7");
123    let mut but8 = MyButton::new("8");
124    let mut but9 = MyButton::new("9");
125    let but_mul = MyButton::new("x");
126    hpack.end();
127    hpack.set_type(PackType::Horizontal);
128
129    let mut hpack = Pack::new(0, 0, win_w - 40, 60, "");
130    let mut but4 = MyButton::new("4");
131    let mut but5 = MyButton::new("5");
132    let mut but6 = MyButton::new("6");
133    let but_sub = MyButton::new("-");
134    hpack.end();
135    hpack.set_type(PackType::Horizontal);
136
137    let mut hpack = Pack::new(0, 0, win_w - 40, 60, "");
138    let mut but1 = MyButton::new("1");
139    let mut but2 = MyButton::new("2");
140    let mut but3 = MyButton::new("3");
141    let but_add = MyButton::new("+");
142    hpack.end();
143    hpack.set_type(PackType::Horizontal);
144
145    let mut hpack = Pack::new(0, 0, win_w - 40, 60, "");
146    let mut but_dot = MyButton::new(".");
147    let mut but0 = MyButton::new("0");
148    let but_eq = MyButton::new("=");
149    hpack.end();
150    hpack.set_type(PackType::Horizontal);
151
152    vpack.end();
153
154    wind.make_resizable(false);
155    wind.end();
156    wind.show_with_args(&["-scheme", "gtk+", "-nokbd"]);
157
158    app::set_focus(&*but1);
159
160    let but_vec = vec![
161        &mut but1, &mut but2, &mut but3, &mut but4, &mut but5, &mut but6, &mut but7, &mut but8,
162        &mut but9, &mut but0,
163    ];
164
165    let but_op_vec = vec![
166        but_add, but_sub, but_mul, but_div, but_c, but_ce, but_back, but_eq,
167    ];
168
169    let (s, r) = app::channel::<Message>();
170
171    for but in but_vec {
172        let label = but.label().unwrap();
173        but.emit(s, Message::Number(label.parse().unwrap()));
174    }
175
176    for mut but in but_op_vec {
177        let op = match but.label().unwrap().as_str() {
178            "+" => Ops::Add,
179            "-" => Ops::Sub,
180            "x" => Ops::Mul,
181            "/" => Ops::Div,
182            "=" => Ops::Eq,
183            "CE" => Ops::CE,
184            "C" => Ops::C,
185            "@<-" => Ops::Back,
186            _ => Ops::None,
187        };
188        but.emit(s, Message::Op(op));
189    }
190
191    but_dot.emit(s, Message::Dot);
192
193    while app.wait() {
194        if let Some(val) = r.recv() {
195            match val {
196                Message::Number(num) => {
197                    if out.value() == "0" {
198                        txt.clear();
199                    }
200                    txt.push_str(&num.to_string());
201                    out.set_value(txt.as_str());
202                }
203                Message::Dot => {
204                    if operation == Ops::Eq {
205                        txt.clear();
206                        operation = Ops::None;
207                        out.set_value("0.");
208                        txt.push_str("0.");
209                    }
210                    if !txt.contains('.') {
211                        txt.push('.');
212                        out.set_value(txt.as_str());
213                    }
214                }
215                Message::Op(op) => match op {
216                    Ops::Add | Ops::Sub | Ops::Div | Ops::Mul => {
217                        old_val.clear();
218                        old_val.push_str(&out.value());
219                        operation = op;
220                        out.set_value("0");
221                    }
222                    Ops::Back => {
223                        let val = out.value();
224                        txt.pop();
225                        if val.len() > 1 {
226                            out.set_value(txt.as_str());
227                        } else {
228                            out.set_value("0");
229                        }
230                    }
231                    Ops::CE => {
232                        txt.clear();
233                        old_val.clear();
234                        txt.push('0');
235                        out.set_value(txt.as_str());
236                    }
237                    Ops::C => {
238                        txt.clear();
239                        txt.push('0');
240                        out.set_value(txt.as_str());
241                    }
242                    Ops::Eq => {
243                        new_val = out.value();
244                        let old: f64 = old_val.parse().unwrap();
245                        let new: f64 = new_val.parse().unwrap();
246                        let val = match operation {
247                            Ops::Div => old / new,
248                            Ops::Mul => old * new,
249                            Ops::Add => old + new,
250                            Ops::Sub => old - new,
251                            _ => new,
252                        };
253                        operation = Ops::None;
254                        txt = String::from("0");
255                        out.set_value(&val.to_string());
256                    }
257                    _ => (),
258                },
259            }
260        }
261    }
262}
Source

pub fn set_on_top(&mut self)

Set the window to be on top of other windows. Must only be called after the window has been shown.

Source

pub fn maximize(&mut self)

Maximize the window

Source

pub fn un_maximize(&mut self)

Unmaximize the window

Source

pub fn maximize_active(&self) -> bool

Checks whether the window is maximized

Source

pub fn default_xclass() -> Option<String>

Get the default XA_WM_CLASS property for all windows of your application

Source

pub fn set_default_xclass(s: &str)

Set the default XA_WM_CLASS property for all windows of your application. This should be called before showing with window

Source§

impl DoubleWindow

Source

pub fn pixels_per_unit(&self) -> f32

Returns the pixels per unit/point

Source

pub fn pixel_w(&self) -> i32

Gets the window’s width in pixels

Source

pub fn pixel_h(&self) -> i32

Gets the window’s height in pixels

Source§

impl DoubleWindow

Source

pub fn new<'a, T: Into<Option<&'a str>>>( x: i32, y: i32, w: i32, h: i32, title: T, ) -> Self

Creates a new window, with title as its window title if the window is decorated

Examples found in repository?
examples/hello_svg.rs (line 8)
5fn main() {
6    let app = app::App::default().with_scheme(app::Scheme::Gleam);
7
8    let mut wind = Window::new(100, 100, 400, 300, "Hello from rust");
9
10    let mut frame = Frame::default().with_size(360, 260).center_of_parent();
11    frame.set_frame(FrameType::EngravedBox);
12    let mut image1 = SvgImage::load("screenshots/RustLogo.svg").unwrap();
13    image1.scale(200, 200, true, true);
14    frame.set_image(Some(image1));
15
16    wind.make_resizable(true);
17    wind.end();
18    wind.show();
19
20    app.run().unwrap();
21}
More examples
Hide additional examples
examples/rounded_images.rs (line 54)
46fn main() {
47    let app = app::App::default().with_scheme(app::Scheme::Gleam);
48    app::background(0, 0, 0);
49    let image = image::SharedImage::load("screenshots/calc2.jpg")
50        .unwrap()
51        .as_rgb_image()
52        .unwrap();
53
54    let mut wind = window::Window::new(100, 100, 800, 400, "Hello from rust");
55    let row = group::Flex::default()
56        .row()
57        .with_size(800, 200)
58        .center_of_parent();
59    for i in 1..=4 {
60        let color_depth = enums::ColorDepth::from_u8(i).unwrap();
61        let image = image.convert(color_depth).unwrap();
62        RoundImageBox::new(100, image);
63    }
64    row.end();
65    wind.end();
66    wind.show();
67
68    app.run().unwrap();
69}
examples/charts.rs (line 5)
3fn main() {
4    let app = app::App::default().with_scheme(app::Scheme::Gtk);
5    let mut win = window::Window::new(100, 100, 800, 600, "Charts");
6    let mut chart = misc::Chart::default().size_of_parent();
7    chart.set_type(misc::ChartType::Pie);
8    chart.set_bounds(0.0, 100.0);
9    chart.set_text_size(18);
10    chart.add(88.4, "Rust", enums::Color::from_u32(0xcc9c59));
11    chart.add(8.4, "C++", enums::Color::Red);
12    chart.add(3.2, "C", enums::Color::Black);
13    chart.set_color(enums::Color::White);
14    let mut choice = menu::Choice::new(300, 5, 200, 40, "Chart type");
15    choice.add_choice("Bar|HorzBar|Line|Fill|Spike|Pie|SpecialPie");
16    choice.set_value(5);
17    choice.set_color(enums::Color::White);
18    win.end();
19    win.show();
20
21    choice.set_callback(move |c| {
22        chart.set_type(misc::ChartType::from_i32(c.value()));
23        chart.redraw();
24    });
25
26    app.run().unwrap();
27}
examples/tile.rs (line 30)
3fn main() {
4    let app = app::App::default();
5    let mut window = window::Window::default().with_size(300, 300);
6    window.set_frame(FrameType::NoBox);
7    window.make_resizable(true);
8
9    let dx = 20;
10    let dy = dx; // border width of resizable() - see below
11    let tile = group::Tile::default_fill();
12
13    // create the symmetrical resize box with dx and dy pixels distance, resp.
14    // from the borders of the Fl_Tile widget before all other children
15    let r = frame::Frame::new(
16        tile.x() + dx,
17        tile.y() + dy,
18        tile.w() - 2 * dx,
19        tile.h() - 2 * dy,
20        None,
21    );
22    tile.resizable(&r);
23
24    let mut box0 = frame::Frame::new(0, 0, 150, 150, "0");
25    box0.set_frame(FrameType::DownBox);
26    box0.set_color(Color::by_index(9));
27    box0.set_label_size(36);
28    box0.set_align(Align::Clip);
29
30    let mut w1 = window::Window::new(150, 0, 150, 150, "1");
31    w1.set_frame(FrameType::NoBox);
32    let mut box1 = frame::Frame::new(0, 0, 150, 150, "1\nThis is a child window");
33    box1.set_frame(FrameType::DownBox);
34    box1.set_color(Color::by_index(19));
35    box1.set_label_size(18);
36    box1.set_align(Align::Clip | Align::Inside | Align::Wrap);
37    w1.resizable(&box1);
38    w1.end();
39
40    let mut box2a = frame::Frame::new(0, 150, 70, 150, "2a");
41    box2a.set_frame(FrameType::DownBox);
42    box2a.set_color(Color::by_index(12));
43    box2a.set_label_size(36);
44    box2a.set_align(Align::Clip);
45
46    let mut box2b = frame::Frame::new(70, 150, 80, 150, "2b");
47    box2b.set_frame(FrameType::DownBox);
48    box2b.set_color(Color::by_index(13));
49    box2b.set_label_size(36);
50    box2b.set_align(Align::Clip);
51
52    let mut box3a = frame::Frame::new(150, 150, 150, 70, "3a");
53    box3a.set_frame(FrameType::DownBox);
54    box3a.set_color(Color::by_index(12));
55    box3a.set_label_size(36);
56    box3a.set_align(Align::Clip);
57
58    let mut box3b = frame::Frame::new(150, 150 + 70, 150, 80, "3b");
59    box3b.set_frame(FrameType::DownBox);
60    box3b.set_color(Color::by_index(13));
61    box3b.set_label_size(36);
62    box3b.set_align(Align::Clip);
63
64    tile.end();
65    window.end();
66
67    w1.show();
68    window.show();
69
70    app.run().unwrap();
71}
examples/terminal.rs (lines 32-38)
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 flush(&mut self)

Forces the window to be drawn, this window is also made current and calls draw()

Source

pub fn platform_show(&self)

Show a window after it had been hidden. Works on Windows and X11 systems

Source

pub fn platform_hide(&self)

Hide a window using the platforms hide call. Works on Windows and X11 systems

Trait Implementations§

Source§

impl Clone for DoubleWindow

Source§

fn clone(&self) -> DoubleWindow

Returns a duplicate 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 DoubleWindow

Source§

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

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

impl Default for DoubleWindow

Source§

fn default() -> Self

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

impl GroupExt for DoubleWindow

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

Find a widget within a group and return its index
Source§

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

Add a widget to a group
Source§

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

Insert a widget to a group at a certain index
Source§

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

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)

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)

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)

Draw a child widget, the call should be in a WidgetBase::draw method
Source§

fn update_child<W: WidgetExt>(&self, w: &mut W)

Update a child widget, the call should be in a WidgetBase::draw method
Source§

fn draw_outside_label<W: WidgetExt>(&self, w: &mut W)

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 as_group(&self) -> Group

Converts a widget implementing GroupExt into a Group widget Read more
Source§

impl IntoIterator for DoubleWindow

Source§

type Item = Widget

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<DoubleWindow 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 PartialEq for DoubleWindow

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 DoubleWindow

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 DoubleWindow

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 DoubleWindow

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 WindowExt for DoubleWindow

Source§

fn set_center_screen(&mut self)

Positions the window to the center of the screen
Source§

fn make_modal(&mut self, val: bool)

Makes a window modal, should be called before show
Source§

fn fullscreen(&mut self, val: bool)

Makes a window fullscreen. Requires that the window is resizable.
Source§

fn make_current(&mut self)

Makes the window current
Source§

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

Returns the icon of the window
Source§

fn set_icon(&mut self, image: Option<RgbImage>)

Sets the windows icon. Supported formats are bmp, jpeg, png and rgb.
Source§

fn set_cursor(&mut self, cursor: Cursor)

Sets the cursor style within the window. Needs to be called after the window is shown
Source§

fn shown(&self) -> bool

Returns whether a window is shown
Source§

fn set_border(&mut self, flag: bool)

Sets whether the window has a border
Source§

fn border(&self) -> bool

Returns whether a window has a border
Source§

fn free_position(&mut self)

Frees the position of the window
Source§

fn raw_handle(&self) -> RawHandle

Get the raw system handle of the window
Source§

fn region(&self) -> Region

Get the graphical draw region of the window
Source§

unsafe fn set_region(&mut self, region: Region)

Set the graphical draw region of the window Read more
Source§

fn iconize(&mut self)

Iconifies the window. You can tell that the window is iconized by checking that it’s shown and not visible
Source§

fn fullscreen_active(&self) -> bool

Returns whether the window is fullscreen or not
Source§

fn decorated_w(&self) -> i32

Returns the decorated width
Source§

fn decorated_h(&self) -> i32

Returns the decorated height
Source§

fn size_range(&mut self, min_w: i32, min_h: i32, max_w: i32, max_h: i32)

Set the window’s minimum width, minimum height, max width and max height. You can pass 0 as max_w and max_h to allow unlimited upward resize of the window.
Source§

fn hotspot<W: WidgetExt>(&mut self, w: &W)

Set the hotspot widget of the window
Source§

fn set_shape(&mut self, image: Option<RgbImage>)

Set the shape of the window. Supported image formats are BMP, RGB and Pixmap. The window covers non-transparent/non-black shape of the image. The image must not be scaled(resized) beforehand. The size will be adapted to the window’s size
Source§

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

Get the shape of the window
Source§

fn x_root(&self) -> i32

Get the window’s x coord from the screen
Source§

fn y_root(&self) -> i32

Get the window’s y coord from the screen
Source§

fn set_cursor_image(&mut self, image: RgbImage, hot_x: i32, hot_y: i32)

Set the cursor image
Source§

fn default_cursor(&mut self, cursor: Cursor)

Set the window’s default cursor
Source§

fn screen_num(&self) -> i32

Get the screen number
Source§

fn set_screen_num(&mut self, n: i32)

Set the screen number
Source§

fn wait_for_expose(&self)

wait for the window to be displayed after calling show(). More info here
Source§

fn opacity(&self) -> f64

Get the window’s opacity
Source§

fn set_opacity(&mut self, val: f64)

Set the window’s opacity, Ranges from 0.0 to 1.0, where 1.0 is fully opaque and 0.0 is fully transparent. This should be called on a shown window. On X11, opacity support depends on the window manager and can be queried: Read more
Source§

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

Get the window’s XA_WM_CLASS property
Source§

fn set_xclass(&mut self, s: &str)

Set the window’s XA_WM_CLASS property. This should be called before showing the window
Source§

fn clear_modal_states(&mut self)

Clear the modal state of the window
Source§

fn force_position(&mut self, flag: bool)

Forces the position of the window
Source§

fn set_override(&mut self)

removes the window border and sets the window on top, by settings the NOBORDER and OVERRIDE flags
Source§

fn is_override(&self) -> bool

Checks whether the OVERRIDE flag was set
Source§

fn set_icon_label(&mut self, label: &str)

Set the icon label
Source§

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

Get the icon label
Source§

impl Eq for DoubleWindow

Source§

impl Send for DoubleWindow

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

impl Sync for DoubleWindow

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