From ed2d56729c36cc82e066b4f3f464a227894b46d9 Mon Sep 17 00:00:00 2001 From: lu Date: Mon, 11 Apr 2022 16:39:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0screen=E7=9A=84JS=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lu Change-Id: Ia964383329b3d2bce85b26a3a04a58621f74c5eb --- api/@ohos.screen.d.ts | 156 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 api/@ohos.screen.d.ts diff --git a/api/@ohos.screen.d.ts b/api/@ohos.screen.d.ts new file mode 100644 index 0000000000..eb1c7b1162 --- /dev/null +++ b/api/@ohos.screen.d.ts @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { AsyncCallback, Callback } from './basic'; + +/** + * interface of screen manager + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @systemapi Hide this for inner system use. + * @since 9 + */ +declare namespace screen { + /** + * get all screen + * @since 9 + */ + function getAllScreens(callback: AsyncCallback>): void; + function getAllScreens(): Promise>; + + /** + * Register the callback for screen changes. + * @param eventType: type of callback + * @since 9 + */ + function on(eventType: 'connect' | 'disconnect' | 'change', callback: Callback): void; + + /** + * Unregister the callback for screen changes. + * @param eventType: type of callback + * @since 9 + */ + function off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback): void; + + /** + * make screens as expand-screen + * @since 9 + */ + function makeExpand(options:Array, callback: AsyncCallback): void; + function makeExpand(options:Array): Promise; + + /** + * make screens as mirror-screen + * @since 9 + */ + function makeMirror(mainScreen:number, mirrorScreen:Array, callback: AsyncCallback): void; + function makeMirror(mainScreen:number, mirrorScreen:Array): Promise; + + /** + * the parameter of making expand screen + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + interface ExpandOption { + /** + * screen id + */ + screenId: number; + + /** + * the start coordinate X of the screen origin + */ + startX: number; + + /** + * the start coordinate Y of the screen origin + */ + startY: number; + } + + /** + * interface for screen + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + interface Screen { + /** + * screen id + */ + readonly id: number; + + /** + * group id + */ + readonly parent: number; + + /** + * mode supported by the screen + */ + readonly supportedModeInfo: Array; + + /** + * currently active mode + */ + readonly activeModeIndex: number; + + /** + * orientation of the screen + */ + readonly orientation: Orientation; + + /** + * set the orientation of the screen + * @since 9 + */ + setOrientation(orientation: Orientation, callback: AsyncCallback): void; + setOrientation(orientation: Orientation): Promise; + + /** + * active the mode + */ + setScreenActiveMode(modeIndex: number, callback: AsyncCallback): void; + setScreenActiveMode(modeIndex: number): Promise; + } + + /** + * screen orientation + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + enum Orientation { + UNSPECIFIED = 0, + VERTICAL = 1, + HORIZONTAL = 2, + REVERSE_VERTICAL = 3, + REVERSE_HORIZONTAL = 4, + SENSOR = 5, + SENSOR_VERTICAL = 6, + SENSOR_HORIZONTAL = 7, + } + + /** + * the infomation of the screen + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + interface ScreenModeInfo { + id: number; + width: number; + height: number; + refreshRate: number; + } +} + +export default screen; -- Gitee