home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / lisp / mcl / 1673 < prev    next >
Encoding:
Text File  |  1992-11-23  |  2.0 KB  |  63 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!data.nas.nasa.gov!taligent!apple!cambridge.apple.com!jbk@world.std.com
  2. From: jbk@world.std.com (Jeffrey B Kane)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: Re: Basic color use in MCL
  5. Message-ID: <199211231817.AA09150@world.std.com>
  6. Date: 23 Nov 92 18:17:32 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 52
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10.  
  11. Bill,
  12.  A couple of mistakes:
  13.  
  14. (defclass TWindow (window)
  15.   nil) ; a dull class
  16.  
  17. (defvar temp (make-instance 'TWindow :window-title "Dull Window"))
  18.  
  19. (defmethod view-draw-contents ((self TWindow))
  20.   (with-fore-color *red-color*
  21.     (with-pstrs ((str "hello"))
  22.       (move-to self 40 40) ; default pen position is 0,0 so you won't see anything
  23.       (#_DrawString str))
  24.   (move-to self 40 80)Hello againHello again
  25.   (format self "Hello again")))
  26.  
  27. (with-focused-view temp
  28. (view-draw-contents temp))
  29.  
  30.  
  31. Note that MCL will focus the view for you before it calls your 
  32. view-draw-contents. You only need to focus it again if you call 
  33. view-draw-contents on another view that's not in the normal drawing 
  34. event chain.
  35.  
  36. Since you are defining a primary method you -- may -- want to call
  37. (call-next-method) so you don't shadow the default draw method for
  38. that view.  I usually define an :after method for most drawing routines.
  39.  
  40. Last of all the problem you may be having is that you didn't move the 
  41. pen to a visible part of the view.  The default is 0,0 which puts the
  42. text up out of the content area of the window.
  43.  
  44. The only other item of note is that you can use Lisp's format statement
  45. to draw into windows since they are streams in Lisp. This can make 
  46. formating a lot easier for a lot of applications.
  47.  
  48.     Jeffrey
  49.  
  50. P.S. How's U-of-M? I haven't been back their for years (Chem Eng Terp '79)
  51.  
  52.  
  53. ======================================
  54. Jeffrey Kane, MD
  55. Kane Biomedical Systems
  56. Boston, MA
  57.  
  58. Internet    jbk@world.std.com
  59. Compuserve  74206,640
  60. AppleLink   D0738
  61.  
  62. [Don't take life too seriously... it's not like anyone gets out of it alive.]
  63.