nsIScreen 编辑
widget/nsIScreen.idl
Scriptable This interface provides information about a display screen. Inherits from: 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 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. |
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.
Note: This returns a rectangle representing the region of the screen that is available for application use. For example, this would exclude the area occupied by the menu bar and Dock on Mac OS X.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]);
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论