Browse files

added demo files

  • Loading branch information...
1 parent e7ddefa commit cc17e1353d020734606cb4194eee5952ce1b7310 @matthewfl committed Aug 30, 2009
Showing with 342 additions and 0 deletions.
  1. +79 −0 Demos/HelloWorld.j
  2. +95 −0 Demos/Lag.j
  3. +12 −0 Demos/messageHello.j
  4. +47 −0 Demos/test.j
  5. +39 −0 Demos/test2.j
  6. +70 −0 Demos/windowSample.j
View
79 Demos/HelloWorld.j
@@ -0,0 +1,79 @@
+@import <eyeos/ui/Window.j>
+@import <eyeos/ui/Label.j>
+@import <eyeos/ui/Textbox.j>
+@import <eyeos/ui/Button.j>
+@import <eyeos/event.j>
+@import <eyeos/server.j>
+
+
+@implementation Control : CPObject
+{
+ Window wind;
+ Button click;
+ Label outPut;
+ Textbox inPut;
+}
+
+-(void)on:(Event)e
+{
+ [outPut text:[inPut text]];
+ [inPut text:""];
+ [inPut focus];
+}
+
+-(void)load
+{
+ [eyeX flush:YES];
+ [self draw];
+}
+
+
+-(void)draw
+{
+ wind = [Window new];
+ [wind center:1];
+ [wind height:150];
+ [wind width:200];
+ [wind title:"eyeJ - Hello world"];
+
+ outPut = [Label new];
+ [outPut father:wind];
+ [outPut x:20 y:20];
+ [outPut text:"Hello World!"];
+
+ inPut = [Textbox new];
+ [inPut father:wind];
+ [inPut width:150];
+ [inPut x:20 y:50];
+
+ click = [Button new];
+ [click father:wind];
+ [click x:20 y:80];
+ [click width:120];
+ [click text:"Change Label Text"];
+
+ [click onClick:@selector(on:) of:self];
+ [click addFriend:inPut];
+
+ [wind show];
+ [outPut show];
+ [inPut show];
+ [click show];
+
+ [inPut focus];
+}
+
+@end
+
+
+function main () {
+ try {
+ BindJSEvent("Close", exit);
+ control = [Control new];
+ [control load];
+ }catch(e) {
+ var t = [json toString:e];
+ alert(t);
+ exit();
+ }
+}
View
95 Demos/Lag.j
@@ -0,0 +1,95 @@
+/*
+ add a lag to the system server calls, not to eyeJ calls
+ how it would be when working with a slow server
+*/
+
+@import <eyeos/server.j>
+@import <eyeos/eyeX.j>
+@import <eyeos/event.j>
+@import <eyeos/ui/Window.j>
+@import <eyeos/ui/Label.j>
+@import <eyeos/ui/Button.j>
+@import <eyeos/ui/Textbox.j>
+
+@implementation Control : CPObject
+{
+ Window wind;
+ Textboc time;
+ Button button;
+ Label textLabel;
+}
+
+-(void)close:(Event)e
+{
+ [self setLag:0];
+ //[eyeX rawjs:"eyeJ.SendMessage = LagSendMessage"];
+ exit();
+}
+
+-(void)setLag:(CPNumber)t
+{
+ t = t*1000+1;
+ [eyeX rawjs:"LagTime = "+t.toString()+";"];
+ [eyeX flush];
+}
+
+-(void) load
+{
+ [eyeX flush:YES];
+ [eyeX rawjs:"LagTime = 1;"];
+ // we know that eyeJ will be loaded
+ // the real message system is at eyeJ.SendMessage
+ [eyeX rawjs:"if(typeof LagSendMessage == 'undefined') LagSendMessage = eyeJ.SendMessage;"]
+ [eyeX rawjs:"eyeJ.SendMessage = function (a,b,c) { setTimeout(function () { LagSendMessage(a,b,c); }, LagTime); };"]
+ [self draw];
+ [EyeOSEvent on:"Close" act:@selector(close:) of:self];
+ [eyeX flush];
+ [eyeX flush:NO];
+}
+
+-(void)click:(Event)e
+{
+ var ti = [time text]*1;
+ [self setLag:ti];
+ [eyeX message:"Lag set to "+ti+" secs"];
+}
+
+-(void) draw
+{
+ wind = [Window new];
+ [wind title:"Lag"];
+ [wind height:150];
+ [wind width:150];
+ [wind center:1];
+
+ textLabel = [Label new];
+ [textLabel x:20 y:20];
+ [textLabel father:wind];
+ [textLabel text:"Server Lag"];
+
+ time = [Textbox new];
+ [time x:20 y:50];
+ [time width:100];
+ [time father:wind];
+ [time text:"0"];
+
+ button = [Button new];
+ [button x:20 y:80];
+ [button father:wind];
+ [button text:"set Lag"];
+
+ [button onClick:@selector(click:) of:self];
+ [button addFriend:time];
+
+ [wind show];
+ [textLabel show];
+ [time show];
+ [button show];
+}
+
+@end
+
+function main () {
+ control = [Control new];
+ [control load];
+}
View
12 Demos/messageHello.j
@@ -0,0 +1,12 @@
+@import <eyeos/eyeX.j>
+@import <eyeos/server.j>
+
+function main () {
+ try{
+ //alert('running');
+ [eyeX check];
+[eyeX message:"Hello world"];
+ //alert('exit');
+ exit();
+ }catch(e) { alert(JSON.stringify(e)); }
+}
View
47 Demos/test.j
@@ -0,0 +1,47 @@
+@import <Foundation/CPObject.j>
+@import <eyeos/server.j>
+@impoer <eyeos/event.j>
+
+@implementation man : CPObject
+{
+ CPString _s;
+ EyeOsEvent e;
+}
+
+-(void) set:(CPString) s
+{
+ _s = s;
+}
+
+-(void) alert
+{
+ alert(_s);
+}
+
+-(CPString) get
+{
+ return _s;
+}
+
+-(void) do
+{
+ [e call];
+}
+/*
+-(void) setup
+{
+ e = [EyeOsEvent new];
+ [e setAction:@selector(alert:)];
+}
+*/
+@end
+
+function main () {
+ alert('main');
+ var m = [man new];
+ [m set:"hello world"];
+ [m alert];
+ //var s = [m get];
+ //alert(s);
+ exit();
+}
View
39 Demos/test2.j
@@ -0,0 +1,39 @@
+@import <Foundation/CPObject.j>
+@import <eyeos/server.j>
+@import <eyeos/event.j>
+@import <eyeos/eyeX.j>
+
+
+@implementation Base : CPObject
+{
+}
+
+-(void) On:(Event)e
+{
+ //var s = [e getData];
+ [eyeX message:"receved"];
+ [eyeX message:[e getData]];
+}
+
+-(void) run
+{
+ [EyeOSEvent on:"what" act:@selector(On:) of:self];
+}
+
+@end
+
+
+function main () {
+ //var alert = function () {};
+ try{
+ //BindJSEvent('what', function () {alert('hi');});
+ alert('loaded');
+ var b = [Base new];
+ [b run];
+ alert('message');
+ [eyeX message:"hello world"];
+ alert('sendMessage');
+ [eyeX sendRawMessage:"what" prams:"hello"];
+ alert('exit');
+ }catch(e){ alert(JSON.stringify(e)); }
+}
View
70 Demos/windowSample.j
@@ -0,0 +1,70 @@
+@import <eyeos/server.j>
+@import <eyeos/ui/Window.j>
+@import <eyeos/ui/Button.j>
+@import <eyeos/ui/Label.j>
+@import <eyeos/ui/Textbox.j>
+@import <eyeos/event.j>
+
+
+@implementation Control : CPObject
+{
+ Window Wind;
+ Button But;
+ Label Lab;
+ Textbox Text;
+}
+
+-(void) click:(Event)e
+{
+ var t = [e getData];//[Text text];
+ alert('got');
+ alert(t);
+}
+
+-(void) run
+{
+ Wind = [Window new];
+ [Wind center:1];
+ [Wind height:100];
+ [Wind width:300];
+ [Wind title:"hello world"];
+
+ But = [Button new];
+ [But x:20 y:20];
+ [But text:"hi"];
+ [But father:Wind];
+ [But onClick:@selector(click:) of:self];
+
+ Lab = [Label new];
+ [Lab x:120 y:20];
+ [Lab text:"cool"];
+ [Lab father:Wind];
+
+ Text = [Textbox new];
+ [Text x:140 y:20];
+ [Text father:Wind];
+
+ [But addFriend:Text];
+
+ [Wind show];
+ [But show];
+ [Lab show];
+ [Text show];
+}
+
+
+@end
+
+
+
+function main() {
+ try{
+ BindJSEvent("Close", exit);
+ [eyeX flush:YES];
+ base = [Control new];
+ [base run];
+ }catch(e) { alert(JSON.stringify(e)); }
+ //exit();
+}
+
+//function main () { exit(); }

0 comments on commit cc17e13

Please sign in to comment.