source: release/1.5/source/contrib/krueger/InterfaceProjects/Controller Test 1/controller-test1.lisp

Last change on this file was 13631, checked in by Paul Krueger, 15 years ago

Version 2 of InterfaceProjects

File size: 2.2 KB
Line 
1;; controller-test1.lisp
2
3;; Test window that displays lisp lists using an NSTableView
4
5(eval-when (:compile-toplevel :load-toplevel :execute)
6 (require :lisp-controller)
7 (require :ns-string-utils)
8 (require :nslog-utils)
9 (require :date))
10
11(defpackage :controller-test1
12 (:nicknames :ct1)
13 (:use :ccl :common-lisp :iu :lc)
14 (:export test-controller get-root))
15
16(in-package :ct1)
17
18(defclass lisp-controller-test (ns:ns-window-controller)
19 ((lisp-ctrl :foreign-type :id :accessor lisp-ctrl))
20 (:metaclass ns:+ns-object))
21
22(defmethod get-root ((self lisp-controller-test))
23 (when (lisp-ctrl self)
24 (root (lisp-ctrl self))))
25
26(objc:defmethod (#/initWithNibPath: :id)
27 ((self lisp-controller-test) (nib-path :id))
28 (let* ((init-self (#/initWithWindowNibPath:owner: self nib-path self)))
29 init-self))
30
31(defun make-dated-list ()
32 (list (now) 0 (random 20) (random 30)))
33
34(defun selected-cell (window controller root row-num col-num obj)
35 (declare (ignore window controller root))
36 (cond ((and (minusp row-num) (minusp col-num))
37 (ns-log "Nothing selected"))
38 ((minusp row-num)
39 (ns-log (format nil "Selected column ~s with title ~s" col-num obj)))
40 ((minusp col-num)
41 (ns-log (format nil "Selected row ~s: ~s" row-num obj)))
42 (t
43 (ns-log (format nil "Selected ~s in row ~s, col ~s" obj row-num col-num)))))
44
45(defun edited-cell (window controller root row-num col-num obj old-val new-val)
46 (declare (ignore window controller root))
47 (ns-log (format nil "Changed ~s in row ~s, col ~s: ~s to ~s"
48 old-val row-num col-num obj new-val)))
49
50(defun added-row (window controller root parent new-row)
51 (declare (ignore window controller root))
52 (ns-log (format nil "Added ~s to ~s" new-row parent)))
53
54(defun removed-row (window controller root parent old-row)
55 (declare (ignore window controller root))
56 (ns-log (format nil "Removed row ~s from ~s " old-row parent)))
57
58(defun test-controller ()
59 (let* ((nib-name (lisp-to-temp-nsstring
60 (namestring (truename "ip:Controller Test 1;lc-test1.nib"))))
61 (wc (make-instance 'lisp-controller-test
62 :with-nib-path nib-name)))
63 (#/window wc)
64 wc))
65
66(provide :controller-test1)
Note: See TracBrowser for help on using the repository browser.