<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On May 24, 2010, at 6:42 PM, Richard Sutton wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>hello,<br><br>LUI looks very promising and i am trying to use it. I can get the examples in LUI.lisp working fine. However, none of these examples actually does any conventional drawing; most just set a color for a whole view. I have done drawing previously with easygui so i have some idea what is involved, but i am still having trouble with exactly the sequence needed to get something to appear. Is there an example anywhere of, say, simply drawing a line on a window? or maybe something like tiny.lisp? thanks for any pointers.<br><br>rich<br></div></blockquote><br></div><div>Hi Rich,</div><div><br></div><div>for Cocoa based drawing you would have to define a subclass of view and define its drawing method essentially the same way as in easygui. Here is and existing but rather boring example of a colored rectangle:</div><div><br></div><div><br></div><div>=== from file LUI Cocoa.lisp ==========</div><div><br></div><div><br></div><div><div>(defmethod DRAW ((Self rectangle-view))</div><div> (when (native-color Self)</div><div> (#/set (native-color Self)))</div><div> (ns:with-ns-rect (Frame 0.0 0.0 (width Self) (height Self))</div><div> (#_NSRectFill Frame)))</div></div><div><br></div><div><br></div><div>Create your own class, define its draw method and put an instance via add-subviews into a window, e.g.,</div><div><br></div><div><div>(add-subviews</div><div> (make-instance 'window)</div><div> (make-instance 'rectangle-view))</div><div><br></div><div>If you want to have more sophisticated, Web page like, layout management you may want to use the XML layer on top of things.</div><div><br></div><div>Alternatively, if you want to use OpenGL based drawing you subclass opengl-view</div><div><br></div><div>==== from circle.lisp ==============</div><div><br></div><div><div>(in-package :xlui)</div><div><br></div><div>(defclass CIRCLE-VIEW (opengl-dialog)</div><div> ((radius :accessor radius :initform 1.0 :type float)</div><div> (slices :accessor slices :initform 10 :type integer)))</div><div><br></div><div><br></div><div>(defmethod PREPARE-OPENGL ((Self circle-view))</div><div> (glColor3f 1.0 0.0 0.0))</div><div><br></div><div><br></div><div>(defmethod DRAW ((Self circle-view))</div><div> (let ((delta (/ (* (float pi 0.0) 2.0) (slices Self))))</div><div> (glBegin GL_LINE_LOOP)</div><div> (dotimes (i (slices Self))</div><div> (let ((angle (* i delta)))</div><div> (glVertex2f (* (cos angle) (radius Self)) (* (sin angle) (radius Self)))))</div><div> (glEnd)))</div><div><br></div><div><br></div><div><application-window title="circle, kinda?" y="300"></div><div> <circle-view slices="6"/></div><div></application-window></div><div><br></div><div><br></div><div>;; this will create window containing an opengl view that will resize:</div><div><br></div><div><img id="69cd780e-624d-42be-a7b3-8df220b6d32b" height="260" width="264" apple-width="yes" apple-height="yes" src="cid:51EFDE6D-ABF9-4186-9001-45BCAA0C88C8"></div></div><div><br></div></div><div><br></div><div>Does this help at all?</div><div><br></div><div>All the best, Alex</div><div><br></div><div><br></div><br><div>
<span class="Apple-style-span" style="font-size: 12px; "><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Prof. Alexander Repenning</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><br class="khtml-block-placeholder"></p><p style="margin: 0.0px 0.0px 0.0px 0.0px">University of Colorado</p><p style="margin: 0.0px 0.0px 0.0px 0.0px">Computer Science Department</p><p style="margin: 0.0px 0.0px 0.0px 0.0px">Boulder, CO 80309-430</p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><br class="khtml-block-placeholder"></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">vCard: <a href="http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf">http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf</a></font></p><br class="Apple-interchange-newline"></span>
</div>
<br></body></html>