annotate togglePanel.urs @ 19:3a303df9ae92

Partial generalize togglePanel solution (breaks build)
author Ron de Bruijn <rmbruijn@gmail.com>
date Fri, 23 Sep 2011 13:30:01 +0200
parents 16447dc6a68c
children 554e342665fe
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
kkallio@8 6 (* The type of appearing and disappearing panels. The argument
kkallio@8 7 * is the type of the content. *)
kkallio@8 8
rmbruijn@19 9 con formatCtl :: {Unit} -> Type
rmbruijn@19 10
rmbruijn@19 11 (* type formatCtl = {FormatPanel : xbody -> xbody -> xbody, *)
rmbruijn@19 12 (* (\* Allows for formatting the panel. The first two parameters *)
rmbruijn@19 13 (* * represent "holes" for the control and panel respectively while *)
rmbruijn@19 14 (* * the result should be the desired xml laying out the whole structure. *)
rmbruijn@19 15 (* * The controls can be formatted with the options below. *)
rmbruijn@19 16 (* * The panel part appears and disappears according to the use *)
rmbruijn@19 17 (* * of the controls. *\) *)
kkallio@8 18
rmbruijn@19 19 (* OpenCtl : transaction unit -> xbody, *)
rmbruijn@19 20 (* (\* This should accept the transaction representing the opening of *)
rmbruijn@19 21 (* * the panel and produce an xml control having this as action. *\) *)
kkallio@8 22
rmbruijn@19 23 (* CloseCtl : transaction unit -> xbody} *)
rmbruijn@19 24 (* (\* This should accept the transaction representing the closing of *)
rmbruijn@19 25 (* * the panel and produce an xml control having this as action. *\) *)
kkallio@8 26
kkallio@8 27 (* Some reasonable default formats for the layout and controls. *)
rmbruijn@19 28 val defaultFormat : other_ctx:::{Unit} -> [other_ctx ~ body] => formatCtl other_ctx
kkallio@8 29
rmbruijn@19 30 val create : t ::: Type -> other_ctx:::{Unit} -> [other_ctx ~ body] =>
rmbruijn@19 31 Gui.gui t (xml ([Body] ++ other_ctx) [] []) -> formatCtl other_ctx -> t -> bool -> transaction (togglePanel t other_ctx)
kkallio@8 32 (* Given instructions for formatting the display, some content and whether to start in
kkallio@8 33 * the open state get such a togglePanel. *)
kkallio@8 34
rmbruijn@19 35 val gui_togglePanel : t ::: Type -> other_ctx:::{Unit} -> [other_ctx ~ body] =>
rmbruijn@19 36 Gui.gui t (xml ([Body] ++ other_ctx) [] []) -> Gui.gui (togglePanel t other_ctx) (xml ([Body] ++ other_ctx) [] [])
kkallio@8 37 (* The togglePanel is itself a widget. It can be pretty printed to a piece
kkallio@8 38 * of xml with a use of toXml. *)