;;==================================================
;; DEMONSTRACE


(defclass color-changing-window (window)
  ((cb :initform (move (make-instance 'combobox)  30 30))))


(defmethod cb ((ccw color-changing-window))
  (slot-value ccw 'cb))

(defmethod ev-item-selected-cb1 ((ccw color-changing-window) sender item)
  (cond 
   ((= (index item) 0) (set-background ccw :yellow))
   ((= (index item) 1) (set-background ccw :green))
   ((= (index item) 2) (set-background ccw :red))
   ((= (index item) 3) (set-background ccw :blue))
   ((= (index item) 4) (set-background ccw :purple))
   ((= (index item) 5) (set-background ccw :brown))))
;; slo by sice napsat 
;; (set-background ccw (nth (index item) (list ...)))
;; ale nechame to pro prehlednost takto

(defmethod initialize-instance ((ccw color-changing-window)&key)
  (call-next-method)

  (set-background ccw :black)

  (set-items (itemlist (cb ccw)) (mapcar #'make-list-item 
                                         (list "yellow"
                                               "green"
                                               "red"
                                               "blue"
                                               "purple"
                                               "brown")))

  (set-shape ccw (cb ccw))
  (add-event (cb ccw) '(ev-item-selected ev-item-selected-cb1)))

(make-instance 'color-changing-window)

