diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/togglepanel.ur	Fri Jun 17 10:12:05 2011 -0430
@@ -0,0 +1,35 @@
+open Gui
+open TogglePanel
+
+val defaultContent : xbody = <xml><p>Here I am inside the panel.<br/><b>Default format</b></p></xml>
+val otherContent : xbody = <xml><p>Here I am inside the panel.<br/><b>Other format</b></p></xml>
+
+val otherFormat = {FormatPanel = fn ctl panel => <xml><span>A Custom {ctl} Format</span>{panel}</xml>,
+                   OpenCtl = fn behaviour => <xml><a href={bless "http://#"} onclick={behaviour}>View</a></xml>,
+                   CloseCtl = fn behaviour => <xml><a href={bless "http://#"} onclick={behaviour}>Hide</a></xml>}
+
+fun main () =
+
+    defaultFormatPanel <- create defaultFormat defaultContent True;
+    otherFormatPanel <- create otherFormat otherContent False;
+
+    return <xml>
+      <head>
+        <title>A panel that can be shown or hidden.</title>
+      </head>
+      <body>
+        <h1>Example using the togglePanel widget.</h1>
+        <p>
+          This is a widget which has a content display panel
+          which can be shown or hidden.
+        </p>
+        <h2>Example of the default format, starting open.</h2>
+        <p>
+          {toXml defaultFormatPanel}
+        </p>
+        <h2>Example of another format, starting closed.</h2>
+        <p>
+          {toXml otherFormatPanel}
+        </p>
+      </body>
+    </xml>