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

📄 bfunc.java

📁 类似于Windows上的Excel
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    /* (sheet-setwidthheight sheet axis:ShortAtom index:ShortAtom widthheight:ShortAtom ) -> nil */
                    Sheet sheet1 = sexp.getSheet1();
                    int axis = sexp.getShort2();
                    RowColumn rw = new RowColumn( sexp.getShort3(), sexp.getShort( 4 ) );
                    if( axis == Sheet.AXIS_X)
                    	sheet1.columns.put( rw, rw );
                    else
                    	sheet1.rows.put( rw, rw ); 
                    break;
                }
//#ifndef NOGUI    
                case NAME_SHEET_REPAINT:
                    /* (sheet-repaint) -> nil */
                    canvasHandler.repaint();
                    break;
                case NAME_SELECTION_GET:
                {
                    /* (selection-get bound axis) -> ShortAtom */
                    int bound = sexp.getShort1();
                    int axis = sexp.getShort2();
                    return new ShortAtom( 
                        bound == 0 ? 
                        (axis==0?canvasHandler.selectionx1:canvasHandler.selectiony1) : 
                        (axis==0?canvasHandler.selectionx2:canvasHandler.selectiony2) );
                }
                case NAME_SELECTION_SET:
                {
                    /* (selection-set bound axis index) -> nil */
                    int bound = sexp.getShort1();
                    int axis = sexp.getShort2();
                    int index = sexp.getShort3();
                    if( bound == 0 ) {
                        if( axis == 0 )
                            canvasHandler.selectionx1 = index;
                        else
                            canvasHandler.selectiony1 = index;
                    }
                    else {
                        if( axis == 0 )
                            canvasHandler.selectionx2 = index;
                        else
                            canvasHandler.selectiony2 = index;
                    }
                    break;
                }
//#ifndef MINIMAL_SET                
                case NAME_GOLD_KEY:
                    /* (gold-key keycode:ShortAtom) -> nil */
                    canvasHandler.goldkey = sexp.getShort1();
                    break;
//#endif                    
//#endif                    
                case NAME_CELL_CLEAR:
                {
                    /* (cell-clear [sheet] cell) -> nil */
                    Sheet sh = sheet;
                    int nn = 1;
                    if( size >= 3 ) {
                        sh = (Sheet)sexp.evaluateArgN(nn++);
                    }
                    Cell cl = (Cell) sexp.evaluateArgN(nn);
                    sh.clearCell( cl.i, cl.j );
                    break;
                }
                case NAME_REFERENCE_PROCESS:
                {
                    /* (reference-process [sheet] reference func) -> nil */
                    /* will call (func cell) */
                    int nn = 1;
                    Sheet sh = sheet;
                    if( size >= 4 )
                        sh = (Sheet) sexp.evaluateArgN(nn++);
                    Reference ref = (Reference) sexp.evaluateArgN(nn++);
                    NameObjectBase functor = (NameObjectBase)sexp.getArgumentN(nn++);
                    LispObject rez = NIL;
                    for( int i=ref.i1; i<=ref.i2; i++ )
                        for( int j=ref.j1; j<=ref.j2; j++ ) {
                            rez = new FunctorList1(functor,sh.getCell( i, j )).evaluateSExp();
                        }
                    return rez;
                }
//#ifndef NOGUI    
                case NAME_SELECTION:
                    /* (selection) -> reference */
                    return new Reference( canvasHandler.selectiony1, canvasHandler.selectionx1, canvasHandler.selectiony2, canvasHandler.selectionx2 ); // w/o normalization
                case NAME_SETSHEETSIZE:
	        {
                    /* (setsheetsize axis maxrowclumns) -> nil */
                	int newsize = sexp.getShort2();
                	if( sexp.getShort1() == Sheet.AXIS_X )
                		sheet.visibleX = newsize; 
                	else
                		sheet.visibleY = newsize; 
                    break;
		}
//#endif    
                case NAME_SHEET_INSERT:
                {
                    /* (sheet-insert sheet axis index [size]) -> nil */
                    int nn = 1;
                    Sheet sh = sheet;
                    if( size > 4 )
                        sh = (Sheet)sexp.evaluateArgN(nn++);
                    int axis = sexp.getShort( nn++ );
                    int index = sexp.getShort( nn++ );
                    int nrows = sexp.getShort( nn++ );
                    if( axis == 1 ) {
                        sheet.insertCells( index, 0, nrows, 0 );
                    }
                    else {
                        sheet.insertCells( 0, index, 0, nrows );
                    }
                    break;
                }
                case NAME_CELL_GETWSVALUE:
                {
                    /* (cell-getwsvalue cell) -> string */
                    Cell cell = sexp.getCell1();
                    return new StringAtom( cell.getText() );
                }
//#ifndef NOGUI    
                case NAME_STR_GETWIDTH:
                {
                    /* (str-getwidth string) -> short */
                    String ss = ((StringAtomBase) sexp.evaluateArg1()).getValue();
                    int sswidth = canvasHandler.font.stringWidth(ss);
                    return new ShortAtom( (sswidth*Sheet.fontDivider+canvasHandler.fontWidth-1)/canvasHandler.fontWidth );
                }
//#endif                
                case NAME_CELL_COPY:
                {
                    /* (cell-copy cell i j) -> nil */
                    Cell cell = sexp.getCell1();
                    int di = sexp.getShort2();
                    int dj = sexp.getShort3();
                    sheet.copyCell1( cell.i, cell.j, di, dj );
                    break;
                }
                case NAME_CELL_COPYFROM:
                {
                     /* (cell-copyfrom cell i j) -> nil */
                     Cell cell = sexp.getCell1();
                     int si = sexp.getShort2();
                     int sj = sexp.getShort3();
                     sheet.copyCell1( si, sj, cell.i-si, cell.j-sj );
                     break;
                }
                case NAME_CELL_GETTYPE:
                {
                    /* (cell-gettype cell) -> short */
                    Cell cell = sexp.getCell1();
                    return new ShortAtom( cell.value.typeNumber() );
                }
                case NAME_ERROR:
                    /* (error number:short) -> error */
                    return fromList( sexp );
//#ifndef MINIMAL_SET                
                case NAME_SYSTEM_INFO:
                {
                    /* (system-info) -> '(freeMem:long totalMem:long platform:string) */
//#ifdef MIDP                    
                    Runtime rt = Runtime.getRuntime();
                    rt.gc();
//#ifndef NO_PROPERTY                    
                    String platform = System.getProperty("microedition.platform");
//#else                    
//#                    String platform = "#applet#";
//#endif                    
                    if(platform==null)
                    	platform = "null";
                    return new QuotedList(
                        new LispObject[] {
                            new LongAtom( rt.freeMemory() ),
                            new LongAtom( rt.totalMemory() ),
                            new StringAtom( platform ),
                            // FIXME count names from all installed modules
                            new ShortAtom( namesCount )
                        }
                    );
//#endif                    
                }
//#ifndef NOGUI    
                case NAME_DEBUG_SET:
                    /* (set-debug level:short) -> nil */
                    CanvasHandler1.debugLevel = sexp.getShort1();
                    break;
//#endif                
//#endif /* MIDP */                
//#ifndef NOGUI    
                case NAME_SCREEN_SETMODE:
                    /* (screen-setmode mode:short) -> nil */
                    canvasHandler.setScreenMode( sexp.getShort1() );
                    break;
                case NAME_SCREEN_SETFORMULABAR:
                    /* (screen-setformulabar string:string) -> nil */
                    canvasHandler.formula = sexp.getString1();
                case NAME_FORMULABAR_REPAINT:
                    /* (formulabar-repaint) -> nil */
                    canvasHandler.repaintFormulaBar();
                    break;
                case NAME_SCREEN_GETFORMULABAR:
                    /* (screen-getformulabar) ->  string */
                    return new StringAtom( canvasHandler.formula );
                case NAME_SCREEN_GETMODE:
                    /* (screen-getmode) -> short (1/2/4/8 - NORMAL/GOLD/NUMERIC/FORMULA)*/
                    return new ShortAtom( canvasHandler.screenmode );
//#endif    
                case NAME_PARSE_WS:
                    /* (parse-ws formula:string) -> obj */
                    try {
                        return Operator.OPERATOR.parseFormula( sexp.getString1() );
                    }
                    catch( FormulaParseException ee ) {
                        throw new EvaluateException( ee.getMessage(), sexp );
                    }
//#ifndef NOGUI    
                case NAME_SCREEN_SETFONT:
                    /* (screen-setfont face:short style:short size:short ) -> nil */
                    // MIDP: Font.getFont()
                    // face: FACE_SYSTEM, FACE_MONOSPACE, or FACE_PROPORTIONAL (0/32/64)
                    // style: STYLE_PLAIN, or a combination of STYLE_BOLD, STYLE_ITALIC, and STYLE_UNDERLINED (0/1/2/4)
                    // size: SIZE_SMALL, SIZE_MEDIUM, or SIZE_LARGE (8/0/16)
                    canvasHandler.font = Font.getFont( 
                        sexp.getShort1(),
                        sexp.getShort2(),
                        sexp.getShort3()
                    );
                    canvasHandler.fontSize[0] = canvasHandler.fontWidth = canvasHandler.font.charWidth( '#' );
                    canvasHandler.fontSize[1] = canvasHandler.fontHeight = canvasHandler.font.getHeight();
                    canvasHandler.headerWidth = canvasHandler.fontWidth * 2;
                    canvasHandler.headerHeight = canvasHandler.fontHeight;
                    break;
//#endif                    
                case NAME_SHEET_SETDEFAULTSIZE:
                {
                    /* (screen-setdefaultsize sheet axis:short valuepts:short ) -> nil */
                    Sheet sheet1 = (Sheet)sexp.evaluateArg1();
                    sheet1.defaultWidthHeight[ sexp.getShort2() ] = sexp.getShort3();
                    break;
                }
//#ifndef MINIMAL_SET                
                case NAME_COLOR_RGB:
                    /** (color-rgb R:long G:long B:long ) */
                    return new LongAtom(sexp.getShort1()*256*256+sexp.getShort2()*256+sexp.getShort3());
//#ifndef NOGUI    
                case NAME_COLORS_SET:
                {
                    QuotedList colors = sexp.getQuotedList(1);
                    canvasHandler.headerFontColor = colors.getInt(0);
                    canvasHandler.headerBackColor = colors.getInt(1);
                    canvasHandler.cellFontColor = colors.getInt(2);
                    canvasHandler.cellBackColor = colors.getInt(3);
                    canvasHandler.gridColor = colors.getInt(4);
                    canvasHandler.gridSelectedColor = colors.getInt(5);
                    canvasHandler.selectionFontColor = colors.getInt(6);
                    canvasHandler.selectionBackColor = colors.getInt(7);
                    break;
                }
//#endif                
//#endif                
                case NAME_QLIST:
                {
                    /** (qlist arg1 ... argN) -> '(arg1 ... argN) */
                    return new QuotedList(sexp,1,size);
                }
//#ifndef MINIMAL_SET                
//#ifndef NOGUI    
                case NAME_APP_GETPROPERTY:
                {
                    /** (getproperty appproperty:string) -> string */
                    return new StringAtom( canvasHandler.getAppProperty(sexp.getString1()) );
                }
//#endif                
//#endif                
//#ifdef HISTORY                    
//#ifndef NOGUI    
                case NAME_HISTORY_GET:
                {
                    /* (history-get ) -> qoutedList */
                    /* (history-get any) -> sheet */
                    if(size==1) {
                        int len = CanvasHandler1.history.size();
                        LispObject list[] = new LispObject[len];
                        for( int i=0; i<len; i++ )
                            list[i] = new StringAtom( (String)CanvasHandler1.history.elementAt( i ) );
                        return new QuotedList( list );
                    }
                    else {
                        Sheet sh = new Sheet();
                        int len = CanvasHandler1.history.size();
                        if(len > sh.visibleY)
                            len = sh.visibleY;
                                                                 
                        sh.name = "log history";
                        for( int i=0; i<len; i++ ) {
                            Cell cell = new Cell(i,0,new StringAtom( (String)CanvasHandler1.history.elementAt( CanvasHandler1.history.size()-i-1 ) ),0);
                            sh.putCell(cell);
                        }
                        return sh;
                    }
                }
//#endif                
//#endif
            }
            return NIL;

    }

//#ifdef JAVA_COMPILER     
    protected String getModuleClassName() {
        return "Bfunc";
    }
//#endif

}

⌨️ 快捷键说明

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