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

📄 displayablecmd.java

📁 Hecl编程语言是一个高层次的脚本语言的Java实现。其用意是要小
💻 JAVA
字号:
/* * Copyright 2005-2007 * Wolfgang S. Kechel, data2c GmbH (www.data2c.com) *  * Author: Wolfgang S. Kechel - wolfgang.kechel@data2c.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *  * http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.hecl.midp20.lcdui;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Displayable;//#ifdef polish.usePolishGui import javax.microedition.lcdui.Canvas;import javax.microedition.lcdui.Screen;import javax.microedition.lcdui.Ticker;//#endifimport org.hecl.HeclException;import org.hecl.Interp;import org.hecl.IntThing;import org.hecl.ObjectThing;import org.hecl.Properties;import org.hecl.Thing;import org.hecl.midp20.MidletCmd;public abstract class DisplayableCmd extends OptionCmd {    protected DisplayableCmd() {}        public Thing cget(Interp ip,Object target,String optname)	throws HeclException {	Displayable d = (Displayable)target;		if(optname.equals(WidgetInfo.NTICKER)) {//#ifdef polish.usePolishGui 	    if(d instanceof Screen) {		Screen s = (Screen)d;		Ticker t = s.getTicker();		return ObjectThing.create(t);//#ifdef notdef	    } else if(d instanceof Canvas) {		Canvas c = (Canvas)d;		Ticker t = c.getTicker();		return ObjectThing.create(t);//#endif	    } else {		return ObjectThing.create(null);	    }	    //#else	    return ObjectThing.create(d.getTicker());//#endif	}	if(optname.equals(WidgetInfo.NTITLE)) {	    optname = d.getTitle();	    return new Thing(optname != null ? optname : "");	}	if(optname.equals(WidgetInfo.NWIDTH))	    return IntThing.create(d.getWidth());	if(optname.equals(WidgetInfo.NHEIGHT))	    return IntThing.create(d.getHeight());	if(optname.equals(WidgetInfo.NCOMMANDACTION)) {	    throw new HeclException("option '"				    +WidgetInfo.NCOMMANDACTION+"' is write only");	}	if(optname.equals("-isshown"))	    return new Thing(d.isShown() ? IntThing.ONE : IntThing.ZERO);	return super.cget(ip,target,optname);    }        public void cset(Interp ip,Object target,String optname,Thing optval)	throws HeclException {	Displayable d = (Displayable)target;	if(optname.equals(WidgetInfo.NTICKER)) {//#ifdef polish.usePolishGui 	    Ticker t = WidgetInfo.asTicker(optval,true,true);	    if(d instanceof Screen) {		Screen s = (Screen)d;		s.setTicker(t);//#ifdef notdef	    } else if(d instanceof Canvas) {		Canvas c = (Canvas)d;		c.setTicker(t);	    } else {		d.setTicker(t);//#endif	    }//#else	    d.setTicker(WidgetInfo.asTicker(optval,true,true));//#endif	    return;	}	if(optname.equals(WidgetInfo.NTITLE)) {	    d.setTitle(optval.toString());	    return;	}	if(optname.equals(WidgetInfo.NCOMMANDACTION)) {	    CommandListener listener = null;	    if(optval.toString().length() > 0) {		listener = new WidgetListener(ip,optval);	    }	    d.setCommandListener(listener);	    return;	}	super.cset(ip,target,optname,optval);    }        public Thing handlecmd(Interp ip,Object target,String subcmd, Thing[] argv,int startat)	throws HeclException {	Displayable d = (Displayable)target;	if(subcmd.equals(WidgetInfo.NADDCOMMAND)) {	    int n = startat+1;	    if(argv.length != n) {		throw HeclException.createWrongNumArgsException(		    argv, n, "command");	    }	    d.addCommand(WidgetInfo.asCommand(argv[2],false,true));	    return null;	}	if(subcmd.equals(WidgetInfo.NREMOVECOMMAND)) {	    int n = startat+1;	    if(argv.length != n) {		throw HeclException.createWrongNumArgsException(		    argv, n, "command");	    }	    d.removeCommand(WidgetInfo.asCommand(argv[2],false,true));	    return null;	}	if(subcmd.equals(WidgetInfo.NSETCURRENT)) {	    /*	     * There is a problem with the WTK2.5.2 emulator:	     * When switching from a fullscreen canvas to something else, the	     * fullscreen mode of the canvas gets lost. We extract the old	     * status and set it properly on display switch.	     */	    Display displ = MidletCmd.getDisplay();	    Displayable oldd = displ.getCurrent();	    if(oldd != null && oldd instanceof HeclCanvas) {		boolean flag = ((HeclCanvas)oldd).getFullScreenMode();		displ.setCurrent(d);		((HeclCanvas)oldd).setFullScreenMode(flag);	    } else {		displ.setCurrent(d);	    }	    return null;	}	return super.handlecmd(ip,target,subcmd,argv,startat);    }    private static final char COMMANDACTIONEXPANDCHARS[] = {'W','D'};}// Variables:// mode:java// coding:utf-8// End:

⌨️ 快捷键说明

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