Re: To Irv: about GraphApp
- Posted by Irv Mullins <irv at ELLIJAY.COM> Mar 10, 2000
- 479 views
----- Original Message ----- From: Mike Hurley <mike_hurley_2 at YAHOO.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Friday, March 10, 2000 10:43 AM Subject: To Irv: about GraphApp > Irv- > Where is the documentation for your GraphApp library? > I d/l'd the demos but I can't find anything that looks > like documentation (routine useage...etc.) Hi Mike: The documentation on using GraphApp is online at Loki's website, http://www.cs.su.oz.au/~loki/graphapp/tutorial/ I have retained the same function names as used in Loki's C version, so the translation to Euphoria is fairly easy. Note that Loki has functions in both English and 'Merkun : setcolor() and setcolour(), for example, call the same function. I've implemented the US spelling for these. One difference is in calling routines which require coordinates. In C, they are passed via a function (rect) that returns a pointer to a structure, which is then passed to the routine you are calling. In Euphoria, all that is unnecessary, as you can just form the coordinates as a sequence {x1,y1,x2,y2} and pass them directly. Example in C: #include "graphapp.h" void main(void) { window w; w = newwindow("A Window", rect(50,50,150,200), StandardWindow); /* create your controls here */ show(w); mainloop(); /* close files and tidy up here */ } Same thing in Euphoria: include graphapp.e constant w = newwindow("A Window",{50,50,150,200},StandardWindow) -- create your controls here show(w) mainloop() show() is always necessary. mainloop() is the message processing part, so it is necessary if you expect controls to respond to events. A second difference is in passing callbacks to your event handler functions: setkeydown(w, call_back(routine_id("MyKeyPressedFunction"))) which is somewhat more complicated than the way it would be done in C, so I usually include a wrapper function like the following: function call(sequence routine) return call_back(routine_id(routine)) end function That makes it possible to call the event handler like this: setkeydown(w,call("MyKeyPressedFunction")) Write if you have questions. Regards, Irv