xtd 0.2.0
Loading...
Searching...
No Matches
circular_form.cpp

demonstrates the use of xtd::forms::control::region property for create a circular form.

Windows

macOS

Gnome

#include <xtd/drawing/drawing_2d/linear_gradient_brush>
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/form>
#include <xtd/startup>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::drawing::drawing_2d;
using namespace xtd::forms;
class form_main : public form {
public:
static auto main() {
application::run(form_main());
}
form_main() {
form_border_style(forms::form_border_style::none);
client_size({300, 300});
// Create a circular region for the form
path.add_ellipse(client_rectangle());
paint += [&](object& sender, paint_event_args& e) {
e.graphics().fill_rectangle(linear_gradient_brush(e.clip_rectangle(), {color::black, color::blue, color::black}, 90), e.clip_rectangle());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
mouse_location = e.location();
cursor(cursors::no_move_2d());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
mouse_location = point::empty;
cursor(cursors::default_cursor());
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
if (mouse_location != point::empty) location(location() + e.location() - mouse_location);
};
close_button.parent(*this);
close_button.location({client_size().width() / 2 - close_button.width() / 2, client_size().height() / 2 - close_button.height() / 2});
close_button.back_color(color::from_argb(32, color::white));
close_button.fore_color(color::dark_blue);
close_button.text("close");
close_button.click += [&] {
close();
};
}
private:
button close_button;
point mouse_location = point::empty;
};
startup_(form_main::main);
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics_path.h:35
Encapsulates a xtd::drawing::brush with a linear gradient. This class cannot be inherited.
Definition linear_gradient_brush.h:31
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.h:54
Describes the interior of a graphics shape composed of rectangles and paths. This class cannot be inh...
Definition region.h:32
Represents a Windows button control.
Definition button.h:47
Represents the image used to paint the mouse pointer.
Definition cursor.h:38
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:52
Provides data for the xtd::forms::control::mouse_up, xtd::forms::control::mouse_down,...
Definition mouse_event_args.h:32
Provides data for the xtd::forms::control::paint event.
Definition paint_event_args.h:28
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.h:166
form_border_style
Specifies the border styles for a form.
Definition form_border_style.h:20
The xtd::drawing::drawing_2d namespace provides advanced two-dimensional and vector graphics function...
Definition compositing_mode.h:12
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.h:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10