annotate examples/togglepanel.ur @ 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 554e342665fe
rev   line source
kkallio@8 1 open Gui
kkallio@8 2 open TogglePanel
kkallio@8 3
kkallio@8 4 val defaultContent : xbody = <xml><p>Here I am inside the panel.<br/><b>Default format</b></p></xml>
kkallio@8 5 val otherContent : xbody = <xml><p>Here I am inside the panel.<br/><b>Other format</b></p></xml>
kkallio@8 6
kkallio@8 7 val otherFormat = {FormatPanel = fn ctl panel => <xml><span>A Custom {ctl} Format</span>{panel}</xml>,
kkallio@8 8 OpenCtl = fn behaviour => <xml><a href={bless "http://#"} onclick={behaviour}>View</a></xml>,
kkallio@8 9 CloseCtl = fn behaviour => <xml><a href={bless "http://#"} onclick={behaviour}>Hide</a></xml>}
kkallio@8 10
kkallio@8 11 fun main () =
kkallio@8 12
kkallio@8 13 defaultFormatPanel <- create defaultFormat defaultContent True;
kkallio@8 14 otherFormatPanel <- create otherFormat otherContent False;
kkallio@8 15
kkallio@8 16 return <xml>
kkallio@8 17 <head>
kkallio@8 18 <title>A panel that can be shown or hidden.</title>
kkallio@8 19 </head>
kkallio@8 20 <body>
kkallio@8 21 <h1>Example using the togglePanel widget.</h1>
kkallio@8 22 <p>
kkallio@8 23 This is a widget which has a content display panel
kkallio@8 24 which can be shown or hidden.
kkallio@8 25 </p>
kkallio@8 26 <h2>Example of the default format, starting open.</h2>
kkallio@8 27 <p>
kkallio@8 28 {toXml defaultFormatPanel}
kkallio@8 29 </p>
kkallio@8 30 <h2>Example of another format, starting closed.</h2>
kkallio@8 31 <p>
kkallio@8 32 {toXml otherFormatPanel}
kkallio@8 33 </p>
kkallio@8 34 </body>
kkallio@8 35 </xml>