Changeset 6758
- Timestamp:
- Jun 18, 2007, 1:38:34 AM (17 years ago)
- File:
-
- 1 edited
-
branches/ide-1.0/ccl/examples/cocoa-defaults.lisp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ide-1.0/ccl/examples/cocoa-defaults.lisp
r6748 r6758 59 59 ;;; Names which contain #\* confuse Cocoa Bindings. 60 60 (defun objc-default-key (name) 61 (ns-constant-string ( remove #\* (lisp-to-objc-message (list name)))))61 (ns-constant-string (lisp-to-objc-message (list (make-symbol (remove #\* (string name))))))) 62 62 63 63 … … 90 90 91 91 (defun update-cocoa-defaults-list (domain defaults) 92 (let* ((need-synch nil)) 93 (dolist (d defaults) 94 (let* ((name (cocoa-default-symbol d)) 95 (key (objc-constant-string-nsstringptr (cocoa-default-string d)))) 96 (if (%null-ptr-p (#/objectForKey: domain key)) 97 (let* ((value (cocoa-default-value d))) 98 (case (cocoa-default-type d) 99 (:int (#/setInteger:forKey: domain value key)) 100 (:float (#/setFloat:forKey: domain value key)) 101 (:bool (#/setBool:forKey: domain value key)) 102 (:color (#/setObject:forKey: domain 103 (#/archivedDataWithRootObject: 104 ns:ns-archiver 105 value) 106 key)) 107 (t 108 (#/setObject:forKey: domain 109 (%make-nsstring (format nil "~a" (cocoa-default-value d))) 92 (dolist (d defaults) 93 (let* ((name (cocoa-default-symbol d)) 94 (type (cocoa-default-type d)) 95 (key (objc-constant-string-nsstringptr (cocoa-default-string d)))) 96 (let* ((hook (cocoa-default-change-hook d)) 97 (old-value (symbol-value name))) 98 (case type 99 (:int 100 (set name (#/integerForKey: domain key))) 101 (:float 102 (set name (#/floatForKey: domain key))) 103 (:bool 104 (set name (#/boolForKey: domain key))) 105 (:string 106 (let* ((nsstring (#/stringForKey: domain key))) 107 (unless (%null-ptr-p nsstring) 108 (set name (lisp-string-from-nsstring nsstring))))) 109 (:color 110 (let* ((data (#/dataForKey: domain key))) 111 (unless (%null-ptr-p data) 112 (set name (#/retain (#/unarchiveObjectWithData: ns:ns-unarchiver data))))))) 113 (when hook (funcall hook old-value (symbol-value name))))))) 110 114 111 key)))112 (setq need-synch t))113 (let* ((hook (cocoa-default-change-hook d))114 (old-value (symbol-value name)))115 (case (cocoa-default-type d)116 (:int117 (set name (#/integerForKey: domain key)))118 (:float119 (set name (#/floatForKey: domain key)))120 (:bool121 (set name (#/boolForKey: domain key)))122 (:string123 (let* ((nsstring (#/stringForKey: domain key)))124 (unless (%null-ptr-p nsstring)125 (set name (lisp-string-from-nsstring nsstring)))))126 (:color127 (let* ((data (#/dataForKey: domain key)))128 (unless (%null-ptr-p data)129 (set name (#/retain (#/unarchiveObjectWithData: ns:ns-unarchiver data)))))))130 (when hook (funcall hook old-value (symbol-value name)))))))131 (when need-synch (#/synchronize domain))))132 115 133 ;;; Type of newval depends on cocoa-default-type.134 (defun update-cocoa-default (d newval)135 (let* ((name (cocoa-default-symbol d)))136 (case (cocoa-default-type d)137 (:int138 (set name (#/intValue newval)))139 (:bool140 (#_NSLog #@"newvalue = %@" :id newval)141 (set name (coerce-from-bool (#/intValue newval))))142 (:float143 (set name (#/floatValue newval)))144 (:string145 (unless (%null-ptr-p newval)146 (set name (lisp-string-from-nsstring newval))))147 (:color148 (unless (%null-ptr-p newval)149 (set name (#/retain (#/unarchiveObjectWithData: ns:ns-unarchiver newval))))))))150 116 151 117 ;;; Return an NSDictionary describing the "default" values of the defaults. … … 156 122 (dolist (d defaults dict) 157 123 (let* ((value (cocoa-default-value d))) 158 (#/setObject:forKey: dict 159 (case (cocoa-default-type d) 160 (:color (#/archivedDataWithRootObject: 161 ns:ns-archiver 162 value)) 163 (:int (make-instance 'ns:ns-number 164 :with-int value)) 165 (:float (make-instance 'ns:ns-number 166 :with-float value)) 167 (:bool (make-instance 'ns:ns-number 168 :with-bool (coerce-to-bool value))) 169 (t 170 (%make-nsstring (format nil "~a" (cocoa-default-value d))))) 171 (objc-constant-string-nsstringptr (cocoa-default-string d))))))) 124 (#/setObject:forKey: dict 125 (case (cocoa-default-type d) 126 (:color (#/archivedDataWithRootObject: 127 ns:ns-archiver 128 value)) 129 (:bool (if value #@"YES" #@"NO")) 130 (t 131 (%make-nsstring (format nil "~a" (cocoa-default-value d))))) 132 (objc-constant-string-nsstringptr (cocoa-default-string d)))))))
Note:
See TracChangeset
for help on using the changeset viewer.
