xtd 0.2.0
form_background_image2.cpp

demonstrates how to use of xtd::forms::form control with background_image.

Windows

macOS

Gnome

#include <xtd/diagnostics/process>
#include <xtd/forms/application>
#include <xtd/forms/choice>
#include <xtd/forms/form>
#include <xtd/forms/link_label>
#include "../properties/resources.hpp"
using namespace xtd;
using namespace xtd::diagnostics;
using namespace xtd::drawing;
using namespace xtd::forms;
namespace form_background_image2 {
class form1 : public form {
public:
form1() {
background_image(application::dark_mode() ? properties::resources::bliss_night() : properties::resources::bliss_day());
client_size({600, 450});
controls().push_back_range({bliss_url, image_layout_choice});
double_buffered(true);
text("form with background image example 2");
bliss_url.back_color(color::from_argb(64, system_colors::control()));
bliss_url.dock(dock_style::bottom);
bliss_url.text("MACOS BLISS");
bliss_url.links().push_back({0, bliss_url.text().size(), "https://basicappleguy.com/basicappleblog/macosbliss"});
bliss_url.link_clicked += [](object & sender, link_label_clicked_event_args & e) {
e.visited(true);
process::start(as<string>(e.link().link_data()));
};
image_layout_choice.items().push_back({name, value});
image_layout_choice.location({10, 10});
image_layout_choice.selected_index_changed += [&] {
background_image_layout(as<xtd::forms::image_layout>(image_layout_choice.selected_item().tag()));
};
image_layout_choice.selected_index(0);
}
protected:
void on_system_colors_changed(const event_args &e) {
background_image(application::dark_mode() ? properties::resources::bliss_night() : properties::resources::bliss_day());
bliss_url.back_color(color::from_argb(64, system_colors::control()));
}
private:
link_label bliss_url;
choice image_layout_choice;
};
}
auto main() -> int {
application::run(::form_background_image2::form1 {});
}
bool start()
Starts (or reuses) the process resource that is specified by the xtd::diagnostics::process::start_inf...
static xtd::drawing::color from_argb(uint32 argb) noexcept
Creates a xtd::drawing::color class from a 32-bit ARGB value.
static xtd::drawing::color control()
Gets a xtd::drawing::color structure that is the face color of a 3-D element.
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
static void run()
Begins running a standard application message loop on the current thread, without a form.
static bool dark_mode() noexcept
Gets a value indicating whether dark mode is enabled for the application.
Represents a choice control.
Definition choice.hpp:37
virtual void on_system_colors_changed(const event_args &e)
Raises the control::system_colors_changed event.
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
@ e
The E key.
Definition console_key.hpp:96
@ bottom
The control's bottom edge is docked to the bottom of its containing control.
Definition dock_style.hpp:29
@ middle_center
Content is vertically aligned at the middle, and horizontally aligned at the center.
Definition content_alignment.hpp:31
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
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
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Provides the base class for enumerations.
Definition enum_object.hpp:49