# HG changeset patch # User Thinker K.F. Li # Date 1283184371 -28800 # Node ID 37a1bd3e3ce1ab35bd15c0c1fd30c00dd6d9e043 # Parent a47431293043f3611700fa75d6c6106e3575bd34 mbapp accept arguments for display, width and height diff -r a47431293043 -r 37a1bd3e3ce1 nodejs/mbapp.js --- a/nodejs/mbapp.js Mon Aug 30 23:52:59 2010 +0800 +++ b/nodejs/mbapp.js Tue Aug 31 00:06:11 2010 +0800 @@ -1,16 +1,26 @@ var mbfly = require("mbfly"); var svg = require("./svg"); var sys = require("sys"); -var mb_rt = new mbfly.mb_rt(":0.0", 720,480); var ldr = mbfly.img_ldr_new("."); -var background = mb_rt.rect_new(0, 0, 720, 480, 0, 0); -var paint = mb_rt.paint_color_new(1, 1, 1, 1); -paint.fill(background); -mb_rt.root.add_shape(background); + + +app=function(display, w, h) { + var self = this; + var mb_rt; -app=function() { - var self = this; - this.mb_rt = mb_rt; + if(typeof display == "undefined") + display = ":0.0"; + if(typeof w == "undefined") + w = 720; + if(typeof h == "undefined") + h = 480; + + mb_rt = this.mb_rt = new mbfly.mb_rt(display, w, h); + var background = mb_rt.rect_new(0, 0, 720, 480, 0, 0); + var paint = mb_rt.paint_color_new(1, 1, 1, 1); + paint.fill(background); + mb_rt.root.add_shape(background); + this.mb_rt.kbevents.add_event_observer(exports.EVT_KB_PRESS, function(evt) { self.KeyPress(evt);}); this.keymap={}; this.onKeyPress = null; diff -r a47431293043 -r 37a1bd3e3ce1 nodejs/svg.js --- a/nodejs/svg.js Mon Aug 30 23:52:59 2010 +0800 +++ b/nodejs/svg.js Tue Aug 31 00:06:11 2010 +0800 @@ -16,6 +16,7 @@ return new loadSVG(mb_rt, root, filename); }; + function loadSVG(mb_rt, root, filename) { var doc = libxml.parseXmlFile(filename); var nodes = doc.root().childNodes();