#include "olbasewindow.h" #include "component.h" #include "olbutton.h" #include "olmenubutton.h" #include "olscrollbar.h" #include "oltextfield.h" #include "olcheckbox.h" #include "group.h" #include "menu.h" #include "olsetting.h" #include "settings.h" #include "ollist.h" #include "olnotice.h" #include "layout.h" #include "label.h" extern object hn; int wx, wy = 250; olbasewindow newwindow(char *str, char *footer) { olbasewindow win = (olbasewindow)hn.newmember(/olbasewindow); olbutton b; win.framelabel = str; win.resizable = true; win.footer = true; win.reshape(wx += 50,wy -= 25,300,200); win.@current_layout.setscript("","/OnOpen {[FOOT number 10 string cvs] /setfooters @parent Send} def"); win.@current_layout[/FOOT] = footer; b = (olbutton)win.@current_layout.newmember(/olbutton); b.setscript("","/Action {systemdict /hn undef} def"); b.setlabel("Quit"); b.setposition(20,5,null,null); b.map(); b = (olbutton)win.@window_layout.newmember(/olbutton); b.setscript("","/Action {[] /goto_next_layout self Send} def"); b.setlabel("Next"); b.setposition(null,5,20,null); b.map(); return win; } void newlayout(olbasewindow win, char *footer) { win.new_layout(); win.@current_layout.setscript("","/OnOpen {[FOOT number 10 string cvs] /setfooters @parent Send} def"); win.@current_layout[/FOOT] = footer; } olbasewindow demo1() { olbasewindow win; ollist l; char **list; any a; /* create a OL window */ win = newwindow("scrolling list demo","Exclusive"); l = (ollist)win.@current_layout.newmember(/ollist); l.setposition(10,30,10,10); l.setchoicemode(/Exclusive); l.setitems(["TNT",logo,"OpenLook","OpenWindows","X-windows","Macintosh"]); l.setdefaultchoice(1); l.map(); newlayout(win,"Exclusive Variation"); l = (ollist)win.@current_layout.newmember(/ollist); l.setposition(10,30,10,10); l.setchoicemode(/ExclusiveVariation); l.setitems([["red",rgbcolor(1,0,0)],["green",rgbcolor(0,1,0)],["blue",rgbcolor(0,0,1)]]); l.map(); newlayout(win,"Non Exclusive"); l = (ollist)win.@current_layout.newmember(/ollist); l.setposition(10,30,10,10); l.setchoicemode(/NonExclusive); list = (char **)[]; forall (a ; ; hn) list = (char **)append(list,[cvs(a,string(64))]); l.setitems(list); l.map(); win.goto_first_layout(); return win; } group demo2group(drawable parent) { char *s; group g; olbutton b; g = (group)parent.newmember(/group); forall(; s ; ["First","Second","Third","Fourth","Last"]) { b = (olbutton)g.newmember(/olbutton); b.setlabel(s); b.map(); } g.setposition(10,30,10,10); g.map(); return g; } olbasewindow demo2() { olbasewindow win; group g; /* create a OL window */ win = newwindow("placement demo","left to right"); g = demo2group(win.@current_layout); g.setplacement(/left2right); newlayout(win,"left to right and centered"); g = demo2group(win.@current_layout); g.setplacement(/left2right); g.setjustification(/Centered); newlayout(win,"top to bottom"); g = demo2group(win.@current_layout); g.setplacement(/top2bottom); newlayout(win,"top to bottom and centered"); g = demo2group(win.@current_layout); g.setplacement(/top2bottom); g.setjustification(/Centered); win.goto_first_layout(); return win; } settings demo3settings(drawable parent) { char *s; settings c; olsetting b; c = (settings)parent.newmember(/settings); forall(; s ; ["First","Second","Third","Fourth","Last"]) { b = (olsetting)c.newmember(/olsetting); b.setlabel(s); b.map(); } c.setposition(10,30,10,10); c.map(); return c; } group demo3checkboxes(drawable parent) { int i; group c; olcheckbox b; c = (group)parent.newmember(/group); for (i = 0 ; i < 5 ; i++) { b = (olcheckbox)c.newmember(/olcheckbox); b.map(); } c.setposition(10,30,10,10); c.map(); return c; } olbasewindow demo3() { olbasewindow win; settings c; group g; /* create a OL window */ win = newwindow("settings demo","Exclusive"); c = demo3settings(win.@current_layout); newlayout(win,"Exclusive Variation"); c = demo3settings(win.@current_layout); c.setchoicemode(/ExclusiveVariation); newlayout(win,"Non Exclusive"); c = demo3settings(win.@current_layout); c.setchoicemode(/NonExclusive); newlayout(win,"Check boxes"); g = demo3checkboxes(win.@current_layout); g.setplacement(/top2bottom); win.goto_first_layout(); return win; } olbasewindow demo4() { olbasewindow win = newwindow("notice demo","Hello"); olbutton b = (olbutton)win.@current_layout.newmember(/olbutton); olnotice n = (olnotice)newobject(/olnotice); settings s; n.reshape(0,0,400,100); b.setscript("","/Action {w 2 div h 2 div /mapxy n send} def"); b.addslave(n); b.setlabel("Show notice"); b.move(40,40); b[/n] = n; b.map(); b = (olbutton)n.@current_layout.newmember(/olbutton); b.setscript("","/Action {[] /unmap @window Send} def"); b.setlabel("Cancel"); b.setdefaultchoice(true); b.minwidth = b.preferredwidth(); b.fixedwidth = true; b.setposition(0,10,0,null); b.map(); s = demo3settings(n.@current_layout); s.setjustification(/Centered); win.goto_first_layout(); return win; } olbasewindow demo5() { olbasewindow win = (olbasewindow)hn.newmember(/olbasewindow); char *s; group g; olbutton b; win.framelabel = "ClassButtons Demo"; win.resizable = true; win.footer = true; win.reshape(wx += 50,wy -= 25,300,200); g = (group)win.@current_layout.newmember(/group); forall(; s ; ["Weather","Sport","Gossip","NeWS","Entertainment","Finance","Happy Talk"]) { b = (olbutton)g.newmember(/olbutton); b.setscript("","/Action {[(The % is extremely boring...)[str] sprintf] /setleftfooter /@window Send} def"); b.setlabel(s); b.map(); } ((olbutton)g.members[3]).setdefaultchoice(true); ((olbutton)g.members[3]).setscript("","/Action {5 {beep 0.0005 sleep} repeat} def"); g.setplacement(/left2right); g.setposition(10,10,10,10); g.map(); return win; } olbasewindow demo6() { olbasewindow win = (olbasewindow)hn.newmember(/olbasewindow); oltextfield t; label l; win.framelabel = "ClassTextField Demo"; win.resizable = true; win.footer = true; win.reshape(wx += 50,wy -= 25,300,200); t = (oltextfield)win.@current_layout.newmember(/oltextfield); t.setscript("","/Action {[exch] /setleftfooter /@window Send} def"); t.setvalue("Sample Text"); t.setposition(10,10,10,50); t.map(); l = (label)win.@current_layout.newmember(/label); l.setlabel(["Cathy",rgbcolor(1,0,0)]); l.setposition(10,null,null,0); l.map(); return win; } void main() { demo1().map(); demo2().map(); demo3().map(); demo4().map(); demo5().map(); demo6().map(); }