xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
control_paint.h
Go to the documentation of this file.
1
4#pragma once
5#include <optional>
6#include <string>
7#include <xtd/drawing/color.h>
8#include <xtd/drawing/font.h>
10#include <xtd/drawing/image.h>
14#include "../forms_export.h"
15#include "button_state.h"
16#include "image_layout.h"
17#include "text_format_flags.h"
18
20namespace xtd {
22 namespace forms {
30 public:
42 static xtd::drawing::color average(const xtd::drawing::color& color1, const xtd::drawing::color& color2, double weight, bool average_alpha) {return xtd::drawing::color::average(color1, color2, weight, average_alpha);}
43
54 //static xtd::drawing::color average(const xtd::drawing::color& color1, const xtd::drawing::color& color2, double weight) {return xtd::drawing::color::from_argb(static_cast<uint8_t>(color1.a() * weight + color2.a() * (1 - weight)), static_cast<uint8_t>(color1.r() * weight + color2.r() * (1 - weight)), static_cast<uint8_t>(color1.g() * weight + color2.g() * (1 - weight)), static_cast<uint8_t>(color1.b() * weight + color2.b() * (1 - weight)));}
55 static xtd::drawing::color average(const xtd::drawing::color& color1, const xtd::drawing::color& color2, double weight) {return average(color1, color2, weight, false);}
56
61 static xtd::drawing::color dark(const xtd::drawing::color& base_color) {return dark(base_color, 1.0/3);}
66 static xtd::drawing::color dark(const xtd::drawing::color& base_color, double perc_of_dark_dark) {return xtd::drawing::color::dark(base_color, perc_of_dark_dark);}
67
72 static xtd::drawing::color dark_dark(const xtd::drawing::color& base_color) {return dark(base_color, 1.0);}
73
74 static void draw_button(xtd::drawing::graphics& graphics, const xtd::drawing::rectangle& rectangle, xtd::forms::button_state state) {draw_button(graphics, rectangle.x(), rectangle.y(), rectangle.width(), rectangle.height(), state);}
75 static void draw_button(xtd::drawing::graphics& graphics, int32_t x, int32_t y, int32_t width, int32_t height, xtd::forms::button_state state);
76
82 static void draw_image(xtd::drawing::graphics& graphics, const xtd::drawing::image& image, const xtd::drawing::rectangle& rectangle, xtd::forms::image_layout image_layout) {draw_image(graphics, image, rectangle.x(), rectangle.y(), rectangle.width(), rectangle.height(), image_layout);}
91 static void draw_image(xtd::drawing::graphics& graphics, const xtd::drawing::image& image, int32_t x, int32_t y, int32_t width, int32_t height, xtd::forms::image_layout image_layout);
92
100 static void draw_image_disabled(xtd::drawing::graphics& graphics, const xtd::drawing::image& image, int32_t x, int32_t y, float brightness);
108 static void draw_image_disabled(xtd::drawing::graphics& graphics, const xtd::drawing::image& image, int32_t x, int32_t y, const xtd::drawing::color& background) {draw_image_disabled(graphics, image, x, y, background.get_brightness());}
115 static void draw_image_disabled(xtd::drawing::graphics& graphics, const xtd::drawing::image& image, const xtd::drawing::point& location, float brightness) {draw_image_disabled(graphics, image, location.x(), location.y(), brightness);}
122 static void draw_image_disabled(xtd::drawing::graphics& graphics, const xtd::drawing::image& image, const xtd::drawing::point& location, const xtd::drawing::color& background) {draw_image_disabled(graphics, image, location.x(), location.y(), background.get_brightness());}
123
128 static xtd::drawing::color light(const xtd::drawing::color& base_color) {return light(base_color, 1.0/3);}
133 static xtd::drawing::color light(const xtd::drawing::color& base_color, double perc_of_light_light) {return xtd::drawing::color::light(base_color, perc_of_light_light);}
134
139 static xtd::drawing::color light_light(const xtd::drawing::color& base_color) {return light(base_color, 1.0);}
140
145 xtd::drawing::string_format string_format;
148
149 if ((flags & text_format_flags::horizontal_center) == text_format_flags::horizontal_center) string_format.alignment(xtd::drawing::string_alignment::center);
150 else if ((flags & text_format_flags::right) == text_format_flags::right) string_format.alignment(xtd::drawing::string_alignment::far);
152
153 if ((flags & text_format_flags::vertical_center) == text_format_flags::vertical_center) string_format.line_alignment(xtd::drawing::string_alignment::center);
154 else if ((flags & text_format_flags::bottom) == text_format_flags::bottom) string_format.line_alignment(xtd::drawing::string_alignment::far);
156
157 if ((flags & text_format_flags::no_prefix) == text_format_flags::no_prefix) string_format.hotkey_prefix(xtd::drawing::hotkey_prefix::none);
158 else if ((flags & text_format_flags::hide_prefix) == text_format_flags::hide_prefix) string_format.hotkey_prefix(xtd::drawing::hotkey_prefix::hide);
160
161 return string_format;
162 }
163 };
164 }
165}
Contains xtd::forms::button_state enum class. @copyflat Copyright (c) 2021 Gammasoft....
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
static color dark(const color &color, double weight)
Returns a darker version of the specified color.
Definition: color.h:610
static color average(const color &color1, const color &color2, double weight, bool average_alpha)
Returns the weighted average color between the two given colors.
Definition: color.h:592
float get_brightness() const
Gets the hue-saturation-brightness (HSB) brightness value for this xtd::drawing::color structure.
static color light(const color &color, double weight)
Returns a lighter version of the specified color.
Definition: color.h:620
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: graphics.h:48
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition: image.h:34
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:48
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:25
Encapsulates text layout information (such as alignment, orientation and tab stops) display manipulat...
Definition: string_format.h:25
xtd::drawing::string_alignment line_alignment() const
Gets vertical alignment of the string.
Definition: string_format.h:108
xtd::drawing::string_alignment alignment() const
Gets horizontal alignment of the string.
Definition: string_format.h:74
xtd::drawing::hotkey_prefix hotkey_prefix() const
Gets the HotkeyPrefix object for this string_format object.
Definition: string_format.h:96
Provides methods used to paint common Windows controls and their elements. This class cannot be inher...
Definition: control_paint.h:29
static xtd::drawing::color dark(const xtd::drawing::color &base_color)
Creates a new dark color object for the control from the specified color.
Definition: control_paint.h:61
static xtd::drawing::color average(const xtd::drawing::color &color1, const xtd::drawing::color &color2, double weight)
Returns the weighted average color between the two given colors.
Definition: control_paint.h:55
static xtd::drawing::color light(const xtd::drawing::color &base_color, double perc_of_light_light)
Creates a new light color object for the control from the specified color and lightens it by the spec...
Definition: control_paint.h:133
static void draw_image_disabled(xtd::drawing::graphics &graphics, const xtd::drawing::image &image, int32_t x, int32_t y, float brightness)
Draws the specified image in a disabled state.
static xtd::drawing::color average(const xtd::drawing::color &color1, const xtd::drawing::color &color2, double weight, bool average_alpha)
Returns the weighted average color between the two given colors.
Definition: control_paint.h:42
static xtd::drawing::string_format string_format(xtd::forms::text_format_flags flags)
Convert xtd::forms::text_format_flags to xtd::drawing::string_format.
Definition: control_paint.h:144
static void draw_image(xtd::drawing::graphics &graphics, const xtd::drawing::image &image, const xtd::drawing::rectangle &rectangle, xtd::forms::image_layout image_layout)
Draws the specified image in a specified rectangle with specified layout.
Definition: control_paint.h:82
static void draw_image_disabled(xtd::drawing::graphics &graphics, const xtd::drawing::image &image, const xtd::drawing::point &location, const xtd::drawing::color &background)
Draws the specified image in a disabled state.
Definition: control_paint.h:122
static void draw_image(xtd::drawing::graphics &graphics, const xtd::drawing::image &image, int32_t x, int32_t y, int32_t width, int32_t height, xtd::forms::image_layout image_layout)
Draws the specified image in a specified rectangle with specified layout.
static void draw_image_disabled(xtd::drawing::graphics &graphics, const xtd::drawing::image &image, const xtd::drawing::point &location, float brightness)
Draws the specified image in a disabled state.
Definition: control_paint.h:115
static xtd::drawing::color dark_dark(const xtd::drawing::color &base_color)
Creates a new dark color object for the control from the specified color.
Definition: control_paint.h:72
static void draw_image_disabled(xtd::drawing::graphics &graphics, const xtd::drawing::image &image, int32_t x, int32_t y, const xtd::drawing::color &background)
Draws the specified image in a disabled state.
Definition: control_paint.h:108
static xtd::drawing::color light_light(const xtd::drawing::color &base_color)
Creates a new light color object for the control from the specified color.
Definition: control_paint.h:139
static xtd::drawing::color light(const xtd::drawing::color &base_color)
Creates a new light color object for the control from the specified color.
Definition: control_paint.h:128
static xtd::drawing::color dark(const xtd::drawing::color &base_color, double perc_of_dark_dark)
Creates a new dark color object for the control from the specified color and darkens it by the specif...
Definition: control_paint.h:66
Contains xtd::drawing::color class.
Contains xtd::drawing::font class.
Contains xtd::drawing::graphics class.
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition: static.h:38
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
@ y
The Y key.
@ x
The X key.
@ none
No hot-key prefix.
@ show
Display the hot-key prefix.
@ hide
Do not display the hot-key prefix.
@ far
Specifies that text is aligned far from the origin position of the layout rectangle....
@ near
Specifies the text be aligned near the layout. In a left-to-right layout, the near position is left....
@ center
Specifies that text is aligned in the center of the layout rectangle.
text_format_flags
Specifies the display and layout information for text strings.
Definition: text_format_flags.h:18
button_state
Specifies the appearance of a button.
Definition: button_state.h:19
image_layout
Specifies the position of the image on the control.
Definition: image_layout.h:17
@ location
Specifies that both the x and y coordinates of the control are defined.
Contains xtd::drawing::image class.
Contains xtd::forms::image_layout enum class.
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
Contains xtd::drawing::rectangle class.
Contains xtd::drawing::string_format class.
Contains xtd::drawing::system_fonts factory.
Contains xtd::forms::text_format_flags enum class.