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

📄 screenlite.java

📁 类似于Windows上的Excel
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		            // input canceled?		            if(isCancelled)		            	return INPUT_FORM_CANCELLED;		            		            EvaluateException ee;		            try {		            	LispObject code = currentInputForm.buildCode();		            	return code.interpret();		            }		            catch(EvaluateException e) {	                    ee = e;		            }	            	String errmsg = ee.getMessage();	            	debug("Exception in ExecuteAssigment(): "+errmsg);                    ee.printStackTrace();                    Alert aa = new Alert( "Error", errmsg, null, AlertType.ERROR );                    aa.setTimeout( Alert.FOREVER );                    CanvasHandler1.canvasHandler.display.setCurrent( aa,screen );	// will return to 'screen' display,                     									// and the thread will wait on currentInputForm 	            } while(true);			// repeat when EvaluateException has been encountered     	}    	finally {    		currentInputForm = saved;            CanvasHandler1.setDisplay(savedScreen);    	}    }        // gets all assigments starting with given path    // puth must end with '/'    // menupaths must start with '/'    // returns Vector of Strings or Asses, strings for submenu items    static Vector getMenuItems( String path ) {        Vector rez = new Vector(10);        Hashtable hash = new Hashtable(10);        int len = path.length();        for( int i=0; i<menuBindings.size(); i++ ) {            Assigment ass = (Assigment) menuBindings.elementAt(i);            if( ass.menupath.startsWith( path ) ) {                String label = ass.menupath.substring( len );                int nn = label.indexOf( '/' );                if( nn > 0 ) {      // can't be 0 because "//" isn't allowed                     // will have submenu, check if it has been already added                    label = label.substring( 0, nn );                    Object ss = hash.get( label );                    // no check String/Assigment                    if( hash.get( label ) == null ) {                        hash.put( label, label );                        rez.addElement( ass.menupath );                    }                }                // no subitems, Assigment                else {                    hash.put( label, ass );                    rez.addElement( ass );                }            }        }        return rez;    }        // build menu list for given path    // and displayes it    static void setMenu( String path ) {        Vector menulist = getMenuItems( path );        List list = new List( path, Choice.IMPLICIT );        for( int i=0; i<menulist.size(); i++ ) {            Object el = menulist.elementAt( i );            String label = (el instanceof Assigment) ? ((Assigment)el).menupath : (String)el;            int len = path.length();            int nn = label.indexOf( '/', len );            if( nn > 0 )                label = label.substring( len, nn );            else                label = label.substring( len );            list.append( label, null );        }        //        list.addCommand( cmdOK );        list.addCommand( cmdCancel );        list.setCommandListener( SCREENLITE );        currentMenu = list;        currentMenuPath = path;        currentMenuList = menulist;        CanvasHandler1.canvasHandler.display.setCurrent( list );    }        static void startMenu( String path ) {        startPath = path;//        savedDisplayable = CanvasHandler1.canvasHandler.display.getCurrent();        setMenu( path );    }//    private static InputForm createInputForm(FunctorList sexp, int startFrom) {//        int size = sexp.listSize();//        LispObject code = size == startFrom+2 ? sexp.getArgumentN(startFrom+1) : new QuotedList( sexp, startFrom+1, size );//        return new InputForm( sexp.getArgumentN(startFrom), code);//    }//        // functor implementation    public LispObject evaluate(ModuleName modulename,FunctorList sexp) throws EvaluateException {        	LispObject rez = LispObject.NIL;            int size = sexp.listSize();            int optype = modulename.offset;                        // don't forget to evaluate inner s-exp (if need to)!            switch( optype ) {                 // control ops                case NAME_BIND:                {                    /* (bind '(mode gameaction keycode) '(commandlabe type priority) menupath '(goldkeys) code) -> nil */                    /* if code == NIL - removes binding */                     Assigment ass = new Assigment();                    ass.code =  size == 6 ? sexp.getArgumentN(5) : new QuotedList(sexp,5,size);                                        // keypad                    QuotedList ql = sexp.getQuotedList( 1 );                    if( ql != null ) {                        ass.screenmode = ql.getShort( 0 );                        ass.gameaction = ql.getShort( 1 );                        ass.keycode = ql.getShort( 2 );                        if( ass.code == NIL ) {                            Assigment ass1 = findKeyBinding( ass.screenmode, ass.gameaction, ass.keycode );                            keyBindings.removeElement( ass1 );                        }                        else                            keyBindings.addElement( ass );                    }                                        // command                    ql = sexp.getQuotedList( 2 );                    if( ql != null ) {                        String label = ql.getString( 0 );                        int cmdtype = ql.getShort( 1 );                        int priority = ql.getShort( 2 );                        if( ass.code == NIL ) {                            Assigment ass1 = findCommandBinding( label );                            if(ass1!=null) {                                commandBindings.removeElement( ass1 );                                CanvasHandler1.canvasHandler.canvas.removeCommand( ass1.command );                            }                        }                        else {                            ass.command = new Command( label, cmdtype, priority );                            commandBindings.addElement( ass );                            CanvasHandler1.canvasHandler.canvas.addCommand( ass.command );                        }                    }                                        // menupath                    String menupath = sexp.getString3();                    if( menupath != null ) {                        ass.menupath = menupath;                        if( ass.code == NIL ) {                            Assigment ass1 = findCommandBinding( menupath );                            menuBindings.removeElement( ass1 );                        }                        else {                            menuBindings.addElement( ass );                        }                    }                                        // gold keys                    ql = sexp.getQuotedList( 4 );                    if( ql != null ) {                        ass.goldkeys = ql;                        goldBindings.addElement( ass );                    }                                        break;                }                case NAME_BIND_TO_KEY:                {                    /* (bind-to-key mode:short gameaction:short keycode:short formtitle:string code ...) */                    Assigment ass = new Assigment();                    ass.screenmode = sexp.getShort1();                    ass.gameaction = sexp.getShort2( );                    ass.keycode = sexp.getShort3();                    ass.code =  size == 5 ? sexp.getArgumentN(4) : new QuotedList(sexp,4,size);                    keyBindings.addElement( ass );                    break;                }                case NAME_BIND_TO_COMMAND:                {                    Assigment ass = new Assigment();                    String label = sexp.getString1();                    int cmdtype = sexp.getShort2();                    int priority = sexp.getShort3();                    ass.code =  size == 5 ? sexp.getArgumentN(4) : new QuotedList(sexp,4,size);                    ass.command = new Command( label, cmdtype, priority );                    commandBindings.addElement( ass );                    // add command to canvas                    CanvasHandler1.canvasHandler.canvas.addCommand( ass.command );                    break;                }                case NAME_BIND_TO_MENU:                {                    Assigment ass = new Assigment();                    // TODO: checks for NIL                    ass.menupath = sexp.getString1();                    ass.code =  size == 3 ? sexp.getArgumentN(2) : new QuotedList(sexp,2,size);                    menuBindings.addElement( ass );                    break;                }                case NAME_BIND_TO_GOLD:                {                    Assigment ass = new Assigment();                    ass.goldkeys = (QuotedList)sexp.evaluateArg1();                    ass.code =  size == 3 ? sexp.getArgumentN(2) : new QuotedList(sexp,2,size);                    goldBindings.addElement( ass );                    break;                }                case NAME_PROMPT:                {                    throw new EvaluateException("(prompt) should never occur when evaluating", sexp);                }                case NAME_APP_EXIT:                {                    LispTask.LispMachine.stop = true;                    CanvasHandler1.canvasHandler.midlet.notifyDestroyed();                    break;                }                case NAME_APP_DEBUG:                {                    System.out.print( sexp.toString() + " : " );                    for( int i=1; i<size; i++ ) {                        System.out.print( (rez=sexp.evaluateArgN(i)) );                        System.out.print( ' ' );                    }                    System.out.print( "\n" );                    break;                }                case NAME_MENU_START:                {                    /** (menu-start path:string) -> nil */                    startMenu( sexp.getString1() );                    break;                }                case NAME_INPUT_FORM:                {                    /** (input-form formtitle:string sexp:code ...) -> any */                    /* Evaluates sexp and returns result, if exception sets focus to currentForm.                      * Blocks caller's thread until user finishes input                     */                	LispObject code;                	if(size==3)                		code = sexp.getArgument2();                	else                		code = new QuotedList(sexp,2,size);                	InputForm inputForm = new InputForm(sexp.getArgument1(),code);                	return executeAssigment(inputForm);                }                case NAME_MENU_INPUT_FORM:                {                    /** (menu-input-form input-form:code) -> any */                    /*                     * If OK returns not to previous Displayable (menu) but Canvas instead                     */                	rez = sexp.interpretArg1();                	if(rez != INPUT_FORM_CANCELLED)                		CanvasHandler1.setCanvas();		// go to canvas screen, otherwise stay in menu (after cancel)                	break;                }//#ifdef POINTER                case NAME_COORD_TRANSLATE:                {                    /** (coord-translate axis:short coord:short) -> cell */                    /*                     * translate screen coordinates into cell address                     */                    int axis = sexp.getShort(1);                    int screen = sexp.getShort(2);                    return new ShortAtom(CanvasHandler1.canvasHandler.findCellByCoord(axis,screen));                }                case NAME_POINTER_PRESSED:                    break;//                {//                    /** (pointer-pressed x y) -> nil *///                    /*//                     * default handler for pointer press//                     *///                    int x = sexp.getShort(1);//                    int y = sexp.getShort(2);//                    CanvasHandler1 handler = CanvasHandler1.canvasHandler;//                    Sheet sheet = handler.sheet;//                    int cellx = handler.findCellByCoord(Sheet.AXIS_X,x);//                    int celly = handler.findCellByCoord(Sheet.AXIS_Y,y);//                    debug("cellx="+cellx+" celly="+celly);//                    if(!(handler.cursorx==cellx && handler.cursory==celly)) {//                        int oldcellx = handler.cursorx;//                        int oldcelly = handler.cursory;//                        int paintx = handler.setCursorX( cellx );//                        int painty = handler.setCursorY( celly );//                        if( paintx == 2 || painty == 2)//                            handler.repaint();//                        else if( paintx == 1 || painty == 1) {//                            handler.repaintCell( oldcelly, oldcellx );//                            handler.repaintCell( celly, cellx );//                        }//                    }//                    break;//                }//#endif                            }                    return rez;    }//#endif /* NOGUI */     //#ifdef JAVA_COMPILER         protected String getModuleClassName() {        return "ScreenLite";    }//#endif}

⌨️ 快捷键说明

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