xtd 1.0.0
Loading...
Searching...
No Matches
xtd::forms::screen Class Reference
Inheritance diagram for xtd::forms::screen:
xtd::object xtd::iequatable< screen > xtd::interface xtd::extensions::equality_operators< screen, iequatable< screen > >

Definition

Represents a display device or multiple display devices on a single system.

Header
#include <xtd/forms/screen>
Namespace
xtd::forms
Library
xtd.forms
Remarks
The constructor for this object is not public, so you cannot explicitly create a screen object. The object is created when you call its public methods.
Examples
The following code example demonstrates the use of screen class.
#include <xtd/xtd>
auto main() -> int {
form form1;
form1.location(area.location());
form1.size({area.size().width / 2, area.size().height / 2});
form1.text("screen 1/4");
form1.visible(true);
form form2;
form2.location({area.location().x + area.size().width / 2, area.location().y});
form2.size({area.size().width / 2, area.size().height / 2});
form2.text("screen 2/4");
form2.visible(true);
form form3;
form3.start_position(form_start_position::manual);
form3.location({area.location().x, area.location().y + area.size().height / 2});
form3.size({area.size().width / 2, area.size().height / 2});
form3.text("screen 3/4");
form3.visible(true);
form form4;
form4.start_position(form_start_position::manual);
form4.location({area.location().x + area.size().width / 2, area.location().y + area.size().height / 2});
form4.size({area.size().width / 2, area.size().height / 2});
form4.text("screen 4/4");
form4.visible(true);
application::run(form1);
}
virtual auto size() const noexcept -> xtd::drawing::size
Gets the height and width of the control.
virtual auto text() const noexcept -> const xtd::string &
Gets the text associated with this control.
virtual auto location() const noexcept -> xtd::drawing::point
Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its...
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
virtual auto start_position() const noexcept -> xtd::forms::form_start_position
Gets the starting position of the form at run time.
auto visible(bool visible) -> xtd::forms::control &override
Sets a value indicating whether the control and all its child controls are displayed.
static auto primary_screen() -> screen
Gets the primary display.
xtd::forms::style_sheets::control form
The form data allows you to specify the box of a form control.
Definition form.hpp:23
@ manual
The position of the form is determined by the Location property.
Definition form_start_position.hpp:24
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.hpp:44
auto size() const noexcept -> xtd::drawing::size
Gets the size of this xtd::drawing::rectangle.
auto location() const noexcept -> xtd::drawing::point
Gets the coordinates of the upper-left corner of this xtd::drawing::rectangle structure.
Examples
The following code example shows how to get screen informations of screen component.
#include <xtd/xtd>
class main_form : public form {
public:
main_form() {
back_color(colors::dark_blue());
client_size({450, 300});
fore_color(colors::yellow());
text("Screen informations example");
screen_informations_text_box.dock(dock_style::fill);
screen_informations_text_box.multiline(true);
screen_informations_text_box.parent(*this);
screen_informations_text_box.read_only(true);
screen_informations_text_box.word_wrap(false);
screen_informations_text_box.append_text(string::format("Number of screens: {}{}", screen::all_screens().length(), environment::new_line()));
screen_informations_text_box.append_text(string::format("Standard pixels per inch: {}{}", screen::get_standard_pixels_per_inch(), environment::new_line()));
auto index = 0;
for (auto screen : screen::all_screens()) {
screen_informations_text_box.append_text(environment::new_line());
screen_informations_text_box.append_text(string::format("Screen: {}\n", ++index, environment::new_line()));
screen_informations_text_box.append_text(string::format(" Device name: {}{}", screen.device_name(), environment::new_line()));
screen_informations_text_box.append_text(string::format(" Bounds: {}{}", screen.bounds(), environment::new_line()));
screen_informations_text_box.append_text(string::format(" High resolution: {}{}", screen.high_resolution(), environment::new_line()));
screen_informations_text_box.append_text(string::format(" working area: {}{}", screen.working_area(), environment::new_line()));
screen_informations_text_box.append_text(string::format(" Primary: {}{}", screen.primary(), environment::new_line()));
screen_informations_text_box.append_text(string::format(" Bits per pixels (Depth): {}{}", screen.bits_per_pixel(), environment::new_line()));
screen_informations_text_box.append_text(string::format(" Pixels per Inch (PPI): {}{}", screen.pixels_per_inch(), environment::new_line()));
screen_informations_text_box.append_text(string::format(" Scale factor: {}{}", screen.scale_factor()));
}
}
private:
text_box screen_informations_text_box;
};
auto main() -> int {
}
static auto new_line() noexcept -> xtd::string
Gets the newline string defined for this environment.
static auto run() -> void
Begins running a standard application message loop on the current thread, without a form.
virtual auto back_color() const noexcept -> xtd::drawing::color
Gets the background color for the control.
virtual auto fore_color() const noexcept -> xtd::drawing::color
Gets the foreground color of the control.
virtual auto client_size() const noexcept -> const xtd::drawing::size &
Gets the height and width of the client area of the control.
Represents a display device or multiple display devices on a single system.
Definition screen.hpp:32
auto high_resolution() const noexcept -> bool
Gets a value indicating whether a particular display is high resolution.
auto device_name() const -> const xtd::string &
Gets the device name associated with a display.
static auto get_standard_pixels_per_inch() -> xtd::int32
Gets the the standard number of pixels per inch of the display.
auto working_area() const noexcept -> const xtd::drawing::rectangle &
Gets the working area of the display. The working area is the desktop area of the display,...
auto scale_factor() const noexcept -> double
Gets the scale factor of the display.
auto primary() const noexcept -> bool
Gets a value indicating whether a particular display is the primary device.
auto bits_per_pixel() const noexcept -> xtd::int32
Gets the number of bits of memory, associated with one pixel of data.
auto bounds() const noexcept -> const xtd::drawing::rectangle &
Gets the bounds of the display.
static auto all_screens() -> xtd::array< screen >
Gets an array of all displays on the system.
auto pixels_per_inch() const noexcept -> xtd::int32
Gets the number of pixels per inch of the display.
static auto format(const basic_string< char > &fmt, args_t &&... args) -> basic_string
@ fill
All the control's edges are docked to the all edges of its containing control and sized appropriately...
Definition dock_style.hpp:35
constexpr auto length() const noexcept -> size_type
Returns the length of the current read_only_span.
Definition read_only_span.hpp:213

Public Properties

auto bits_per_pixel () const noexcept -> xtd::int32
 Gets the number of bits of memory, associated with one pixel of data.
auto bounds () const noexcept -> const xtd::drawing::rectangle &
 Gets the bounds of the display.
auto device_name () const -> const xtd::string &
 Gets the device name associated with a display.
auto high_resolution () const noexcept -> bool
 Gets a value indicating whether a particular display is high resolution.
auto pixels_per_inch () const noexcept -> xtd::int32
 Gets the number of pixels per inch of the display.
auto primary () const noexcept -> bool
 Gets a value indicating whether a particular display is the primary device.
auto scale_factor () const noexcept -> double
 Gets the scale factor of the display.
auto working_area () const noexcept -> const xtd::drawing::rectangle &
 Gets the working area of the display. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Public Methods

auto equals (const xtd::object &obj) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
auto equals (const screen &other) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
auto get_hash_code () const noexcept -> xtd::usize override
 Serves as a hash function for a particular type.

Public Static Properties

static auto all_screens () -> xtd::array< screen >
 Gets an array of all displays on the system.
static auto primary_screen () -> screen
 Gets the primary display.

Public Static Methods

static auto create_graphics () -> xtd::drawing::graphics
 Creates the xtd::drawing::graphics for the screen.
static auto from_control (const xtd::forms::control &control) -> screen
 Retrieves a screen for the display that contains the largest portion of the specified control.
static auto from_handle (xtd::intptr handle) -> screen
 Retrieves a screen for the display that contains the largest portion of the object referred to by the specified handle.
static auto from_point (const xtd::drawing::point &point) -> screen
 Retrieves a screen for the display that contains the specified point.
static auto from_rectangle (const xtd::drawing::rectangle &rect) -> screen
 Retrieves a screen for the display that contains the largest portion of the rectangle.
static auto get_bounds (const xtd::forms::control &control) -> xtd::drawing::rectangle
 Retrieves the bounds of the display that contains the largest portion of the specified control.
static auto get_bounds (xtd::intptr handle) -> xtd::drawing::rectangle
 Retrieves the bounds of the display that contains the largest portion of the specified handle.
static auto get_bounds (const xtd::drawing::point &point) -> xtd::drawing::rectangle
 Retrieves the bounds of the display that contains the specified point.
static auto get_bounds (const xtd::drawing::rectangle &rect) -> xtd::drawing::rectangle
 Retrieves the bounds of the display that contains the largest portion of the specified rectangle.
static auto get_standard_pixels_per_inch () -> xtd::int32
 Gets the the standard number of pixels per inch of the display.
static auto get_working_area (const xtd::forms::control &control) -> xtd::drawing::rectangle
 Retrieves the working area for the display that contains the largest region of the specified control. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.
static auto get_working_area (xtd::intptr handle) -> xtd::drawing::rectangle
 Retrieves the working area for the display that contains the largest region of the specified handle. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.
static auto get_working_area (const xtd::drawing::point &point) -> xtd::drawing::rectangle
 Retrieves the working area closest to the specified point. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.
static auto get_working_area (const xtd::drawing::rectangle &rect) -> xtd::drawing::rectangle
 Retrieves the working area for the display that contains the largest portion of the specified rectangle. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Additional Inherited Members

 object ()=default
 Create a new instance of the ultimate base class object.
virtual auto get_type () const noexcept -> type_object
 Gets the type of the current instance.
template<typename object_t>
auto memberwise_clone () const -> xtd::unique_ptr_object< object_t >
 Creates a shallow copy of the current object.
virtual auto to_string () const -> xtd::string
 Returns a xtd::string that represents the current object.
virtual auto equals (const screen &) const noexcept -> bool=0
 Indicates whether the current object is equal to another object of the same type.
template<typename object_a_t, typename object_b_t>
static auto equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are considered equal.
template<typename object_a_t, typename object_b_t>
static auto reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are the same instance.

Member Function Documentation

◆ bits_per_pixel()

auto xtd::forms::screen::bits_per_pixel ( ) const -> xtd::int32
nodiscardnoexcept

Gets the number of bits of memory, associated with one pixel of data.

Returns
The number of bits of memory, associated with one pixel of data.
Remarks
Typically, the number of bits per pixel for a screen is useful when working with bitmaps.

◆ bounds()

auto xtd::forms::screen::bounds ( ) const -> const xtd::drawing::rectangle &
nodiscardnoexcept

Gets the bounds of the display.

Returns
A xtd::drawing::rectangle, representing the bounds of the display.

◆ device_name()

auto xtd::forms::screen::device_name ( ) const -> const xtd::string &
nodiscard

Gets the device name associated with a display.

Returns
The device name associated with a display.
Remarks
This string may contain non-printable characters.

◆ high_resolution()

auto xtd::forms::screen::high_resolution ( ) const -> bool
nodiscardnoexcept

Gets a value indicating whether a particular display is high resolution.

Returns
true if this display is high resolution; otherwise, false.

◆ pixels_per_inch()

auto xtd::forms::screen::pixels_per_inch ( ) const -> xtd::int32
nodiscardnoexcept

Gets the number of pixels per inch of the display.

Returns
The number of pixels per inch of the display.
Remarks
See get_standard_pixels_per_inch() for more informations.

◆ primary()

auto xtd::forms::screen::primary ( ) const -> bool
nodiscardnoexcept

Gets a value indicating whether a particular display is the primary device.

Returns
true if this display is primary; otherwise, false.

◆ scale_factor()

auto xtd::forms::screen::scale_factor ( ) const -> double
nodiscardnoexcept

Gets the scale factor of the display.

Returns
The scale factor of the display.
Remarks
This value is computed from pixels_per_inch() for the display divided by get_standard_pixels_per_inch().
If scale factor is equal to 1.0 is a standard display; greater than 1.0 is a high DPI display.
See get_standard_pixels_per_inch() for more informations.

◆ working_area()

auto xtd::forms::screen::working_area ( ) const -> const xtd::drawing::rectangle &
nodiscardnoexcept

Gets the working area of the display. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Returns
A xtd::drawing::rectangle, representing the working area of the display.
Remarks
The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.
working_area will return the entire area of the screen if the Windows Taskbar is set to Auto-Hide, no matter whether the Taskbar is currently displayed or not.

◆ all_screens()

auto xtd::forms::screen::all_screens ( ) -> xtd::array< screen >
staticnodiscard

Gets an array of all displays on the system.

Returns
An array of type screen, containing all displays on the system.

◆ primary_screen()

auto xtd::forms::screen::primary_screen ( ) -> screen
staticnodiscard

Gets the primary display.

Returns
The primary display.
Remarks
For a single display system, the primary display is the only display.

◆ equals() [1/2]

auto xtd::forms::screen::equals ( const xtd::object & obj) const -> bool
nodiscardoverridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

Reimplemented from xtd::object.

◆ equals() [2/2]

auto xtd::forms::screen::equals ( const screen & other) const -> bool
nodiscardoverridenoexcept

Determines whether the specified object is equal to the current object.

Parameters
otherThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

◆ get_hash_code()

auto xtd::forms::screen::get_hash_code ( ) const -> xtd::usize
nodiscardoverridevirtualnoexcept

Serves as a hash function for a particular type.

Returns
A hash code for the current object.

Reimplemented from xtd::object.

◆ create_graphics()

auto xtd::forms::screen::create_graphics ( ) -> xtd::drawing::graphics
staticnodiscard

Creates the xtd::drawing::graphics for the screen.

Returns
A xtd::drawing::graphics for the screen.

◆ from_control()

auto xtd::forms::screen::from_control ( const xtd::forms::control & control) -> screen
staticnodiscard

Retrieves a screen for the display that contains the largest portion of the specified control.

Parameters
controlA xtd::forms::control for which to retrieve a Screen.
Returns
A screen for the display that contains the largest region of the specified control. In multiple display environments where no display contains the control, the display closest to the specified control is returned.

◆ from_handle()

auto xtd::forms::screen::from_handle ( xtd::intptr handle) -> screen
staticnodiscard

Retrieves a screen for the display that contains the largest portion of the object referred to by the specified handle.

Parameters
handleThe window handle for which to retrieve the screen.
Returns
A screen for the display that contains the largest region of the object. In multiple display environments where no display contains any portion of the specified handle, the display closest to the object is returned.

◆ from_point()

auto xtd::forms::screen::from_point ( const xtd::drawing::point & point) -> screen
staticnodiscard

Retrieves a screen for the display that contains the specified point.

Parameters
pointA xtd::drawing::point that specifies the location for which to retrieve a screen.
Returns
A screen for the display that contains the point. In multiple display environments where no display contains the point, the display closest to the specified point is returned.

◆ from_rectangle()

auto xtd::forms::screen::from_rectangle ( const xtd::drawing::rectangle & rect) -> screen
staticnodiscard

Retrieves a screen for the display that contains the largest portion of the rectangle.

Parameters
Axtd::drawing::rectangle that specifies the area for which to retrieve the display.
Returns
A screen for the display that contains the largest region of the specified rectangle. In multiple display environments where no display contains the rectangle, the display closest to the rectangle is returned.

◆ get_bounds() [1/4]

auto xtd::forms::screen::get_bounds ( const xtd::forms::control & control) -> xtd::drawing::rectangle
staticnodiscard

Retrieves the bounds of the display that contains the largest portion of the specified control.

Parameters
controlThe control for which to retrieve the display bounds.
Returns
A xtd::drawing::rectangle that specifies the bounds of the display that contains the specified control. In multiple display environments where no display contains the specified control, the display closest to the control is returned.

◆ get_bounds() [2/4]

auto xtd::forms::screen::get_bounds ( xtd::intptr handle) -> xtd::drawing::rectangle
staticnodiscard

Retrieves the bounds of the display that contains the largest portion of the specified handle.

Parameters
handleThe window handle for which to retrieve the display bounds.
Returns
A xtd::drawing::rectangle that specifies the bounds of the display that contains the specified handle. In multiple display environments where no display contains the specified handle, the display closest to the object is returned.

◆ get_bounds() [3/4]

auto xtd::forms::screen::get_bounds ( const xtd::drawing::point & point) -> xtd::drawing::rectangle
staticnodiscard

Retrieves the bounds of the display that contains the specified point.

Parameters
pointA xtd::drawing::point that specifies the coordinates for which to retrieve the display bounds.
Returns
A xtd::drawing::rectangle that specifies the bounds of the display that contains the specified point. In multiple display environments where no display contains the specified point, the display closest to the point is returned.

◆ get_bounds() [4/4]

auto xtd::forms::screen::get_bounds ( const xtd::drawing::rectangle & rect) -> xtd::drawing::rectangle
staticnodiscard

Retrieves the bounds of the display that contains the largest portion of the specified rectangle.

Parameters
rectA xtd::drawing::rectangle that specifies the area for which to retrieve the display bounds.
Returns
A xtd::drawing::rectangle that specifies the bounds of the display that contains the specified rectangle. In multiple display environments where no monitor contains the specified rectangle, the monitor closest to the rectangle is returned.

◆ get_standard_pixels_per_inch()

auto xtd::forms::screen::get_standard_pixels_per_inch ( ) -> xtd::int32
staticnodiscard

Gets the the standard number of pixels per inch of the display.

Returns
The standard number of pixels per inch of the display.
Remarks
In printing, DPI (dots per inch) refers to the output resolution of a printer, scanner or image setter, and PPI (pixels per inch) refers to the input resolution of a photograph, image or screen.
The following table shows the standard values by operating system :
Values and conversion Windows macOS linux
Pixels per inch (PPI) 96 72 96
Pixels per centimeters (pixel/cm) 38 28 38
Pitch (µm) 265 353 265

◆ get_working_area() [1/4]

auto xtd::forms::screen::get_working_area ( const xtd::forms::control & control) -> xtd::drawing::rectangle
staticnodiscard

Retrieves the working area for the display that contains the largest region of the specified control. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Parameters
controlThe control for which to retrieve the working area.
Returns
A xtd::drawing::rectangle that specifies the working area. In multiple display environments where no display contains the specified control, the display closest to the control is returned.

◆ get_working_area() [2/4]

auto xtd::forms::screen::get_working_area ( xtd::intptr handle) -> xtd::drawing::rectangle
staticnodiscard

Retrieves the working area for the display that contains the largest region of the specified handle. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Parameters
handleThe window handle for which to retrieve the working area.
Returns
A xtd::drawing::rectangle that specifies the working area. In multiple display environments where no display contains the specified handle, the display closest to the object is returned.

◆ get_working_area() [3/4]

auto xtd::forms::screen::get_working_area ( const xtd::drawing::point & point) -> xtd::drawing::rectangle
staticnodiscard

Retrieves the working area closest to the specified point. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Parameters
pointA xtd::drawing::point that specifies the coordinates for which to retrieve the working area.
Returns
A xtd::drawing::rectangle that specifies the working area. In multiple display environments where no display contains the specified point, the display closest to the point is returned.

◆ get_working_area() [4/4]

auto xtd::forms::screen::get_working_area ( const xtd::drawing::rectangle & rect) -> xtd::drawing::rectangle
staticnodiscard

Retrieves the working area for the display that contains the largest portion of the specified rectangle. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Parameters
rectThe xtd::drawing::rectangle that specifies the area for which to retrieve the working area.
Returns
A xtd::drawing::rectangle that specifies the working area. In multiple display environments where no display contains the specified rectangle, the display closest to the rectangle is returned.

The documentation for this class was generated from the following file: