annotate togglePanel.urs @ 27:5905b56e0cd9

Adapt to new HTML contexts
author Adam Chlipala <adam@chlipala.net>
date Tue, 20 Dec 2011 21:04:21 -0500
parents 30f9a763f5fb
children 7d0014542199
rev   line source
kkallio@8 1 (* TogglePanel provides a panel or section of xml which appears and
kkallio@8 2 * disappears when the user activates an associated control. The
kkallio@8 3 * panel may contain another gui widget as content. *)
kkallio@8 4
rmbruijn@19 5 con togglePanel :: Type -> {Unit} -> Type
adam@20 6 (* The type of appearing and disappearing panels. The arguments
adam@20 7 * are as for [Gui.gui]. *)
kkallio@8 8
adam@27 9 con formatCtl = fn ctx :: {Unit} => [[Dyn] ~ ctx] =>
adam@27 10 {FormatPanel : xml ([Dyn] ++ ctx) [] []
adam@27 11 -> xml ([Dyn] ++ ctx) [] []
adam@27 12 -> xml ([Dyn] ++ ctx) [] [],
adam@20 13 (* Allows for formatting the panel. The first two parameters
adam@20 14 * represent "holes" for the control and panel respectively while
adam@20 15 * the result should be the desired XML laying out the whole structure.
adam@20 16 * The controls can be formatted with the options below.
adam@20 17 * The panel part appears and disappears according to the use
adam@20 18 * of the controls. *)
adam@20 19
adam@27 20 OpenCtl : transaction unit -> xml ([Dyn] ++ ctx) [] [],
adam@20 21 (* This should accept the transaction representing the opening of
adam@20 22 * the panel and produce an XML control having this as action. *)
rmbruijn@19 23
adam@27 24 CloseCtl : transaction unit -> xml ([Dyn] ++ ctx) [] []}
adam@20 25 (* This should accept the transaction representing the closing of
adam@20 26 * the panel and produce an xml control having this as action. *)
kkallio@8 27
kkallio@8 28 (* Some reasonable default formats for the layout and controls. *)
adam@27 29 val defaultFormat : formatCtl body'
kkallio@8 30
adam@20 31 val create : t ::: Type -> ctx ::: {Unit} ->
adam@27 32 formatCtl ctx (* Formatting instructions *)
adam@20 33 -> t (* Enclosed widget *)
adam@20 34 -> bool (* Start in open state? *)
adam@20 35 -> transaction (togglePanel t ctx)
kkallio@8 36
adam@20 37 val gui_togglePanel : t ::: Type -> ctx ::: {Unit}
adam@20 38 -> Gui.gui t ctx
adam@20 39 -> Gui.gui (togglePanel t ctx) ctx
kkallio@8 40 (* The togglePanel is itself a widget. It can be pretty printed to a piece
adam@20 41 * of XML with a use of [toXml]. *)