source: branches/acode-rewrite/source/examples/cocoa/easygui/example/view-hierarchy.lisp

Last change on this file was 7802, checked in by Gary Byers, 17 years ago

Import from trunk.

File size: 1.6 KB
Line 
1(in-package :easygui-user)
2
3(defclass view-hierarchy-demo-window (window)
4 ()
5 (:default-initargs :size (point 480 270)
6 :position (point 125 513)
7 :resizable-p nil
8 :minimizable-p t
9 :title "View tree demo")
10 (:documentation "Shows a window with a simple view hierarchy and a button
11action that manipulates this hierarchy."))
12
13(defmethod initialize-view :after ((w view-hierarchy-demo-window))
14 (let ((left-box (make-instance 'box-view
15 :position (point 17 51)
16 :size (point 208 199)
17 :title "Left"))
18 (right-box (make-instance 'box-view
19 :position (point 255 51)
20 :size (point 208 199)
21 :title "Right"))
22 (swap-button (make-instance 'push-button-view
23 :position (point 173 12)
24 :text "Switch sides"))
25 (text (make-instance 'static-text-view
26 :text "Oink!"
27 :position (point 37 112)))
28 (leftp t))
29 (setf (action swap-button)
30 (lambda ()
31 (retaining-objects (text)
32 (cond (leftp
33 (remove-subviews left-box text)
34 (add-subviews right-box text))
35 (t
36 (remove-subviews right-box text)
37 (add-subviews left-box text))))
38 (setf leftp (not leftp))))
39 (add-subviews w left-box right-box swap-button)
40 (add-subviews left-box text)
41 (window-show w)))
42
43;;; (make-instance 'view-hierarchy-demo-window)
Note: See TracBrowser for help on using the repository browser.