Mercurial > gui
annotate datebox.ur @ 18:16447dc6a68c
Introduction of multi-parameter type class for gui components
author | Ron de Bruijn <rmbruijn@gmail.com> |
---|---|
date | Thu, 22 Sep 2011 19:24:01 +0200 |
parents | 8300d5f0dc19 |
children | 3a303df9ae92 |
rev | line source |
---|---|
kkallio@14 | 1 type t = {Cal : Calendar.t, |
kkallio@14 | 2 Panel : TogglePanel.togglePanel Calendar.t} |
adam@2 | 3 |
kkallio@14 | 4 type date = Calendar.date |
kkallio@14 | 5 val date_eq = Calendar.date_eq |
kkallio@14 | 6 val date_ord = Calendar.date_ord |
kkallio@14 | 7 val time = Calendar.time |
kkallio@14 | 8 val date = Calendar.date |
adam@2 | 9 |
kkallio@14 | 10 val format = TogglePanel.defaultFormat |
kkallio@14 | 11 --#OpenCtl -- #CloseCtl |
kkallio@14 | 12 ++ {OpenCtl = fn behaviour => <xml><button value="Choose" onclick={behaviour}/></xml>, |
kkallio@14 | 13 CloseCtl = fn behaviour => <xml><button value="Hide" onclick={behaviour}/></xml>} |
adam@3 | 14 |
adam@4 | 15 fun create tm = |
kkallio@14 | 16 cal <- Calendar.create tm; |
kkallio@14 | 17 panel <- TogglePanel.create format cal False; |
adam@2 | 18 |
kkallio@14 | 19 return {Cal = cal, |
kkallio@14 | 20 Panel = panel} |
adam@2 | 21 |
adam@15 | 22 fun onChange db f = |
adam@15 | 23 Calendar.onChange db.Cal f |
adam@4 | 24 |
kkallio@14 | 25 fun set db day = |
kkallio@14 | 26 Calendar.set db.Cal day |
kkallio@12 | 27 |
kkallio@14 | 28 fun value db = Calendar.value db.Cal |
kkallio@12 | 29 |
kkallio@14 | 30 fun render db = |
kkallio@12 | 31 <xml> |
kkallio@14 | 32 <dyn signal={date <- Calendar.value db.Cal; |
kkallio@14 | 33 return <xml>{[date.Year]}-{[date.Month]}-{[date.Day]}</xml>}/> |
kkallio@14 | 34 {Gui.toXml db.Panel} |
kkallio@12 | 35 </xml> |