home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / oodleutl.cpt / oodles-of-utils / examples / hairy-view.lisp < prev    next >
Encoding:
Text File  |  1992-01-29  |  2.8 KB  |  71 lines

  1. #|
  2. Example of a relatively complex dialog item which is actually implemented
  3. as a view with subviews.
  4.  
  5. Very little code is written to define the class. The work is all done by
  6. the mixins.
  7.  
  8. |#
  9.  
  10. (oou-dependencies
  11.  :ICON-di
  12.  :frame-svm
  13.  :droppable-svm
  14.  :static-text-di
  15.  :PICT-di
  16.  )
  17.  
  18.  
  19. (open-res-file "oou:examples;examples.rsrc")
  20.  
  21. (defclass hairy-view (frame-svm droppable-svm view) nil)
  22.  
  23. (defmethod initialize-instance :after ((v hairy-view) &rest initargs &key &allow-other-keys)
  24.   (add-subviews v  (apply #'make-instance
  25.                           'ICON-button-di
  26.                           :view-nick-name :icon
  27.                           :view-position (make-point (round (- (point-h (view-size v)) 32) 2) 5)
  28.                           :view-size #@(32 32)
  29.                           :dialog-item-action #'(lambda (item) (set-dialog-item-text (view-named :name (view-container item)) "YOU FOOL!"))
  30.                           :allow-other-keys t
  31.                           initargs)
  32.                 (apply #'make-instance
  33.                        'editable-text-dialog-item
  34.                        :view-nick-name :name
  35.                        :view-position #@(10 42)
  36.                        :view-size (make-point (- (point-h (view-size v)) 20) 15)
  37.                        :view-font '("Geneva" 12)
  38.                        :allow-other-keys t
  39.                        initargs)))
  40.  
  41.  
  42. ;;now try it out
  43.  
  44. (defparameter *test-w* (make-instance 'dialog
  45.                          :window-title "it slices, it dices, ..."
  46.                          :view-size #@(300 200)
  47.                          :view-subviews
  48.                          (list
  49.  
  50.                           (make-instance
  51.                             'hairy-view
  52.                             :drag-bounds :window
  53.                             :drag-end-action-fn #'(lambda (sv delta pt) (declare (ignore pt)) (offset-view-position sv delta))
  54.                             :drop-action-fn #'(lambda (di targ off where) (declare (ignore di targ off where)) (ed-beep))
  55.                             :ICON-name "executioner"
  56.                             :dialog-item-text "John Doe"
  57.                             :view-size #@(80 80)
  58.                             :view-position #@(10 10))
  59.  
  60.                           (make-instance
  61.                                  'static-text-di
  62.                                  :view-nick-name :msg
  63.                                  :view-position #@(10 150)
  64.                                  :view-size #@(150 50)
  65.                                  :view-font '("Geneva" 10)
  66.                                  :text-string "Enter your name & drag yourself to the guilotine. And don't click on my head!")
  67.  
  68.                           (make-instance 'PICT-di
  69.                             :PICT-name "gill"
  70.                             :view-position #@(270 150)))))
  71.