Os nossos voluntários ainda não traduziram este artigo para Português (Europeu) . Junte-se a nós e ajude-nos a fazer o trabalho!
nsISupports
Last changed in Gecko 13.0 (Firefox 13.0 / Thunderbird 13.0 / SeaMonkey 2.10)Use nsIScreenManager
to obtain references to screens.
Implemented by: @mozilla.org/gfx/screenmanager;1
as a service:
var screen = Components.classes["@mozilla.org/gfx/screenmanager;1"] .getService(Components.interfaces.nsIScreen);
Method overview
void GetAvailRect(out long left, out long top, out long width, out long height); |
void GetRect(out long left, out long top, out long width, out long height); |
void lockMinimumBrightness(in unsigned long brightness); |
void unlockMinimumBrightness(in unsigned long brightness); |
Attributes
Attribute | Type | Description |
colorDepth |
long |
The screen's color depth; this is the number of bits used to represent a color. Read only. |
pixelDepth |
long |
The screen's pixel depth; this is the number of bits used to represent a pixel. Read only. |
rotation |
unsigned long |
The screen's current rotation; you may set this to any of the values listed in Screen rotation constants. This will only have an effect on platforms that support screen rotation. |
Constants
Screen brightness constants
Constant | Value | Description |
BRIGHTNESS_DIM |
0 | The screen is fully dimmed (that is, off). |
BRIGHTNESS_FULL |
1 | The screen is at full brightness. |
BRIGHTNESS_LEVELS |
2 | The number of different brightness levels. |
Screen rotation constants
Constant | Value | Description |
ROTATION_0_DEG |
0 | 0° of rotation (that is, no rotation, or default orientation). |
ROTATION_90_DEG |
1 | 90° of rotation. |
ROTATION_180_DEG |
2 | 180° of rotation. |
ROTATION_270_DEG |
3 | 270° of rotation. |
Methods
GetAvailRect()
Returns a rectangle indicating the portion of the screen that is available for use.
void GetAvailRect( out long left, out long top, out long width, out long height );
Parameters
-
left
- The left edge of the available screen rectangle.
-
top
- The top edge of the available screen rectangle.
-
width
- The width of the available screen rectangle.
-
height
- The height edge of the available screen rectangle.
GetRect()
Returns a rectangle indicating the entire screen's coordinate space.
void GetRect( out long left, out long top, out long width, out long height );
Parameters
-
left
- The left edge of the screen's rectangle.
-
top
- The top edge of the screen's rectangle.
-
width
- The width of the screen's rectangle.
-
height
- The height edge of the screen's rectangle.
lockMinimumBrightness()
Locks the minimum brightness of the screen, preventing it from becoming any dimmer than that brightness level. Each call to this method must eventually be followed by a corresponding call to unlockMinimumBrightness()
with the same value for the brightness
parameter.
void lockMinimumBrightness( in unsigned long brightness );
Parameters
-
brightness
- The new minimum brightness level; this must be one of the values specified in Screen brightness constants.
unlockMinimumBrightness()
Releases a lock on the minimum brightness of the screen, which was previously established through a corresponding call to lockMinimumBrightness()
.
void unlockMinimumBrightness( in unsigned long brightness );
Parameters
-
brightness
- The brightness level to release; this must be one of the values specified in Screen brightness constants.
Example
var screenMan = Components.classes["@mozilla.org/gfx/screenmanager;1"] .getService(Components.interfaces.nsIScreenManager); var left = {}, top = {}, width = {}, height = {}; screenMan.primaryScreen.GetRect(left, top, width, height); print([left.value, top.value, width.value, height.value]);