xtd 0.2.0
picture_box.cpp

demonstrates the use of xtd::forms::picture_box control.

Windows

macOS

Gnome

#include <xtd/forms/application>
#include <xtd/forms/choice>
#include <xtd/forms/form>
#include <xtd/forms/picture_box>
#include "../properties/resources.hpp"
using namespace xtd::drawing;
using namespace xtd::forms;
namespace picture_box {
class form1 : public form {
public:
form1() {
text("Picture box example");
client_size({300, 345});
choice1.parent(*this);
choice1.location({20, 20});
choice1.width(260);
choice1.items().push_back_range({{"normal", picture_box_size_mode::normal}, {"stretch_image", picture_box_size_mode::stretch_image}, {"auto_size", picture_box_size_mode::auto_size}, {"center_image", picture_box_size_mode::center_image}, {"zoom", picture_box_size_mode::zoom}});
choice1.selected_index(0);
choice1.selected_value_changed += [&] {
picture_box1.size_mode(std::any_cast<picture_box_size_mode>(choice1.selected_item().tag()));
};
picture_box1.parent(*this);
picture_box1.border_style(border_style::groove);
picture_box1.location({20, 65});
picture_box1.size({260, 260});
picture_box1.image(properties::resources::logo());
picture_box1.size_mode(std::any_cast<picture_box_size_mode>(choice1.selected_item().tag()));
}
private:
choice choice1;
};
}
auto main() -> int {
application::run(::picture_box::form1 {});
}
static void run()
Begins running a standard application message loop on the current thread, without a form.
Represents a choice control.
Definition choice.hpp:37
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Represents a standard Windows picture box.
Definition picture_box.hpp:34
@ center_image
The image is displayed in the center if the picture_box is larger than the image. If the image is lar...
Definition picture_box_size_mode.hpp:30
@ zoom
The size of the image is increased or decreased maintaining the size ratio.
Definition picture_box_size_mode.hpp:32
@ stretch_image
The image within the picture_box is stretched or shrunk to fit the size of the picture_box.
Definition picture_box_size_mode.hpp:26
@ auto_size
The picture_box is sized equal to the size of the image that it contains.
Definition picture_box_size_mode.hpp:28
@ normal
The image is placed in the upper-left corner of the picture_box. The image is clipped if it is larger...
Definition picture_box_size_mode.hpp:24
@ groove
Defines a 3D grooved border. The effect depends on the border color value.
Definition border_style.hpp:34
@ bottom
Bind control edges to the bottom of its container.
Definition anchor_styles.hpp:25
@ right
Bind control edges to the right of its container.
Definition anchor_styles.hpp:29
@ left
Bind control edges to the left of its container.
Definition anchor_styles.hpp:27
@ top
Bind control edges to the top of its container.
Definition anchor_styles.hpp:23
The xtd::drawing::text namespace provides advanced GDI+ typography functionality.
Definition font_collection.hpp:14
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:217