changeset 872:bcc63b20d5c6

mbapp.js support to create an application with existed window
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 24 Sep 2010 16:00:04 +0800
parents 67d0fed24120
children 881efcd8a18f 23dffb564ace 4c7f0ec97ad9
files nodejs/mbapp.js
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/mbapp.js	Fri Sep 24 14:09:02 2010 +0800
+++ b/nodejs/mbapp.js	Fri Sep 24 16:00:04 2010 +0800
@@ -69,7 +69,32 @@
 	}
 }
 
+var app_with_win = function(display, win) {
+    var self = this;
+    var mb_rt;
+    var background;
+    var paint;
+
+    if(typeof display == "undefined" || typeof win == "undefined")
+	throw "Invalid argument";
+    
+    mb_rt = this.mb_rt = new mbfly.mb_rt_with_win(display, win);
+    background = mb_rt.rect_new(0, 0, 720, 480, 0, 0);
+    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;
+}
+
+app_with_win.prototype = app.prototype;
+
 exports.app=app;
+exports.app_with_win = app_with_win;
 
 // Put all key definition here
 exports.KEY_LEFT = 0xff51;