view togglePanel.urs @ 8:90be8b8917d5

Add a widget that opens and closes a panel.
author Karn Kallio <kkallio@eka>
date Fri, 17 Jun 2011 10:12:05 -0430
parents
children 16447dc6a68c
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 -> 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 -> Gui.gui (togglePanel t)
(* The togglePanel is itself a widget.  It can be pretty printed to a piece
 * of xml with a use of toXml. *)