view 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
line wrap: on
line source
(* TogglePanel provides a panel or section of xml which appears and
 * disappears when the user activates an associated control.  The
 * panel may contain another gui widget as content. *)

con togglePanel :: Type -> {Unit} -> Type
(* The type of appearing and disappearing panels.  The argument
 * is the type of the content. *)

con formatCtl :: {Unit} -> Type 

(* type formatCtl = {FormatPanel : xbody -> xbody -> xbody, *)
(*                   (\* Allows for formatting the panel.  The first two parameters *)
(*                    * represent "holes" for the control and panel respectively while *)
(*                    * the result should be the desired xml laying out the whole structure. *)
(*                    * The controls can be formatted with the options below. *)
(*                    * The panel part appears and disappears according to the use  *)
(*                    * of the controls. *\) *)
                  
(*                   OpenCtl : transaction unit -> xbody, *)
(*                   (\* This should accept the transaction representing the opening of *)
(*                    * the panel and produce an xml control having this as action. *\) *)

(*                   CloseCtl : transaction unit -> xbody} *)
(*                   (\* This should accept the transaction representing the closing of *)
(*                    * the panel and produce an xml control having this as action. *\) *)

(* Some reasonable default formats for the layout and controls. *)
val defaultFormat :  other_ctx:::{Unit} -> [other_ctx ~ body] => formatCtl other_ctx

val create : t ::: Type -> other_ctx:::{Unit} -> [other_ctx ~ body] => 
    Gui.gui t (xml ([Body] ++ other_ctx) [] []) -> formatCtl other_ctx -> t -> bool -> transaction (togglePanel t other_ctx)
(* Given instructions for formatting the display, some content and whether to start in
 * the open state get such a togglePanel. *)

val gui_togglePanel : t ::: Type ->  other_ctx:::{Unit} -> [other_ctx ~ body] => 
    Gui.gui t (xml ([Body] ++ other_ctx) [] []) -> Gui.gui (togglePanel t other_ctx) (xml ([Body] ++ other_ctx) [] [])
(* The togglePanel is itself a widget.  It can be pretty printed to a piece
 * of xml with a use of toXml. *)