Struct 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. Default 5
  • grow: The number of images by which the image list can grow when the system needs to make room for new images. Default 5
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§

Source§

impl ImageList

Source

pub fn builder() -> ImageListBuilder

Source

pub fn size(&self) -> (i32, i32)

Returns the size of the images in the image list

Source

pub fn set_size(&self, size: (i32, i32))

Sets the size of the image list. This clears all current image data.

Source

pub fn len(&self) -> u32

Returns the number of images in the image list

Source

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

Source

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

Source

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

Source

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

Source

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.

Source

pub fn replace_bitmap(&self, index: i32, bitmap: &Bitmap)

Replaces an image in the image list. Panics if the bitmap was not initialized

Source

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§

Source§

impl Default for ImageList

Source§

fn default() -> ImageList

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

impl Drop for ImageList

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq for ImageList

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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<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.