Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. (load "\micro-graphics/load.lisp")
  2. (load "08.lisp")
  3. (load "08_text-shape.lisp")
  4.  
  5. (defmethod properties ((shape shape))
  6. '(color thickness filledp))
  7.  
  8. (defmethod properties ((point point))
  9. '(x y r phi))
  10.  
  11. (defmethod properties ((circle circle))
  12. (append (call-next-method) (list 'radius)))
  13.  
  14. (defmethod properties ((polygon polygon))
  15. (append (call-next-method) (list 'closedp)))
  16.  
  17. (defmethod properties ((window window))
  18. '(delegate shape background))
  19.  
  20. (defclass inspected-window (window)
  21. ())
  22.  
  23. (defmethod install-callbacks ((w inspected-window))
  24. (call-next-method)
  25.  
  26. w)
  27.  
  28. (defmethod install-right-mouse-down-callback ((w inspected-window))
  29. (mg:set-callback
  30. (mg-window w)
  31. :mouse-down (lambda (mgw button x y)
  32. (declare (ignore mgw))
  33. (ev-right-mouse-down
  34. w
  35. button
  36. (move (make-instance 'point) x y)))))
  37.  
  38. (defmethod ev-right-mouse-down ((w inspected-window) button position)
  39. (let ((shape (find-clicked-shape w position)))
  40. (if shape
  41. (mouse-down-inside-shape w shape button position)
  42. (mouse-down-no-shape w button position))))
  43.  
  44. (defmethod mouse-down-inside-shape ((w inspected-window) shape button position)
  45. (set-shape w (append (items w) (menu shape button position)))
  46. w)
  47.  
  48. (defmethod mouse-down-no-shape ((w inspected-window) button position)
  49. (set-shape w (append (items w) (menu w button position)))
  50. w)
  51.  
  52. (defun show-menu (shape)
  53. (let* ((a (make-instance 'window))
  54. (sloty (properties shape))
  55. (y 20)
  56. (x 20)
  57. (slots (list
  58. (move
  59. (set-text
  60. (make-instance 'text-shape)
  61. (format nil "CLASS -> ~a" (type-of shape)))
  62. x y))))
  63. (setf y (+ y 20))
  64. (dolist (slot sloty)
  65. (progn
  66. (setf slots (cons
  67. (move
  68. (set-text
  69. (make-instance 'text-shape)
  70. (format nil "~a -> ~a" slot (apply 'funcall
  71. `(,slot ,shape))))
  72. x y)
  73. slots))
  74. (setf y (+ y 20))))
  75. (set-shape a slots)
  76. a))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement