pub struct AndroidWindow { /* private fields */ }Expand description
An Android window
Implementations§
Source§impl AndroidWindow
impl AndroidWindow
Sourcepub fn with_label(self, title: &str) -> Self
pub fn with_label(self, title: &str) -> Self
Initialize with a label
Sourcepub fn with_align(self, align: Align) -> Self
pub fn with_align(self, align: Align) -> Self
Initialize with alignment
Sourcepub fn with_type<T: WidgetType>(self, typ: T) -> Self
pub fn with_type<T: WidgetType>(self, typ: T) -> Self
Initialize with type
Sourcepub fn below_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
pub fn below_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize at bottom of another widget
Sourcepub fn above_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
pub fn above_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize above of another widget
Sourcepub fn right_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
pub fn right_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize right of another widget
Sourcepub fn left_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
pub fn left_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self
Initialize left of another widget
Sourcepub fn center_x<W: WidgetExt>(self, w: &W) -> Self
pub fn center_x<W: WidgetExt>(self, w: &W) -> Self
Initialize center of another widget on the x axis
Sourcepub fn center_y<W: WidgetExt>(self, w: &W) -> Self
pub fn center_y<W: WidgetExt>(self, w: &W) -> Self
Initialize center of another widget on the y axis
Sourcepub fn center_of_parent(self) -> Self
pub fn center_of_parent(self) -> Self
Initialize center of parent
Sourcepub fn size_of_parent(self) -> Self
pub fn size_of_parent(self) -> Self
Initialize to the size of the parent
Methods from Deref<Target = Window>§
Sourcepub fn show_with_env_args(&mut self)
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?
56fn main() {
57 let app = app::App::default();
58 let mut wind = Window::default()
59 .with_label("timeout")
60 .with_size(720, 486)
61 .center_screen();
62 let mut frame = Frame::new(-200, 150, 200, 200, "");
63 let mut pxm = Pixmap::new(PXM).unwrap();
64 pxm.scale(200, 200, true, true);
65 frame.set_image_scaled(Some(pxm));
66 wind.set_color(enums::Color::White);
67 wind.end();
68 wind.show_with_env_args();
69
70 app::add_timeout3(0.016, move |handle| {
71 let frame = frame.clone();
72 move_image(frame, handle);
73 });
74 app.run().unwrap();
75}Sourcepub fn show_with_args(&mut self, args: &[&str])
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?
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 .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();
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().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}Sourcepub fn set_on_top(&mut self)
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.
Sourcepub fn un_maximize(&mut self)
pub fn un_maximize(&mut self)
Unmaximize the window
Sourcepub fn maximize_active(&self) -> bool
pub fn maximize_active(&self) -> bool
Checks whether the window is maximized
Sourcepub fn pixels_per_unit(&self) -> f32
pub fn pixels_per_unit(&self) -> f32
Returns the pixels per unit/point
Sourcepub fn flush(&mut self)
pub fn flush(&mut self)
Forces the window to be drawn, this window is also made current and calls draw()
Sourcepub fn platform_show(&self)
pub fn platform_show(&self)
Show a window after it had been hidden. Works on Windows and X11 systems
Sourcepub fn platform_hide(&self)
pub fn platform_hide(&self)
Hide a window using the platforms hide call. Works on Windows and X11 systems