xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
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"
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;
38  static std::vector<screen> all_screens();
43  int32_t bits_per_pixel() const {return bits_per_pixel_;}
47  const drawing::rectangle& bounds() const {return bounds_;}
52  const xtd::ustring& device_name() const {return device_name_;}
56  bool high_resolution() const {return scale_factor_ > 1.;}
61  int32_t pixels_per_inch() const {return pixels_per_inch_;}
65  bool primary() const {return primary_;}
72  double scale_factor() const {return scale_factor_;}
78  std::vector<screen> screens = all_screens();
79  for (auto& screen : screens)
80  if (screen.primary()) return screen;
81  return screens[0];
82  }
88  const drawing::rectangle& working_area() const {return working_area_;}
93  static drawing::graphics create_graphics();
98  static screen from_control(const control& control);
103  static screen from_handle(intptr_t handle);
108  static screen from_point(const drawing::point& point);
113  static screen from_rectangle(const drawing::rectangle& rect);
118  static drawing::rectangle get_bounds(const control& control);
123  static drawing::rectangle get_bounds(intptr_t handle);
128  static drawing::rectangle get_bounds(const drawing::point& point);
133  static drawing::rectangle get_bounds(const drawing::rectangle& rect);
144  static int32_t get_standard_pixels_per_inch();
149  static drawing::rectangle get_working_area(const control& control);
154  static drawing::rectangle get_working_area(intptr_t handle);
159  static drawing::rectangle get_working_area(const drawing::point& point);
164  static drawing::rectangle get_working_area(const drawing::rectangle& rect);
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) {}
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 }
bool primary() const
Gets a value indicating whether a particular display is the primary device.
Definition: screen.h:65
Represents a display device or multiple display devices on a single system.
Definition: screen.h:29
const drawing::rectangle & bounds() const
Gets the bounds of the display.
Definition: screen.h:47
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
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:48
const xtd::ustring & device_name() const
Gets the device name associated with a display.
Definition: screen.h:52
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
bool high_resolution() const
Gets a value indicating whether a particular display is high resolution.
Definition: screen.h:56
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Contains xtd::drawing::rectangle class.
double scale_factor() const
Gets the scale factor of the display.
Definition: screen.h:72
static screen primary_screen()
Gets the primary display.
Definition: screen.h:77
int32_t bits_per_pixel() const
Gets the number of bits of memory, associated with one pixel of data.
Definition: screen.h:43
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
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:26
Contains xtd::forms::control control.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: graphics.h:48
int32_t pixels_per_inch() const
Gets the number of pixels per inch of the display.
Definition: screen.h:61