Changeset 5730


Ignore:
Timestamp:
Jan 18, 2007, 3:12:58 AM (18 years ago)
Author:
Gary Byers
Message:

Use CGFloat, type casts, etc. Avoid deprecated NSFont stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/examples/cocoa-window.lisp

    r5565 r5730  
    9999      (let* ((e (send (@class ns-event)
    100100                      :other-event-with-type #$NSApplicationDefined
    101                       :location (ns-make-point 0.0e0 0.0e0)
     101                      :location (ns-make-point +cgfloat-zero+ +cgfloat-zero+)
    102102                      :modifier-flags 0
    103103                      :timestamp 0.0d0
     
    138138    (funcall (appkit-interrupt-function (send e 'data1)))
    139139    (send-super :send-event e)))
    140 
    141 ;;; This is a reverse-engineered version of most of -[NSApplication terminate],
    142 ;;; split off this way because we don't necessarily want to just do
    143 ;;  (#_exit 0) when we've shut down the Cocoa UI.
    144 #+apple-objc
    145 (define-objc-method ((:void shutdown)
    146                      lisp-application)
    147   (unless (eql (pref self :<NSA>pplication._app<F>lags._app<D>ying) #$YES)
    148     (if (eql #$NO (external-call "__runningOnAppKitThread" :<BOOL>))
    149       (send self
    150             :perform-selector-on-main-thread (@selector "shutdown")
    151             :with-object (%null-ptr)
    152             :wait-until-done nil)
    153       (progn
    154         (setf (pref self :<NSA>pplication._app<F>lags._app<D>ying) #$YES)
    155         (send (send (@class ns-notification-center) 'default-center)
    156               :post-notification-name #@"NSApplicationWillTerminateNotification"
    157               :object self)
    158         ;; Remove self as the observer of all notifications (the
    159         ;; precise set of notifications for which it's registered
    160         ;; may vary from release to release
    161         (send (send (@class ns-notification-center) 'default-center)
    162               :remove-observer self
    163               :name (%null-ptr)
    164               :object (%null-ptr))
    165         (objc-message-send (@class ns-menu) "_saveTornOffMenus" :void)
    166         (send (send (@class ns-user-defaults) 'standard-user-defaults)
    167               'synchronize)
    168         (objc-message-send (@class ns-pasteboard)
    169                            "_provideAllPromisedData" :void)
    170         (objc-message-send (send (@class ns-help-manager) 'shared-help-manager)
    171                            "_cleanupHelpForQuit" :void)
    172         ;; See what happens when you muck around in Things You Shouldn't
    173         ;; Know About ?
    174         (let* ((addr (or (foreign-symbol-address
    175                           "__NSKeyboardUIHotKeysUnregister")
    176                          (foreign-symbol-address
    177                           "__NSKeyboardUIHotKeysCleanup"))))
    178           (if addr (ff-call addr :void)))
    179         (send (the ns-application self) :stop (%null-ptr))))))
    180140
    181141
     
    270230                          (attributes ()))
    271231                               
    272   (setq size (float size 0.0f0))
     232  (setq size (float size +cgfloat-zero+))
    273233  (with-cstrs ((name name))
    274234    (with-autorelease-pool
    275         (rletz ((matrix (:array :float 6)))
    276           (setf (%get-single-float matrix 0) size
    277                 (%get-single-float matrix 12) size)
     235        (rletz ((matrix (:array :<CGF>loat 6)))
     236          (setf (paref matrix (:* :<CGF>loat) 0) size
     237                (paref matrix (:* :<CGF>loat) 3) size)
    278238          (let* ((fontname (send (@class ns-string) :string-with-c-string name))
    279239                 (font (send (@class ns-font)
     
    305265(defun create-paragraph-style (font line-break-mode)
    306266  (let* ((p (make-objc-instance 'ns-mutable-paragraph-style))
    307          (charwidth (send (send font 'screen-font)
    308                           :width-of-string #@" ")))
     267         (charwidth (slet ((advance
     268                            (send font 'maximum-advancement)))
     269                      (fround (pref advance :<NSS>ize.width)))))
    309270    (send p
    310271          :set-line-break-mode
     
    392353                         (auto-display t)
    393354                         (activate t))
    394   (rlet ((frame :<NSR>ect :origin.x (float x) :origin.y (float y) :size.width (float width) :size.height (float height)))
     355  (rlet ((frame :<NSR>ect
     356           :origin.x (float x +cgfloat-zero+)
     357           :origin.y (float y +cgfloat-zero+)
     358           :size.width (float width +cgfloat-zero+)
     359           :size.height (float height +cgfloat-zero+)))
    395360    (let* ((stylemask
    396361            (logior #$NSTitledWindowMask
Note: See TracChangeset for help on using the changeset viewer.