/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.ctecinf.theme;

import java.awt.Color;
import java.awt.Font;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;

/**
 *
 * @author Cássio Conceição
 * @since 01/11/2019
 * @version 1911
 * @see http://ctecinf.com.br/
 */
public class DefaultTheme extends DefaultMetalTheme {

    public DefaultTheme() {
        init();
    }

    private void init() {

        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);

        MetalLookAndFeel.setCurrentTheme(this);
        
        SwingUtilities.invokeLater(() -> {
            
            UIManager.put("Menu.selectionBackground", getPrimaryControl());
            UIManager.put("MenuItem.selectionBackground", getPrimaryControl());
            
            UIManager.put("Menu.font", getControlTextFont().deriveFont(Font.PLAIN, 17));
            UIManager.put("MenuItem.font", getControlTextFont().deriveFont(Font.PLAIN, 17));
            
            UIManager.put("Button.font", getControlTextFont().deriveFont(Font.PLAIN, 11));
            UIManager.put("ComboBox.font", getControlTextFont().deriveFont(Font.PLAIN));
            UIManager.put("List.font", getControlTextFont().deriveFont(Font.PLAIN));
        });
    }

    @Override
    public final ColorUIResource getControl() {
        return super.getControl();
    }

    @Override
    protected final ColorUIResource getPrimary1() {
        return new ColorUIResource(getPrimaryDark());
    }

    @Override
    protected final ColorUIResource getPrimary2() {
        return new ColorUIResource(getPrimaryMedium());
    }

    @Override
    protected final ColorUIResource getPrimary3() {
        return new ColorUIResource(getPrimaryLight());
    }

    @Override
    protected final ColorUIResource getSecondary1() {
        return new ColorUIResource(getPrimaryDark());
    }

    @Override
    protected final ColorUIResource getSecondary2() {
        return new ColorUIResource(getPrimaryMedium());
    }

    protected Color getPrimaryLight() {
        return super.getPrimary3();
    }

    protected Color getPrimaryMedium() {
        return super.getPrimary2();
    }

    protected Color getPrimaryDark() {
        return super.getPrimary1();
    }
}
