/// <reference path="./sigApi.ApiBase.d.ts" />
/// <reference path="./sigApi.Window.d.ts" />

declare namespace SigApi {
    interface ApiWindowManager extends ApiBase {
        /**
         * Gets a Window object
         * 
         * @param {number|string} id the index or the name of the window
         * 
         * @returns {Window|null} a window object or null 
         */
        getWindow(id: number | string): Window | null
        /**
         * Opens a window. This Function can also overload the window directly after the window is opened.
         * 
         * @param {number|string} id the index or the name of the window
         * @param {number|string} [ovId=null] the index or name of the datapoint with which the overload should be performed  
         * @param {number} [selGr=null]  the selection group for the overload
         * @param {number|string} [targetId=null] the id or the name of the target datapoint for the overload
         * @returns {Promise} Promise -> resolve: () => void, reject: (string) => void
         * 
         * A promise which is resolved if the window was opened.
         * 
         * If it gets rejected, the cause is given as string
         */
        openWindow(
            id: number | string,
            ovId?: number | string,
            selGr?: number,
            targetId?: number | string
        ): Promise<void>
        /**
         * Closes a window
         * 
         * @param {number|string} id the index or the name of the window
         * 
         * @returns {Promise} Promise -> resolve: () => void, reject: (string) => void}
         * 
         * A promise which is resolved if the window was closed.
         * 
         * If it gets rejected, the cause is given as string
         */
        closeWindow(id: number | string): Promise<void>
        /**
         * Gets a Window object
         * 
         * @param {number} id the windowIndex of the window
         * @param {boolean} [resolveOverwrite=false] If true, a possible defined overwrite of the view is taken into account.
         * 
         * @returns {Window|null} a window object or null 
         */
        getWindowByWindowIndex(id: number, resolveOverwrite?: boolean): Window | null
        /**
         * Opens a window. This Function can also overload the window directly after the window is opened.
         * 
         * @param {number} windowIndex the windowIndex of the window
         * @param {number|string} [ovId=null] the index or name of the datapoint with which the overload should be performed  
         * @param {number} [selGr=null]  the selection group for the overload
         * @param {number|string} [targetId=null] the id or the name of the target datapoint for the overload
         * @param {boolean} [resolveOverwrite=false] If true, a possible defined overwrite of the view is taken into account.
         * 
         * @returns {Promise} Promise -> resolve: () => void, reject: (string) => void
         * 
         * A promise which is resolved if the window was opened.
         * 
         * If it gets rejected, the cause is given as string
         */
        openWindowByWindowIndex(
            windowIndex: number,
            ovId?: number | string,
            selGr?: number,
            targetId?: number | string,
            resolveOverwrite?: boolean
        ): Promise<void>
        /**
         * Closes a window
         * 
         * @param {number} windowIndex the windowIndex of the window
         * @param {boolean} [resolveOverwrite=false] If true, a possible defined overwrite of the view is taken into account.
         *
         * @returns {Promise} Promise -> resolve: () => void, reject: (string) => void}
         * 
         * A promise which is resolved if the window was closed.
         * 
         * If it gets rejected, the cause is given as string
         */
        closeWindowByWindowIndex(windowIndex: number, resolveOverwrite?: boolean): Promise<void>
        /**
         * Returns an array of all open windows
         * 
         * @returns {Window[]} a array with all window objects which are currently open
         */
        getOpenWindows(): Window[]
        /**
         * Returns an array of all windows
         * 
         * @returns {Window[]} a array with all window objects
         */
        getWindows(): Window[]
        /**
         * Closes all open windows and resets all windows to their default size and position.
         */
        resetWindows(): void,
        /**
         * Creates a Window
         * 
         * @param {number} [top=0] position in pixel
         * @param {number} [left=0] position in pixel
         * @param {number} [width=100] dimension in pixel
         * @param {number} [height=50] dimension in pixel
         * @param {Function} [renderCallback=()=>{}] render callback
         * 
         * signature:
         * ```
         *     ({HTMLElement}) => {undefined}
         * ```
         * @param {object} [props={}] properties -> eg. 
         * ```
         *     {
         *         window: {hasCloseButton: false, ...},
         *         css: {--theme-background-color: "red", ...},
         *         events: {jspanelbeforeclose: () => {}, ...},
         *         eventHandler: {open: SIG_CONST.EVENT_LIST_USER_INTERN + "OpenWindow", ...},
         *         fonts: {--theme-element-main-font: "FontName", ...}
         *      }
         * ```
         * @param {string} [id=undefined] the instanceId of the window
         * 
         * @returns {Promise} Promise -> resolve: () => void, reject: (string) => void}
         * 
         * A promise which is resolved if the window was opened.
         * 
         * If it gets rejected, the cause is given as string
         */
        createWindow(
            top?: number,
            left?: number,
            width?: number,
            height?: number,
            renderCallback?: (element: HTMLElement) => void,
            props?: object,
            id?: string
        ): Promise<void>
        /**
         * Opens an alert window
         * 
         * @param {string|object} message A static text of a textListObject of the displayed text
         * 
         * eg. 'this is a text' or a textListObject:
         * ```
         *     {
         *         textList: 'textListName', //Name of the textlist
         *         text: 'textName',         //Name of the text
         *         param: [                  //Values with which the escape sequences gets replaced
         *             'replText', 
         *             ...
         *         ]
         *     }
         * ```
         * @param {string|object} title A static text of a textListObject of the title text (eg. 'this is a text' or textListObject(see systemWindow_alert::message))
         * @param {number} status The state of the Window (info = 0(SYSTEM_WINDOW_INFO), warning = 1(SYSTEM_WINDOW_WARNING), error = 2(SYSTEM_WINDOW_ERROR))
         * @param {object} [style=undefined] A object to style the window (if no styling is needed leave parameter undefined for better performace)
         * 
         * eg. 
         * ```
         *    {
         *       props: { //Props for the window itself
         *           isModal: { src: 0, dest: 9, value: false }
         *       },
         *       controls: { //props for the controls
         *           okButton: { //The confirm Button
         *               props: {
         *                   '--theme-sig-control-button-background-color': {
         *                       src: 0,
         *                       dest: 2,
         *                       value: "#0000FF"
         *                   }
         *               }
         *           },
         *           cancelButton: { //The Cancel Button -> only for confirm and prompt
         *               props: { ... }
         *           },
         *           Text: { //The Output Text
         *               props: { ... }
         *           },
         *           Input { // The Input Field -> only for prompt
         *               props: { ... }
         *           },
         *           Rectangle: { // The Line between Buttons and the Output Text
         *               props: { ... }
         *           }
         *       }
         *   }
         *   ```
         * 
         * @returns {Promise} Promise -> resolve: () => void, reject: (string) => void}
         * 
         * A promise which is resolved if the ok button is pressed
         * 
         * If it gets rejected, the cause is given as string
         */
        systemWindow_alert(
            message: string | object,
            title: string | object,
            status: number,
            style?: object
        ): Promise<void>
        /**
         * Opens a confirm window
         * 
         * @param {string|object} message A static text of a textListObject of the displayed text (eg. 'this is a text' or a textListObject(see systemWindow_alert::message))
         * @param {string|object} title A static text of a textListObject of the title text (eg. 'this is a text' or textListObject(see systemWindow_alert::message))
         * @param {number} status The state of the Window (info = 0(SYSTEM_WINDOW_INFO), warning = 1(SYSTEM_WINDOW_WARNING), error = 2(SYSTEM_WINDOW_ERROR))
         * @param {object} [style=undefined] A object to style the window (if no styling is needed leave parameter undefined for better performace) eg. see alert
         *
         * @returns {Promise} Promise -> resolve: () => void, reject: () => void}
         * 
         * A promise which is resolved if the ok button is pressed, or rejected on cancel
         */
        systemWindow_confirm(
            message: string | object,
            title: string | object,
            status: number,
            style?: object
        ): Promise<void>
        /**
         * Opens a prompt 
         * 
         * @param {string|object} message A static text of a textListObject of the displayed text (eg. 'this is a text' or a textListObject(see systemWindow_alert::message))
         * @param {string|object} title A static text of a textListObject of the title text (eg. 'this is a text' or textListObject(see systemWindow_alert::message))
         * @param {string|object} promptValue A static text of a textListObject of the preentered value (eg. 'this is a text' or textListObject(see systemWindow_alert::message))
         * @param {number} [status=SIG_CONST.SYSTEM_WINDOW_INFO] The state of the Window (info = 0(SYSTEM_WINDOW_INFO), warning = 1(SYSTEM_WINDOW_WARNING), error = 2(SYSTEM_WINDOW_ERROR))
         * @param {object} [style=undefined] A object to style the window (if no styling is needed leave parameter undefined for better performace) eg. see alert
         *
         * @returns {Promise} Promise -> resolve: (string) => void, reject: () => void}
         * 
         * A promise which is resolved with the entered value if the ok button is pressed, or rejected on cancel
         */
        systemWindow_prompt(
            message: string | object,
            title: string | object,
            promptValue: string | object,
            status?: number,
            style?: object
        ): Promise<string>
        /**
         * Close a system window
         * 
         * @param {number} windowId The id of a system window
         * @param {boolean} [confirm=false] resolves or rejects resulting promise of a systemWindow_confirm/systemWindow_prompt
         */
        closeSystemWindow(windowId: number, confirm?: boolean): void
        /**
         * Function to check if parameter object is a instanceof Window.
         * This function can be used without importing the type Window to be used with the instanceof operator.
         * @param {*} object Any object to type check
         * @returns {boolean} Returns true if parameter object is instanceof Window, else false
         */
        instanceofWindow(object: any): boolean
    }
}
