Mercurial > gui
view 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 |
line wrap: on
line source
type t = {Cal : Calendar.t, Panel : TogglePanel.togglePanel Calendar.t} type date = Calendar.date val date_eq = Calendar.date_eq val date_ord = Calendar.date_ord val time = Calendar.time val date = Calendar.date val format = TogglePanel.defaultFormat --#OpenCtl -- #CloseCtl ++ {OpenCtl = fn behaviour => <xml><button value="Choose" onclick={behaviour}/></xml>, CloseCtl = fn behaviour => <xml><button value="Hide" onclick={behaviour}/></xml>} fun create tm = cal <- Calendar.create tm; panel <- TogglePanel.create format cal False; return {Cal = cal, Panel = panel} fun addListener f db = Calendar.addListener f db.Cal fun set db day = Calendar.set db.Cal day fun value db = Calendar.value db.Cal fun render db = <xml> <dyn signal={date <- Calendar.value db.Cal; return <xml>{[date.Year]}-{[date.Month]}-{[date.Day]}</xml>}/> {Gui.toXml db.Panel} </xml>