1/* 2* Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3* Licensed under the Apache License, Version 2.0 (the "License"); 4* you may not use this file except in compliance with the License. 5* You may obtain a copy of the License at 6* 7* http://www.apache.org/licenses/LICENSE-2.0 8* 9* Unless required by applicable law or agreed to in writing, software 10* distributed under the License is distributed on an "AS IS" BASIS, 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12* See the License for the specific language governing permissions and 13* limitations under the License. 14*/ 15import { AsyncCallback, Callback } from './basic' ; 16import { Context } from './app/context'; 17import { ContenStorage } from './@internal/component/ets/stateManagement' 18import image from './@ohos.multimedia.image'; 19import rpc from './@ohos.rpc' 20 21/** 22 * Window manager. 23 * @syscap SystemCapability.WindowManager.WindowManager.Core 24*/ 25declare namespace window { 26 /** 27 * Describes the window manager error code 28 * @since 7 29 * @deprecated since 9 30 */ 31 enum WMError { 32 WM_DO_NOTHING, 33 WM_ERROR_NO_MEM, 34 WM_ERROR_DESTROYED_OBJECT, 35 WM_ERROR_INVALID_WINDOW, 36 WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, 37 WM_ERROR_INVALID_OPERATION, 38 WM_ERROR_INVALID_PERMISSION, 39 WM_ERROR_NO_REMOTE_ANIMATION, 40 WM_ERROR_DEVICE_NOT_SUPPORT, 41 WM_ERROR_NULLPTR, 42 WM_ERROR_INVALID_TYPE, 43 WM_ERROR_INVALID_PARAM, 44 WM_ERROR_SAMGR, 45 WM_ERROR_IPC_FAILED, 46 } 47 48 /** 49 * Describes the window manager error code 50 * @since 9 51 */ 52 enum WmErrorCode { 53 WM_ERROR_NO_PERMISSION, 54 WM_ERROR_INVALID_PARAM, 55 WM_ERROR_DEVICE_NOT_SUPPORT, 56 WM_ERROR_REPEAT_OPERATION, 57 WM_ERROR_STATE_ABNORMALLY, 58 WM_ERROR_SYSTEM_ABNORMALLY, 59 WM_ERROR_INVALID_CALLING, 60 } 61 62 /** 63 * The type of a window. 64 * @syscap SystemCapability.WindowManager.WindowManager.Core 65 */ 66 enum WindowType { 67 /** 68 * App. 69 */ 70 TYPE_APP, 71 /** 72 * System alert. 73 */ 74 TYPE_SYSTEM_ALERT, 75 /** 76 * Input method. 77 */ 78 TYPE_INPUT_METHOD, 79 /** 80 * Status bar. 81 */ 82 TYPE_STATUS_BAR, 83 /** 84 * Notification hubs. 85 */ 86 TYPE_PANEL, 87 /** 88 * Screen lock. 89 */ 90 TYPE_KEYGUARD, 91 /** 92 * Volume bar. 93 */ 94 TYPE_VOLUME_OVERLAY, 95 /** 96 * Navigation bar. 97 */ 98 TYPE_NAVIGATION_BAR, 99 /** 100 * Dialog window. 101 */ 102 TYPE_DIALOG, 103 104 /** 105 * System gesture. 106 */ 107 TYPE_SYSTEM_GESTURE, 108 } 109 110 /** 111 * Describes the type of avoid area 112 * @syscap SystemCapability.WindowManager.WindowManager.Core 113 * @since 7 114 */ 115 enum AvoidAreaType { 116 /** 117 * Default area of the system 118 */ 119 TYPE_SYSTEM, 120 121 /** 122 * Notch 123 */ 124 TYPE_CUTOUT, 125 126 /** 127 * area for system gesture 128 */ 129 TYPE_SYSTEM_GESTURE, 130 131 /** 132 * area for soft input keyboard 133 * @since 9 134 */ 135 TYPE_KEYBOARD 136 } 137 138 /** 139 * Describes the scale Transition Options of window 140 * @syscap SystemCapability.WindowManager.WindowManager.Core 141 * @since 9 142 * @systemapi 143 */ 144 declare interface ScaleOptions { 145 /** 146 * The scale param of x direction. Default is 1.f 147 */ 148 x?: number; 149 /** 150 * The scale param of y direction. Default is 1.f 151 */ 152 y?: number; 153 /** 154 * The scale param of pivot point of x. Default is 0.5f, Interval is 0.f - 1.f 155 */ 156 pivotX?: number; 157 /** 158 * The scale param of pivot point of y. Default is 0.5f, Interval is 0.f - 1.f 159 */ 160 pivotY?: number; 161 } 162 163 /** 164 * Describes the rotate Transition Options of window 165 * @syscap SystemCapability.WindowManager.WindowManager.Core 166 * @since 9 167 * @systemapi 168 */ 169 declare interface RotateOptions { 170 /** 171 * The rotate degree of x direction. Default value is 0.f 172 */ 173 x?: number; 174 /** 175 * The rotate degree of y direction. Default value is 0.f 176 */ 177 y?: number; 178 /** 179 * The rotate degree of z direction. Default value is 0.f 180 */ 181 z?: number; 182 /** 183 * The param of pivot point of x. Default is 0.5f, Interval is 0.f - 1.f 184 */ 185 pivotX?: number; 186 /** 187 * The param of pivot point of y. Default is 0.5f, Interval is 0.f - 1.f 188 */ 189 pivotY?: number; 190 } 191 192 /** 193 * Describes the translate Transition Options of window 194 * @syscap SystemCapability.WindowManager.WindowManager.Core 195 * @since 9 196 * @systemapi 197 */ 198 declare interface TranslateOptions { 199 /** 200 * The translate pixel param of x direction. Default is 0.f 201 */ 202 x?: number; 203 /** 204 * The translate pixel param of y direction. Default is 0.f 205 */ 206 y?: number; 207 /** 208 * The translate pixel param of z direction. Default is 0.f 209 */ 210 z?: number; 211 } 212 213 /** 214 * Describes the window mode of an application 215 * @systemapi Hide this for inner system use. 216 * @since 7 217 */ 218 enum WindowMode { 219 UNDEFINED = 1, 220 FULLSCREEN, 221 PRIMARY, 222 SECONDARY, 223 FLOATING 224 } 225 226 /** 227 * Describes the mode of window layout 228 * @syscap SystemCapability.WindowManager.WindowManager.Core 229 * @systemapi Hide this for inner system use. 230 * @since 9 231 */ 232 enum WindowLayoutMode { 233 /** 234 * CASCADE 235 * @systemapi Hide this for inner system use. 236 * @since 9 237 */ 238 WINDOW_LAYOUT_MODE_CASCADE, 239 /** 240 * TILE 241 * @systemapi Hide this for inner system use. 242 * @since 9 243 */ 244 WINDOW_LAYOUT_MODE_TILE 245 } 246 247 /** 248 * Create a sub window with a specific id and type. 249 * @param id Indicates window id. 250 * @param type Indicates window type. 251 * @since 7 252 */ 253 function create(id: string, type: WindowType, callback: AsyncCallback<Window>): void; 254 255 /** 256 * Create a sub window with a specific id and type. 257 * @param id Indicates window id. 258 * @param type Indicates window type. 259 * @since 7 260 */ 261 function create(id: string, type: WindowType): Promise<Window>; 262 263 /** 264 * Create a system window with a specific id and type. 265 * @param ctx Indicates the context on which the window depends 266 * @param id Indicates window id. 267 * @param type Indicates window type. 268 * @systemapi Hide this for inner system use. 269 * @since 8 270 */ 271 function create(ctx: Context, id: string, type: WindowType): Promise<Window>; 272 273 /** 274 * Find the window by id. 275 * @param id Indicates window id. 276 * @since 7 277 */ 278 function find(id: string, callback: AsyncCallback<Window>): void; 279 280 /** 281 * Find the window by id. 282 * @param id Indicates window id. 283 * @since 7 284 */ 285 function find(id: string): Promise<Window>; 286 287 /** 288 * Get the final show window. 289 * @param id Indicates window id. 290 * @since 6 291 */ 292 function getTopWindow(callback: AsyncCallback<Window>): void; 293 294 /** 295 * Get the final show window. 296 * @since 6 297 */ 298 function getTopWindow(): Promise<Window>; 299 300 /** 301 * Get the final show window. 302 * @param ctx Indicates the context on which the window depends 303 * @since 8 304 */ 305 function getTopWindow(ctx: Context): Promise<Window>; 306 307 /** 308 * Get the final show window. 309 * @param ctx Indicates the context on which the window depends 310 * @since 8 311 */ 312 function getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void; 313 314 /** 315 * minimize all app windows. 316 * @systemapi Hide this for inner system use. 317 * @since 8 318 */ 319 function minimizeAll(id: number, callback: AsyncCallback<void>): void; 320 321 /** 322 * minimize all app windows. 323 * @systemapi Hide this for inner system use. 324 * @since 8 325 */ 326 function minimizeAll(id: number): Promise<void>; 327 328 /** 329 * Toggle shown state for all app windows. Minimize or restore all app windows. 330 * @systemapi Minimize or restore all app windows for inner system use. 331 * @since 9 332 */ 333 function toggleShownStateForAllAppWindows(callback: AsyncCallback<void>): void; 334 335 /** 336 * Toggle shown state for all app windows. Minimize or restore all app windows. 337 * @systemapi Minimize or restore all app windows for inner system use. 338 * @since 9 339 */ 340 function toggleShownStateForAllAppWindows(): Promise<void>; 341 342 /** 343 * Set the layout mode of a window. 344 * @param mode the layout mode of a window. 345 * @systemapi Hide this for inner system use. 346 * @since 9 347 */ 348 function setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback<void>): void; 349 350 /** 351 * Set the layout mode of a window. 352 * @param mode the layout mode of a window. 353 * @systemapi Hide this for inner system use. 354 * @since 9 355 */ 356 function setWindowLayoutMode(mode: WindowLayoutMode): Promise<void>; 357 358 /** 359 * register the callback of systemBarTintChange 360 * @param type: 'systemBarTintChange' 361 * @systemapi Hide this for inner system use. 362 * @since 8 363 */ 364 function on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): void; 365 366 /** 367 * register the callback of keyboardHeightChange 368 * @param type: 'keyboardHeightChange' 369 * @since 7 370 */ 371 function on(type: 'keyboardHeightChange', callback: Callback<number>): void; 372 373 /** 374 * unregister the callback of systemBarTintChange 375 * @param type: 'systemBarTintChange' 376 * @systemapi Hide this for inner system use. 377 * @since 8 378 */ 379 function off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState>): void; 380 381 382 /** 383 * unregister the callback of keyboardHeightChange 384 * @param type: 'keyboardHeightChange' 385 * @since 7 386 */ 387 function off(type: 'keyboardHeightChange', callback?: Callback<number>): void; 388 389 /** 390 * Properties of status bar and navigation bar, it couldn't update automatically 391 * @syscap SystemCapability.WindowManager.WindowManager.Core 392 * @since 6 393 */ 394 interface SystemBarProperties { 395 /** 396 * the color of the status bar. 397 * @since 6 398 */ 399 statusBarColor?: string; 400 401 /** 402 * the light icon of the status bar. 403 * @since 7 404 */ 405 isStatusBarLightIcon?: boolean; 406 407 /** 408 * the content color of the status bar 409 * @since 8 410 */ 411 statusBarContentColor?: string; 412 413 /** 414 * the color of the navigation bar. 415 * @since 6 416 */ 417 navigationBarColor?: string; 418 419 /** 420 * the light icon of the navigation bar. 421 * @since 7 422 */ 423 isNavigationBarLightIcon?: boolean; 424 425 /** 426 * the content color of the navigation bar 427 * @since 8 428 */ 429 navigationBarContentColor?: string; 430 } 431 432 /** 433 * system bar tint of region 434 * @syscap SystemCapability.WindowManager.WindowManager.Core 435 * @systemapi Hide this for inner system use. 436 * @since 8 437 */ 438 interface SystemBarRegionTint { 439 /** 440 * system bar type 441 */ 442 type: WindowType; 443 444 /** 445 * the visibility of system bar 446 */ 447 isEnable?: boolean; 448 449 /** 450 * the region of system bar 451 */ 452 region?: Rect; 453 454 /** 455 * the background color of the system bar. 456 */ 457 backgroundColor?: string; 458 459 /** 460 * the content color of the system bar. 461 */ 462 contentColor?: string 463 } 464 465 /** 466 * system bar tint state for systemui 467 * @syscap SystemCapability.WindowManager.WindowManager.Core 468 * @systemapi Hide this for inner system use. 469 * @since 8 470 */ 471 interface SystemBarTintState { 472 /** 473 * id of display 474 */ 475 displayId: number; 476 /** 477 * region tint of systembar 478 */ 479 regionTint: Array<SystemBarRegionTint>; 480 } 481 482 /** 483 * Rectangle 484 * @syscap SystemCapability.WindowManager.WindowManager.Core 485 * @since 7 486 */ 487 interface Rect { 488 left: number; 489 490 top: number; 491 492 width: number; 493 494 height: number; 495 } 496 497 /** 498 * avoid area 499 * @syscap SystemCapability.WindowManager.WindowManager.Core 500 * @since 7 501 */ 502 interface AvoidArea { 503 /** 504 * Whether avoidArea is visible on screen 505 * @since 9 506 */ 507 visible: boolean; 508 509 /** 510 * Rectangle on the left of the screen 511 */ 512 leftRect: Rect; 513 514 /** 515 * Rectangle on the top of the screen 516 */ 517 topRect: Rect; 518 519 /** 520 * Rectangle on the right of the screen 521 */ 522 rightRect: Rect; 523 524 /** 525 * Rectangle on the bottom of the screen 526 */ 527 bottomRect: Rect; 528 } 529 530 /** 531 * window size 532 * @syscap SystemCapability.WindowManager.WindowManager.Core 533 * @since 7 534 */ 535 interface Size { 536 /** 537 * the width of the window. 538 */ 539 width: number; 540 541 /** 542 * the height of the window. 543 */ 544 height: number; 545 } 546 547 /** 548 * Properties of window, it couldn't update automatically 549 * @syscap SystemCapability.WindowManager.WindowManager.Core 550 * @since 6 551 */ 552 interface WindowProperties { 553 /** 554 * the position and size of the window 555 * @since 7 556 */ 557 windowRect: Rect; 558 559 /** 560 * window type 561 * @since 7 562 */ 563 type: WindowType; 564 565 /** 566 * window name 567 * @since 8 568 */ 569 name: string; 570 571 /** 572 * Whether the window is displayed in full screen mode. The default value is false. 573 * @since 6 574 */ 575 isFullScreen: boolean 576 577 /** 578 * Whether the window layout is in full screen mode(whether the window is immersive). The default value is false. 579 * @since 6 580 */ 581 isLayoutFullScreen: boolean 582 583 /** 584 * Whether the window can gain focus. The default value is true 585 * @since 7 586 */ 587 focusable: boolean 588 589 /** 590 * Whether the window is touchable. The default value is false 591 * @since 6 592 */ 593 touchable: boolean 594 595 596 /** 597 * Brightness value of window. 598 * @since 7 599 */ 600 brightness: number 601 602 /** 603 * The dimbehind value of window. 604 * @since 7 605 */ 606 dimBehindValue: number 607 608 /** 609 * Whether keep screen on. 610 * @since 7 611 */ 612 isKeepScreenOn: boolean 613 614 /** 615 * Whether make window in privacy mode or not. 616 * @since 7 617 */ 618 isPrivacyMode: boolean 619 620 /** 621 * Whether is round corner or not. 622 * @since 7 623 */ 624 isRoundCorner: boolean 625 626 /** 627 * Whether is transparent or not. 628 * @since 7 629 */ 630 isTransparent: boolean 631 } 632 633 /** 634 * Type of allowing the specified of color space. 635 * @since 8 636 */ 637 enum ColorSpace { 638 /** 639 * Default color space. 640 */ 641 DEFAULT, 642 /** 643 * Wide gamut color space. The specific wide color gamut depends on thr screen. 644 */ 645 WIDE_GAMUT, 646 } 647 648 interface Window { 649 /** 650 * hide sub window. 651 * @systemapi Hide this for inner system use. 652 * @since 7 653 */ 654 hide (callback: AsyncCallback<void>): void; 655 656 /** 657 * hide sub window. 658 * @systemapi Hide this for inner system use. 659 * @since 7 660 */ 661 hide(): Promise<void>; 662 663 /** 664 * hide window with animation. 665 * @since 9 666 * @systemapi 667 */ 668 hideWithAnimation(callback: AsyncCallback<void>): void; 669 670 /** 671 * hide window with animation. 672 * @since 9 673 * @systemapi 674 */ 675 hideWithAnimation(): Promise<void>; 676 677 /** 678 * show sub window. 679 * @since 7 680 */ 681 show(callback: AsyncCallback<void>): void; 682 683 /** 684 * show window. 685 * @since 7 686 */ 687 show(): Promise<void>; 688 689 /** 690 * show window with animation. 691 * @since 9 692 * @systemapi 693 */ 694 showWithAnimation(callback: AsyncCallback<void>): void; 695 696 /** 697 * show window with animation. 698 * @since 9 699 * @systemapi 700 */ 701 showWithAnimation(): Promise<void>; 702 703 /** 704 * Destroy the sub window. 705 * @since 7 706 */ 707 destroy(callback: AsyncCallback<void>): void; 708 709 /** 710 * Destroy the sub window. 711 * @since 7 712 */ 713 destroy(): Promise<void>; 714 715 /** 716 * Set the position of a window. 717 * @param x Indicate the X-coordinate of the window. 718 * @param y Indicate the Y-coordinate of the window. 719 * @syscap SystemCapability.WindowManager.WindowManager.Core 720 * @since 7 721 */ 722 moveTo(x: number, y: number): Promise<void>; 723 724 /** 725 * Set the position of a window. 726 * @param x Indicate the X-coordinate of the window. 727 * @param y Indicate the Y-coordinate of the window. 728 * @syscap SystemCapability.WindowManager.WindowManager.Core 729 * @since 7 730 */ 731 moveTo(x: number, y: number, callback: AsyncCallback<void>): void; 732 733 /** 734 * Set the size of a window . 735 * @param width Indicates the width of the window. 736 * @param height Indicates the height of the window. 737 * @syscap SystemCapability.WindowManager.WindowManager.Core 738 * @since 7 739 */ 740 resize(width: number, height: number): Promise<void>; 741 742 /** 743 * Set the size of a window . 744 * @param width Indicates the width of the window. 745 * @param height Indicates the height of the window. 746 * @syscap SystemCapability.WindowManager.WindowManager.Core 747 * @since 7 748 */ 749 resize(width: number, height: number, callback: AsyncCallback<void>): void; 750 751 /** 752 * Set the type of a window. 753 * @param windowType Indicate the type of a window. 754 * @syscap SystemCapability.WindowManager.WindowManager.Core 755 * @since 7 756 */ 757 setWindowType(windowType: WindowType): Promise<void>; 758 759 /** 760 * Set the type of a window. 761 * @param windowType Indicate the type of a window. 762 * @syscap SystemCapability.WindowManager.WindowManager.Core 763 * @since 7 764 */ 765 setWindowType(windowType: WindowType, callback: AsyncCallback<void>): void; 766 767 /** 768 * get the properties of current window 769 * @syscap SystemCapability.WindowManager.WindowManager.Core 770 * @since 6 771 */ 772 getProperties(callback: AsyncCallback<WindowProperties>): void; 773 774 /** 775 * get the properties of current window 776 * @syscap SystemCapability.WindowManager.WindowManager.Core 777 * @since 6 778 */ 779 getProperties(): Promise<WindowProperties>; 780 781 /** 782 * get the avoid area 783 * @param type Type of the area 784 * @since 7 785 */ 786 getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): void; 787 788 /** 789 * get the avoid area 790 * @param type Type of the area 791 * @since 7 792 */ 793 getAvoidArea(type: AvoidAreaType): Promise<AvoidArea>; 794 795 /** 796 * set the flag of the window is shown full screen 797 * @param isFullScreen the flag of the window is shown full screen 798 * @syscap SystemCapability.WindowManager.WindowManager.Core 799 * @since 6 800 */ 801 setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void; 802 803 /** 804 * set the flag of the window is shown full screen 805 * @param isFullScreen the flag of the window is shown full screen 806 * @syscap SystemCapability.WindowManager.WindowManager.Core 807 * @since 6 808 */ 809 setFullScreen(isFullScreen: boolean): Promise<void>; 810 811 /** 812 * set the property of the window can layout in full screen 813 * @param isLayoutFullScreen the window can layout in full screen 814 * @syscap SystemCapability.WindowManager.WindowManager.Core 815 * @since 7 816 */ 817 setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void; 818 819 /** 820 * set the property of the window can layout in full screen 821 * @param isLayoutFullScreen the window can layout in full screen 822 * @syscap SystemCapability.WindowManager.WindowManager.Core 823 * @since 7 824 */ 825 setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void>; 826 827 /** 828 * set the system bar to have visible. 829 * @param names the set of system bar 830 * @syscap SystemCapability.WindowManager.WindowManager.Core 831 * @since 7 832 */ 833 setSystemBarEnable(names: Array<'status'|'navigation'>, callback: AsyncCallback<void>): void; 834 835 /** 836 * set the system bar to have visible. 837 * @param names the set of system bar 838 * @syscap SystemCapability.WindowManager.WindowManager.Core 839 * @since 7 840 */ 841 setSystemBarEnable(names: Array<'status'|'navigation'>): Promise<void>; 842 843 /** 844 * set the background color of statusbar 845 * @param color the background color of statusbar 846 * @syscap SystemCapability.WindowManager.WindowManager.Core 847 * @since 6 848 */ 849 setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void; 850 851 /** 852 * set the background color of statusbar 853 * @param color the background color of statusbar 854 * @syscap SystemCapability.WindowManager.WindowManager.Core 855 * @since 6 856 */ 857 setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void>; 858 859 /** 860 * Loads content 861 * @param path path Path of the page to which the content will be loaded 862 * @param storage storage The data object shared within the content instance loaded by the window 863 * @syscap SystemCapability.WindowManager.WindowManager.Core 864 * @since 8 865 */ 866 loadContent(path: string, storage: ContenStorage, callback: AsyncCallback<void>): void; 867 868 /** 869 * Loads content 870 * @param path path of the page to which the content will be loaded 871 * @syscap SystemCapability.WindowManager.WindowManager.Core 872 * @since 7 873 */ 874 loadContent(path: string, callback: AsyncCallback<void>): void; 875 876 /** 877 * Loads content 878 * @param path path of the page to which the content will be loaded 879 * @syscap SystemCapability.WindowManager.WindowManager.Core 880 * @since 7 881 */ 882 loadContent(path: string, storage?: ContenStorage): Promise<void>; 883 884 /** 885 * register the callback of windowSizeChange 886 * @param type: 'windowSizeChange' 887 * @syscap SystemCapability.WindowManager.WindowManager.Core 888 * @since 7 889 */ 890 on(type: 'windowSizeChange', callback: Callback<Size>): void; 891 892 /** 893 * unregister the callback of windowSizeChange 894 * @param type: 'windowSizeChange' 895 * @syscap SystemCapability.WindowManager.WindowManager.Core 896 * @since 7 897 */ 898 off(type: 'windowSizeChange', callback?: Callback<Size>): void; 899 900 /** 901 * register the callback of systemAvoidAreaChange 902 * @param type: 'systemAvoidAreaChange' 903 * @syscap SystemCapability.WindowManager.WindowManager.Core 904 * @since 7 905 * @deprecated since 9, please use on_avoidAreaChange instead. 906 */ 907 on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void; 908 909 /** 910 * unregister the callback of systemAvoidAreaChange 911 * @param type: 'systemAvoidAreaChange' 912 * @syscap SystemCapability.WindowManager.WindowManager.Core 913 * @since 7 914 * @deprecated since 9, please use off_avoidAreaChange instead. 915 */ 916 off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void; 917 918 /** 919 * register the callback of avoidAreaChange 920 * @param type: 'avoidAreaChange' 921 * @syscap SystemCapability.WindowManager.WindowManager.Core 922 * @since 9 923 */ 924 on(type: 'avoidAreaChange', callback: Callback<{ type: AvoidAreaType, area: AvoidArea }>): void; 925 926 /** 927 * unregister the callback of avoidAreaChange 928 * @param type: 'avoidAreaChange' 929 * @syscap SystemCapability.WindowManager.WindowManager.Core 930 * @since 9 931 */ 932 off(type: 'avoidAreaChange', callback?: Callback<{ type: AvoidAreaType, area: AvoidArea }>): void; 933 934 /** 935 * register the callback of screenshotEvent, only the focused window called back 936 * @param type: 'screenshotEvent' 937 * @syscap SystemCapability.WindowManager.WindowManager.Core 938 * @since 9 939 */ 940 on(type: 'screenshotEvent', callback: Callback<void>): void; 941 942 /** 943 * unregister the callback of screenshotEvent 944 * @param type: 'screenshotEvent' 945 * @syscap SystemCapability.WindowManager.WindowManager.Core 946 * @since 9 947 */ 948 off(type: 'screenshotEvent', callback?: Callback<void>): void; 949 950 /** 951 * register the callback of dialogTargetTouch 952 * @param type: 'dialogTargetTouch' 953 * @syscap SystemCapability.WindowManager.WindowManager.Core 954 * @since 9 955 */ 956 on(type: 'dialogTargetTouch', callback: Callback<void>): void; 957 958 /** 959 * unregister the callback of dialogTargetTouch 960 * @param type: 'dialogTargetTouch' 961 * @syscap SystemCapability.WindowManager.WindowManager.Core 962 * @since 9 963 */ 964 off(type: 'dialogTargetTouch', callback?: Callback<void>): void; 965 966 /** 967 * bind dialog to the target window. 968 * @param token token of the target window. 969 * @param deathCallback the callback of dialogDeath. 970 * @systemapi 971 * @since 9 972 */ 973 bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): Promise<void>; 974 975 /** 976 * bind dialog to the target window. 977 * @param token token of the target window. 978 * @param deathCallback the callback of dialogDeath. 979 * @systemapi 980 * @since 9 981 */ 982 bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, callback: AsyncCallback<void>); 983 984 /** 985 * Whether the window supports thr wide gamut setting. 986 * @since 8 987 */ 988 isSupportWideGamut(): Promise<boolean>; 989 990 /** 991 * Whether the window supports thr wide gamut setting. 992 * @since 8 993 */ 994 isSupportWideGamut(callback: AsyncCallback<boolean>): void; 995 996 /** 997 * Sets the specified color space. 998 * @param colorSpace the specified color space. 999 * @since 8 1000 */ 1001 setColorSpace(colorSpace:ColorSpace): Promise<void>; 1002 1003 /** 1004 * Sets the specified color space. 1005 * @param colorSpace the specified color space. 1006 * @since 8 1007 */ 1008 setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void; 1009 1010 /** 1011 * Obtains thr set color space. 1012 * @since 8 1013 */ 1014 getColorSpace(): Promise<ColorSpace>; 1015 1016 /** 1017 * Obtains thr set color space. 1018 * @since 8 1019 */ 1020 getColorSpace(callback: AsyncCallback<ColorSpace>): void; 1021 1022 /** 1023 * Sets the background color of window. 1024 * @param color the specified color. 1025 * @since 7 1026 */ 1027 setBackgroundColor(color: string): Promise<void>; 1028 1029 /** 1030 * Sets the background color of window. 1031 * @param color the specified color. 1032 * @since 7 1033 */ 1034 setBackgroundColor(color: string, callback: AsyncCallback<void>): void; 1035 1036 /** 1037 * Sets the brightness of window. 1038 * @param brightness the specified brightness value. 1039 * @since 7 1040 */ 1041 setBrightness(brightness: number): Promise<void>; 1042 1043 /** 1044 * Sets the brightness of window. 1045 * @param brightness the specified brightness value. 1046 * @since 7 1047 */ 1048 setBrightness(brightness: number, callback: AsyncCallback<void>): void; 1049 1050 /** 1051 * Sets the dimBehind of window. 1052 * @param dimBehindValue the specified dimBehind. 1053 * @since 7 1054 */ 1055 setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void; 1056 1057 /** 1058 * Sets the dimBehind of window. 1059 * @param dimBehind the specified dimBehind. 1060 * @since 7 1061 */ 1062 setDimBehind(dimBehindValue: number): Promise<void>; 1063 1064 /** 1065 * Sets whether focusable or not. 1066 * @param isFocusable can be focus if true, or can not be focus if false. 1067 * @since 7 1068 */ 1069 setFocusable(isFocusable: boolean): Promise<void>; 1070 1071 /** 1072 * Sets whether focusable or not. 1073 * @param isFocusable can be focus if true, or can not be focus if false. 1074 * @since 7 1075 */ 1076 setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void; 1077 1078 /** 1079 * Sets whether keep screen on or not. 1080 * @param isKeepScreenOn keep screen on if true, or not if false. 1081 * @since 7 1082 */ 1083 setKeepScreenOn(isKeepScreenOn: boolean): Promise<void>; 1084 1085 /** 1086 * Sets whether keep screen on or not. 1087 * @param isKeepScreenOn keep screen on if true, or not if false. 1088 * @since 7 1089 */ 1090 setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void; 1091 1092 /** 1093 * Sets whether outside can be touch or not. 1094 * @param touchable outside can be touch if true, or not if false. 1095 * @since 7 1096 */ 1097 setOutsideTouchable(touchable: boolean): Promise<void>; 1098 1099 /** 1100 * Sets whether outside can be touch or not. 1101 * @param touchable outside can be touch if true, or not if false. 1102 * @since 7 1103 */ 1104 setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void; 1105 1106 /** 1107 * Sets whether is private mode or not. 1108 * @param isPrivacyMode in private mode if true, or not if false. 1109 * @since 7 1110 */ 1111 setPrivacyMode(isPrivacyMode: boolean): Promise<void>; 1112 1113 /** 1114 * Sets whether is private mode or not. 1115 * @param isPrivacyMode in private mode if true, or not if false. 1116 * @since 7 1117 */ 1118 setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void; 1119 1120 /** 1121 * Sets whether is touchable or not. 1122 * @param isTouchable is touchable if true, or not if false. 1123 * @since 7 1124 */ 1125 setTouchable(isTouchable: boolean): Promise<void>; 1126 1127 /** 1128 * Sets whether is touchable or not. 1129 * @param isTouchable is touchable if true, or not if false. 1130 * @since 7 1131 */ 1132 setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void; 1133 1134 /** 1135 * Sets whether is transparent or not. 1136 * @param isTransparent is transparent if true, or not if false. 1137 * @since 7 1138 */ 1139 setTransparent(isTransparent: boolean): Promise<void>; 1140 1141 /** 1142 * Sets whether is transparent or not. 1143 * @param isTransparent is transparent if true, or not if false. 1144 * @since 7 1145 */ 1146 setTransparent(isTransparent: boolean, callback: AsyncCallback<void>): void; 1147 1148 /** 1149 * Set the preferred orientation config of a window 1150 * @param orientation the orientation config of a window 1151 * @since 9 1152 */ 1153 setPreferredOrientation(orientation: Orientation): Promise<void>; 1154 1155 /** 1156 * Set the preferred orientation config of a window 1157 * @param orientation the orientation config of a window 1158 * @since 9 1159 */ 1160 setPreferredOrientation(orientation: Orientation, callback: AsyncCallback<void>): void; 1161 1162 /** 1163 * disable window decoration. It must be called before loadContent. 1164 * @systemapi 1165 * @since 9 1166 */ 1167 disableWindowDecor(): void; 1168 1169 /** 1170 * Dump window client information. 1171 * Called in the dump callback of ability is the typical usage scenario. 1172 * @since 9 1173 * @param params Indicates the params from command. 1174 * @return The dump info array. 1175 */ 1176 dump(params: Array<string>): Array<string>; 1177 1178 /** 1179 * set the flag of the window is forbidden to move in split screen mode 1180 * @param isForbidSplitMove the flag of the window is forbidden to move in split screen mode 1181 * @syscap SystemCapability.WindowManager.WindowManager.Core 1182 * @systemapi 1183 * @since 9 1184 */ 1185 setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void; 1186 1187 /** 1188 * set the flag of the window is forbidden to move in split screen mode 1189 * @param isForbidSplitMove the flag of the window is forbidden to move in split screen mode 1190 * @syscap SystemCapability.WindowManager.WindowManager.Core 1191 * @systemapi 1192 * @since 9 1193 */ 1194 setForbidSplitMove(isForbidSplitMove: boolean): Promise<void>; 1195 /** 1196 * Sets opacity of window 1197 * @param opacity Interval is 0.f-1.f. 1198 * @systemapi 1199 * @since 9 1200 */ 1201 opacity(opacity: number): void; 1202 /** 1203 * Sets scale options of window. 1204 * @param scaleOptions scale param of window. 1205 * @systemapi 1206 * @since 9 1207 */ 1208 scale(scaleOptions: ScaleOptions): void; 1209 /** 1210 * Sets rotate options of window. 1211 * @param rotateOptions rotate param of window. 1212 * @systemapi 1213 * @since 9 1214 */ 1215 setRotateSync(rotateOptions: RotateOptions): void; 1216 /** 1217 * Sets whether is transparent or not. 1218 * @param translateOptions translate param of window. 1219 * @systemapi 1220 * @since 9 1221 */ 1222 setTranslateSync(translateOptions: TranslateOptions): void; 1223 /** 1224 * Get Transition Controller. 1225 * @systemapi 1226 * @since 9 1227 */ 1228 getTransitionControllerSync(): TransitionController; 1229 1230 /** 1231 * Obtains snapshot of window 1232 * @syscap SystemCapability.WindowManager.WindowManager.Cor 1233 * @since 9 1234 */ 1235 snapshot(callback: AsyncCallback<image.PixelMap>): void; 1236 1237 /** 1238 * Obtains snapshot of window 1239 * @syscap SystemCapability.WindowManager.WindowManager.Co 1240 * @since 9 1241 */ 1242 snapshot(): Promise<image.PixelMap>; 1243 } 1244 /** 1245 * Transition Context 1246 * @syscap SystemCapability.WindowManager.WindowManager.Core 1247 * @systempi 1248 * @since 9 1249 */ 1250 interface TransitionContext { 1251 /** 1252 * The target window with animation 1253 */ 1254 toWindow: Window 1255 /** 1256 * Set complete state of animation transition 1257 * @param isCompleted is Completed if true, or not if false. 1258 */ 1259 completeTransition(isCompleted: boolean): void; 1260 } 1261 1262 /** 1263 * Transition Controller 1264 * @syscap SystemCapability.WindowManager.WindowManager.Core 1265 * @systempi 1266 * @since 9 1267 */ 1268 interface TransitionController { 1269 /** 1270 * Animation configuration when showing window 1271 * @param context transition Context. 1272 */ 1273 animationForShown(context: TransitionContext): void; 1274 /** 1275 * Animation configuration when hiding window 1276 * @param context transition context. 1277 */ 1278 animationForHidden(context: TransitionContext): void; 1279 } 1280 1281 enum WindowStageEventType { 1282 FOREGROUND = 1, 1283 ACTIVE, 1284 INACTIVE, 1285 BACKGROUND, 1286 } 1287 /** 1288 * WindowStage 1289 * @syscap SystemCapability.WindowManager.WindowManager.Core 1290 */ 1291 interface WindowStage { 1292 /** 1293 * Get main window of the stage. 1294 * @since 8 1295 */ 1296 getMainWindow(): Promise<Window>; 1297 /** 1298 * Get main window of the stage. 1299 * @since 8 1300 */ 1301 getMainWindow(callback: AsyncCallback<Window>): void; 1302 /** 1303 * Create sub window of the stage. 1304 * @param name window name of sub window 1305 * @since 8 1306 */ 1307 createSubWindow(name: string): Promise<Window>; 1308 /** 1309 * Create sub window of the stage. 1310 * @param name window name of sub window 1311 * @since 8 1312 */ 1313 createSubWindow(name: string, callback: AsyncCallback<Window>): void; 1314 /** 1315 * Get sub window of the stage. 1316 * @since 8 1317 */ 1318 getSubWindow(): Promise<Array<Window>>; 1319 /** 1320 * Get sub window of the stage. 1321 * @since 8 1322 */ 1323 getSubWindow(callback: AsyncCallback<Array<Window>>): void; 1324 /** 1325 * Loads content 1326 * @param path path Path of the page to which the content will be loaded 1327 * @param storage storage The data object shared within the content instance loaded by the window 1328 * @syscap SystemCapability.WindowManager.WindowManager.Core 1329 * @since 8 1330 */ 1331 loadContent(path: string, storage: ContenStorage, callback: AsyncCallback<void>): void; 1332 /** 1333 * Loads content 1334 * @param path path of the page to which the content will be loaded 1335 * @syscap SystemCapability.WindowManager.WindowManager.Core 1336 * @since 8 1337 */ 1338 loadContent(path: string, callback: AsyncCallback<void>): void; 1339 /** 1340 * Loads content 1341 * @param path path of the page to which the content will be loaded 1342 * @syscap SystemCapability.WindowManager.WindowManager.Core 1343 * @since 8 1344 */ 1345 loadContent(path: string, storage?: ContenStorage): Promise<void>; 1346 /** 1347 * get the windowmode of current window 1348 * @syscap SystemCapability.WindowManager.WindowManager.Core 1349 * @systemapi 1350 * @since 8 1351 */ 1352 getWindowMode(callback: AsyncCallback<WindowMode>): void; 1353 /** 1354 * get the windowmode of current window 1355 * @syscap SystemCapability.WindowManager.WindowManager.Core 1356 * @systemapi 1357 * @since 8 1358 */ 1359 getWindowMode(): Promise<WindowMode>; 1360 /** 1361 * window stage event callback on. 1362 * @since 8 1363 */ 1364 on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>): void; 1365 /** 1366 * window stage event callback off. 1367 * @since 8 1368 */ 1369 off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType>): void; 1370 } 1371 1372 /** 1373 * screen orientation 1374 * @syscap SystemCapability.WindowManager.WindowManager.Core 1375 * @since 9 1376 */ 1377 enum Orientation { 1378 UNSPECIFIED = 0, 1379 PORTRAIT = 1, 1380 LANDSCAPE = 2, 1381 PORTRAIT_INVERTED = 3, 1382 LANDSCAPE_INVERTED = 4, 1383 AUTO_ROTATION = 5, 1384 AUTO_ROTATION_PORTRAIT = 6, 1385 AUTO_ROTATION_LANDSCAPE = 7, 1386 AUTO_ROTATION_RESTRICTED = 8, 1387 AUTO_ROTATION_PORTRAIT_RESTRICTED = 9, 1388 AUTO_ROTATION_LANDSCAPE_RESTRICTED = 10, 1389 LOCKED = 11, 1390 } 1391} 1392 1393export default window; 1394