xtd 0.2.0
Loading...
Searching...
No Matches
graphics.h
1#pragma once
3#if !defined(__XTD_DRAWING_NATIVE_LIBRARY__)
4#error "Do not include this file: Internal use only"
5#endif
7
8#include <cstdint>
9#include <tuple>
10#include <xtd/collections/generic/key_value_pair>
11#include <xtd/static>
12#include <xtd/string>
13#include <xtd/drawing_native_export.h>
14#include "hot_key_prefixes.h"
15#include "path_fill_modes.h"
16
18namespace xtd {
20 namespace drawing {
22 class graphics;
24
27 namespace native {
35 class drawing_native_export_ graphics final static_ {
37 protected:
39
52 static void copy_from_graphics(intptr handle, intptr handle_source, int32 source_x, int32 source_y, int32 destination_x, int32 destination_y, int32 block_region_width, int32 block_region_height, int32 copy_pixel_operation);
60 static void clear(intptr handle, xtd::byte a, xtd::byte r, xtd::byte g, xtd::byte b);
61
66 static void clip(intptr handle, intptr region);
67
72 static void compositing_mode(intptr handle, int32 compositing_mode);
73
78 static void compositing_quality(intptr handle, int32 compositing_quality);
79
90 static void copy_from_screen(intptr handle, int32 source_x, int32 source_y, int32 destination_x, int32 destination_y, int32 block_region_width, int32 block_region_height, int32 copy_pixel_operation);
91
95 static void destroy(intptr handle);
96
107 static void draw_arc(intptr handle, intptr pen, float x, float y, float width, float height, float start_angle, float sweep_angle);
108
121 static void draw_bezier(intptr handle, intptr pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
122
129
136 static void draw_closed_curve(intptr handle, intptr pen, std::vector<xtd::collections::generic::key_value_pair<float, float>> points, float tension);
137
146 static void draw_curve(intptr handle, intptr pen, std::vector<xtd::collections::generic::key_value_pair<float, float>> points, float tension);
147
156 static void draw_ellipse(intptr handle, intptr pen, float x, float y, float width, float heigh);
157
164 static void draw_image(intptr handle, intptr image, float x, float y, float width, float height);
165
174 static void draw_image(intptr handle, intptr image, float dest_x, float dest_y, float dest_width, float dest_height, float src_x, float src_y, float src_width, float src_height);
175
185 static void draw_image_disabled(intptr handle, intptr image, float x, float y, float width, float height, float brightness);
186
195 static void draw_line(intptr handle, intptr pen, float x1, float y1, float x2, float y2);
196
203
210
221 static void draw_pie(intptr handle, intptr pen, float x, float y, float width, float height, float start_angle, float sweep_angle);
222
229
238 static void draw_rectangle(intptr handle, intptr pen, float x, float y, float width, float height);
239
245 static void draw_rectangles(intptr handle, intptr pen, std::vector<std::tuple<float, float, float, float>>& rects);
246
256 static void draw_rotated_string(intptr handle, const xtd::string& text, intptr font, intptr brush, float x, float y, float angle);
257
267 static void draw_rounded_rectangle(intptr handle, intptr pen, float x, float y, float width, float height, float radius);
268
281 static void draw_string(intptr handle, const xtd::string& text, intptr font, intptr brush, float x, float y, int32 alignment, int32 line_alignment, int32 hot_key_prefix, int32 trimming);
297 static void draw_string(intptr handle, const xtd::string& text, intptr font, intptr brush, float x, float y, float width, float height, int32 alignment, int32 line_alignment, int32 hot_key_prefix, int32 trimming, int32 string_formats);
298
306 static void fill_closed_curve(intptr handle, intptr brush, std::vector<xtd::collections::generic::key_value_pair<float, float>> points, uint32 fill_mode, float tension);
307
316 static void fill_ellipse(intptr handle, intptr brush, float x, float y, float width, float heigh);
317
324 static void fill_path(intptr handle, intptr brush, intptr graphics_path, int32 mode);
325
336 static void fill_pie(intptr handle, intptr brush, float x, float y, float width, float height, float start_angle, float sweep_angle);
337
344 static void fill_polygon(intptr handle, intptr pen, const std::vector<xtd::collections::generic::key_value_pair<float, float>>& points, int32 fill_mode);
345
354 static void fill_rectangle(intptr handle, intptr brush, float x, float y, float width, float height);
355
361 static void fill_rectangles(intptr handle, intptr brush, std::vector<std::tuple<float, float, float, float>>& rects);
362
369
379 static void fill_rounded_rectangle(intptr handle, intptr brush, float x, float y, float width, float height, float radius);
380
385 static void flush(intptr handle, int32 intention);
386
391 static intptr from_hdc(intptr hdc);
397 static intptr from_hdc(intptr hdc, intptr hdevice);
398
403 static intptr from_hwnd(intptr hwnd);
404
410
415 static float get_dpi_x(intptr handle);
416
421 static float get_dpi_y(intptr handle);
422
427 static intptr get_hdc(intptr handle);
428
440 static void get_nearest_color(intptr handle, xtd::byte original_a, xtd::byte original_r, xtd::byte original_g, xtd::byte original_b, xtd::byte& nearest_a, xtd::byte& nearest_r, xtd::byte& nearest_g, xtd::byte& nearest_b);
441
446 static void interpolation_mode(intptr handle, int32 interpolation_mode);
447
452 static void pixel_offset_mode(intptr handle, int32 pixel_offst_mode);
453
469 static void measure_string(intptr handle, const xtd::string& text, intptr font, float& width, float& height, float max_width, float max_height, int32 alignment, int32 line_alignment, int32 hot_key_prefix, int32 trimming, size_t characters_fitted, size_t lines_filled, bool measure_trailing_spaces);
470
475 static void release_hdc(intptr handle, intptr hdc);
476
480 static void reset_transform(intptr handle);
481
486 static void restore(intptr handle, intptr& gstate);
487
493 static void rotate_transform(intptr handle, float angle, int32 order);
494
499 static intptr save(intptr handle);
500
507 static void scale_transform(intptr handle, float sx, float sy, int32 order);
508
513 static void smoothing_mode(intptr handle, int32 smoothing_mode);
514
520 static void text_contrast(intptr handle, int32 text_contrast);
521
526 static void text_rendering_hint(intptr handle, int32 text_rendering_hint);
527
532 static intptr transform(intptr handle);
537 static void transform(intptr handle, intptr matrix);
538
545 static void translate_transform(intptr handle, float dx, float dy, int32 order);
546
554 static xtd::string trim_string(intptr handle, const xtd::string& text, intptr font, float width, int32 trimming);
555
563 static void visible_clip_bounds(intptr handle, float& x, float& y, float& width, float& height);
565 };
566 }
567 }
568}
Represents text as a sequence of character units.
Definition basic_string.h:79
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.h:70
Contains brush native API.
Definition brush.h:41
Contains font native API.
Definition font.h:32
Contains graphics_path native API.
Definition graphics_path.h:36
Contains graphics native API.
Definition graphics.h:35
static intptr from_hwnd(intptr hwnd)
Creates a new graphics from the specified handle to a window.
static void clear(intptr handle, xtd::byte a, xtd::byte r, xtd::byte g, xtd::byte b)
Clears the entire drawing surface and fills it with the specified background color.
static void get_nearest_color(intptr handle, xtd::byte original_a, xtd::byte original_r, xtd::byte original_g, xtd::byte original_b, xtd::byte &nearest_a, xtd::byte &nearest_r, xtd::byte &nearest_g, xtd::byte &nearest_b)
Gets the nearest color to the specified color.
static void reset_transform(intptr handle)
Resets the world transformation matrix of the graphics to the identity matrix.
static void draw_pie(intptr handle, intptr pen, float x, float y, float width, float height, float start_angle, float sweep_angle)
Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height,...
static void compositing_quality(intptr handle, int32 compositing_quality)
Sets the rendering quality of composited images drawn to the graphics.
static void draw_rounded_rectangle(intptr handle, intptr pen, float x, float y, float width, float height, float radius)
Draws a rounded rectangle specified by a coordinate pair, a width, a height, and radius.
static void draw_arc(intptr handle, intptr pen, float x, float y, float width, float height, float start_angle, float sweep_angle)
Draws an arc representing a portion of an ellipse specified by a pair of coordinates,...
static void copy_from_screen(intptr handle, int32 source_x, int32 source_y, int32 destination_x, int32 destination_y, int32 block_region_width, int32 block_region_height, int32 copy_pixel_operation)
Performs a bit-block transfer of color data, corresponding to a rectangle of pixels,...
static void destroy(intptr handle)
Destroys graphics_path.
static void flush(intptr handle, int32 intention)
Forces execution of all pending graphics operations with the method waiting or not waiting,...
static void draw_polygon(intptr handle, intptr pen, const std::vector< xtd::collections::generic::key_value_pair< float, float > > &points)
Draws a polygon defined by an array of xtd::collections::generic::key_value_pair<float,...
static void draw_closed_curve(intptr handle, intptr pen, std::vector< xtd::collections::generic::key_value_pair< float, float > > points, float tension)
Draws a closed cardinal spline defined by an array of xtd::collections::generic::key_value_pair<float...
static void rotate_transform(intptr handle, float angle, int32 order)
Applies the specified rotation to the transformation matrix of the graphics in the specified order.
static void fill_polygon(intptr handle, intptr pen, const std::vector< xtd::collections::generic::key_value_pair< float, float > > &points, int32 fill_mode)
Fills the interior of a polygon defined by an array of points specified by xtd::collections::generic:...
static void measure_string(intptr handle, const xtd::string &text, intptr font, float &width, float &height, float max_width, float max_height, int32 alignment, int32 line_alignment, int32 hot_key_prefix, int32 trimming, size_t characters_fitted, size_t lines_filled, bool measure_trailing_spaces)
Measures the specified string when drawn with the specified font and formatted with the specified for...
static void interpolation_mode(intptr handle, int32 interpolation_mode)
Sets the interpolation mode associated with the graphics.
static void scale_transform(intptr handle, float sx, float sy, int32 order)
Applies the specified scaling operation to the transformation matrix of the graphics in the specified...
static void draw_ellipse(intptr handle, intptr pen, float x, float y, float width, float heigh)
Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner o...
static intptr save(intptr handle)
Saves the current state of the graphics and identifies the saved state with a graphics state.
static void draw_image(intptr handle, intptr image, float dest_x, float dest_y, float dest_width, float dest_height, float src_x, float src_y, float src_width, float src_height)
Draws the specified image, using its original physical size, at the specified location.
static void draw_rotated_string(intptr handle, const xtd::string &text, intptr font, intptr brush, float x, float y, float angle)
Draws the specified text string at the specified location with the specified brush,...
static void draw_string(intptr handle, const xtd::string &text, intptr font, intptr brush, float x, float y, int32 alignment, int32 line_alignment, int32 hot_key_prefix, int32 trimming)
Draws the specified text string at the specified point with the specified brush and font handle using...
static intptr from_hdc(intptr hdc, intptr hdevice)
Creates a new graphics from the specified handle to a device contextand handle to a device.
static void fill_rounded_rectangle(intptr handle, intptr brush, float x, float y, float width, float height, float radius)
Fills the interior of a rounded rectangle specified by a pair of coordinates, a width,...
static void fill_pie(intptr handle, intptr brush, float x, float y, float width, float height, float start_angle, float sweep_angle)
Fills the interior of a pie section defined by an ellipse specified by a pair of coordinates,...
static void draw_beziers(intptr handle, intptr pen, const std::vector< xtd::collections::generic::key_value_pair< float, float > > &points)
Draws a series of Bézier splines from an array of xtd::collections::generic::key_value_pair<float,...
static intptr transform(intptr handle)
Gets a copy of the geometric world transformation for the graphics.
static void smoothing_mode(intptr handle, int32 smoothing_mode)
Sets the rendering quality for the graphics.
static void fill_path(intptr handle, intptr brush, intptr graphics_path, int32 mode)
Fills the interior of a graphics path.
static void draw_line(intptr handle, intptr pen, float x1, float y1, float x2, float y2)
Draws a line connecting the two points specified by the coordinate pairs.
static void visible_clip_bounds(intptr handle, float &x, float &y, float &width, float &height)
Gets the bounding rectangle of the visible clipping region of the graphics.
static void clip(intptr handle, intptr region)
Sets a region handle that limits the drawing region of the graphics.
static void copy_from_graphics(intptr handle, intptr handle_source, int32 source_x, int32 source_y, int32 destination_x, int32 destination_y, int32 block_region_width, int32 block_region_height, int32 copy_pixel_operation)
Performs a bit-block transfer of color data, corresponding to a rectangle of pixels,...
static void draw_image(intptr handle, intptr image, float x, float y, float width, float height)
Draws the specified image, using its original physical size, at the specified location,...
static void pixel_offset_mode(intptr handle, int32 pixel_offst_mode)
Sets a value specifying how pixels are offset during rendering of this graphics.
static void text_contrast(intptr handle, int32 text_contrast)
Sets the gamma correction value for rendering text.
static void draw_rectangles(intptr handle, intptr pen, std::vector< std::tuple< float, float, float, float > > &rects)
Draws a series of rectangles specified by std::tuple<float, float, float, float> structures.
static void draw_string(intptr handle, const xtd::string &text, intptr font, intptr brush, float x, float y, float width, float height, int32 alignment, int32 line_alignment, int32 hot_key_prefix, int32 trimming, int32 string_formats)
Draws the specified text string at the specified rectangle with the specified brush and font handle u...
static void draw_path(intptr handle, intptr pen, intptr graphics_path)
Draws a graphics path.
static void fill_ellipse(intptr handle, intptr brush, float x, float y, float width, float heigh)
Fills the interior of an ellipse defined by a bounding rectangle specified by a pair of coordinates,...
static void translate_transform(intptr handle, float dx, float dy, int32 order)
Changes the origin of the coordinate system by prepending the specified translation to the transforma...
static void fill_rectangles(intptr handle, intptr brush, std::vector< std::tuple< float, float, float, float > > &rects)
Fills the interiors of a series of rectangles specified by std::tuple<float, float,...
static void draw_bezier(intptr handle, intptr pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
Draws a Bézier spline defined by four ordered pairs of coordinates that represent points.
static void text_rendering_hint(intptr handle, int32 text_rendering_hint)
Sets the rendering mode for text associated with the graphics.
static intptr from_image(intptr image)
Creates a new graphics from the specified image.
static void compositing_mode(intptr handle, int32 compositing_mode)
Sets a value that specifies how composited images are drawn to the graphics.
static intptr from_hdc(intptr hdc)
Creates a new graphics from the specified handle to a device context.
static float get_dpi_y(intptr handle)
Gets the vertical resolution of this graphics.
static void restore(intptr handle, intptr &gstate)
Restores the state of the graphics to the state represented by a graphics state.
static void fill_rectangle(intptr handle, intptr brush, float x, float y, float width, float height)
Fills the interior of a rectangle specified by a pair of coordinates, a width, and a height.
static void fill_region(intptr handle, intptr brush, intptr region)
Fills the interior of a region.
static void draw_image_disabled(intptr handle, intptr image, float x, float y, float width, float height, float brightness)
Draws the specified dosabled image at the specified location and size.
static xtd::string trim_string(intptr handle, const xtd::string &text, intptr font, float width, int32 trimming)
Trims the specified string for a specified width with the specified font and trimming.
static void fill_closed_curve(intptr handle, intptr brush, std::vector< xtd::collections::generic::key_value_pair< float, float > > points, uint32 fill_mode, float tension)
Fills the interior of a closed cardinal spline curve defined by an array of xtd::collections::generic...
static float get_dpi_x(intptr handle)
Gets the horizontal resolution of this graphics.
static void draw_rectangle(intptr handle, intptr pen, float x, float y, float width, float height)
Draws a rectangle specified by a coordinate pair, a width, and a height.
static void draw_lines(intptr handle, intptr pen, const std::vector< xtd::collections::generic::key_value_pair< float, float > > &points)
Draws a series of line segments that connect an array of xtd::collections::generic::key_value_pair<fl...
static void transform(intptr handle, intptr matrix)
Sets a copy of the geometric world transformation for the graphics.
static void release_hdc(intptr handle, intptr hdc)
Releases a device context handle obtained by a previous call to the xtd::drawing::native::graphics::g...
static void draw_curve(intptr handle, intptr pen, std::vector< xtd::collections::generic::key_value_pair< float, float > > points, float tension)
Draws a cardinal spline through a specified array of xtd::collections::generic::key_value_pair<float,...
static intptr get_hdc(intptr handle)
Gets the handle to the device context associated with this graphics.
Contains image native API.
Definition image.h:36
Contains matrix native API.
Definition matrix.h:36
Contains pen native API.
Definition pen.h:32
Contains region native API.
Definition region.h:31
std::pair< key_t, value_t > key_value_pair
Defines a key/value pair that can be set or retrieved.
Definition key_value_pair.h:29
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.h:37
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.h:23
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.h:23
uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.h:23
copy_pixel_operation
Determines how the source color in a copy pixel operation is combined with the destination color to r...
Definition copy_pixel_operation.h:18
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10