📄 style.java
字号:
package com.podome.style;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Image;
import com.podome.log.Logger;
/**
* 和图片或背景图片相关的属性都放到样式中,文字前面需要显示小图标,不同的状态显示不
* 同的图标等。
*/
public class Style {
/***************布局参数***********************/
public final static int disableColor = 0x75CCCCCC;
//参考屏幕
public static int LAYOUT_LEFT = -1;
public static int LAYOUT_RIGHT = -2;
public static int LAYOUT_TOP = -3;
public static int LAYOUT_BOTTOM = -4;
//参考上一个元素
public final byte LAYOUT_PRE_LEFT = -10; //左对齐
public final byte LAYOUT_PRE_CENTER = -20; //居中
public final byte LAYOUT_PRE_RIGHT = -30; //右对齐
/******************字体对象**************************/
public Font dfont; // 默认字体
public int charHeight; // 一个字符的默认高度
public int wCharCH; // 一个中文的默认宽度
public int wCharEN; // 一个英文半角字符的默认宽度
/************************样式:填充和空白边************************/
public int marginTop = 2;
public int marginLeft = 1;
public int marginBottom = 1;
public int marginRight = 1;
public int paddingTop = 2;
public int paddingRight = 2;
public int paddingBottom = 2;
public int paddingLeft = 2;
/**
* 和背景色
*/
public int bColorNormal = 0xFFFFFF; //正常显示文字背景色
public int bColorFocus = 0x00FF00; //获得焦点文字背景色
public int bColorEnable = 0xCCCCCC; //获得焦点文字背景色
/**
* 前景色颜色
*/
public int fColorNormal = 0x000000;
public int fColorFocus = 0xFFFFFF;
public int fColorEnable = 0x666666;
/**
* 边框颜色
*/
public int sColorNormal = 0x000000;
public int sColorFocus = 0x339933;
public int sColorEnable = 0x999999;
/****************************圆角设置*********************/
public int roundHeight = 5;
public int rountWidth = 5;
public Image bImageLeftTop = null;
public Image bImageRightTop = null;
public Image bImageLeftBottom = null;
public Image bImageRightBottom = null;
public Image bImageMid = null;
public Image bImageLeftTopFocus = null;
public Image bImageRightTopFocus = null;
public Image bImageLeftBottomFocus = null;
public Image bImageRightBottomFocus = null;
public Image bImageMidFocus = null;
public boolean isImageRepeat = true; //中间图片是否重复
private static Style defaultStyle;
/**
* 新建一个默认样式
*/
public Style(){
setFontSize(Font.SIZE_SMALL);
}
/**
* 创建一个指定字体大小的默认样式
* @param size
*/
public Style(int fontSize){
setFontSize(fontSize);
}
/**
* 获取系统默认样式
* @return
*/
public static Style getDefaultStyle(){
if( defaultStyle == null ){
defaultStyle = new Style();
}
return defaultStyle;
}
/**
* 获取系统默认样式
* @return
*/
public static Style getStyle(String url,String styleName){
if( defaultStyle == null ){
defaultStyle = new Style();
}
return defaultStyle;
}
/**
* 设置字体大小
*/
public void setFontSize(int size){
dfont = Font.getFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN,size);
wCharCH = dfont.stringWidth("中文") /2;
wCharEN = dfont.stringWidth("EN") /2;
charHeight = dfont.getHeight();
}
public void debug(){
String s = " Left:" + paddingLeft +
" Right:" + paddingRight +
" TOP:" + paddingTop +
" BOTTOM:" + paddingBottom;
Logger.info(s);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -