Mercurial > gui
view navbar.urs @ 30:c1f06342c81f
Add margin example
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 12 May 2012 10:07:45 -0400 |
parents | d314d2ec3300 |
children |
line wrap: on
line source
(* NAVBAR provides services to construct and pretty print to xml typical * menu items (of a visible text and a url link) and menu bars assembled * from them. It is intended to be used as a low-level component in * constructing navigation related widgets and theme parts. *) type navItem (* Items in the navigation menu. *) con navBar :: Type -> Type (* A menu bar of navigation links. Up to one link may be active. *) type build type print (* These track the current navbar mode. *) class mode (* To make sure we always print the navbar correctly. *) val navToXml_build : mode build val navToXml_print : mode print (* How to print both modes. *) val printingNavBar : navBar build -> navBar print (* This switches the navbar from building mode to printing mode. Normally not * necessary to call this, but is in the signature in case the programmer will * pass the same navbar to several components wanting to print it. Then by * using this first multiple (redundant) calls to List.rev can be avoided. * Mode tracking makes this optimization safe. *) val emptyNavBar : navBar build (* An empty menu bar. *) val mkNavItem : string -> url -> navItem (* Make a menu item with visible text given by the string and linking to url. *) val navAdd : navItem -> navBar build -> navBar build (* Add an unactive item to the right end of the navbar. *) val navAddActive : navItem -> navBar build -> navBar build (* Add an active item to the right end of the navbar. If there already * was an active item it will be deactivated. *) val navItemToXml : option css_class -> navItem -> xbody (* Pretty print a navItem with an optional style to a piece of <a>...</a> xml. *) val navBarToXml : t ::: Type -> mode t -> navBar t -> xbody (* Pretty print the navigation menu as a piece of xml made of * a chain <li><a>...</a></li> repeated. *) val name : navItem -> string (* navItems have a name, which this function returns *) style active style last (* CSS classes to mark the active and last menu item. *)