NAME
HTML::Object::DOM::Screen - HTML Object DOM Screen Class
SYNOPSIS
use HTML::Object::DOM::Screen;
my $screen = HTML::Object::DOM::Screen->new ||
die( HTML::Object::DOM::Screen->error, "\n" );
VERSION
v0.2.0
DESCRIPTION
The Screen
interface represents the screen, the only one, under perl, on which the current window object exists, and is obtained using "screen" in HTML::Object::DOM::Window.
INHERITANCE
+-----------------------+ +---------------------------+ +---------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Screen |
+-----------------------+ +---------------------------+ +---------------------------+
PROPERTIES
Inherits properties from its parent HTML::Object::EventTarget
availHeight
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows.
Example:
use HTML::Object::DOM qw( screen window );
my $availHeight = window->screen->availHeight;
my $paletteWindow = window->open( "panels.html", "Panels", "left=0, top=0, width=200" );
Another example:
window->outerHeight = window->screen->availHeight;
See also Mozilla documentation
availLeft
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this returns the first available pixel available from the left side of the screen.
Example:
use HTML::Object::DOM qw( screen window );
my $availLeft = window->screen->availLeft;
my $setX = window->screen->width - window->screen->availLeft;
my $setY = window->screen->height - window->screen->availTop;
# The following does absolutely nothing in perl, obviously
window->moveTo( $setX, $setY );
See also Mozilla documentation
availTop
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
Example:
my $availTop = window->screen->availTop;
my $setX = window->screen->width - window->screen->availLeft;
my $setY = window->screen->height - window->screen->availTop;
# The following does absolutely nothing in perl, obviously
window->moveTo( $setX, $setY );
See also Mozilla documentation
availWidth
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this returns the amount of horizontal space in pixels available to the window.
Example:
my $width = window->screen->availWidth
my $screenAvailWidth = window->screen->availWidth;
say( $screenAvailWidth );
See also Mozilla documentation
colorDepth
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this returns the color depth of the screen.
Example:
use HTML::Object::DOM qw( screen window );
# Check the color depth of the screen
if( window->screen->colorDepth < 8 )
{
# Use low-color version of page
}
else
{
# Use regular, colorful page
}
See also Mozilla documentation
height
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this returns the height of the screen in pixels.
Example:
my $height = window->screen->height
use HTML::Object::DOM qw( screen window );
if( window->screen->availHeight !== window->screen->height )
{
# Something is occupying some screen real estate!
}
See also Mozilla documentation
left
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this returns the distance in pixels from the left side of the main screen to the left side of the current screen.
Example:
use HTML::Object::DOM qw( screen window );
my $left = window->screen->left;
See also Mozilla documentation
lockOrientation
Under perl environment this returns undef
by default, but you can set whatever value you want.
Under JavaScript, this locks the screen into a specified orientation into which to lock the screen. This is either a string or an array of strings. Passing several strings lets the screen rotate only in the selected orientations.
Possible values that are not enforced under this perl interface are:
- portrait-primary
-
It represents the orientation of the screen when it is in its primary portrait mode. A screen is considered in its primary portrait mode if the device is held in its normal position and that position is in portrait, or if the normal position of the device is in landscape and the device held turned by 90° clockwise. The normal position is device dependant.
- portrait-secondary
-
It represents the orientation of the screen when it is in its secondary portrait mode. A screen is considered in its secondary portrait mode if the device is held 180° from its normal position and that position is in portrait, or if the normal position of the device is in landscape and the device held is turned by 90° counterclockwise. The normal position is device dependant.
- landscape-primary
-
It represents the orientation of the screen when it is in its primary landscape mode. A screen is considered in its primary landscape mode if the device is held in its normal position and that position is in landscape, or if the normal position of the device is in portrait and the device held is turned by 90° clockwise. The normal position is device dependant.
- landscape-secondary
-
It represents the orientation of the screen when it is in its secondary landscape mode. A screen is considered in its secondary landscape mode if the device held is 180° from its normal position and that position is in landscape, or if the normal position of the device is in portrait and the device held is turned by 90° counterclockwise. The normal position is device dependant.
- portrait
-
It represents both portrait-primary and portrait-secondary.
- landscape
-
It represents both landscape-primary and landscape-secondary.
- default
-
It represents either portrait-primary and landscape-primary depends on natural orientation of devices. For example, if the panel resolution is 1280*800, default will make it landscape, if the resolution is 800*1280, default will make it to portrait.
See also Mozilla documentation
mozBrightness
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this Controls the brightness of a device's screen. A double between 0 and 1.0 is expected.
Example:
use HTML::Object::DOM qw( screen window );
my $screenBrightness = window->screen->mozBrightness;
See also Mozilla documentation
mozEnabled
Normally this is read-only, but under perl you can set whatever boolean value you want.
Under JavaScript, when this is set to false, it will turn off the device's screen.
Example:
use HTML::Object::DOM qw( screen window );
my $screenEnabled = window->screen->mozEnabled
See also Mozilla documentation
orientation
Normally this returns undef
under perl, but you can set whatever string value you want. This returns a scalar object
Under JavaScript, this returns the ScreenOrientation
instance associated with this screen.
Example:
use HTML::Object::DOM qw( screen window );
my $orientation = screen->$orientation;
my $orientation = screen->orientation;
if( $orientation == "landscape-primary" )
{
say( "That looks good." );
}
elsif( $orientation == "landscape-secondary" )
{
say( "Mmmh... the screen is upside down!" );
}
elsif( $orientation == "portrait-secondary" || $orientation == "portrait-primary" )
{
say( "Mmmh... you should rotate your device to landscape" );
}
elsif( $orientation == undefined )
{
say( "The orientation API is not supported in this browser :(" );
}
See also Mozilla documentation
pixelDepth
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this gets the bit depth of the screen.
Example:
use HTML::Object::DOM qw( screen window );
my $depth = window->screen->pixelDepth
# if there is not adequate bit depth
# choose a simpler color
if( window->screen->pixelDepth > 8 )
{
$doc->style->color = "#FAEBD7";
}
else
{
$doc->style->color = "#FFFFFF";
}
See also Mozilla documentation
top
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this returns the distance in pixels from the top side of the current screen.
Example:
use HTML::Object::DOM qw( screen window );
my $top = window->screen->top;
See also Mozilla documentation
width
Normally this returns undef
under perl, but you can set whatever number value you want.
Under JavaScript, this returns the width of the screen.
Example:
use HTML::Object::DOM qw( screen window );
my $lWidth = window->screen->width
# Crude way to check that the screen is at least 1024x768
if( window->screen->width >= 1024 && window->screen->height >= 768 )
{
# Resolution is 1024x768 or above
}
See also Mozilla documentation
METHODS
Inherits methods from its parent HTML::Object::EventTarget
unlockOrientation
This always returns undef
under perl.
Normally, under JavaScript, this unlocks the screen orientation (only works in fullscreen or for installed apps)
See also Mozilla documentation
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
COPYRIGHT & LICENSE
Copyright(c) 2021 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.