comparison nodejs/mbapp.js @ 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 6133319d3fb4
children 7875e8026e86
comparison
equal deleted inserted replaced
783:a47431293043 784:37a1bd3e3ce1
1 var mbfly = require("mbfly"); 1 var mbfly = require("mbfly");
2 var svg = require("./svg"); 2 var svg = require("./svg");
3 var sys = require("sys"); 3 var sys = require("sys");
4 var mb_rt = new mbfly.mb_rt(":0.0", 720,480);
5 var ldr = mbfly.img_ldr_new("."); 4 var ldr = mbfly.img_ldr_new(".");
6 var background = mb_rt.rect_new(0, 0, 720, 480, 0, 0);
7 var paint = mb_rt.paint_color_new(1, 1, 1, 1);
8 paint.fill(background);
9 mb_rt.root.add_shape(background);
10 5
11 app=function() { 6
7 app=function(display, w, h) {
12 var self = this; 8 var self = this;
13 this.mb_rt = mb_rt; 9 var mb_rt;
10
11 if(typeof display == "undefined")
12 display = ":0.0";
13 if(typeof w == "undefined")
14 w = 720;
15 if(typeof h == "undefined")
16 h = 480;
17
18 mb_rt = this.mb_rt = new mbfly.mb_rt(display, w, h);
19 var background = mb_rt.rect_new(0, 0, 720, 480, 0, 0);
20 var paint = mb_rt.paint_color_new(1, 1, 1, 1);
21 paint.fill(background);
22 mb_rt.root.add_shape(background);
23
14 this.mb_rt.kbevents.add_event_observer(exports.EVT_KB_PRESS, function(evt) { self.KeyPress(evt);}); 24 this.mb_rt.kbevents.add_event_observer(exports.EVT_KB_PRESS, function(evt) { self.KeyPress(evt);});
15 this.keymap={}; 25 this.keymap={};
16 this.onKeyPress = null; 26 this.onKeyPress = null;
17 } 27 }
18 app.prototype.loadSVG=function(fname) { 28 app.prototype.loadSVG=function(fname) {