nsIScreen 编辑

widget/nsIScreen.idlScriptable 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

AttributeTypeDescription
colorDepthlongThe screen's color depth; this is the number of bits used to represent a color. Read only.
pixelDepthlongThe screen's pixel depth; this is the number of bits used to represent a pixel. Read only.
rotationunsigned longThe 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.
Gecko 1.9.2 note Starting in Gecko 1.9.2, Gecko running on Microsoft Windows reports 24 bits per pixel instead of 32 bits per pixel on 8-bits per color component displays, since this is typically what the caller is actually looking for.

Constants

Screen rotation constants

Screen brightness constants

ConstantValueDescription
BRIGHTNESS_DIM0The screen is fully dimmed (that is, off).
BRIGHTNESS_FULL1The screen is at full brightness.
BRIGHTNESS_LEVELS2The number of different brightness levels.
Requires Gecko 13.0(Firefox 13.0 / Thunderbird 13.0 / SeaMonkey 2.10)
ConstantValueDescription
ROTATION_0_DEG00° of rotation (that is, no rotation, or default orientation).
ROTATION_90_DEG190° of rotation.
ROTATION_180_DEG2180° of rotation.
ROTATION_270_DEG3270° 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:88 次

字数:8842

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文