annotate togglePanel.urs @ 21:30f9a763f5fb

Tweak TogglePanel signature
author Adam Chlipala <adam@chlipala.net>
date Sat, 24 Sep 2011 17:35:33 -0400
parents 554e342665fe
children 5905b56e0cd9
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@20 9 con formatCtl = fn ctx :: {Unit} => [body ~ ctx] =>
adam@21 10 {FormatPanel : xml (body ++ ctx) [] []
adam@21 11 -> xml (body ++ ctx) [] []
adam@21 12 -> xml (body ++ 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@21 20 OpenCtl : transaction unit -> xml (body ++ 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@21 24 CloseCtl : transaction unit -> xml (body ++ 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@20 29 val defaultFormat : formatCtl []
kkallio@8 30
adam@20 31 val create : t ::: Type -> ctx ::: {Unit} ->
adam@20 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]. *)