view popupNav.urs @ 31:b5432d74841a

Update for key/mouse handler change
author Adam Chlipala <adam@chlipala.net>
date Sat, 21 Jul 2012 10:15:14 -0400
parents 48a4180171b0
children
line wrap: on
line source
(* POPUPNAV provides a simple navigation menu which opens and
 * closes when the user clicks on an associated control. *)

con popupNav :: Type -> Type
(* The type of popping open navigation menus. *)

type formatCtl = {FormatMenu : xbody -> xbody -> xbody,
                  (* Allows for formatting the menu.  The first two parameters
                   * represent "holes" for the control and menu items and
                   * the result should be the desired menu xml.  The controls
                   * can be formatted with the options below, and the menu items
                   * will be placed as a chain of <li><a> ....</a></li> wrapped
                   * as given below.  The menu part appears and disappears according
                   * to the use of the controls. *)

                   WrapMenu : xbody -> xbody,
                   (* This allows for the wrapping of menu <li> ... </li> with some
                    * chrome that will appear and disappear. *)

                  OpenCtl : transaction unit -> xbody,
                  (* This should accept the transaction representing the opening of
                   * the menu and produce an xml control having this as action. *)

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

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

val create : t ::: Type -> formatCtl -> Navbar.mode t -> Navbar.navBar t -> transaction (popupNav t)
(* Given instructions for formatting the display and a navbar, get a popup navigation. *)

val render : t ::: Type -> Navbar.mode t -> popupNav t -> xbody
(* Pretty prints a popup navigation as a piece of xml. *)