xtd 0.2.0
xtd::forms::image_list Class Referencefinal

Definition

Provides methods to manage a collection of xtd::drawing::image objects. This class cannot be inherited.

Header
#include <xtd/forms/image_list>
Namespace
xtd::forms
Library
xtd.forms
Remarks
image_list is typically used by other controls, such as the list_view, tree_view, or tool_bar. You can add bitmaps or icons to the image_list, and the other controls are able to use the images as they require.
image_list uses a handle to manage the list of images. The handle is not created until certain operations, such as getting the handle or calling draw, are performed on the image list. Performing other operations, such as setting the color_depth or image_size will cause the handle to be recreated. Therefore, you should perform these operations before you add images to the image_list.
Examples
The following code example demonstrates the use of image_list class.
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/button_images>
#include <xtd/forms/form>
#include <xtd/forms/open_file_dialog>
#include <xtd/forms/picture_box>
#include <xtd/drawing/system_colors>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
namespace example {
class form1 : public form {
public:
form1() {
text("Image list example");
client_size({300, 250});
controls().push_back_range({picture, button_previous, button_next});
pictures.image_size({128, 128});
picture.back_color(system_colors::window());
picture.border_style(forms::border_style::fixed_3d);
picture.bounds({75, 25, 150, 150});
picture.click += [&] {
load_images();
};
button_previous.auto_repeat(true);
button_previous.image(button_images::previous());
button_previous.location({75, 200});
button_previous.enabled(false);
button_previous.click += [&] {
if (current_image_index > 0) picture.image(pictures.images()[--current_image_index]);
button_previous.enabled(current_image_index > 0);
button_next.enabled(current_image_index < pictures.images().size() - 1);
};
button_next.auto_repeat(true);
button_next.image(button_images::next());
button_next.location({150, 200});
button_next.enabled(false);
button_next.click += [&] {
if (current_image_index < pictures.images().size()) picture.image(pictures.images()[++current_image_index]);
button_previous.enabled(current_image_index > 0);
button_next.enabled(current_image_index < pictures.images().size() - 1);
};
show();
load_images();
}
private:
void load_images() {
ofd.multiselect(true);
ofd.filter("All Image Files|*.bmp;*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff;*.xpm|Bitmap Files|*.bmp|Gif Files|*.gif|Jpeg Files|*.jpg;*.jpeg|Png Files|*.png|Tiff Files|*.tif;*.tiff|xpm Files|*.xpm");
pictures.images().clear();
for (auto file : ofd.file_names())
pictures.images().push_back(drawing::image::from_file(file));
current_image_index = 0;
picture.image(pictures.images()[current_image_index]);
button_previous.enabled(current_image_index > 0);
button_next.enabled(current_image_index < pictures.images().size() - 1);
}
}
size_t current_image_index = 0;
image_list pictures;
picture_box picture;
button button_previous;
button button_next;
};
}
auto main()->int {
application::run(example::form1 {});
}
Examples:
colored_tab_pages.cpp, and image_list.cpp.

Alias

using image_collection = layout::arranged_element_collection< drawing::image >
 Encapsulates the collection of xtd::drawing::image objects in an image_list. More...
 

Fields

static image_list empty
 Represents an image_list empty. More...
 
static const size_t npos = image_collection::npos
 

Constructors

 image_list ()
 Initialize a new instance ao image_list class. More...
 

Properties

intptr handle () const noexcept
 Gets the handle of the image list object. More...
 
bool handle_created () const noexcept
 Gets a value indicating whether the underlying Win32 handle has been created. More...
 
image_collectionimages ()
 Gets the xtd::forms::image_list::image_collection for this image list. More...
 
const image_collectionimages () const noexcept
 Gets the xtd::forms::image_list::image_collection for this image list. More...
 
const drawing::size image_size () const noexcept
 Gets the size of the images in the image list. More...
 
const image_listimage_size (const drawing::size &value)
 Sets the size of the images in the image list. More...
 
std::any tag () const noexcept
 Gets an object that contains additional data about the image_list. More...
 
image_listtag (const std::any &tag)
 Sets an object that contains additional data about the image_list. More...
 

Methods

bool equals (const image_list &value) const noexcept override
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const noexcept
 Creates a shallow copy of the current object. More...
 
virtual xtd::ustring to_string () const noexcept
 Returns a sxd::ustring that represents the current object. More...
 
- Public Member Functions inherited from xtd::iequatable< image_list >
virtual bool equals (const image_list &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type. More...
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 
- Protected Member Functions inherited from xtd::forms::component
 component ()
 Initialises a new instance of the component class. More...
 
virtual bool can_raise_events () const noexcept
 Gets a value indicating whether the component can raise an event. More...
 
bool design_mode () const noexcept
 Gets a value that indicates whether the component is currently in design mode. More...
 

Member Typedef Documentation

◆ image_collection

Constructor & Destructor Documentation

◆ image_list()

xtd::forms::image_list::image_list ( )

Initialize a new instance ao image_list class.

Member Function Documentation

◆ handle()

intptr xtd::forms::image_list::handle ( ) const
noexcept

Gets the handle of the image list object.

Returns
The handle for the image list. The default is 0.

◆ handle_created()

bool xtd::forms::image_list::handle_created ( ) const
noexcept

Gets a value indicating whether the underlying Win32 handle has been created.

Returns
true if the Handle has been created; otherwise, false. The default is false.

◆ image_size() [1/2]

const drawing::size xtd::forms::image_list::image_size ( ) const
noexcept

Gets the size of the images in the image list.

Returns
The xtd::drawing::size that defines the height and width, in pixels, of the images in the list. The default size is 16 by 16. The maximum size is 256 by 256.

◆ image_size() [2/2]

const image_list& xtd::forms::image_list::image_size ( const drawing::size value)

Sets the size of the images in the image list.

Parameters
valueThe xtd::drawing::size that defines the height and width, in pixels, of the images in the list. The default size is 16 by 16. The maximum size is 256 by 256.
Remarks
Setting the image_size property prior to adding images to the image collection causes the images to be resized to the image size specified.
When you set the image_size property to a new value, the handle for the image list is recreated.
Because setting the image_size property causes the handle to be recreated, you should set image_size prior to setting the Images property. When the handle for the image_list has been created, setting the color_depth or image_size properties in code, after setting the images property, will cause the collection of images set for the images property to be deleted.

◆ images() [1/2]

image_collection& xtd::forms::image_list::images ( )

Gets the xtd::forms::image_list::image_collection for this image list.

Returns
The collection of images.
Remarks
If the image collection has not yet been created, it is created when you retrieve this property.

◆ images() [2/2]

const image_collection& xtd::forms::image_list::images ( ) const
noexcept

Gets the xtd::forms::image_list::image_collection for this image list.

Returns
The collection of images.
Remarks
If the image collection has not yet been created, it is created when you retrieve this property.

◆ tag() [1/2]

std::any xtd::forms::image_list::tag ( ) const
noexcept

Gets an object that contains additional data about the image_list.

Returns
A object that contains additional data about the image_list.

◆ tag() [2/2]

image_list& xtd::forms::image_list::tag ( const std::any tag)

Sets an object that contains additional data about the image_list.

Parameters
tagA object that contains additional data about the image_list.

Member Data Documentation

◆ empty

image_list xtd::forms::image_list::empty
static

Represents an image_list empty.


The documentation for this class was generated from the following file: