WindowHandle

Struct WindowHandle 

Source
pub struct WindowHandle(/* private fields */);

Implementations§

Source§

impl WindowHandle

Source

pub fn show(&self)

Examples found in repository?
examples/hello.rs (line 113)
98fn main() {
99    druid_win_shell::init();
100
101    let mut file_menu = Menu::new();
102    file_menu.add_item(0x100, "E&xit");
103    file_menu.add_item(0x101, "O&pen");
104    let mut menubar = Menu::new();
105    menubar.add_dropdown(file_menu, "&File");
106
107    let mut run_loop = win_main::RunLoop::new();
108    let mut builder = WindowBuilder::new();
109    builder.set_handler(Box::new(HelloState::default()));
110    builder.set_title("Hello example");
111    builder.set_menu(menubar);
112    let window = builder.build().unwrap();
113    window.show();
114    run_loop.run();
115}
More examples
Hide additional examples
examples/perftest.rs (line 139)
124fn main() {
125    druid_win_shell::init();
126
127    let mut run_loop = win_main::RunLoop::new();
128    let mut builder = WindowBuilder::new();
129    let perf_state = PerfState {
130        dwrite_factory: directwrite::Factory::new().unwrap(),
131        handle: Default::default(),
132        last_time: 0.0,
133    };
134    builder.set_handler(Box::new(PerfTest(RefCell::new(perf_state))));
135    builder.set_title("Performance tester");
136    // Note: experiment with changing this
137    builder.set_present_strategy(PresentStrategy::FlipRedirect);
138    let window = builder.build().unwrap();
139    window.show();
140    run_loop.run();
141}
Source

pub fn close(&self)

Examples found in repository?
examples/perftest.rs (line 103)
101    fn command(&self, id: u32) {
102        match id {
103            0x100 => self.0.borrow().handle.close(),
104            _ => println!("unexpected id {}", id),
105        }
106    }
More examples
Hide additional examples
examples/hello.rs (line 55)
53    fn command(&self, id: u32) {
54        match id {
55            0x100 => self.handle.borrow().close(),
56            0x101 => {
57                let mut options = FileDialogOptions::default();
58                options.set_show_hidden();
59                let filename = self.handle.borrow().file_dialog(FileDialogType::Open, options);
60                println!("result: {:?}", filename);
61            }
62            _ => println!("unexpected id {}", id),
63        }
64    }
Source

pub fn invalidate(&self)

Source

pub fn get_hwnd(&self) -> Option<HWND>

Get the raw HWND handle, for uses that are not wrapped in druid_win_shell.

Source

pub fn file_dialog( &self, ty: FileDialogType, options: FileDialogOptions, ) -> Result<OsString, Error>

Examples found in repository?
examples/hello.rs (line 59)
53    fn command(&self, id: u32) {
54        match id {
55            0x100 => self.handle.borrow().close(),
56            0x101 => {
57                let mut options = FileDialogOptions::default();
58                options.set_show_hidden();
59                let filename = self.handle.borrow().file_dialog(FileDialogType::Open, options);
60                println!("result: {:?}", filename);
61            }
62            _ => println!("unexpected id {}", id),
63        }
64    }
Source

pub fn get_idle_handle(&self) -> Option<IdleHandle>

Get a handle that can be used to schedule an idle task.

Source

pub fn get_dpi(&self) -> f32

Get the dpi of the window.

Source

pub fn px_to_pixels(&self, x: f32) -> i32

Convert a dimension in px units to physical pixels (rounding).

Source

pub fn px_to_pixels_xy(&self, x: f32, y: f32) -> (i32, i32)

Convert a point in px units to physical pixels (rounding).

Source

pub fn pixels_to_px<T: Into<f64>>(&self, x: T) -> f32

Convert a dimension in physical pixels to px units.

Source

pub fn pixels_to_px_xy<T: Into<f64>>(&self, x: T, y: T) -> (f32, f32)

Convert a point in physical pixels to px units.

Trait Implementations§

Source§

impl Clone for WindowHandle

Source§

fn clone(&self) -> WindowHandle

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

Source§

fn default() -> WindowHandle

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.