AndroidWindow

Struct AndroidWindow 

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

An Android window

Implementations§

Source§

impl AndroidWindow

Source

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

Initialize to position x, y

Source

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

Initialize to size width, height

Source

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

Initialize with a label

Source

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

Initialize with alignment

Source

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

Initialize with type

Source

pub fn below_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self

Initialize at bottom of another widget

Source

pub fn above_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self

Initialize above of another widget

Source

pub fn right_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self

Initialize right of another widget

Source

pub fn left_of<W: WidgetExt>(self, wid: &W, padding: i32) -> Self

Initialize left of another widget

Source

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

Initialize center of another widget

Source

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

Initialize center of another widget on the x axis

Source

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

Initialize center of another widget on the y axis

Source

pub fn center_of_parent(self) -> Self

Initialize center of parent

Source

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

Initialize to the size of another widget

Source

pub fn size_of_parent(self) -> Self

Initialize to the size of the parent

Methods from Deref<Target = Window>§

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 68)
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}
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        .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}
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 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

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 Default for AndroidWindow

Source§

fn default() -> Self

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

impl Deref for AndroidWindow

Source§

type Target = DoubleWindow

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for AndroidWindow

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.