view togglePanel.urs @ 18:16447dc6a68c

Introduction of multi-parameter type class for gui components
author Ron de Bruijn <rmbruijn@gmail.com>
date Thu, 22 Sep 2011 19:24:01 +0200
parents 90be8b8917d5
children 3a303df9ae92
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 -> Type
(* The type of appearing and disappearing panels.  The argument
 * is the type of the content. *)

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. *)

val defaultFormat : formatCtl
(* Some reasonable default formats for the layout and controls. *)

val create : t ::: Type ->  Gui.gui t xbody -> formatCtl -> t -> bool -> transaction (togglePanel t)
(* 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 -> Gui.gui t xbody -> Gui.gui (togglePanel t) xbody
(* The togglePanel is itself a widget.  It can be pretty printed to a piece
 * of xml with a use of toXml. *)