Mercurial > gui
annotate datebox.ur @ 19:3a303df9ae92
Partial generalize togglePanel solution (breaks build)
author | Ron de Bruijn <rmbruijn@gmail.com> |
---|---|
date | Fri, 23 Sep 2011 13:30:01 +0200 |
parents | 8300d5f0dc19 |
children | 554e342665fe |
rev | line source |
---|---|
rmbruijn@19 | 1 con t other_ctx = {Cal : Calendar.t, |
rmbruijn@19 | 2 Panel : TogglePanel.togglePanel Calendar.t other_ctx} |
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 |
rmbruijn@19 | 10 (* : other_ctx:::{Unit} -> [other_ctx ~ body] => formatCtl other_ctx *) |
rmbruijn@19 | 11 |
rmbruijn@19 | 12 val format = TogglePanel.defaultFormat |
kkallio@14 | 13 --#OpenCtl -- #CloseCtl |
kkallio@14 | 14 ++ {OpenCtl = fn behaviour => <xml><button value="Choose" onclick={behaviour}/></xml>, |
kkallio@14 | 15 CloseCtl = fn behaviour => <xml><button value="Hide" onclick={behaviour}/></xml>} |
adam@3 | 16 |
adam@4 | 17 fun create tm = |
kkallio@14 | 18 cal <- Calendar.create tm; |
kkallio@14 | 19 panel <- TogglePanel.create format cal False; |
adam@2 | 20 |
kkallio@14 | 21 return {Cal = cal, |
kkallio@14 | 22 Panel = panel} |
adam@2 | 23 |
adam@15 | 24 fun onChange db f = |
adam@15 | 25 Calendar.onChange db.Cal f |
adam@4 | 26 |
kkallio@14 | 27 fun set db day = |
kkallio@14 | 28 Calendar.set db.Cal day |
kkallio@12 | 29 |
kkallio@14 | 30 fun value db = Calendar.value db.Cal |
kkallio@12 | 31 |
kkallio@14 | 32 fun render db = |
kkallio@12 | 33 <xml> |
kkallio@14 | 34 <dyn signal={date <- Calendar.value db.Cal; |
kkallio@14 | 35 return <xml>{[date.Year]}-{[date.Month]}-{[date.Day]}</xml>}/> |
kkallio@14 | 36 {Gui.toXml db.Panel} |
kkallio@12 | 37 </xml> |