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.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
screen.h
Go to the documentation of this file.
1 #pragma once
5 #include <cstdint>
6 #include <string>
7 #include <vector>
8 #include <xtd/object.h>
10 #include "control.h"
11 
13 namespace xtd {
15  namespace forms {
29  class forms_export_ screen : public object {
30  public:
32  screen(const screen&) = default;
33  screen& operator=(const screen&) = default;
35 
38  static std::vector<screen> all_screens();
39 
43  int32_t bits_per_pixel() const {return bits_per_pixel_;}
44 
47  const drawing::rectangle& bounds() const {return bounds_;}
48 
52  const xtd::ustring& device_name() const {return device_name_;}
53 
56  bool high_resolution() const {return scale_factor_ > 1.;}
57 
61  int32_t pixels_per_inch() const {return pixels_per_inch_;}
62 
65  bool primary() const {return primary_;}
66 
72  double scale_factor() const {return scale_factor_;}
73 
78  std::vector<screen> screens = all_screens();
79  for (auto& screen : screens)
80  if (screen.primary()) return screen;
81  return screens[0];
82  }
83 
88  const drawing::rectangle& working_area() const {return working_area_;}
89 
94 
99 
103  static screen from_handle(intptr_t handle);
104 
108  static screen from_point(const drawing::point& point);
109 
114 
119 
123  static drawing::rectangle get_bounds(intptr_t handle);
124 
129 
134 
145 
150 
154  static drawing::rectangle get_working_area(intptr_t handle);
155 
160 
165 
166  private:
167  screen() = default;
168  screen(int32_t bits_per_pixel, const drawing::rectangle& bounds, const xtd::ustring& device_name, int32_t pixels_per_inch, bool primary, double scale_factor, const drawing::rectangle& working_area) : bits_per_pixel_(bits_per_pixel), bounds_(bounds), device_name_(device_name), pixels_per_inch_(pixels_per_inch), primary_(primary), scale_factor_(scale_factor), working_area_(working_area) {}
169 
170  int32_t bits_per_pixel_ = 0;
171  drawing::rectangle bounds_;
172  xtd::ustring device_name_;
173  int32_t pixels_per_inch_ = 96;
174  bool primary_ = false;
175  double scale_factor_ = 1.;
176  drawing::rectangle working_area_;
177  };
178  }
179 }
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: graphics.h:48
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
Defines the base class for controls, which are components with visual representation.
Definition: control.h:67
Represents a display device or multiple display devices on a single system.
Definition: screen.h:29
static screen from_point(const drawing::point &point)
Retrieves a screen for the display that contains the specified point.
static std::vector< screen > all_screens()
Gets an array of all displays on the system.
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 drawing::rectangle get_bounds(const drawing::point &point)
Retrieves the bounds of the display that contains the specified point.
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 th...
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...
bool high_resolution() const
Gets a value indicating whether a particular display is high resolution.
Definition: screen.h:56
const xtd::ustring & device_name() const
Gets the device name associated with a display.
Definition: screen.h:52
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....
const drawing::rectangle & bounds() const
Gets the bounds of the display.
Definition: screen.h:47
static drawing::rectangle get_bounds(const control &control)
Retrieves the bounds of the display that contains the largest portion of the specified control.
static int32_t get_standard_pixels_per_inch()
Gets the the standard number of pixels per inch of the display.
static screen from_rectangle(const drawing::rectangle &rect)
Retrieves a screen for the display that contains the largest portion of the rectangle.
double scale_factor() const
Gets the scale factor of the display.
Definition: screen.h:72
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 rectang...
static screen primary_screen()
Gets the primary display.
Definition: screen.h:77
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....
bool primary() const
Gets a value indicating whether a particular display is the primary device.
Definition: screen.h:65
static screen from_control(const control &control)
Retrieves a screen for the display that contains the largest portion of the specified control.
int32_t pixels_per_inch() const
Gets the number of pixels per inch of the display.
Definition: screen.h:61
int32_t bits_per_pixel() const
Gets the number of bits of memory, associated with one pixel of data.
Definition: screen.h:43
static drawing::rectangle get_bounds(intptr_t handle)
Retrieves the bounds of the display that contains the largest portion of the specified handle.
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
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition: object.h:26
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Contains xtd::forms::control control.
static drawing::graphics create_graphics()
Creates the xtd::drawing::graphics for the screen.
#define forms_export_
Define shared library export.
Definition: forms_export.h:13
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::object class.
Contains xtd::drawing::rectangle class.