xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
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.size_mode(picture_box_size_mode::center_image);
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");
if (ofd.show_dialog() == dialog_result::ok) {
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());
}
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.h:34
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a Windows button control.
Definition button.h:54
xtd::forms::dialog_result show_dialog()
Runs a common dialog box with a default owner.
Definition common_dialog.h:60
virtual const xtd::ustring & filter() const
Gets the current file name filter string, which determines the choices that appear in the "Save as fi...
Definition file_dialog.h:150
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:40
Provides methods to manage a collection of xtd::drawing::image objects. This class cannot be inherite...
Definition image_list.h:25
Displays a standard dialog box that prompts the user to open a file. This class cannot be inherited.
Definition open_file_dialog.h:21
virtual bool multiselect() const
Gets a value indicating whether the dialog box allows multiple files to be selected.
Definition open_file_dialog.h:33
Represents a standard Windows picture box.
Definition picture_box.h:24
@ show
Display the hot-key prefix.
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition bitmap.h:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Examples
colored_tab_pages.cpp, and image_list.cpp.

Inherits xtd::forms::component.

Public Types

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

Static Public Attributes

static image_list empty
 Represents an image_list empty.
 

Public Member Functions

 image_list ()
 Initialize a new instance ao image_list class.
 
intptr_t handle () const
 Gets the handle of the image list object.
 
bool handle_created () const
 Gets a value indicating whether the underlying Win32 handle has been created.
 
const drawing::size image_size () const
 Gets the size of the images in the image list.
 
const image_listimage_size (const drawing::size &value)
 Sets the size of the images in the image list.
 
image_collectionimages ()
 Gets the xtd::forms::image_list::image_collection for this image list.
 
const image_collectionimages () const
 Gets the xtd::forms::image_list::image_collection for this image list.
 
std::any tag () const
 Gets an object that contains additional data about the image_list.
 
const image_listtag (std::any &tag)
 Sets an object that contains additional data about the image_list.
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance.
 
virtual xtd::ustring to_string () const noexcept
 Returns a std::string that represents the current object.
 

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.
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 
- Protected Member Functions inherited from xtd::forms::component
 component ()=default
 Initialises a new instance of the component class.
 
virtual bool can_raise_events () const
 Gets a value indicating whether the component can raise an event.
 
bool design_mode () const
 Gets a value that indicates whether the component is currently in design mode.
 

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: