/*
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 */
package com.sun.glass.ui;

import java.util.List;

public class Screen {

    public static Screen getDeepestScreen() {
        return Application.GetApplication().staticScreen_getDeepestScreen();
    }

    public static Screen getMainScreen() {
        return Application.GetApplication().staticScreen_getMainScreen();
    }

    public static Screen getScreenForLocation(int x, int y) {
        return Application.GetApplication().staticScreen_getScreenForLocation(x, y);
    }

    // used by Window.notifyMoveToAnotherScreen
    static Screen getScreenForPtr(long screenPtr) {
        return Application.GetApplication().staticScreen_getScreenForPtr(screenPtr);
    }

    public static List<Screen> getScreens() {
        return Application.GetApplication().staticScreen_getScreens();
    }

    private long ptr;

    private int depth;

    private int x;
    private int y;
    private int width;
    private int height;

    private int visibleX;
    private int visibleY;
    private int visibleWidth;
    private int visibleHeight;

    private int resolutionX;
    private int resolutionY;

    private float scale;

    public Screen() {
        this.ptr = 0L;

        this.depth = 0;

        this.x = 0;
        this.y = 0;
        this.width = 0;
        this.height = 0;

        this.visibleX = 0;
        this.visibleY = 0;
        this.visibleWidth = 0;
        this.visibleHeight = 0;

        this.resolutionX = 0;
        this.resolutionY = 0;

        this.scale = 0.0f;
    }

    protected Screen(
            long ptr,
            int depth,
            int x, int y,
            int width, int height,
            int visibleX, int visibleY,
            int visibleWidth, int visibleHeight,
            int resolutionX, int resolutionY,
            float scale) {
        this.ptr = ptr;

        this.depth = depth;

        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;

        this.visibleX = visibleX;
        this.visibleY = visibleY;
        this.visibleWidth = visibleWidth;
        this.visibleHeight = visibleHeight;

        this.resolutionX = resolutionX;
        this.resolutionY = resolutionY;

        this.scale = scale;
    }

    public int getDepth() {
        return this.depth;
    }

    public int getX() {
        return this.x;
    }

    public int getY() {
        return this.y;
    }

    public int getWidth() {
        return this.width;
    }

    public int getHeight() {
        return this.height;
    }

    public int getVisibleX() {
        return this.visibleX;
    }

    public int getVisibleY() {
        return this.visibleY;
    }

    public int getVisibleWidth() {
        return this.visibleWidth;
    }

    public int getVisibleHeight() {
        return this.visibleHeight;
    }

    public int getResolutionX() {
        return this.resolutionX;
    }

    public int getResolutionY() {
        return this.resolutionY;
    }

    public float getScale() {
        return this.scale;
    }

    public long getNativeScreen() {
        return this.ptr;
    }

    public interface SettingsChangedCallback {
        public void settingsChanged();
    }

    private static SettingsChangedCallback callback = null;

    public static void setCallback(SettingsChangedCallback callback) {
        Screen.callback = callback;
    }

    public static SettingsChangedCallback getCallback() {
        return callback;
    }

    private static void notifySettingsChanged() {
        if (callback != null) {
            callback.settingsChanged();
        }
    }

    @Override public String toString() {
        return  "Screen:"+"\n"+
                "    ptr:"+getNativeScreen()+"\n"+
                "    depth:"+getDepth()+"\n"+
                "    x:"+getX()+"\n"+
                "    y:"+getY()+"\n"+
                "    width:"+getWidth()+"\n"+
                "    height:"+getHeight()+"\n"+
                "    visibleX:"+getVisibleX()+"\n"+
                "    visibleY:"+getVisibleY()+"\n"+
                "    visibleWidth:"+getVisibleWidth()+"\n"+
                "    visibleHeight:"+getVisibleHeight()+"\n"+
                "    scale:"+getScale()+"\n"+
                "    resolutionX:"+getResolutionX()+"\n"+
                "    resolutionY:"+getResolutionY()+"\n";
    }
}
