{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses , TemplateHaskell, UndecidableInstances #-} module WidgetList where import Graphics.UI.WxGeneric import Graphics.UI.WxGeneric.Composite import Graphics.UI.SybWidget.MySYB import Graphics.UI.WX import Graphics.UI.WXCore data Activity = Activities Activity [String] Activity | Activity String deriving (Show, Eq) data Minutes = Minutes Int deriving (Show, Eq) data Alarm = Alarm { location :: String , timeOfDay :: Minutes , activity :: Activity } deriving (Show, Eq) $(derive [''Minutes,''Alarm,''Activity]) instance WxGen Alarm instance WxGen Minutes instance WxGen Activity aAlarm :: Alarm aAlarm = Alarm "My alarm" (Minutes 117) $ Activities (Activity "Foo") ["bar"] (Activity "Foobar") main :: IO () main = start $ do f <- frame [ text := "Alarm Example" ] p <- panel f [] en <- genericWidget p aAlarm -- 234::Int, [ "Foo", "Bar" ]) toColor <- variable [ value := 0 ] timer f [ interval := 500 , on command := do cs <- fmap depthFirstTraversal $ get en widgetTree toDrop <- get toColor value mapM_ (\wid -> set wid [ bgcolor := colorFromInt 0xffffff ]) cs case drop toDrop cs of [] -> set toColor [ value := 0 ] x:_ -> do set x [ bgcolor := colorFromInt 0xff0000 ] set toColor [ value := toDrop + 1 ] ] b <- button p [ text := "&Print alarm" , on command := get en widgetValue >>= print ] set f [ layout := container p $ row 10 [ widget en, vfloatCenter $ widget b ] ]