提交 e35d8816 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 de02c805
# Window Development
# 窗口开发指导
## When to Use
The interface layer of the window runs in the application process. It loads the page layout and provides APIs.
By calling these APIs, you can create and destroy a window, set the position and size of a window, and enter the immersive mode (full-screen mode).
## 场景介绍
窗口的接口层在应用进程运行,负责对页面布局的加载,和提供应用程序接口。
通过调用窗口接口可以实现窗口创建与销毁,窗口的位置、大小布局,以及进入沉浸式等。
## Available APIs
For details about the APIs, see [Window](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-window.md).
## 接口说明
窗口开放的能力如下:Window类,具体的API详见[接口文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-window.md)
**Table 1** Main window APIs
**表1** 窗口主要接口API
| API | Description |
| 接口名 | 描述 |
| :----------------------------------------------------------- | :--------------------------------------------- |
| create(id: string, type: WindowType, callback: AsyncCallback\<Window>): void | Creates a subwindow. |
| moveTo(x: number, y: number): Promise\<void> | Moves the window position. A positive value of **x** indicates that the window moves to the right, and a positive value of **y** indicates that the window moves downwards.|
| resetSize(width: number, height: number): Promise\<void> | Changes the window size. |
| hide(): Promise\<void> | Hides the window. |
| destroy(): Promise\<void> | Destroys the window. |
| create(id: string, type: WindowType, callback: AsyncCallback\<Window>): void | 创建子窗口。 |
| moveTo(x: number, y: number): Promise\<void> | 移动窗口位置,x值为正表示右移,y为正表示下移。 |
| resetSize(width: number, height: number): Promise\<void> | 改变当前窗口大小。 |
| hide(): Promise\<void> | 隐藏当前窗口。 |
| destroy(): Promise\<void> | 销毁当前窗口。 |
## How to Develop
## 开发步骤
### Creating a Main Window
### 创建主窗口
Currently, the main window is automatically created when the application is started. The declaration period, hiding, and destruction of the main window are managed by the application.
### Creating a Subwindow
You can call **create** to create a subwindow. The sample code is as follows:
在当前模型下,应用启动时会自动创建主窗口,由应用管理窗口的声明周期,隐藏及销毁由应用管理。
### 创建子窗口
当前可以通过`create`接口创建子窗口。具体示例代码如下:
```
import window from '@ohos.window';
......@@ -37,9 +37,9 @@ You can call **create** to create a subwindow. The sample code is as follows:
});
```
### Obtaining a Window Object
### 获取窗口对象
- Call **getTopWindow** to obtain the top window of the application. The sample code is as follows:
- 应用内可以通过`getTopWindow`来获取当前应用内最后显示的窗口。具体示例代码如下:
```
var windowClass = null;
......@@ -52,7 +52,7 @@ You can call **create** to create a subwindow. The sample code is as follows:
})
```
- You can also call **find** to obtain created subwindows in the application. The sample code is as follows:
- 应用内也可以通过`Find`来获取已经创建的子窗口。具体示例代码如下:
```
var windowClass = null;
......@@ -65,9 +65,9 @@ You can call **create** to create a subwindow. The sample code is as follows:
});
```
### Hiding and Destroying a Window
### 窗口的隐藏和销毁
After a window object is obtained, you can call **hide** and **destroy** to hide and destroy the window object, respectively. The sample code is as follows:
在已经获取到窗口对象的前提下,可以调用`hide``destroy`来隐藏和销毁已经创建的窗口对象。具体示例代码如下:
```
let promise = windowClass.hide();
......@@ -85,11 +85,11 @@ After a window object is obtained, you can call **hide** and **destroy** to hide
})
```
### Enabling the Full-Screen Mode
### 设置沉浸式窗口
After a window object is obtained, you can call **setFullScreen** to enable the full-screen mode for the window.
在已经获取到应用窗口对象的前提下,调用`setFullScreen`来设置窗口进入全屏沉浸式。
The sample code is as follows:
示例代码如下:
```
import window from '@ohos.window';
......@@ -101,4 +101,5 @@ try {
}
```
For the complete code, see [immersive](https://gitee.com/openharmony/windowmanager/tree/master/AppDemo/window/immersive).
完整[示例工程](https://gitee.com/openharmony/windowmanager/tree/master/AppDemo/window/immersive)
# Window Overview
# 窗口开发概述
The Window Manager subsystem provides basic capabilities of window and display management. It is the basis for UI display.
The Window Manager subsystem enables multiple applications to use the same physical screen for display and interaction. For each application, you need to design the interaction interface in the fixed window area. A window acts as a display container of the application interface, and the Window Manager subsystem organizes the interaction interfaces into a form visible to end users.
**窗口子系统**提供窗口管理和Display管理的基础能力,是系统图形界面显示所需的基础子系统。
窗口系统的作用,是提供一种机制,让多个应用界面复用同一块物理屏幕进行显示和交互。每个应用程序中,需要实现固定窗口区域内的交互界面设计,窗口作用应用界面的显示容器,而窗口系统负责将这些交互界面组织成最终用户见到的形态。
## Basic Concepts
## 基本概念
** Immersive**: The colors of the application interface, status bar, and navigation bar are the same to achieve the visual integrity.
**沉浸式**:应用窗口跟状态栏与导航栏颜色一致,视觉上融合。
## Working Principles
## 运作机制
To display a UI on a screen, the application and system need to request a window object from the Window Manager subsystem. This object generally represents a rectangular area on the screen and has attributes such as the position, width, height, and overlay layer. The object also loads the root node of the UI framework in the interface. The UI of the application is loaded and displayed in the window through the root node.
为了将图形界面显示在屏幕上,应用和系统需要向窗口系统申请窗口对象,这通常代表了屏幕上一块矩形区域,具有位置、宽高、和叠加层次等属性。同时,窗口对象也负责加载界面中UI框架的根节点,应用程序的UI界面就通过这个根节点在窗口中加载显示。
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册