📄 stylesheet.java
字号:
/*
* Created on 05-Jan-2004 at 20:41:52.
*
* Copyright (c) 2004-2005 Robert Virkus / Enough Software
*
* This file is part of J2ME Polish.
*
* J2ME Polish is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* J2ME Polish is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with J2ME Polish; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Commercial licenses are also available, please
* refer to the accompanying LICENSE.txt or visit
* http://www.j2mepolish.org for details.
*/
package de.enough.polish.ui;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Timer;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import de.enough.polish.ui.tasks.ImageTask;
import de.enough.polish.util.Locale;
/**
* <p>Manages all defined styles of a specific project.</p>
* <p>This class is actually pre-processed to get the styles specific for the project and the device.</p>
*
* @author Robert Virkus, robert@enough.de
* <pre>
* history
* 05-Jan-2004 - rob creation
* </pre>
*/
public final class StyleSheet {
protected static Hashtable imagesByName;
//#ifdef polish.images.backgroundLoad
//# private static Hashtable scheduledImagesByName;
//# //private static final Boolean TRUE = new Boolean( true );
//# private static Timer timer;
//#endif
//#ifdef polish.LibraryBuild
//# public static Style defaultStyle = new Style( 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0x000000, Font.getDefaultFont(), null, null, null, null );
//# public static Style focusedStyle = new Style( 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0xFF0000, Font.getDefaultFont(), null, null, null, null );
//# public static Style labelStyle = new Style( 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, Item.LAYOUT_NEWLINE_AFTER, 0x000000, Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL ), null, null, null, null );;
//# public static Style menuStyle = null;
//# private static Hashtable stylesByName = new Hashtable();
//#endif
//#if polish.ScreenChangeAnimation.forward:defined
//#if false
//# private static ScreenChangeAnimation forwardAnimation;
//# private static ScreenChangeAnimation backwardAnimation;
//#endif
//#= private static ScreenChangeAnimation forwardAnimation = ${polish.ScreenChangeAnimation.forward};
//#if polish.ScreenChangeAnimation.back:defined
//#= private static ScreenChangeAnimation backwardAnimation = ${polish.ScreenChangeAnimation.back};
//#elif polish.ScreenChangeAnimation.backward:defined
//#= private static ScreenChangeAnimation backwardAnimation = ${polish.ScreenChangeAnimation.backward};
//#else
//#abort You need to define the polish.ScreenChangeAnimation.backward screen change animation as well, when you define the forward animation!
//#endif
//#endif
// do not change the following line!
//$$IncludeStyleSheetDefinitionHere$$//
public final static int defaultFontColor = 0x000000;
public final static Font defaultFont = Font.getFont( Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM );
public final static Background defaultBackground = null;
public final static Border defaultBorder = null;
public final static Style defaultStyle = new Style (
0,0,0,0, // default margin
1,1,1,1,1,1, // default padding
Item.LAYOUT_DEFAULT, // default layout
defaultFontColor,
null,
defaultFont,
defaultBackground,
defaultBorder
, null, null // no additional attributes have been defined
);
//static and referenced styles:
public final static Style loadgamealertStyle = new Style (
20,20,20,20, // margin
15,15,5,5,5,5, // padding
Item.LAYOUT_EXPAND | Item.LAYOUT_CENTER | Item.LAYOUT_VCENTER,
defaultFontColor, // font-color is not defined
null, // font-color is not defined
defaultFont,
new de.enough.polish.ui.backgrounds.TranslucentSimpleBackground( 0x96ffffff),
null // no border
, new short[]{ 112}
, new Object[]{ Style.FALSE}
);
public final static Style alertcontentStyle = new Style (
0,0,0,0, // default margin
1,1,1,1,1,1, // default padding
Item.LAYOUT_DEFAULT, // default layout
0x1e5556, // font-color
new Color(0x1e5556, false), // font-color
Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL ), //font
null, // no background
null // no border
, null, null // no additional attributes have been defined
);
public final static Style maincommandStyle = new Style (
2,2,2,2, // margin
5,5,5,5,5,5, // padding
Item.LAYOUT_CENTER | Item.LAYOUT_EXPAND,
0x1e5556, // font-color
new Color(0x1e5556, false), // font-color
Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL ), //font
null, // background:none was specified
null // no border
, new short[]{ 59, 6, 7}
, new Object[]{ new Integer(100), "/icon%INDEX%.png", new Integer(2)}
);
public final static Style menuitemStyle = new Style (
0,0,2,0, // margin
5,2,2,2,2,2, // padding
Item.LAYOUT_LEFT,
0x1e5556, // font-color
new Color(0x1e5556, false), // font-color
Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM ), //font
null, // no background
null // no border
, null, null // no additional attributes have been defined
);
public final static Style titleStyle = new Style (
0,0,0,5, // margin
2,2,2,2,2,2, // padding
Item.LAYOUT_CENTER | Item.LAYOUT_EXPAND,
0xeef1e5, // font-color
new Color(0xeef1e5, false), // font-color
Font.getFont( Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_LARGE ), //font
new de.enough.polish.ui.backgrounds.SimpleBackground( new Color( 0x848f60, false)),
null // border:none was specified
, null, null // no additional attributes have been defined
);
public final static Style browserStyle = new Style (
0,0,0,0, // default margin
1,1,1,1,1,1, // default padding
Item.LAYOUT_DEFAULT, // default layout
defaultFontColor, // font-color is not defined
null, // font-color is not defined
defaultFont,
null, // no background
null // no border
, new short[]{ 39}
, new Object[]{ new de.enough.polish.ui.containerviews.MIDP2LayoutView()}
);
public final static Style focusedStyle = new Style (
0,0,0,0, // default margin
5,5,5,5,5,5, // padding
Item.LAYOUT_EXPAND | Item.LAYOUT_CENTER,
0x1e5556, // font-color
new Color(0x1e5556, false), // font-color
Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL ), //font
new de.enough.polish.ui.backgrounds.BorderedRoundRectBackground( 0xeef1e5,8, 8, 0x1e5556, 2),
null // no border
, null, null // no additional attributes have been defined
);
public final static Style menufocusedStyle = new Style (
0,0,2,0, // margin
5,2,2,2,2,2, // padding
Item.LAYOUT_LEFT | Item.LAYOUT_EXPAND,
0xeef1e5, // font-color
new Color(0xeef1e5, false), // font-color
Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM ), //font
new de.enough.polish.ui.backgrounds.SimpleBackground( new Color( 0x848f60, false)),
null // no border
, null, null // no additional attributes have been defined
);
public final static Style browserlinkfocusedStyle = new Style (
0,0,0,0, // default margin
1,1,1,1,1,1, // padding
Item.LAYOUT_DEFAULT, // default layout
0xFF0000, // font-color
new Color(0xFF0000, false), // font-color
Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM ), //font
null, // no background
null // no border
, new short[]{ 209}
, new Object[]{ Style.FALSE}
);
public final static Style browsertextbolditalicfocusedStyle = new Style (
0,0,0,0, // default margin
1,1,1,1,1,1, // padding
Item.LAYOUT_DEFAULT, // default layout
0xFF0000, // font-color
new Color(0xFF0000, false), // font-color
Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD | Font.STYLE_ITALIC, Font.SIZE_MEDIUM ), //font
null, // no background
null // no border
, new short[]{ 209}
, new Object[]{ Style.FALSE}
);
public final static Style browsertextboldfocusedStyle = new Style (
0,0,0,0, // default margin
1,1,1,1,1,1, // padding
Item.LAYOUT_DEFAULT, // default layout
0xFF0000, // font-color
new Color(0xFF0000, false), // font-color
Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM ), //font
null, // no background
null // no border
, new short[]{ 209}
, new Object[]{ Style.FALSE}
);
public final static Style browsertextfocusedStyle = new Style (
0,0,0,0, // default margin
1,1,1,1,1,1, // padding
Item.LAYOUT_DEFAULT, // default layout
0xFF0000, // font-color
new Color(0xFF0000, false), // font-color
Font.getDefaultFont(), //font
null, // no background
null // no border
, new short[]{ 209}
, new Object[]{ Style.FALSE}
);
public final static Style browsertextitalicfocusedStyle = new Style (
0,0,0,0, // default margin
1,1,1,1,1,1, // padding
Item.LAYOUT_DEFAULT, // default layout
0xFF0000, // font-color
new Color(0xFF0000, false), // font-color
Font.getFont( Font.FACE_SYSTEM, Font.STYLE_ITALIC, Font.SIZE_MEDIUM ), //font
null, // no background
null // no border
, new short[]{ 209}
, new Object[]{ Style.FALSE}
);
public final static Style browserinputfocusedStyle = new Style (
0,0,0,0, // default margin
1,1,1,1,1,1, // padding
Item.LAYOUT_EXPAND | Item.LAYOUT_LEFT,
0xFF0000, // font-color
new Color(0xFF0000, false), // font-color
Font.getDefaultFont(), //font
null, // no background
new de.enough.polish.ui.borders.RoundRectBorder( 0x142850,2, 10, 10)
, new short[]{ 209}
, new Object[]{ Style.FALSE}
);
public final static Style mainscreenfocusedStyle = new Style (
0,0,0,0, // default margin
5,5,5,5,5,5, // padding
Item.LAYOUT_CENTER,
0x1e5556, // font-color
new Color(0x1e5556, false), // font-color
Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL ), //font
null, // background:none was specified
null // no border
, new short[]{ 59}
, new Object[]{ new Integer(100)}
);
public final static Style mainscreenStyle = new Style (
0,0,0,0, // default margin
10,10,5,5,10,5, // padding
Item.LAYOUT_EXPAND | Item.LAYOUT_CENTER | Item.LAYOUT_VCENTER,
defaultFontColor, // font-color is not defined
null, // font-color is not defined
defaultFont,
new de.enough.polish.ui.backgrounds.SimpleBackground( new Color( 0xeef1e5, false)),
null // no border
, new short[]{ 39, 1}
, new Object[]{ new de.enough.polish.ui.containerviews.CarrouselContainerView(), mainscreenfocusedStyle}
);
public final static Style browsertextbolditalicStyle = new Style (
0,0,0,0, // default margin
1,1,1,1,1,1, // padding
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -