Struct native_windows_gui::Icon [−][src]
pub struct Icon { pub handle: HANDLE, // some fields omitted }
A wrapper over a icon file (*.ico)
Windows icons are a legacy thing and should only be used when winapi forces you to use them (ex: when setting a window icon).
The Bitmap
object of NWG not only supports transparency if “image-decoder” is enabled but it can also be create from multiple
different sources (including “.ico” files).
To display a icon in an application, see the ImageFrame
control.
Note: Loading an icon from binary source (source_bin) REQUIRES the “image-decoder” feature.
Builder parameters:
source_file
: The source of the icon if it is a file.source_bin
: The source of the icon if it is a binary blob. For example usinginclude_bytes!("my_icon.ico")
.source_system
: The source of the icon if it is a system resource (see OemIcon)source_embed
: The source of the icon if it is stored in an embedded filesource_embed_id
: The number identifier of the icon in the embedded filesource_embed_str
: The string identifier of the icon in the embedded filesize
: Optional. Resize the image to this size.strict
: Use a system placeholder instead of panicking if the image source do no exists.
Example:
use native_windows_gui as nwg; fn load_icon() -> nwg::Icon { nwg::Icon::from_file("hello.ico", true).unwrap() } fn load_icon_builder() -> nwg::Icon { let mut icon = nwg::Icon::default(); nwg::Icon::builder() .source_file(Some("hello.ico")) .strict(true) .build(&mut icon); icon }
Fields
handle: HANDLE
Implementations
impl Icon
[src]
pub fn builder<'a>() -> IconBuilder<'a>
[src]
pub fn from_system(sys_icon: OemIcon) -> Icon
[src]
Single line helper function over the icon builder api.
Use system resources.
pub fn from_file(path: &str, strict: bool) -> Result<Icon, NwgError>
[src]
Single line helper function over the icon builder api.
Use a file resource.
pub fn from_bin(bin: &[u8]) -> Result<Icon, NwgError>
[src]
Single line helper function over the icon builder api.
Use a binary resource.
pub fn from_embed(
embed: &EmbedResource,
embed_id: Option<usize>,
embed_str: Option<&str>
) -> Result<Icon, NwgError>
[src]
embed: &EmbedResource,
embed_id: Option<usize>,
embed_str: Option<&str>
) -> Result<Icon, NwgError>
Single line helper function over the icon builder api.
Use an embedded resource. Either embed_id
or embed_str
must be defined, not both.
Requires the embed-resource
feature.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Icon
impl !Send for Icon
impl !Sync for Icon
impl Unpin for Icon
impl UnwindSafe for Icon
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
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.
pub 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>,