📄 compieretheme.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.plaf;
import java.awt.*;
import java.util.logging.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import org.compiere.util.*;
import sun.awt.*;
/**
* Compiere User definable Theme (if used in Metal L&F).
* In other Environments, it provides UI extensions (e.g. Error Color)
*
* @author Jorg Janke
* @version $Id: CompiereTheme.java,v 1.19 2005/10/21 15:44:12 jjanke Exp $
*/
public class CompiereTheme extends MetalTheme
{
/**
* Constructor - nop
*/
public CompiereTheme()
{
} // CompiereTheme
/**
* Return Theme Name
* @return Theme Name
*/
public String getName()
{
return s_name;
} // getName
/**
* String Representation
* @return info
*/
public String toString ()
{
return s_name;
} // toString
/**
* Set Default Colors
*/
protected void setDefault()
{
} // setDefault
/** Static Initializer */
static
{
s_theme = new CompiereThemeBlueMetal();
}
/** Theme Name */
protected static String s_name = "Compiere Theme";
/** Logger */
protected static Logger log = Logger.getLogger(CompiereTheme.class.getName());
/** Active Theme */
protected static CompiereTheme s_theme = null;
/** Blue 51,51,102 */
protected static ColorUIResource primary0 = new ColorUIResource(51, 51, 102);
/** Blue 102, 102, 153 */
protected static ColorUIResource primary1;
/** Blue 153, 153, 204 */
protected static ColorUIResource primary2;
/** Blue 204, 204, 255 */
protected static ColorUIResource primary3;
/** Black */
protected final ColorUIResource secondary0 = new ColorUIResource(0, 0, 0);
/** Gray 102, 102, 102 */
protected static ColorUIResource secondary1;
/** Gray 153, 153, 153 */
protected static ColorUIResource secondary2;
/** BlueGray 214, 224, 234 - background */
protected static ColorUIResource secondary3;
/** White */
protected final ColorUIResource secondary4 = new ColorUIResource(255, 255, 255);
/** Black */
protected static ColorUIResource black;
/** White */
protected static ColorUIResource white;
/** Background for mandatory fields */
protected static ColorUIResource mandatory;
/** Background for fields in error */
protected static ColorUIResource error;
/** Background for inactive fields */
protected static ColorUIResource inactive;
/** Background for info fields */
protected static ColorUIResource info;
/** Foreground Text OK */
protected static ColorUIResource txt_ok;
/** Foreground Text Error */
protected static ColorUIResource txt_error;
/** Control font */
protected static FontUIResource controlFont;
/** System font */
protected static FontUIResource systemFont;
/** User font */
protected static FontUIResource userFont;
/** Small font */
protected static FontUIResource smallFont;
/** Window Title font */
protected static FontUIResource windowFont;
/** Menu font */
protected static FontUIResource menuFont;
/** Default Font */
public static final String FONT_DEFAULT = "Dialog";
/** Default Font Size */
public static final int FONT_SIZE = 12;
/**
* Set Theme to current Metal Theme and copy it
*/
public static void setTheme ()
{
AppContext context = AppContext.getAppContext();
MetalTheme copyFrom = (MetalTheme)context.get("currentMetalTheme");
boolean flat = Ini.isPropertyBool(Ini.P_UI_FLAT);
setTheme (copyFrom, flat);
} // setTheme
/**
* Set Theme to current Metal Theme and copy it
* @param copyFrom
*/
public static void setTheme (MetalTheme copyFrom, boolean flat)
{
if (copyFrom == null || copyFrom instanceof CompiereTheme)
return;
// May not be correct, if Themes overwrites default methods
primary1 = copyFrom.getPrimaryControlDarkShadow();
primary2 = copyFrom.getPrimaryControlShadow();
primary3 = copyFrom.getPrimaryControl();
secondary1 = copyFrom.getControlDarkShadow();
secondary2 = copyFrom.getControlShadow();
secondary3 = copyFrom.getControl();
CompierePanelUI.setDefaultBackground(new CompiereColor(secondary3, flat));
white = copyFrom.getPrimaryControlHighlight();
black = copyFrom.getPrimaryControlInfo();
//
controlFont = copyFrom.getControlTextFont();
systemFont = copyFrom.getSystemTextFont();
userFont = copyFrom.getUserTextFont();
smallFont = copyFrom.getSubTextFont();
menuFont = copyFrom.getMenuTextFont();
windowFont = copyFrom.getWindowTitleFont();
} // setTheme
/**************************************************************************
* Get Primary 1 (blue in default Metal Theme)
* @return color
*/
public ColorUIResource getPrimary1()
{
return ColorBlind.getDichromatColorUIResource(primary1);
}
public ColorUIResource getPrimary2()
{
return ColorBlind.getDichromatColorUIResource(primary2);
}
public ColorUIResource getPrimary3()
{
return ColorBlind.getDichromatColorUIResource(primary3);
}
/**
* Get Seconary 1 (gray in default Metal Theme)
* @return color
*/
public ColorUIResource getSecondary0()
{
return ColorBlind.getDichromatColorUIResource(secondary0);
}
public ColorUIResource getSecondary1()
{
return ColorBlind.getDichromatColorUIResource(secondary1);
}
public ColorUIResource getSecondary2()
{
return ColorBlind.getDichromatColorUIResource(secondary2);
}
public ColorUIResource getSecondary3()
{
return ColorBlind.getDichromatColorUIResource(secondary3);
}
public ColorUIResource getSecondary4()
{
return ColorBlind.getDichromatColorUIResource(secondary4);
}
public ColorUIResource getBlack()
{
return ColorBlind.getDichromatColorUIResource(black);
}
public ColorUIResource getWhite()
{
return ColorBlind.getDichromatColorUIResource(white);
}
/**
* Control Font (plain)
* @return font
*/
protected static FontUIResource _getControlTextFont()
{
if (controlFont == null)
{
try
{
controlFont = new FontUIResource(Font.getFont("swing.plaf.metal.controlFont",
new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE)));
}
catch (Exception e)
{
controlFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE);
}
}
return controlFont;
}
public FontUIResource getControlTextFont() {return _getControlTextFont();}
/**
* System Font
* @return font
*/
protected static FontUIResource _getSystemTextFont()
{
if (systemFont == null)
{
try
{
systemFont = new FontUIResource(Font.getFont("swing.plaf.metal.systemFont",
new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE)));
}
catch (Exception e)
{
systemFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE);
}
}
return systemFont;
}
public FontUIResource getSystemTextFont() {return _getSystemTextFont();}
/**
* User Font
* @return font
*/
protected static FontUIResource _getUserTextFont()
{
if (userFont == null)
{
try
{
userFont = new FontUIResource(Font.getFont("swing.plaf.metal.userFont",
new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE)));
}
catch (Exception e)
{
userFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE);
}
}
return userFont;
}
public FontUIResource getUserTextFont() {return _getUserTextFont();}
/**
* Menu
* @return font
*/
protected static FontUIResource _getMenuTextFont()
{
if (menuFont == null)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -