xtd 0.2.0
Loading...
Searching...
No Matches
xtd::forms::image_list Class Referencefinal
Inheritance diagram for xtd::forms::image_list:
xtd::forms::component xtd::iequatable< image_list > xtd::object xtd::interface xtd::equality_operators< type_t, equatable_t >

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.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() {
auto dialog = open_file_dialog {};
dialog.multiselect(true);
dialog.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 (dialog.show_dialog() == dialog_result::ok) {
pictures.images().clear();
for (auto file : dialog.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 {});
}
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.hpp:49
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a Windows button control.
Definition button.hpp:49
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Provides methods to manage a collection of xtd::drawing::image objects. This class cannot be inherite...
Definition image_list.hpp:30
Provides images factories for use by control.
Definition images.hpp:23
Displays a standard dialog box that prompts the user to open a file. This class cannot be inherited.
Definition open_file_dialog.hpp:30
virtual bool multiselect() const noexcept
Gets a value indicating whether the dialog box allows multiple files to be selected.
Represents a standard Windows picture box.
Definition picture_box.hpp:34
@ show
Display the hot-key prefix.
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Examples
colored_tab_pages.cpp, and image_list.cpp.

Public Aliases

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

Public Fields

static image_list empty
 Represents an image_list empty.
 
static constexpr xtd::size npos
 

Public Constructors

 image_list ()
 Initialize a new instance ao image_list class.
 

Public Properties

intptr handle () const noexcept
 Gets the handle of the image list object.
 
bool handle_created () const noexcept
 Gets a value indicating whether the underlying Win32 handle has been created.
 
image_collectionimages ()
 Gets the xtd::forms::image_list::image_collection for this image list.
 
const image_collectionimages () const noexcept
 Gets the xtd::forms::image_list::image_collection for this image list.
 
const drawing::size image_size () const noexcept
 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.
 
std::any tag () const noexcept
 Gets an object that contains additional data about the image_list.
 
image_listtag (const std::any &tag)
 Sets an object that contains additional data about the image_list.
 

Public Methods

bool equals (const image_list &value) const noexcept override
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 

Additional Inherited Members

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

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.

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

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

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

◆ equals() [1/2]

virtual bool xtd::object::equals ( const object obj) const
virtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.
Examples
The following code example compares the current instance with another object.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
auto object1 = new_ptr<object>();
auto object2 = new_ptr<object>();
auto object3 = object2;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
object3 = object1;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
}
// This code produces the following output :
//
// false
// false
// true
// true
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...

Reimplemented from xtd::object.

◆ equals() [2/2]

template<typename object_a_t , typename object_b_t >
static bool xtd::object::equals ( const object_a_t &  object_a,
const object_b_t &  object_b 
)
inlinestaticnoexcept

Determines whether the specified object instances are considered equal.

Parameters
object_aThe first object to compare.
object_bThe second object to compare.
Returns
true if object_a is the same instance as object_b or if both are null references or if object_a(object_b) returns true. otherwise, false.
Examples
The following code example compares different objects.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
string s1 = "Tom";
string s2 = "Carol";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Tom";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Carol";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
}
// This code produces the following output :
//
// object::equals("Tom", "Carol") => false
// object::equals("Tom", "Tom") => true
// object::equals("", "Tom") => false
// object::equals("Carol", "") => false
// object::equals("", "") => true
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.

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: