Mercurial > gui
annotate datebox.ur @ 31:b5432d74841a
Update for key/mouse handler change
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 21 Jul 2012 10:15:14 -0400 |
parents | 5905b56e0cd9 |
children |
rev | line source |
---|---|
adam@20 | 1 type t = {Cal : Calendar.t, |
adam@27 | 2 Panel : TogglePanel.togglePanel Calendar.t body'} |
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 |
adam@27 | 10 val format : TogglePanel.formatCtl body' = fn [[Dyn] ~ body'] => |
adam@20 | 11 TogglePanel.defaultFormat |
adam@20 | 12 -- #OpenCtl -- #CloseCtl |
adam@31 | 13 ++ {OpenCtl = fn behaviour => <xml><button value="Choose" onclick={fn _ => behaviour}/></xml>, |
adam@31 | 14 CloseCtl = fn behaviour => <xml><button value="Hide" onclick={fn _ => behaviour}/></xml>} |
adam@3 | 15 |
adam@4 | 16 fun create tm = |
kkallio@14 | 17 cal <- Calendar.create tm; |
adam@20 | 18 panel <- TogglePanel.create @format cal False; |
adam@2 | 19 |
kkallio@14 | 20 return {Cal = cal, |
kkallio@14 | 21 Panel = panel} |
adam@2 | 22 |
adam@15 | 23 fun onChange db f = |
adam@15 | 24 Calendar.onChange db.Cal f |
adam@4 | 25 |
kkallio@14 | 26 fun set db day = |
kkallio@14 | 27 Calendar.set db.Cal day |
kkallio@12 | 28 |
kkallio@14 | 29 fun value db = Calendar.value db.Cal |
kkallio@12 | 30 |
adam@27 | 31 val gui_t = Gui.mkGui (fn [[Dyn] ~ body'] db => |
kkallio@12 | 32 <xml> |
kkallio@14 | 33 <dyn signal={date <- Calendar.value db.Cal; |
kkallio@14 | 34 return <xml>{[date.Year]}-{[date.Month]}-{[date.Day]}</xml>}/> |
kkallio@14 | 35 {Gui.toXml db.Panel} |
adam@20 | 36 </xml>) |