Changeset 6231


Ignore:
Timestamp:
Apr 8, 2007, 5:05:17 PM (13 years ago)
Author:
gb
Message:

Use new syntax: OBJC:DEFMETHOD, #/, MAKE-INSTANCE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/examples/tiny.lisp

    r5884 r6231  
    4343(defconstant numsides 12)
    4444
    45 (define-objc-method ((:void :draw-rect (:<NSR>ect rect))
    46                      demo-view)
     45(objc:defmethod (#/drawRect: :void) ((self demo-view) (rect :<NSR>ect))
    4746  (declare (ignore rect))
    48   (slet ((bounds (send self 'bounds)))
    49     (let ((width (ns-width bounds))
    50           (height (ns-height bounds)))
    51       (macrolet ((X (tt) `(* (1+ (sin ,tt)) width 0.5))
    52                  (Y (tt) `(* (1+ (cos ,tt)) height 0.5)))
    53         ;; Fill the view with white
    54         (send (the ns-color (send (@class ns-color) 'white-color)) 'set)
    55         (#_NSRectFill bounds)
    56         ;; Trace two polygons with N sides and connect all of the vertices
    57         ;; with lines
    58         (send (the ns-color (send (@class ns-color) 'black-color)) 'set)
     47  (let* ((bounds (#/bounds self))
     48         (width (ns:ns-rect-width bounds))
     49         (height (ns:ns-rect-height bounds)))
     50    (macrolet ((X (tt) `(* (1+ (sin ,tt)) width 0.5))
     51               (Y (tt) `(* (1+ (cos ,tt)) height 0.5)))
     52      ;; Fill the view with white
     53      (#/set (#/whiteColor ns:ns-color))
     54      (#_NSRectFill bounds)
     55      ;; Trace two polygons with N sides and connect all of the vertices
     56      ;; with lines
     57      (#/set (#/blackColor ns:ns-color))
     58      (rlet ((source-point :ns-point)
     59             (dest-point :ns-point))
     60      (loop
     61        for f from 0.0 below (* 2 short-pi) by (* 2 (/ short-pi numsides))
     62        do
    5963        (loop
    60           for f from 0.0 below (* 2 short-pi) by (* 2 (/ short-pi numsides))
     64          for g from 0.0 below (* 2 short-pi) by (* 2 (/ short-pi numsides))
    6165          do
    62           (loop
    63             for g from 0.0 below (* 2 short-pi) by (* 2 (/ short-pi numsides))
    64             do
    65             (send (@class ns-bezier-path)
    66                   :stroke-line-from-point (ns-make-point (X f) (Y f))
    67                   :to-point (ns-make-point (X g) (Y g)))))))))
     66          (ns:init-ns-point source-point (X f) (Y f))
     67          (ns:init-ns-point dest-point (X g) (Y g))
     68          (#/strokeLineFromPoint:toPoint: ns:ns-bezier-path source-point dest-point)))))))
    6869
    6970
     
    7374(defun tiny-setup ()
    7475  (with-autorelease-pool
    75    (slet ((r (ns-make-rect (float 100.0 +cgfloat-zero+)
    76                            (float 350.0 +cgfloat-zero+)
    77                            (float 400.0 +cgfloat-zero+)
    78                            (float 400.0 +cgfloat-zero+))))
    79          (let ((w (make-instance
     76    (let* ((r (ns:make-ns-rect 100 350 400 400))
     77           (w (make-instance
    8078                   'ns:ns-window
    8179                   :with-content-rect r
     
    8583                   :backing #$NSBackingStoreBuffered
    8684                   :defer t)))
    87            (send w :set-title #@"Tiny Window Application")
    88            (let ((my-view (make-instance 'demo-view :with-frame r)))
    89              (send w :set-content-view my-view)
    90              (send w :set-delegate my-view))
    91            (send w :make-key-and-order-front nil)
    92            w))))
     85      (#/setTitle: w "Tiny Window Application")
     86      (let ((my-view (make-instance 'demo-view :with-frame r)))
     87        (#/setContentView: w my-view)
     88        (#/setDelegate: w my-view))
     89      (#/makeKeyAndOrderFront: w nil)
     90      w)))
    9391
    9492
Note: See TracChangeset for help on using the changeset viewer.