Ocean
Ocean::Platform::Win::Screen Class Reference

This class provides screen functionalities. More...

Static Public Member Functions

static int primaryDisplayWidth ()
 Returns the width of the primary display in pixel. More...
 
static int primaryDisplayHeight ()
 Returns the height of the primary display in pixel. More...
 
static int virtualDisplayWidth ()
 Returns the width of the virtual display in pixel. More...
 
static int virtualDisplayHeight ()
 Returns the height of the virtual display in pixel. More...
 
static CV::PixelBoundingBoxI virtualDisplayBoundingBox ()
 Returns the bounding box of the virtual display with pixel resolution. More...
 
static CV::PixelPositionI suitableWindowPosition (const unsigned int windowWidth, const unsigned int windowHeight, const int left=NumericT< int >::minValue(), const int top=NumericT< int >::minValue(), const HWND parent=nullptr)
 Returns the most suitable top left position of a window that has to be placed on the (virtual) screen. More...
 
static unsigned int screens ()
 Returns the number of installed screens. More...
 
static bool screen (const unsigned int positionX, const unsigned int positionY, unsigned int &left, unsigned int &top, unsigned int &width, unsigned int &height)
 Returns the position and dimension of the screen most suitable for a given cursor point. More...
 
static bool screen (const HWND window, unsigned int &left, unsigned int &top, unsigned int &width, unsigned int &height)
 Returns the position and dimension of the screen most suitable for a given window handle. More...
 
static int dpi (const HDC dc)
 Returns the current DPI value of a given device context. More...
 
static double scaleFactor (const HDC dc)
 Returns the scaling factor transforming the number of (backing) pixels defined in the (virtual) display coordinate system to the number of pixels defined in the (native/physical) screen coordinate system for a specified device context. More...
 
static int scalePixel (const int pixel, const HDC dc)
 Converts a given pixel value defined in the (virtual) display coordinate system to the pixel value defined in the (native/physical) screen coordinate system. More...
 
static int scalePixelByFactor (const int pixel, const double scaleFactor)
 Converts a given pixel value by a given scale factor. More...
 

Detailed Description

This class provides screen functionalities.

Member Function Documentation

◆ dpi()

static int Ocean::Platform::Win::Screen::dpi ( const HDC  dc)
static

Returns the current DPI value of a given device context.

If no context is given, the desktop DC is used instead. A DPI value of 96 complies with a 100 percent scaling, 192 DPI complies with 200 percent scaling

Parameters
dcThe device context, nullptr to determine the scale factor of the default screen
Returns
The resulting DPI value, with range (0, infinity)

◆ primaryDisplayHeight()

static int Ocean::Platform::Win::Screen::primaryDisplayHeight ( )
static

Returns the height of the primary display in pixel.

Returns
Primary display height in pixel

◆ primaryDisplayWidth()

static int Ocean::Platform::Win::Screen::primaryDisplayWidth ( )
static

Returns the width of the primary display in pixel.

Returns
Primary display width in pixel

◆ scaleFactor()

static double Ocean::Platform::Win::Screen::scaleFactor ( const HDC  dc)
static

Returns the scaling factor transforming the number of (backing) pixels defined in the (virtual) display coordinate system to the number of pixels defined in the (native/physical) screen coordinate system for a specified device context.

Parameters
dcThe device context, nullptr to determine the scale factor of the default screen
Returns
The resulting scale factor with range (0, infinity)

◆ scalePixel()

int Ocean::Platform::Win::Screen::scalePixel ( const int  pixel,
const HDC  dc 
)
inlinestatic

Converts a given pixel value defined in the (virtual) display coordinate system to the pixel value defined in the (native/physical) screen coordinate system.

Parameters
pixelPixel value to convert, with range (-infinity, infinity)
dcThe device context, nullptr to determine the scale factor of the default screen
Returns
The converted pixel value for the (native/pyhsical) screen coordinate system, with range (-infinity, infinity)

◆ scalePixelByFactor()

int Ocean::Platform::Win::Screen::scalePixelByFactor ( const int  pixel,
const double  scaleFactor 
)
inlinestatic

Converts a given pixel value by a given scale factor.

Parameters
pixelPixel value to convert, with range (-infinity, infinity)
scaleFactorThe scale factor to be applied, with range (-infinity, infinity)
Returns
The resulting converted pixel value (-infinity, infinity)

◆ screen() [1/2]

static bool Ocean::Platform::Win::Screen::screen ( const HWND  window,
unsigned int &  left,
unsigned int &  top,
unsigned int &  width,
unsigned int &  height 
)
static

Returns the position and dimension of the screen most suitable for a given window handle.

Parameters
windowWindow handle to receive the screen for
leftLeft screen position, pixel in virtual coordinate space
topTop screen position, pixel in virtual coordinate space
widthScreen width, in pixel
heightScreen height, in pixel
Returns
True, if succeeded

◆ screen() [2/2]

static bool Ocean::Platform::Win::Screen::screen ( const unsigned int  positionX,
const unsigned int  positionY,
unsigned int &  left,
unsigned int &  top,
unsigned int &  width,
unsigned int &  height 
)
static

Returns the position and dimension of the screen most suitable for a given cursor point.

Parameters
positionXHorizontal cursor position to receive the screen for
positionYVertical cursor position to receive the screen for
leftLeft screen position, pixel in virtual coordinate space
topTop screen position, pixel in virtual coordinate space
widthScreen width, in pixel
heightScreen height, in pixel
Returns
True, if succeeded

◆ screens()

static unsigned int Ocean::Platform::Win::Screen::screens ( )
static

Returns the number of installed screens.

Returns
Screen number

◆ suitableWindowPosition()

static CV::PixelPositionI Ocean::Platform::Win::Screen::suitableWindowPosition ( const unsigned int  windowWidth,
const unsigned int  windowHeight,
const int  left = NumericT< int >::minValue(),
const int  top = NumericT< int >::minValue(),
const HWND  parent = nullptr 
)
static

Returns the most suitable top left position of a window that has to be placed on the (virtual) screen.

The final position ensures that the window lies inside the bounding box of the (virtual) screen.

Parameters
windowWidthThe width of the window for which the position will be determined in pixel, with range (0, infinity)
windowHeightThe height of the window for which the pose will be determined in pixel, with range (0, infinity)
leftOptional proposed left position of the window, which will be adjusted to fit into the virtual screen
topOptional proposed top position of the window, which will be adjusted to fit into the virtual screen
parentOptional handle of a parent (or associated) window to which the resulting position should match if no proposed position is provided
Returns
The resulting top left position of the window

◆ virtualDisplayBoundingBox()

static CV::PixelBoundingBoxI Ocean::Platform::Win::Screen::virtualDisplayBoundingBox ( )
static

Returns the bounding box of the virtual display with pixel resolution.

Returns
The bounding box of the virtual display

◆ virtualDisplayHeight()

static int Ocean::Platform::Win::Screen::virtualDisplayHeight ( )
static

Returns the height of the virtual display in pixel.

The virtual display is bounded by all screens.

Returns
Virtual display height in pixel

◆ virtualDisplayWidth()

static int Ocean::Platform::Win::Screen::virtualDisplayWidth ( )
static

Returns the width of the virtual display in pixel.

The virtual display is bounded by all screens.

Returns
Virtual display width in pixel

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