source: branches/ppc-purge/source/examples/cocoa/easygui/example/currency-converter.lisp

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

Import from trunk.

File size: 1.7 KB
Line 
1(in-package :easygui-demo)
2
3(defclass converter-window (window)
4 ()
5 (:default-initargs :size (point 383 175)
6 :position (point 125 513)
7 :title "Currency Converter"
8 :resizable-p nil
9 :minimizable-p t))
10
11(defmethod initialize-view :after ((cw converter-window))
12 (let ((currency-form (make-instance 'form-view
13 :autosize-cells-p t
14 :interline-spacing 9.0
15 :position (point 15 70)
16 :size (point 353 90)))
17 (convert-button (make-instance 'push-button-view
18 :default-button-p t
19 :text "Convert"
20 :position (point 247 15)))
21 (line (make-instance 'box-view
22 :position (point 15 59)
23 :size (point 353 2))))
24 (setf (action convert-button)
25 #'(lambda ()
26 (let ((exchange-rate (read-from-string
27 (entry-text currency-form 1) nil nil))
28 (amount (read-from-string (entry-text currency-form 0)
29 nil nil)))
30 (when (and (numberp exchange-rate) (numberp amount))
31 (setf (entry-text currency-form 2)
32 (prin1-to-string (* exchange-rate amount)))))))
33 (setf (editable-p (car (last (add-entries currency-form
34 "Exchange Rate per $1:"
35 "Dollars to Convert:"
36 "Amount in other Currency:"))))
37 nil)
38 (add-subviews cw currency-form line convert-button)
39 (window-show cw)))
40
41;(make-instance 'converter-window)
Note: See TracBrowser for help on using the repository browser.