aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-11-20 16:20:13 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-11-20 16:21:50 +0200
commitfb3df32b0e5a92882cf1f45da9577a8ecae4fcba (patch)
treecc93263e02ff62fdc53cb2df6ac4b1c1eb0dc8d6
parentPy Examples updated (diff)
downloadeo_bindings-fb3df32b0e5a92882cf1f45da9577a8ecae4fcba.tar.gz
JS examples added
-rw-r--r--examples/elw_button.js159
-rw-r--r--examples/elw_button_old.js247
-rw-r--r--examples/elw_eoisa.js24
-rw-r--r--examples/elw_mixin.js18
-rw-r--r--examples/elw_signal.js54
5 files changed, 502 insertions, 0 deletions
diff --git a/examples/elw_button.js b/examples/elw_button.js
new file mode 100644
index 0000000..b2eefd3
--- /dev/null
+++ b/examples/elw_button.js
@@ -0,0 +1,159 @@
+//var elm = require('jse');
+var elm = require('jse');
+
+//var m = new elm.Mixin()
+
+function cb_add(par){
+ par.alert(par.text + ": calback_added")
+}
+
+function cb_del(par){
+ par.alert(par.text + ": calback_deleted")
+}
+
+//==============================
+var global_obj
+
+function freeze_this(par){
+ par.alert("Object: " + par.text)
+ par.alert("Freezing cb for this obj")
+ global_obj = par
+ par.event_freeze()
+ par.alert("Freeze count = " + par.event_freeze_get())
+}
+
+function thaw_cb(par){
+ par.alert("Thawing cb for global_obj")
+ global_obj.event_thaw()
+}
+//==================================
+
+function numbers_cb(par){
+ par.alert("numbers_cb")
+ par.no_par()
+
+ par.ints(0, 0)
+ print (" === Testing int ===")
+
+ o = par.ints(1, 2, 3)
+ par.alert("xx: " + o.xx)
+ par.alert("yy: " + o.yy)
+
+ par.par_by_ref(1, 2, 3)
+
+
+ print (" === Testing floats ===")
+ a = 7.32
+ b = -21474.5134
+ o = par.floats(a, b)
+
+ par.alert("bb: " + o.bb)
+ par.alert("cc: " + o.cc)
+}
+
+function cb3(par)
+{
+ par.alert("callback called for: " + par.text)
+ par.alert("getting size")
+
+ o = par.size
+ par.alert("W: " + o.w)
+ par.alert("H: " + o.h)
+
+ o = par.position
+ par.alert("X: " + o.x)
+ par.alert("Y: " + o.y)
+}
+
+
+
+var w = elm.ElwWin({
+ size: { w: 300, h: 350},
+ elements: {
+ shalom_bt: elm.ElwButton({
+ text: "Hello",
+ position : {x: 30, y: 30},
+ size: {w: 210, h: 60},
+ color: {r: 159, g: 245, b: 255, a: 255},
+ eo_ev_callback_add : cb_add,
+ eo_ev_callback_del : cb_del,
+ ev_clicked : cb3
+ }),
+
+ ba: elm.ElwButton({
+ text: "(B) ADD cb",
+ position : {x: 30, y: 100},
+ size: {w: 100, h: 50},
+ color: {r: 255, g: 0, b: 255, a: 255},
+ ev_clicked : cb3
+ }),
+
+ red_bt: elm.ElwBoxedbutton({
+ text: "Red button",
+ position : {x: 140, y: 100},
+ size: {w: 100, h: 50},
+ color: {r: 255, g: 0, b: 5, a: 255},
+ ev_clicked : cb3
+
+ }),
+
+ but1: elm.ElwButton({
+ text: "1st but in box",
+ //position : { x: 250, y: 100},
+ //size: { w: 90, h: 20},
+ color: { r: 255, g: 0, b: 255, a: 255},
+ ev_clicked : thaw_cb
+ }),
+
+ but2: elm.ElwButton({
+ text: "2nd but in box",
+ //position : { x: 270, y: 150},
+ //size: { w: 90, h: 50},
+ color: {r: 240, g: 240, b: 0, a: 255},
+ ev_clicked : freeze_this
+ }),
+
+ box : elm.ElwBox ({
+ position : {x: 140, y: 170},
+ size: {w: 100, h: 50},
+ }),
+
+ pb: elm.ElwButton({
+ text: "But in BB (num)",
+ //position : { x: 310, y: 150},
+ //size: { w: 70, h: 50},
+ color: {r: 240, g: 240, b: 245, a: 255},
+ ev_clicked : numbers_cb
+ }),
+
+ ebb: elm.ElwBoxedbutton({
+ text: "BoxedButton",
+ position : {x: 30, y: 170},
+ size: { w: 100, h: 50},
+ color: { r: 100, g: 85, b: 255, a: 255},
+ //ev_clicked : freeze_all,
+ }),
+ }
+});
+
+
+var e = elm.realise(w);
+
+
+e.elements.box.pack_end(e.elements.but1)
+e.elements.box.pack_end(e.elements.but2)
+e.elements.ebb.pack_end(e.elements.pb)
+
+//e.elements.shalom_bt.eo_ev_callback_add = cb_add
+e.elements.shalom_bt.ev_clicked = cb3
+
+
+
+elm.ElwWin.event_global_freeze()
+elm.ElwWin.event_global_thaw()
+
+
+
+
+
+
diff --git a/examples/elw_button_old.js b/examples/elw_button_old.js
new file mode 100644
index 0000000..f71790a
--- /dev/null
+++ b/examples/elw_button_old.js
@@ -0,0 +1,247 @@
+var elm = require('elm');
+//var m = new elm.Mixin()
+
+function cb_add(par){
+ par.alert(par.text + ": calback_added")
+}
+
+function cb_del(par){
+ par.alert(par.text + ": calback_deleted")
+}
+
+//==============================
+var global_obj
+
+function freeze_this(par){
+ par.alert("Object: " + par.text)
+ par.alert("Freezing cb for this obj")
+ global_obj = par
+ par.event_freeze()
+ par.alert("Freeze count = " + par.event_freeze_get())
+}
+
+function thaw_cb(par){
+ par.alert("Thawing cb for global_obj")
+ global_obj.event_thaw()
+}
+//==================================
+
+function numbers_cb(par){
+ par.alert("numbers_cb")
+ par.no_par()
+
+ par.ints(0, 0)
+ print (" === Testing int ===")
+
+ o = par.ints(1, 2, 3)
+ par.alert("xx: " + o.xx)
+ par.alert("yy: " + o.yy)
+
+ par.par_by_ref(1, 2, 3)
+
+ // par.floats(0.6, 43.345)
+ print (" === Testing floats ===")
+ a = 7.32
+ b = -21474.5134
+ o = par.floats(a, b)
+
+ par.alert("bb: " + o.bb)
+ par.alert("cc: " + o.cc)
+
+
+}
+
+function cb3(par){
+ par.alert("callback called for: " + par.text)
+ par.alert("getting size")
+
+ o = par.size
+ par.alert("W: " + o.w)
+ par.alert("H: " + o.h)
+
+ o = par.position
+ par.alert("X: " + o.x)
+ par.alert("Y: " + o.y)
+}
+
+var w = elm.ElwWin({
+ size: { w: 300, h: 350},
+ elements: {
+ shalom_bt: elm.ElwButton({
+ text: "שלום",
+ position : { x: 30, y: 30},
+ size: { w: 210, h: 60},
+ color: { r: 159, g: 245, b: 255, a: 255},
+ eo_ev_callback_add : cb_add,
+ eo_ev_callback_del : cb_del,
+ ev_clicked : cb3
+ }),
+
+ ba: elm.ElwButton({
+ text: "(B) ADD cb",
+ position : { x: 30, y: 100},
+ size: { w: 100, h: 50},
+ color: { r: 255, g: 0, b: 255, a: 255},
+ ev_clicked : cb3
+ }),
+
+ red_bt: elm.ElwBoxedbutton({
+ text: "Красная кнопка",
+ position : { x: 140, y: 100},
+ size: { w: 100, h: 50},
+ color: { r: 255, g: 0, b: 5, a: 255},
+ //ev_clicked : cb2
+
+ }),
+
+ but1: elm.ElwButton({
+ text: "1st but in box (thaw_cb)",
+ //position : { x: 250, y: 100},
+ //size: { w: 90, h: 20},
+ color: { r: 255, g: 0, b: 255, a: 255},
+ ev_clicked : thaw_cb
+ }),
+
+ but2: elm.ElwButton({
+ text: "2nd but in box (freeze_this)",
+ //position : { x: 270, y: 150},
+ //size: { w: 90, h: 50},
+ color: { r: 240, g: 240, b: 0, a: 255},
+ ev_clicked : freeze_this
+
+ }),
+
+ box : elm.ElwBox ({
+ position : {x: 140, y: 170},
+ size: { w: 50, h: 100},
+
+ }),
+
+ pb: elm.ElwButton({
+ text: "But in BB (num)",
+ // position : { x: 310, y: 150},
+ // size: { w: 70, h: 50},
+ color: { r: 240, g: 240, b: 245, a: 255},
+ ev_clicked : numbers_cb
+
+ }),
+
+ ebb: elm.ElwBoxedbutton({
+ text: "BoxedButton",
+ position : { x: 30, y: 170},
+ size: { w: 100, h: 50},
+ color: { r: 100, g: 85, b: 255, a: 255},
+ //ev_clicked : freeze_all,
+ }),
+
+/*
+ bb2: elm.ElwBoxedbutton({
+ text: "BoxedButton",
+// mixin: "hello, שלום, привет",
+ position : { x: 180, y: 250},
+ size: { w: 100, h: 65},
+ color: { r: 0, g: 255, b: 0, a: 255},
+ ev_clicked : cb2,
+ // on_test : cb1,
+
+/*
+ disabled1: elm.Button({
+ text: "Dis1",
+ x: 10,
+ y: 160,
+ width: 100,
+ height: 15,
+ enabled: true,
+ on_click : ff,
+ }),
+
+ disabled2: elm.Button({
+ text: "Dis2",
+ x: 10,
+ y: 190,
+ width: 100,
+ height: 15,
+ enabled: true,
+ on_click : ff,
+ }),
+*/
+/*
+ bb2: elm.ElwBoxedbutton({
+ text: "BoxedButton",
+// mixin: "hello, שלום, привет",
+ position : { x: 180, y: 250},
+ size: { w: 100, h: 65},
+ color: { r: 0, g: 255, b: 0, a: 255},
+ ev_clicked : cb2,
+ // on_test : cb1,
+
+ elements : {
+ label_only: elm.ElwButton({
+ color: { r: 10, g: 20, b: 30, a: 255},
+ text: "button in the boxedbutton!",
+ size: { w: 80, h: 65},
+ }),
+ },
+ }),
+*/
+
+/*
+ disabled: elm.Button({
+ text: "Don",
+ x: 10,
+ y: 160,
+ width: 100,
+ height: 300,
+ enabled: true
+ }),
+
+ label_only: elm.Button({
+ weight: { x: 1.0, y: 1.0 },
+ style: "anchor",
+ text: "hello!",
+ x: 110,
+ y: 260,
+ width: 80,
+ height: 65
+ }),
+*/
+/*
+ hbox2 : elm.ElwBox ({
+ position : {x: 90, y: 180},
+
+ elements : {
+ label_only2: elm.ElwButton({
+ text: "button in the box! + exit()",
+ // pos : {x: 110, y: 260},
+ color: { r: 0, g: 5, b: 255, a: 255},
+ size: { w: 80, h: 65},
+ on_test: function(par){
+ par.alert("close application")
+ elm.exit()
+ }
+
+ }),
+ },
+ }),
+*/
+
+ }
+});
+
+
+var e = elm.realise(w);
+
+e.elements.box.pack_end(e.elements.but1)
+e.elements.box.pack_end(e.elements.but2)
+e.elements.ebb.pack_end(e.elements.pb)
+
+//e.elements.shalom_bt.eo_ev_callback_add = cb_add
+e.elements.shalom_bt.ev_clicked = cb3
+
+
+
+elm.ElwWin.event_global_freeze()
+elm.ElwWin.event_global_thaw()
+
+
+
diff --git a/examples/elw_eoisa.js b/examples/elw_eoisa.js
new file mode 100644
index 0000000..636f362
--- /dev/null
+++ b/examples/elw_eoisa.js
@@ -0,0 +1,24 @@
+//var elm = require('jstest');
+var elm = require('jseoisa');
+
+var so = new elm.Simple()
+
+so.a = 2
+a = so.a
+a2 = so.a_square
+a3 = so.a_power_3
+print("a = " + a + "; a^2 = " + a2 + "; a^3 = " + a3)
+
+print("*******************************\n")
+
+
+var co = new elm.Complex()
+co.a = 3
+a = co.a
+a2 = co.a_square
+a3 = co.a_power_3
+print("a = " + a + "; a^2 = " + a2 + "; a^3 = " + a3)
+
+elm.exit()
+
+
diff --git a/examples/elw_mixin.js b/examples/elw_mixin.js
new file mode 100644
index 0000000..e505714
--- /dev/null
+++ b/examples/elw_mixin.js
@@ -0,0 +1,18 @@
+var elm = require('jsmixin');
+
+var obj1 = new elm.Simple({a:5, b:5})
+
+obj1.a = 1
+obj1.b = 2
+sum = obj1.ab_sum
+
+print("Sum for obj1: " + sum)
+
+
+var obj2 = elm.Simple({a:3, b:4})
+var e = elm.realise(obj2)
+
+sum = e.ab_sum
+print("Sum for obj1: " + sum)
+
+elm.exit()
diff --git a/examples/elw_signal.js b/examples/elw_signal.js
new file mode 100644
index 0000000..df00242
--- /dev/null
+++ b/examples/elw_signal.js
@@ -0,0 +1,54 @@
+var elm = require('jssimple');
+
+
+function cb_add(par){
+ print("Callback on callback adding")
+}
+
+var poo = function(pa){
+ print("Callback on changing: a = " + pa.a);
+}
+
+
+var ms = new elm.Simple()
+
+print("\nSetting a...")
+ms.a = 12345678
+print("a = " + ms.a + "\n")
+
+print("\nAdding callback...")
+ms.eo_ev_callback_add = cb_add
+ms.ev_a_changed = poo
+
+print("\nSetting b(a) to 896...")
+ms.b = 896
+print("Reading \"b\" (no getter for \"b\" prop): " + ms.b)
+
+
+print("\nSetting c(a) to 123...")
+ms.c = 123
+print("Reading \"c\" (no setter for \"c\" prop, so it should be 896): " + ms.c + "\n")
+
+
+
+print("\nFreezing callback...")
+ms.event_freeze()
+ms.a = 123
+
+print("\nThawing callback...")
+ms.event_thaw()
+ms.a = 123
+
+
+
+/*
+
+var ss = elm.realise(elm.Simple({a:5, on_change:poo, b:55}))
+
+ss.ev_a_changed = cb
+ss.a = 123
+*/
+
+elm.exit()
+
+