fltk_builder/extensions/builder/
input.rs1use fltk::{
2 enums::{Color, Font},
3 prelude::InputExt,
4};
5
6pub trait InputBuilderExt {
8 fn with_value(self, val: &str) -> Self;
10 fn with_maximum_size(self, val: i32) -> Self;
12 fn with_text_font(self, font: Font) -> Self;
14 fn with_text_color(self, color: Color) -> Self;
16 fn with_text_size(self, sz: i32) -> Self;
18 fn as_readonly(self, val: bool) -> Self;
20 fn as_wrap(self, val: bool) -> Self;
22}
23
24impl<I> InputBuilderExt for I
25where
26 I: InputExt,
27{
28 fn with_value(mut self, val: &str) -> Self {
29 self.set_value(val);
30 self
31 }
32
33 fn with_maximum_size(mut self, val: i32) -> Self {
34 self.set_maximum_size(val);
35 self
36 }
37
38 fn with_text_font(mut self, font: Font) -> Self {
39 self.set_text_font(font);
40 self
41 }
42
43 fn with_text_color(mut self, color: Color) -> Self {
44 self.set_text_color(color);
45 self
46 }
47
48 fn with_text_size(mut self, sz: i32) -> Self {
49 self.set_text_size(sz);
50 self
51 }
52
53 fn as_readonly(mut self, val: bool) -> Self {
54 self.set_readonly(val);
55 self
56 }
57
58 fn as_wrap(mut self, val: bool) -> Self {
59 self.set_wrap(val);
60 self
61 }
62}