packages feed

barrie-0.4.1: demos/CalcWidget.hs

module CalcWidget where

import Barrie

import CalcState
import CalcGadget

--  Widgets are layout, without regard for underlying semantics.
--  Here, we put some buttons into a table
calcLayout :: Widget
calcLayout = vbox [ui "display" $ textLabel ""
                        ,hbox $ map digit [1,2,3] ++ [op "+" Plus]
                        ,hbox $ map digit [4,5,6] ++ [op "-" Minus]
                        ,hbox $ map digit [7,8,9] ++ [op "*" Multiply]
                        ,hbox $ digit 0 : [op "=" Equals, op "C" Clear,
                                              op "/" Divide]
                        ,hbox $ [textLabel "base 8", ui "base8" checkButton]
                  ]
     where digit n = ui (digitButtonName n) (labelButton (show n))
           op lbl fn = ui (operatorButtonName fn) (labelButton lbl)