kkallio@6: (* NAVBAR provides services to construct and pretty print to xml typical kkallio@6: * menu items (of a visible text and a url link) and menu bars assembled kkallio@6: * from them. It is intended to be used as a low-level component in kkallio@6: * constructing navigation related widgets and theme parts. *) kkallio@6: kkallio@6: type navItem kkallio@6: (* Items in the navigation menu. *) kkallio@6: kkallio@6: con navBar :: Type -> Type kkallio@6: (* A menu bar of navigation links. Up to one link may be active. *) kkallio@6: kkallio@6: type build kkallio@6: type print kkallio@6: (* These track the current navbar mode. *) kkallio@6: kkallio@6: class mode kkallio@6: (* To make sure we always print the navbar correctly. *) kkallio@6: kkallio@6: val navToXml_build : mode build kkallio@6: val navToXml_print : mode print kkallio@6: (* How to print both modes. *) kkallio@6: kkallio@6: val printingNavBar : navBar build -> navBar print kkallio@6: (* This switches the navbar from building mode to printing mode. Normally not kkallio@6: * necessary to call this, but is in the signature in case the programmer will kkallio@6: * pass the same navbar to several components wanting to print it. Then by kkallio@6: * using this first multiple (redundant) calls to List.rev can be avoided. kkallio@6: * Mode tracking makes this optimization safe. *) kkallio@6: kkallio@6: val emptyNavBar : navBar build kkallio@6: (* An empty menu bar. *) kkallio@6: kkallio@6: val mkNavItem : string -> url -> navItem kkallio@6: (* Make a menu item with visible text given by the string and linking to url. *) kkallio@6: kkallio@6: val navAdd : navItem -> navBar build -> navBar build kkallio@6: (* Add an unactive item to the right end of the navbar. *) kkallio@6: kkallio@6: val navAddActive : navItem -> navBar build -> navBar build kkallio@6: (* Add an active item to the right end of the navbar. If there already kkallio@6: * was an active item it will be deactivated. *) kkallio@6: kkallio@6: val navItemToXml : option css_class -> navItem -> xbody kkallio@6: (* Pretty print a navItem with an optional style to a piece of ... xml. *) kkallio@6: kkallio@6: val navBarToXml : t ::: Type -> mode t -> navBar t -> xbody kkallio@6: (* Pretty print the navigation menu as a piece of xml made of kkallio@6: * a chain