/*
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 */
package com.sun.javafx.tk.desktop;

import com.sun.javafx.PlatformUtil;
import com.sun.javafx.perf.PerformanceTracker;
import com.sun.javafx.tk.Toolkit;
import com.sun.scenario.animation.AbstractMasterTimer;
import javafx.scene.input.KeyCode;
    
public abstract class DesktopToolkit extends Toolkit {
    protected static boolean hasPlugin; // obsolete, to be removed when sync w/deploy

    /**
     * setPluginMode should be called to indicate if the toolkit is in use by
     * the plugin
     */
    public static void setPluginMode(boolean hasPlugin) { // obsolete, to be removed when sync w/deploy
            DesktopToolkit.hasPlugin = hasPlugin;
    }

    /**
     * Creates an AppletWindow using the provided window pointer as the parent
     * window.
     * 
     * @param parent the native parent which will contain the primary stage
     * window(s). Used on Windows/Linux platforms.
     * 
     * @param serverName the name of CARemoteLayerServer which
     * will be used to register native layer. Used on Mac platform.
     */
    public abstract AppletWindow createAppletWindow(long parent, String serverName);
    public AppletWindow createAppletWindow(long parent) {
        return createAppletWindow(parent, null);
    }
    
    /**
     * Perform cleanup in preparation for applet termination, including closing
     * the applet window.
     */
    public abstract void closeAppletWindow();
    
    public static DesktopToolkit getDesktopToolkit() {
        return (DesktopToolkit) Toolkit.getToolkit();
    }

    private final PerformanceTracker perfTracker = new PerformanceTrackerImpl();

    public abstract boolean isAppletDragSupported();
    
    public AbstractMasterTimer getMasterTimer() {
        return MasterTimer.getInstance();
    }
    
    public PerformanceTracker getPerformanceTracker() {
        return perfTracker;
    }

    @Override public PerformanceTracker createPerformanceTracker() {
        return new PerformanceTrackerImpl();
    }
    
    public KeyCode getPlatformShortcutKey() {
        return PlatformUtil.isMac() ? KeyCode.META : KeyCode.CONTROL;
    }
}
