- Timestamp:
- Dec 2, 2007, 2:26:17 AM (17 years ago)
- Location:
- branches/working-0711/ccl/examples/cocoa/easygui
- Files:
-
- 2 added
- 4 edited
- 2 moved
-
easygui.asd (modified) (1 diff)
-
example (added)
-
example/currency-converter.lisp (moved) (moved from branches/working-0711/ccl/examples/cocoa/easygui/currency-converter.lisp )
-
example/tiny.lisp (moved) (moved from branches/working-0711/ccl/examples/cocoa/easygui/tiny.lisp )
-
example/view-hierarchy.lisp (added)
-
new-cocoa-bindings.lisp (modified) (2 diffs)
-
package.lisp (modified) (2 diffs)
-
views.lisp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/working-0711/ccl/examples/cocoa/easygui/easygui.asd
r7499 r7802 22 22 23 23 (defsystem easygui 24 :depends-on (cocoa.asd) 25 :components ((:file "package") 26 (:file "new-cocoa-bindings" :depends-on ("package")) 27 (:file "events" :depends-on ("new-cocoa-bindings")) 28 (:file "views" :depends-on ("events")) 29 (:file "action-targets" :depends-on ("views")) 30 ;;; example: 31 (:file "tiny" :depends-on ("action-targets")) 32 (:file "currency-converter" :depends-on ("action-targets")))) 24 :depends-on (cocoa.asd) 25 :components ((:file "package") 26 (:file "new-cocoa-bindings" :depends-on ("package")) 27 (:file "events" :depends-on ("new-cocoa-bindings")) 28 (:file "views" :depends-on ("events")) 29 (:file "action-targets" :depends-on ("views")) 30 (:module "example" 31 :depends-on ("action-targets") 32 :components 33 ((:file "tiny") 34 (:file "currency-converter") 35 (:file "view-hierarchy"))))) -
branches/working-0711/ccl/examples/cocoa/easygui/new-cocoa-bindings.lisp
r7499 r7802 50 50 (ns:ns-rect-width r) (ns:ns-rect-height r))) 51 51 52 ;;; 52 ;;; Base class for all Cocoa-based Easygui objects: 53 53 (defclass easy-cocoa-object () 54 ((ref :initarg :cocoa-ref :accessor cocoa-ref))) 54 ((ref :initarg :cocoa-ref) 55 (ref-valid-p :initform t :accessor cocoa-ref-valid-p))) 56 57 (defgeneric cocoa-ref (eg-object) 58 (:method ((eg-object easy-cocoa-object)) 59 (if (cocoa-ref-valid-p eg-object) 60 (slot-value eg-object 'ref) 61 (error "Attempting to access an invalidated Cocoa object on ~A!" 62 eg-object)))) 63 64 (defgeneric (setf cocoa-ref) (new eg-object) 65 (:method (new (eg-object easy-cocoa-object)) 66 (setf (cocoa-ref-valid-p eg-object) t 67 (slot-value eg-object 'ref) new))) 55 68 56 69 (defvar *window-position-default-x* 200) … … 81 94 (defun key-mask (keyword) 82 95 (or (cdr (assoc keyword *key-to-mask-alist*)) 0)) 96 97 ;;; Memory management helpers: 98 99 (defmacro maybe-invalidating-object ((eg-object) &body body) 100 `(if (= 1 (#/retainCount (cocoa-ref ,eg-object))) 101 (multiple-value-prog1 (progn ,@body) 102 (setf (cocoa-ref-valid-p ,eg-object) nil)) 103 (progn ,@body))) 104 105 (defmethod retain-object ((o easy-cocoa-object)) 106 (#/retain (cocoa-ref o))) 107 108 (defmethod release-object ((o easy-cocoa-object)) 109 (#/release (cocoa-ref o))) 110 111 (defmacro retaining-objects ((&rest eg-objects) &body body) 112 "Retains EG-OBJECTS, runs BODY forms and releases them after control 113 has left BODY." 114 (let ((objects (gensym))) 115 `(let ((,objects (list ,@eg-objects))) 116 (mapc #'retain-object ,objects) 117 (unwind-protect (progn ,@body) 118 (mapc #'release-object ,objects))))) 83 119 84 120 ;;; debug macro for #/ funcalls: -
branches/working-0711/ccl/examples/cocoa/easygui/package.lisp
r7529 r7802 5 5 #:point-x #:point-y #:rectangle-x #:rectangle-y #:rectangle-width 6 6 #:rectangle-height 7 ;; cocoa stuff 8 #:retain-object #:release-object #:retaining-objects 7 9 ;; view classes 8 10 #:view #:static-text-view #:text-input-view #:password-input-view … … 13 15 ;; operators 14 16 #:cocoa-ref 15 #:add-subviews #: window-show #:set-window-title17 #:add-subviews #:remove-subviews #:window-show #:set-window-title 16 18 #:content-view 17 19 #:initialize-view #:action #:view-text 18 20 #:add-entry #:add-entries #:editable-p 19 21 #:draw-view-rectangle 20 #:entry-text #: nth-cell #:selection #:redisplay22 #:entry-text #:cell-count #:nth-cell #:selection #:redisplay 21 23 #:string-value-of #:integer-value-of #:float-value-of 22 24 #:double-value-of)) -
branches/working-0711/ccl/examples/cocoa/easygui/views.lisp
r7529 r7802 11 11 (:documentation "Adds a subview to another view in the view hierarchy.")) 12 12 13 (defgeneric remove-1-subview (view super-view) 14 (:documentation "Removes a view from its superview, possibly deallocating it. 15 To avoid deallocation, use RETAINING-OBJECTS")) 13 16 14 17 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; … … 147 150 ()) 148 151 149 (defclass box-view (content-view-mixin view ) ())152 (defclass box-view (content-view-mixin view-text-via-title-mixin view) ()) 150 153 151 154 (defclass drawing-view (view) … … 306 309 superview) 307 310 311 (defmethod remove-1-subview ((view view) (cw-view content-view-mixin)) 312 (remove-1-subview view (content-view cw-view))) 313 314 (defmethod remove-1-subview ((view view) (super-view view)) 315 (assert (eql (cocoa-ref super-view) (#/superview (cocoa-ref view)))) 316 (maybe-invalidating-object (view) 317 (#/removeFromSuperview (cocoa-ref view)))) 318 319 (defun remove-subviews (superview subview &rest subviews) 320 (remove-1-subview subview superview) 321 (dolist (subview subviews) 322 (remove-1-subview subview superview)) 323 superview) 324 308 325 (defmethod window-show ((window window)) 309 326 (dcc (#/makeKeyAndOrderFront: (cocoa-ref window) nil)) … … 323 340 (slot-value view 'autosize-cells-p))))) 324 341 342 (defmethod cell-count ((view form-view)) 343 (dcc (#/numberOfRows (cocoa-ref view)))) 344 325 345 (defmethod nth-cell (index view) 346 (assert (< index (cell-count view))) 326 347 (let ((cocoa-cell (dcc (#/cellAtIndex: (cocoa-ref view) index)))) 327 348 (when cocoa-cell
Note:
See TracChangeset
for help on using the changeset viewer.
