xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Classes | Public Types | Static Public Attributes | Public Member Functions | List of all members
xtd::forms::image_list Class Referencefinal

#include <image_list.h>

Definition

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

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 demonstrate the use of image_list class.
#include <xtd/xtd>
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;
};
}
int main() {
application::run(example::form1());
}
Examples:
colored_tab_pages.cpp, and image_list.cpp.

Public Types

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

Static Public Attributes

static image_list empty
 Represents an image_list empty. More...
 

Public Member Functions

 image_list ()
 Initialize a new instance ao image_list class. More...
 
intptr_t handle () const
 Gets the handle of the image list object. More...
 
bool handle_created () const
 Gets a value indicating whether the underlying Win32 handle has been created. More...
 
const drawing::size image_size () const
 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...
 
image_collectionimages ()
 Gets the xtd::forms::image_list::image_collection for this image list. More...
 
const image_collectionimages () const
 Gets the xtd::forms::image_list::image_collection for this image list. More...
 
std::any tag () const
 Gets an object that contains additional data about the image_list. More...
 
const image_listtag (std::any &tag)
 Sets an object that contains additional data about the image_list. More...
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual 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...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance. More...
 
virtual xtd::ustring to_string () const noexcept
 Returns a std::string that represents the current object. More...
 

Additional Inherited Members

- 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 ()=default
 Initialises a new instance of the component class. More...
 
virtual bool can_raise_events () const
 Gets a value indicating whether the component can raise an event. More...
 
bool design_mode () const
 Gets a value that indicates whether the component is currently in design mode. More...
 

Member Typedef Documentation

◆ image_collection

Encapsulates the collection of xtd::drawing::image objects in an image_list.

Constructor & Destructor Documentation

◆ image_list()

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

Initialize a new instance ao image_list class.

Member Function Documentation

◆ handle()

intptr_t xtd::forms::image_list::handle ( ) const
inline

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
inline

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
inline

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 ( )
inline

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
inline

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
inline

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]

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

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: