Struct native_windows_gui::ImageList
source · [−]pub struct ImageList {
pub handle: HIMAGELIST,
pub owned: bool,
}
Expand description
An image list is a collection of images of the same size, each of which can be referred to by its index. Image lists are used in controls such as tabs container and tree view in order to add icon next to the items.
There are two kinds of image list in Winapi: masked. This is a wrapper over the masked type.
Image list and the method that use them in controls are behind the “image-list” feature.
Builder parameters:
size
: The size size of the images in the image list. Default(32, 32)
initial
: The initial size (in images) of the image list. Default5
grow
: The number of images by which the image list can grow when the system needs to make room for new images. Default5
use native_windows_gui as nwg;
fn build_image_list(list: &mut nwg::ImageList) {
nwg::ImageList::builder()
.size((64, 64))
.initial(10)
.grow(1)
.build(list);
}
Fields
handle: HIMAGELIST
owned: bool
Implementations
sourceimpl ImageList
impl ImageList
pub fn builder() -> ImageListBuilder
sourcepub fn set_size(&self, size: (i32, i32))
pub fn set_size(&self, size: (i32, i32))
Sets the size of the image list. This clears all current image data.
sourcepub fn add_bitmap(&self, bitmap: &Bitmap) -> i32
pub fn add_bitmap(&self, bitmap: &Bitmap) -> i32
Adds a new bitmap to the image list. Returns the index to the image. Panics if the bitmap was not initialized
sourcepub fn add_bitmap_from_filename(&self, filename: &str) -> Result<i32, NwgError>
pub fn add_bitmap_from_filename(&self, filename: &str) -> Result<i32, NwgError>
Adds a bitmap directly from a filename. The image is resized to the image list size. Returns the index to the image or an error if the image could not be loaded
sourcepub fn add_icon(&self, icon: &Icon) -> i32
pub fn add_icon(&self, icon: &Icon) -> i32
Adds a new icon to the image list. Returns the index to the image. Panics if the icon was not initialized
sourcepub fn add_icon_from_filename(&self, filename: &str) -> Result<i32, NwgError>
pub fn add_icon_from_filename(&self, filename: &str) -> Result<i32, NwgError>
Adds a icon directly from a filename. The image is resized to the image list size. Returns the index to the image or an error if the image could not be loaded
sourcepub fn remove(&self, index: i32)
pub fn remove(&self, index: i32)
Removes the image at the specified index
When an image is removed, the indexes of the remaining images are adjusted so that the image indexes always range from zero to one less than the number of images in the image list. For example, if you remove the image at index 0, then image 1 becomes image 0, image 2 becomes image 1, and so on.
sourcepub fn replace_bitmap(&self, index: i32, bitmap: &Bitmap)
pub fn replace_bitmap(&self, index: i32, bitmap: &Bitmap)
Replaces an image in the image list. Panics if the bitmap was not initialized
sourcepub fn replace_icon(&self, index: i32, icon: &Icon)
pub fn replace_icon(&self, index: i32, icon: &Icon)
Replaces an image in the image list by an icon. Panics if the icon was not initialized
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ImageList
impl !Send for ImageList
impl !Sync for ImageList
impl Unpin for ImageList
impl UnwindSafe for ImageList
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more