[−][src]Struct native_windows_gui::Ui
Object that manage the GUI elements
Methods
impl<ID: Hash + Clone> Ui<ID>
[src]
pub fn new() -> Result<Ui<ID>, Error>
[src]
Create a new Ui.
Returns Ok(ui)
if the initialization was successful
Returns Err(Error::System)
if the system could not initialize the ui
pub fn commit(&self) -> Result<(), Error>
[src]
Execute the NWG commands waiting in the Ui command queue in the order they were added.
Returns Ok(())
if everything was executed without Errors
Returns Err(Error)
if an error was encountered while executing the commands.
As soon as an error is found, the function will return. If there are still commands
waiting in the queue, they wont be touched.
pub fn pack_value<T: Into<Box<T>> + 'static>(&self, id: &ID, value: T)
[src]
Add an user value to the Ui.
Delayed, this only registers the command in the ui message queue.
Either call ui.commit
to execute it now or wait for the command to be executed in the main event loop.
Commit returns
• Error::KeyExist
if the key already exists in the ui
pub fn pack_control<T: ControlT<ID> + 'static>(&self, id: &ID, value: T)
[src]
Add a control to the Ui.
Delayed, this only registers the command in the ui message queue.
Either call ui.commit
to execute it now or wait for the command to be executed in the main event loop.
Commit returns
• Error::KeyExist
if the key already exists in the ui
• Error::{Any}
if the template creation fails
pub fn pack_resource<T: ResourceT<ID> + 'static>(&self, id: &ID, value: T)
[src]
Add a resource to the Ui.
Delayed, this only registers the command in the ui message queue.
Either call ui.commit
to execute it now or wait for the command to be executed in the main event loop.
Commit returns
• Error::KeyExist
if the key already exists in the ui
• Error::{Any}
if the template creation fails
pub fn unpack(&self, id: &ID)
[src]
Remove a element from the ui using its ID. The ID can identify a control, a resource or a user value.
Delayed, this only registers the command in the ui message queue.
Either call ui.commit
to execute it now or wait for the command to be executed in the main event loop.
Commit may returns:
• Error::ControlInUse
if the control callbacks are being executed
• Error::ControlInUse
if the object is currently borrowed (using ui.get or ui.get_mut)
• Error::KeyNotFound
if the id do not exists in the Ui
pub fn get<T: 'static>(&self, id: &ID) -> Result<Ref<Box<T>>, Error>
[src]
Return an immutable reference to the element identified by id
in the Ui.
It is required to give a type T
to this function as it is needed to cast the underlying value.
Ex: ui.get::<u32>(100)
Params:
• id: The id that identify the element in the ui
Commit may returns:
• Error::KeyNotFound
will be returned if the key was not found in the Ui
• Error::BadType
will be returned if the key exists, but the type do not match
• Error::BorrowError
will be returned if the element was already borrowed mutably
pub fn get_mut<T: 'static>(&self, id: &ID) -> Result<RefMut<Box<T>>, Error>
[src]
Return an mutable reference to element identified by id
in the Ui.
It is required to give a type T
to this function as it is needed to cast the underlying value.
Ex: ui.get_mut::<u32>(100)
Params:
• id: The id that identify the element in the ui
Commit may returns:
• Error::KeyNotFound
will be returned if the key was not found in the Ui
• Error::BadType
will be returned if the key exists, but the type do not match
• Error::BorrowError
will be returned if the element was already borrowed mutably
pub fn bind<T>(&self, id: &ID, cb_id: &ID, event: Event, cb: T) where
T: Fn(&Ui<ID>, &ID, &Event, &EventArgs) + 'static,
[src]
T: Fn(&Ui<ID>, &ID, &Event, &EventArgs) + 'static,
Bind/Add a callback to a control event.
Delayed, this only registers the command in the ui message queue.
Either call ui.commit
to execute it now or wait for the command to be executed in the main event loop.
Params:
• id: The id that identify the element in the ui
• cb_id: An id the identify the callback (to use with unbind)
• event: Type of event to target
• cb: The callback
Commit may returns:
• Error::EventNotSupported
if the event is not supported on the callback
• Error::ControlRequired
if the id do not indentify a control
• Error::KeyNotFound
if the id is not in the Ui.
• Error::KeyExists
if the cb_id is not unique for the event type.
• Error::ControlInUse
if NWG is currently executing the callback of the event
pub fn unbind(&self, id: &ID, cb_id: &ID, event: Event)
[src]
Unbind/Remove a callback to a control event.
Delayed, this only registers the command in the ui message queue.
Either call ui.commit
to execute it now or wait for the command to be executed in the main event loop.
Params:
• id: The id that identify the element in the ui
• cb_id: The id that identify the callback
• event: The type of the event to unbind
Commit may returns:
• Error::EventNotSupported
if the event is not supported on the callback
• Error::ControlRequired
if the id do not indentify a control
• Error::KeyNotFound
if the id is not in the Ui.
• Error::KeyNotFound
if the cb_id do not exist for the event
• Error::ControlInUse
if NWG is currently executing the callback of the event
pub fn trigger(&self, id: &ID, event: Event, event_arg: EventArgs)
[src]
Trigger the callbacks bound to a control event.
Delayed, this only registers the command in the ui message queue.
Either call ui.commit
to execute it now or wait for the command to be executed in the main event loop.
Params:
• id: The id that identify the control in the ui
• event: The type of the event to trigger
• event_arg: The arguments to send to the callbacks
Commit may returns:
• Error::EventNotSupported
if the event is not supported on the callback
• Error::ControlRequired
if the id do not indentify a control
• Error::KeyNotFound
if the id is not in the Ui.
pub fn handle_of(&self, id: &ID) -> Result<AnyHandle, Error>
[src]
Return the underlying handle of a control or a resource. While this method is safe, anything done with the returned handle definitely won't be.
Returns:
• Ok(AnyHandle)
if the control or the resource is found
• Error::KeyNotFound
if the id is not in the Ui.
• Error::ControlOrResourceRequired
if the id indentify a user value
• Error::BorrowError
if the element was already borrowed mutably
pub fn has_id(&self, id: &ID) -> bool
[src]
Check if an id exists in the ui
Params:
• id -> The ID to check
pub unsafe fn message_handle(&self) -> HWND
[src]
Return the message window handle of the ui. Useful for controls or functions that requires a window (such as timers)
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,