xtd 0.2.0
Loading...
Searching...
No Matches
xtd::forms::screen Class Reference
Inheritance diagram for xtd::forms::screen:
xtd::object

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/forms/application>
#include <xtd/forms/form>
using namespace xtd::forms;
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.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.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);
}
int32 y() const noexcept
Gets the y-coordinate of this xtd::drawing::point.
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.hpp:44
xtd::drawing::size size() const noexcept
Gets the size of this xtd::drawing::rectangle.
xtd::drawing::point location() const noexcept
Gets the coordinates of the upper-left corner of this xtd::drawing::rectangle structure.
int32 height() const noexcept
Gets he vertical component of this xtd::drawing::size class.
int32 width() const noexcept
Gets the horizontal component of this xtd::drawing::size class.
static void run()
Begins running a standard application message loop on the current thread, without a form.
virtual drawing::point location() const noexcept
Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its...
virtual const xtd::string & text() const noexcept
Gets the text associated with this control.
virtual drawing::size size() const noexcept
Gets the height and width of the control.
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
control & visible(bool visible) override
Sets a value indicating whether the control and all its child controls are displayed.
virtual form_start_position start_position() const noexcept
Gets the starting position of the form at run time.
const drawing::rectangle & working_area() const noexcept
Gets the working area of the display. The working area is the desktop area of the display,...
static screen primary_screen()
Gets the primary display.
@ x
Specifies that the left edge of the control is defined.
@ width
Specifies that the width of the control is defined.
@ manual
The position of the form is determined by the Location property.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12
Examples
The following code example shows how to get screen informations of screen component.
#include <xtd/drawing/colors>
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/screen>
#include <xtd/forms/text_box>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
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().size(), 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 {
}
Represents a display device or multiple display devices on a single system.
Definition screen.hpp:32
bool high_resolution() const noexcept
Gets a value indicating whether a particular display is high resolution.
double scale_factor() const noexcept
Gets the scale factor of the display.
const drawing::rectangle & bounds() const noexcept
Gets the bounds of the display.
int32 bits_per_pixel() const noexcept
Gets the number of bits of memory, associated with one pixel of data.
int32 pixels_per_inch() const noexcept
Gets the number of pixels per inch of the display.
bool primary() const noexcept
Gets a value indicating whether a particular display is the primary device.
const xtd::string & device_name() const
Gets the device name associated with a display.
Represents a standard Windows text box.
Definition text_box.hpp:31
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Examples
screen_informations.cpp.

Public Properties

int32 bits_per_pixel () const noexcept
 Gets the number of bits of memory, associated with one pixel of data.
 
const drawing::rectanglebounds () const noexcept
 Gets the bounds of the display.
 
const xtd::stringdevice_name () const
 Gets the device name associated with a display.
 
bool high_resolution () const noexcept
 Gets a value indicating whether a particular display is high resolution.
 
int32 pixels_per_inch () const noexcept
 Gets the number of pixels per inch of the display.
 
bool primary () const noexcept
 Gets a value indicating whether a particular display is the primary device.
 
double scale_factor () const noexcept
 Gets the scale factor of the display.
 
const drawing::rectangleworking_area () const noexcept
 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 Static Properties

static std::vector< screenall_screens ()
 Gets an array of all displays on the system.
 
static screen primary_screen ()
 Gets the primary display.
 

Public Static Methods

static drawing::graphics create_graphics ()
 Creates the xtd::drawing::graphics for the screen.
 
static screen from_control (const control &control)
 Retrieves a screen for the display that contains the largest portion of the specified control.
 
static screen from_handle (intptr handle)
 Retrieves a screen for the display that contains the largest portion of the object referred to by the specified handle.
 
static screen from_point (const drawing::point &point)
 Retrieves a screen for the display that contains the specified point.
 
static screen from_rectangle (const drawing::rectangle &rect)
 Retrieves a screen for the display that contains the largest portion of the rectangle.
 
static drawing::rectangle get_bounds (const control &control)
 Retrieves the bounds of the display that contains the largest portion of the specified control.
 
static drawing::rectangle get_bounds (intptr handle)
 Retrieves the bounds of the display that contains the largest portion of the specified handle.
 
static drawing::rectangle get_bounds (const drawing::point &point)
 Retrieves the bounds of the display that contains the specified point.
 
static drawing::rectangle get_bounds (const drawing::rectangle &rect)
 Retrieves the bounds of the display that contains the largest portion of the specified rectangle.
 
static int32 get_standard_pixels_per_inch ()
 Gets the the standard number of pixels per inch of the display.
 
static drawing::rectangle get_working_area (const control &control)
 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 drawing::rectangle get_working_area (intptr handle)
 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 drawing::rectangle get_working_area (const drawing::point &point)
 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 drawing::rectangle get_working_area (const drawing::rectangle &rect)
 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

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
virtual xtd::string to_string () const noexcept
 Returns a xtd::string that represents the current object.
 
- Static Public Member Functions inherited from xtd::object
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<typename object_a_t , typename object_b_t >
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Member Function Documentation

◆ bits_per_pixel()

int32 xtd::forms::screen::bits_per_pixel ( ) const
noexcept

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.
Examples
screen_informations.cpp.

◆ bounds()

const drawing::rectangle & xtd::forms::screen::bounds ( ) const
noexcept

Gets the bounds of the display.

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

◆ device_name()

const xtd::string & xtd::forms::screen::device_name ( ) const

Gets the device name associated with a display.

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

◆ high_resolution()

bool xtd::forms::screen::high_resolution ( ) const
noexcept

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

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

◆ pixels_per_inch()

int32 xtd::forms::screen::pixels_per_inch ( ) const
noexcept

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.
Examples
screen_informations.cpp.

◆ primary()

bool xtd::forms::screen::primary ( ) const
noexcept

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

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

◆ scale_factor()

double xtd::forms::screen::scale_factor ( ) const
noexcept

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.
Examples
screen_informations.cpp.

◆ working_area()

const drawing::rectangle & xtd::forms::screen::working_area ( ) const
noexcept

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.
Examples
screen_informations.cpp.

◆ all_screens()

static std::vector< screen > xtd::forms::screen::all_screens ( )
static

Gets an array of all displays on the system.

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

◆ primary_screen()

static screen xtd::forms::screen::primary_screen ( )
static

Gets the primary display.

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

◆ create_graphics()

static drawing::graphics xtd::forms::screen::create_graphics ( )
static

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

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

◆ from_control()

static screen xtd::forms::screen::from_control ( const control control)
static

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()

static screen xtd::forms::screen::from_handle ( intptr  handle)
static

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()

static screen xtd::forms::screen::from_point ( const drawing::point point)
static

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()

static screen xtd::forms::screen::from_rectangle ( const drawing::rectangle rect)
static

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]

static drawing::rectangle xtd::forms::screen::get_bounds ( const control control)
static

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]

static drawing::rectangle xtd::forms::screen::get_bounds ( intptr  handle)
static

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]

static drawing::rectangle xtd::forms::screen::get_bounds ( const drawing::point point)
static

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]

static drawing::rectangle xtd::forms::screen::get_bounds ( const drawing::rectangle rect)
static

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()

static int32 xtd::forms::screen::get_standard_pixels_per_inch ( )
static

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]

static drawing::rectangle xtd::forms::screen::get_working_area ( const control control)
static

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]

static drawing::rectangle xtd::forms::screen::get_working_area ( intptr  handle)
static

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]

static drawing::rectangle xtd::forms::screen::get_working_area ( const drawing::point point)
static

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]

static drawing::rectangle xtd::forms::screen::get_working_area ( const drawing::rectangle rect)
static

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: