|Version 12 (modified by alms, 6 years ago) (diff)|
Easy GUI Currency Converter
Easy GUI is a high-level interface for creating windows, dialogs, menus, and simple graphics. This example implements the end-user functionality of Apple's Currency Converter example, but it uses Easy GUI rather than Cocoa. It does not duplicate the Model-View-Controller implementation used by the Cocoa example.
(in-package :easygui-user) (defclass converter-window (window) () (:default-initargs :size (point 383 175) :position (point 125 513) :title "Currency Converter" :resizable-p nil :minimizable-p t)) (defmethod initialize-view :after ((cw converter-window)) (let* ((currency-form (make-instance 'form-view :autosize-cells-p t :interline-spacing 9.0 :position (point 15 70) :size (point 353 90))) (convert-button (make-instance 'push-button-view :default-button-p t :text "Convert" :position (point 247 15))) (line (make-instance 'box-view :position (point 15 59) :size (point 353 2))) (entries (add-entries currency-form "Exchange Rate per $1:" "Dollars to Convert:" "Amount in other Currency:"))) (setf (action convert-button) #'(lambda () (let ((n1 (read-from-string (entry-text currency-form 1) nil nil)) (n2 (read-from-string (entry-text currency-form 0) nil nil))) (when (and (numberp n1) (numberp n2)) (setf (entry-text currency-form 2) (prin1-to-string (* n1 n2))))))) (setf (editable-p (car (last entries))) nil) (add-subviews cw currency-form line convert-button) (window-show cw))) ;(make-instance 'converter-window)