xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Public Member Functions | Static Public Member Functions | List of all members
xtd::forms::screen Class Reference

#include <screen.h>

Definition

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

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>
using namespace xtd::forms;
int main() {
form form1;
form1.start_position(form_start_position::manual);
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.start_position(form_start_position::manual);
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);
}
int32_t y() const
Gets the y-coordinate of this point.
Definition: point.h:205
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:25
int32_t width() const
Gets the horizontal component of this Size class.
Definition: size.h:67
int32_t height() const
Gets he vertical component of this Size Class.
Definition: size.h:57
static void run()
Begins running a standard application message loop on the current thread, without a form.
static screen primary_screen()
Gets the primary display.
Definition: screen.h:77
const drawing::rectangle & working_area() const
Gets the working area of the display. The working area is the desktop area of the display,...
Definition: screen.h:88
@ x
The X key.
@ 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: about_box.h:13
Examples
The following code example shows how to get screen informations of screen component.
#include <xtd/xtd>
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(ustring::format("Number of screens: {}\n", screen::all_screens().size()));
screen_informations_text_box.append_text(ustring::format("Standard pixels per inch: {}\n", screen::get_standard_pixels_per_inch()));
auto index = 1;
for (auto screen : screen::all_screens()) {
screen_informations_text_box.append_text("\n");
screen_informations_text_box.append_text(ustring::format("Screen: {}\n", index));
screen_informations_text_box.append_text(ustring::format(" Device name: {}\n", screen.device_name()));
screen_informations_text_box.append_text(ustring::format(" Bounds: {}\n", screen.bounds()));
screen_informations_text_box.append_text(ustring::format(" High resolution: {}\n", screen.high_resolution()));
screen_informations_text_box.append_text(ustring::format(" working area: {}\n", screen.working_area()));
screen_informations_text_box.append_text(ustring::format(" Primary: {}\n", screen.primary()));
screen_informations_text_box.append_text(ustring::format(" Bits per pixels (Depth): {}\n", screen.bits_per_pixel()));
screen_informations_text_box.append_text(ustring::format(" Pixels per Inch (PPI): {}\n", screen.pixels_per_inch()));
screen_informations_text_box.append_text(ustring::format(" Scale factor: {}\n", screen.scale_factor()));
++index;
}
}
private:
text_box screen_informations_text_box;
};
auto main()->int {
}
static std::vector< screen > all_screens()
Gets an array of all displays on the system.
static int32_t get_standard_pixels_per_inch()
Gets the the standard number of pixels per inch of the display.
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: ustring.h:689
size_t size
Represents a size of any object in bytes.
Definition: types.h:171
@ text_box
The system-defined color of the accent color (macos specific. On other platform is same as window).
@ fill
All the control's edges are docked to the all edges of its containing control and sized appropriately...
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition: bitmap.h:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17

Inherits xtd::object.

Public Member Functions

int32_t bits_per_pixel () const
 Gets the number of bits of memory, associated with one pixel of data. More...
 
const drawing::rectanglebounds () const
 Gets the bounds of the display. More...
 
const xtd::ustringdevice_name () const
 Gets the device name associated with a display. More...
 
bool high_resolution () const
 Gets a value indicating whether a particular display is high resolution. More...
 
int32_t pixels_per_inch () const
 Gets the number of pixels per inch of the display. More...
 
bool primary () const
 Gets a value indicating whether a particular display is the primary device. More...
 
double scale_factor () const
 Gets the scale factor of the display. More...
 
const drawing::rectangleworking_area () const
 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. More...
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance. More...
 
virtual xtd::ustring to_string () const noexcept
 Returns a std::string that represents the current object. More...
 

Static Public Member Functions

static std::vector< screenall_screens ()
 Gets an array of all displays on the system. More...
 
static drawing::graphics create_graphics ()
 Creates the xtd::drawing::graphics for the screen. More...
 
static screen from_control (const control &control)
 Retrieves a screen for the display that contains the largest portion of the specified control. More...
 
static screen from_handle (intptr_t handle)
 Retrieves a screen for the display that contains the largest portion of the object referred to by the specified handle. More...
 
static screen from_point (const drawing::point &point)
 Retrieves a screen for the display that contains the specified point. More...
 
static screen from_rectangle (const drawing::rectangle &rect)
 Retrieves a screen for the display that contains the largest portion of the rectangle. More...
 
static drawing::rectangle get_bounds (const control &control)
 Retrieves the bounds of the display that contains the largest portion of the specified control. More...
 
static drawing::rectangle get_bounds (const drawing::point &point)
 Retrieves the bounds of the display that contains the specified point. More...
 
static drawing::rectangle get_bounds (const drawing::rectangle &rect)
 Retrieves the bounds of the display that contains the largest portion of the specified rectangle. More...
 
static drawing::rectangle get_bounds (intptr_t handle)
 Retrieves the bounds of the display that contains the largest portion of the specified handle. More...
 
static int32_t get_standard_pixels_per_inch ()
 Gets the the standard number of pixels per inch of the display. More...
 
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. More...
 
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. More...
 
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. More...
 
static drawing::rectangle get_working_area (intptr_t 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. More...
 
static screen primary_screen ()
 Gets the primary display. More...
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 

Member Function Documentation

◆ 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.

◆ bits_per_pixel()

int32_t xtd::forms::screen::bits_per_pixel ( ) const
inline

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

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

Gets the bounds of the display.

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

◆ device_name()

const xtd::ustring& xtd::forms::screen::device_name ( ) const
inline

Gets the device name associated with a display.

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

◆ 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_t  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 ( 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() [3/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_bounds() [4/4]

static drawing::rectangle xtd::forms::screen::get_bounds ( intptr_t  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_standard_pixels_per_inch()

static int32_t 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 ( 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() [3/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.

◆ get_working_area() [4/4]

static drawing::rectangle xtd::forms::screen::get_working_area ( intptr_t  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.

◆ high_resolution()

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

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

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

◆ pixels_per_inch()

int32_t xtd::forms::screen::pixels_per_inch ( ) const
inline

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

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

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

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

◆ primary_screen()

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

Gets the primary display.

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

◆ scale_factor()

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

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

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

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

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