use (setf instead of setter methods.
src/tick-tack-toe.lisp
Mon May 11 20:30:39 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* use (setf instead of setter methods.
--- old-qt.examples/src/tick-tack-toe.lisp 2014-10-30 07:38:54.000000000 +0100
+++ new-qt.examples/src/tick-tack-toe.lisp 2014-10-30 07:38:54.000000000 +0100
@@ -8,18 +8,18 @@
((board :accessor board
:initform (make-array '(3 3)))
(check :accessor check-slot))
- (:metaclass smoke::smoke-wrapper-class))
+ (:metaclass cxx:class))
(defclass chell-button (qt:push-button)
((x :reader x
:initarg :x)
(y :reader y
:initarg :y))
- (:metaclass smoke::smoke-wrapper-class))
+ (:metaclass cxx:class))
(defun update-cell (widget cell)
(when (= 0 (state cell))
- (cxx:set-text cell "X")
+ (setf (cxx:text cell) "X")
(check-end widget)
(computer-move (board widget))
(check-end widget)))
@@ -31,7 +31,7 @@
(dotimes (y 3)
(when (= 0 (state (aref board x y)))
(when (= 0 cell)
- (cxx:set-text (aref board x y) "O")
+ (setf (cxx:text (aref board x y)) "O")
(return-from top))
(decf cell)))))))
@@ -52,7 +52,7 @@
(defun reset-board (board)
(dotimes (x 3)
(dotimes (y 3)
- (cxx:set-text (aref board x y) ""))))
+ (setf (cxx:text (aref board x y)) ""))))
(defun state (cell)
@@ -94,22 +94,20 @@
(defmethod initialize-instance :after ((widget tick-tack-toe) &rest args)
(declare (ignore args))
- (setf (check-slot widget) (qt::make-slot #'(lambda ()
- (update-cell widget
- (qt:sender)))))
-
+ (setf (check-slot widget) (qt:make-slot #'(lambda ()
+ (update-cell widget
+ (qt:sender)))))
(let ((layout (make-instance 'qt:grid-layout)))
(dotimes (x (array-dimension (board widget) 0))
(dotimes (y (array-dimension (board widget) 1))
(setf (aref (board widget) x y)
(make-instance 'chell-button :x x :y y))
- (qt::connect (make-instance 'qt::qt-signal
- :sender (aref (board widget) x y)
- :name "clicked()")
- (check-slot widget))
+ (qt:connect (qt:get-signal (aref (board widget) x y)
+ "clicked()")
+ (check-slot widget))
(cxx:add-widget layout (aref (board widget) x y)
x y)))
- (cxx:set-layout widget layout)))
+ (setf (cxx:layout widget) layout)))
(defun tick-tack-toe ()
"Tick Tack Toe"