Mercurial > gui
annotate datebox.ur @ 14:0827320b0f04
Write calendarCtl in terms of a source with a listener.
author | Karn Kallio <kkallio@eka> |
---|---|
date | Fri, 05 Aug 2011 18:55:24 -0430 |
parents | c016beb0ebac |
children | 8300d5f0dc19 |
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 |
kkallio@14 | 22 fun addListener f db = |
kkallio@14 | 23 Calendar.addListener f db.Cal |
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> |