annotate nodejs/mbapp.js @ 724:503f3d18248e

Add symbolic name of event types.
author wycc
date Mon, 16 Aug 2010 07:32:56 +0800
parents 01d02382dea7
children 299ed9319dc6
rev   line source
716
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
1 var mbfly = require("mbfly");
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
2 var svg = require("./svg");
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
3 var mb_rt = new mbfly.mb_rt(":0.0", 720,480);
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
4 var ldr = mbfly.img_ldr_new(".");
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
5 var background = mb_rt.rect_new(0, 0, 720, 480, 0, 0);
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
6 var paint = mb_rt.paint_color_new(1, 1, 1, 1);
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
7 paint.fill(background);
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
8 mb_rt.root.add_shape(background);
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
9
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
10 app=function() {
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
11 this.mb_rt = mb_rt;
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
12 }
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
13 app.prototype.loadSVG=function(fname) {
721
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
14 svg.loadSVG(this.mb_rt,this.mb_rt.root,fname);
716
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
15 }
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
16
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
17 app.prototype.loop=function() {
721
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
18 this.mb_rt.redraw_all();
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
19 this.mb_rt.flush();
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
20 }
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
21 app.prototype.get=function(name) {
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
22 return this.mb_rt.mbnames[name];
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
23 }
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
24 app.prototype.addKeyboardListener=function(type,f) {
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
25 return this.mb_rt.kbevents.add_event_observer(type,f);
716
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
26 }
724
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
27 app.prototype.refresh=function() {
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
28 this.mb_rt.redraw_all();
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
29 this.mb_rt.flush();
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
30 }
716
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
31
72abb4154936 Add mbapp module
wycc
parents:
diff changeset
32 exports.app=app;
721
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
33
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
34 // Put all key definition here
724
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
35 exports.KEY_UP = 111;
721
01d02382dea7 Refactory the mbapp and testsvg to use keyboard events
wycc
parents: 716
diff changeset
36 exports.KEY_DOWN=116;
724
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
37 exports.EVT_ANY=0;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
38 exports.EVT_MOUSE_OVER=1;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
39 exports.EVT_MOUSE_OUT=2;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
40 exports.EVT_MOUSE_MOVE=3;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
41 exports.EVT_MOUSE_BUT_PRESS4;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
42 exports.EVT_MOUSE_BUT_RELEASE=5
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
43 exports.EVT_KB_PRESS=6;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
44 exports.EVT_KB_RELEASE=7;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
45 exports.EVT_PROGM_COMPLETE=8;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
46 exports.EVT_RDMAN_REDRAW=9;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
47 exports.EVT_MONITOR_ADD=10;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
48 exports.EVT_MONITOR_REMOVE=11;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
49 exports.EVT_MONITOR_FREE=12;
503f3d18248e Add symbolic name of event types.
wycc
parents: 721
diff changeset
50 exports.EVT_MOUSE_MOVE_RAW=13;