Mercurial > MadButterfly
changeset 784:37a1bd3e3ce1
mbapp accept arguments for display, width and height
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 31 Aug 2010 00:06:11 +0800 |
parents | a47431293043 |
children | b6d9c42019d1 |
files | nodejs/mbapp.js nodejs/svg.js |
diffstat | 2 files changed, 19 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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;