summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-12-04 18:38:48 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-12-04 18:38:48 +0200
commit06d5eccf1da69db1a0a537054e3d4ebbce26ce72 (patch)
treeb346844b9e66a87c5c4a92154ae9f69e72b1ebea
parent7f5dececd242d13a1d7ade7903799e4d3835d6cb (diff)
Elm JS example added
Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--examples/elm_elm.js200
1 files changed, 200 insertions, 0 deletions
diff --git a/examples/elm_elm.js b/examples/elm_elm.js
new file mode 100644
index 0000000..fb10fb0
--- /dev/null
+++ b/examples/elm_elm.js
@@ -0,0 +1,200 @@
1//var elm = require('jse');
2var elm = require('jsevaselm');
3
4//var m = new elm.Mixin()
5
6function cb_add(par){
7 print(par.text + ": calback_added")
8}
9
10function cb_del(par){
11 print(par.text + ": calback_deleted")
12}
13
14//==============================
15var global_obj
16
17function freeze_this(par){
18 par.alert("Object: " + par.text)
19 par.alert("Freezing cb for this obj")
20 global_obj = par
21 par.event_freeze()
22 par.alert("Freeze count = " + par.event_freeze_get())
23}
24
25function thaw_cb(par){
26 par.alert("Thawing cb for global_obj")
27 global_obj.event_thaw()
28}
29//==================================
30
31function numbers_cb(par){
32 par.alert("numbers_cb")
33 par.no_par()
34
35 par.ints(0, 0)
36 print (" === Testing int ===")
37
38 o = par.ints(1, 2, 3)
39 par.alert("xx: " + o.xx)
40 par.alert("yy: " + o.yy)
41
42 par.par_by_ref(1, 2, 3)
43
44
45 print (" === Testing floats ===")
46 a = 7.32
47 b = -21474.5134
48 o = par.floats(a, b)
49
50 par.alert("bb: " + o.bb)
51 par.alert("cc: " + o.cc)
52}
53
54function cb3(par)
55{
56 print("callback called for: " + par.text)
57 /*
58 par.alert("getting size")
59
60 o = par.size
61 par.alert("W: " + o.w)
62 par.alert("H: " + o.h)
63
64 o = par.position
65 par.alert("X: " + o.x)
66 par.alert("Y: " + o.y)
67 */
68}
69
70
71var win = elm.ElmWin({
72 evas_obj_size: { w: 300, h: 350},
73 elm_obj_win_title: "My JS window",
74
75 elements: {
76 bg: elm.ElmBg({
77 // text: "Hello",
78 evas_obj_size: {w: 210, h: 60},
79 elm_obj_bg_color: {r: 0, g: 245, b: 255, a: 255},
80 }),
81 shalom_bt: elm.ElmButton({
82 // text: "Hello",
83 evas_obj_position : {x: 30, y: "asdf"},
84 evas_obj_size: {w: 210, h: 60},
85 evas_obj_color: {r: 159, g: 245, b: 255, a: 255},
86 /*
87 eo_ev_callback_add : cb_add,
88 eo_ev_callback_del : cb_del,
89 ev_clicked : cb3
90 */
91 }),
92 ba: elm.ElmButton({
93// text: "(B) ADD cb",
94 evas_obj_position : {x: 30, y: 100},
95 evas_obj_size: {w: 100, h: 50},
96 evas_obj_color: {r: 255, g: 0, b: 255, a: 255},
97// evas_obj_visibility : false,
98 // ev_clicked : cb3
99 }),
100
101 }
102
103});
104/*
105var w = elm.ElwWin({
106 size: { w: 300, h: 350},
107 elements: {
108
109
110 but1: elm.ElwButton({
111 text: "1st but in box",
112 //position : { x: 250, y: 100},
113 //size: { w: 90, h: 20},
114 color: { r: 255, g: 0, b: 255, a: 255},
115 ev_clicked : thaw_cb
116 }),
117
118 but2: elm.ElwButton({
119 text: "2nd but in box",
120 //position : { x: 270, y: 150},
121 //size: { w: 90, h: 50},
122 color: {r: 240, g: 240, b: 0, a: 255},
123 ev_clicked : freeze_this
124 }),
125
126 box : elm.ElwBox ({
127 position : {x: 140, y: 170},
128 size: {w: 100, h: 50},
129 }),
130
131 pb: elm.ElwButton({
132 text: "But in BB (num)",
133 //position : { x: 310, y: 150},
134 //size: { w: 70, h: 50},
135 color: {r: 240, g: 240, b: 245, a: 255},
136 ev_clicked : numbers_cb
137 }),
138
139 ebb: elm.ElwBoxedbutton({
140 text: "BoxedButton",
141 position : {x: 30, y: 170},
142 size: { w: 100, h: 50},
143 color: { r: 100, g: 85, b: 255, a: 255},
144 //ev_clicked : freeze_all,
145 }),
146 }
147});
148*/
149var w = elm.realise(win);
150
151print ("========= DPI ========")
152print (w.elm_obj_win_screen_dpi)
153print ("====================")
154
155print ("==== call for bitton size =====")
156var s = w.elements.ba.evas_obj_size
157print (s)
158print ("==== end call for button size =====")
159
160print ("==== Window size =====")
161print( w.evas_obj_size )
162print ("====================")
163
164//var dpi = e.elements.w.elm_obj_win_screen_dpi
165//print ("DPI: " + dpi)
166
167print ("====================")
168print (w.elm_obj_win_aspect)
169w.elm_obj_win_center(1, 1)
170
171
172
173w.elements.ba.evas_obj_visibility = false
174w.elements.ba.elm_wdg_text_part_set(null, "Button")
175w.elements.ba.evas_obj_visibility = true
176var t = w.elements.ba.elm_wdg_text_part_get(null)
177print ("====================")
178print(t)
179print ("====================")
180
181/*
182
183e.elements.box.pack_end(e.elements.but1)
184
185e.elements.box.pack_end(e.elements.but2)
186e.elements.ebb.pack_end(e.elements.pb)
187
188//e.elements.shalom_bt.eo_ev_callback_add = cb_add
189e.elements.shalom_bt.ev_clicked = cb3
190
191
192
193elm.ElwWin.event_global_freeze()
194elm.ElwWin.event_global_thaw()
195
196
197
198
199
200*/