Window

Overview

Provides window management capabilities, including creating, destroying, showing, hiding, moving, resizing a window, raising a window to the top, and lowering a window to the bottom.

Since:

1.0

Version:

1.0

Summary

Files

File Name

Description

window.h

Declares the Window class that provides a drawing canvas for the RootView, which represents the root node of a view tree.

Data Structures

Data Structure Name

Description

OHOS::WindowConfig

Sets the attributes for this window.

OHOS::Window

Provides a drawing canvas for the RootView, which represents the root node of a view tree.

Enumerations

Enumeration Name

Description

OHOS::WindowPixelFormat { OHOS::WINDOW_PIXEL_FORMAT_RGB565 = 101, OHOS::WINDOW_PIXEL_FORMAT_ARGB1555, OHOS::WINDOW_PIXEL_FORMAT_RGB888, OHOS::WINDOW_PIXEL_FORMAT_ARGB8888 }

Enumerates the pixel formats of this window.

Functions

Function Name

Description

OHOS::Window::CreateWindow (const WindowConfig &config)

static Window 

Creates a Window instance.

OHOS::Window::DestoryWindow (Window window)

static void 

Destroys a specified window.

OHOS::Window::BindRootView (RootViewrootView)=0

virtual void 

Binds the RootView to this window.

OHOS::Window::UnbindRootView ()=0

virtual void 

Unbinds the RootView from this window.

OHOS::Window::GetRootView ()=0

virtual RootView  

Obtains the RootView bound to this window.

OHOS::Window::GetRect ()=0

virtual Rect 

Obtains the rectangle information (position, width, and height) of this window.

OHOS::Window::Show ()=0

virtual void 

Shows this window.

OHOS::Window::Hide ()=0

virtual void 

Hides this window.

OHOS::Window::MoveTo (int16_t x, int16_t y)=0

virtual void 

Moves this window to a specified position.

OHOS::Window::Resize (int16_t width, int16_t height)=0

virtual void 

Resizes this window.

OHOS::Window::RaiseToTop ()=0

virtual void 

Raises this window to the top.

OHOS::Window::LowerToBottom ()=0

virtual void 

Lowers this window to the bottom.

OHOS::Window::GetWindowId ()=0

virtual int32_t 

Obtains the unique ID of this window.

Details

Enumeration Type Documentation

WindowPixelFormat

  1. enum[OHOS::WindowPixelFormat]($api-api-SmartVision-Devices-Window.md#gade9f6a70c1e8547785d266aab3ca5725)

Description:

Enumerates the pixel formats of this window.

Enumerator

Description

WINDOW_PIXEL_FORMAT_RGB565 

RGB565 format

WINDOW_PIXEL_FORMAT_ARGB1555 

ARGB1555 format

WINDOW_PIXEL_FORMAT_RGB888 

RGB888 format

WINDOW_PIXEL_FORMAT_ARGB8888 

ARGB8888 format

Function Documentation

BindRootView()

  1. virtualvoid OHOS::Window::BindRootView([RootView]($api-api-SmartVision-Devices-OHOS-RootView.md)* rootView)

Description:

Binds the RootView to this window.

Parameters:

Name

Description

rootViewIndicates the RootView to bind.

CreateWindow()

  1. static[Window]($api-api-SmartVision-Devices-OHOS-Window.md)* OHOS::Window::CreateWindow(const[WindowConfig]($api-api-SmartVision-Devices-OHOS-WindowConfig.md)& config)

Description:

Creates a Window instance.

Parameters:

Name

Description

configIndicates the window configuration. For details, see WindowConfig.

Returns:

Returns the Window instance if the operation is successful; returns nullptr otherwise.

DestoryWindow()

  1. staticvoid OHOS::Window::DestoryWindow([Window]($api-api-SmartVision-Devices-OHOS-Window.md)* window)

Description:

Destroys a specified window.

Parameters:

Name

Description

windowIndicates the Window instance to destroy.

GetRect()

  1. virtual[Rect]($api-api-SmartVision-Devices-OHOS-Rect.md) OHOS::Window::GetRect()

Description:

Obtains the rectangle information (position, width, and height) of this window.

Returns:

Returns the rectangle information of this window.

GetRootView()

  1. virtual[RootView]($api-api-SmartVision-Devices-OHOS-RootView.md)* OHOS::Window::GetRootView()

Description:

Obtains the RootView bound to this window.

Returns:

Returns the RootView if available; returns nullptr otherwise.

GetWindowId()

  1. virtualint32_t OHOS::Window::GetWindowId()

Description:

Obtains the unique ID of this window.

The window ID is within [0, 31]. An ID will be reused after the current window is destroyed. A maximum of 32 windows can be displayed at the same time.

Returns:

Returns the unique ID of this window if the operation is successful; returns -1 otherwise.

Hide()

  1. virtualvoid OHOS::Window::Hide()

Description:

Hides this window.

LowerToBottom()

  1. virtualvoid OHOS::Window::LowerToBottom()

Description:

Lowers this window to the bottom.

MoveTo()

  1. virtualvoid OHOS::Window::MoveTo(int16_t x,int16_t y )

Description:

Moves this window to a specified position.

Parameters:

Name

Description

xIndicates the x-coordinate of the target position.
yIndicates the y-coordinate of the target position.

RaiseToTop()

  1. virtualvoid OHOS::Window::RaiseToTop()

Description:

Raises this window to the top.

Resize()

  1. virtualvoid OHOS::Window::Resize(int16_t width,int16_t height )

Description:

Resizes this window.

Parameters:

Name

Description

widthIndicates the new window width.
heightIndicates the new window height.

Show()

  1. virtualvoid OHOS::Window::Show()

Description:

Shows this window.

UnbindRootView()

  1. virtualvoid OHOS::Window::UnbindRootView()

Description:

Unbinds the RootView from this window.

Variable Documentation

opacity

  1. uint8_t OHOS::WindowConfig::opacity

Description:

Opacity, within [0, 255]

option

  1. uint32_t OHOS::WindowConfig::option

Description:

Other options

pixelFormat

  1. [WindowPixelFormat]($api-api-SmartVision-Devices-Window.md#gade9f6a70c1e8547785d266aab3ca5725) OHOS::WindowConfig::pixelFormat

Description:

Pixel format

rect

  1. [Rect]($api-api-SmartVision-Devices-OHOS-Rect.md) OHOS::WindowConfig::rect

Description:

Rectangle