⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textdialog.java

📁 手机电子书阅读软件基本框架
💻 JAVA
字号:
/********************************************************************
 * 
 * 版权说明,此程序仅供学习参考。不能用于商业
 * 
 ********************************************************************/
package org.pook.ui.form;

 
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;

import org.pook.log.Log;
import org.pook.ui.core.Platform;
import org.pook.ui.util.FontUtil;

/**
 * <b>类名:TextDialog.java</b> </br> 编写日期: 2006-9-16 <br/> 程序功能描述�? <br/> Demo:
 * <br/> Bug: <br/>
 * 
 * 程序变更日期 �?<br/> 变更作�?? �?<br/> 变更说明 �?<br/>
 * 
 * @author wuhua </br> <a href="mailto:rrq12345@163.com">rrq12345@163.com</a>
 */
public class TextDialog extends Dialog {
	private static Log log = Log.getLog("TextDialog");
 
	 
	 
	public TextDialog(String _title, Panel _parent, Display _display, long _timeOut) {
		super(_title, _parent, _display, Dialog.DIALOG_TEXT, _timeOut);
		this.title = _title;
		 
		initView();
		
	}

 
	protected void paint(Graphics g) {
		this.initView(); //这个把我给害死了
		 parent.paint(g);
		
		 this.paintTextDialogImpl(g);
	}

	public void setDialogTitle(String title){
		this.title = title;
	}
 
	/**
	 * 弹出个窗�?
	 * 
	 */
	public void paintTextDialogImpl(Graphics g) {
		drawRGB(g);
		paintDialog(g);
		softButton.paint(g);
	}
	 
	
	/**
	 * 因为这段代码用在sizeChange�?
	 * �?以nokia初始化一个类的时候也会初始调用这个方�?,而且是在类初始化前调用的.
	 * �?有会抛出NullPointException.
	 * 我找了大半天才发现这个问�?.好累.现在�?12点了.还没冲凉
	 *
	 */
	protected void initView() {
		if(title == null)
			return; 
		int titleWidth = FontUtil.getWidth(font, title);
		int width = Platform.WIDTH - 40;
		int height = FontUtil.siptRow(font, width, title) * font.getHeight();
 
	 
		view[X] = titleWidth < width ? (Platform.WIDTH/2  - titleWidth / 2 - 10) : 10;

		view[Y] = (Platform.HEIGHT/2 - height - 6);

		view[WIDTH] = titleWidth < width ? (titleWidth + 20) : width + 20;

		view[HEIGHT] = height + 12;

		rowTitle = FontUtil.splitOnlyStringToRowString(font, title, width - 6);

	}

	private void paintDialog(Graphics g) {
		fillDialog(g);
		paintDailogTitle(g);

	}

	private void paintDailogTitle(Graphics g) {
		g.setColor(fontColor);
		 
		for (int i = 0; i < rowTitle.length; i++) {
			g.drawString(rowTitle[i], view[X] + 10, view[Y] + 6
					+ font.getHeight() * i, Graphics.TOP | Graphics.LEFT);
		}

	}

	private void fillDialog(Graphics g) {
		g.setColor(0xFFFFFF);
		g.drawRect(view[X], view[Y], view[WIDTH], view[HEIGHT]);
		g.setColor(bgColor);
		g.fillRect(view[X] + 1, view[Y] + 1, view[WIDTH] - 1, view[HEIGHT] - 1);

	}
	
	/**
	 * 这段代码在nokia中有很大的问题啊.记住.
	 * 因为父类有setTitle()�?
	
	
	public void setTitle(String title){
		this.title = title;
		this.initView();
	} */

	 

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -