diff togglePanel.urs @ 20:554e342665fe

Add a new parameter to Gui.gui
author Adam Chlipala <adam@chlipala.net>
date Sat, 24 Sep 2011 15:47:00 -0400
parents 3a303df9ae92
children 30f9a763f5fb
line wrap: on
line diff
--- a/togglePanel.urs	Fri Sep 23 13:30:01 2011 +0200
+++ b/togglePanel.urs	Sat Sep 24 15:47:00 2011 -0400
@@ -3,36 +3,37 @@
  * panel may contain another gui widget as content. *)
 
 con togglePanel :: Type -> {Unit} -> Type
-(* The type of appearing and disappearing panels.  The argument
- * is the type of the content. *)
+(* The type of appearing and disappearing panels.  The arguments
+ * are as for [Gui.gui]. *)
 
-con formatCtl :: {Unit} -> Type 
+con formatCtl = fn ctx :: {Unit} => [body ~ ctx] =>
+                   {FormatPanel : xbody -> xbody -> xml (body ++ ctx) [] [],
+                    (* Allows for formatting the panel.  The first two parameters
+                     * represent "holes" for the control and panel respectively while
+                     * the result should be the desired XML laying out the whole structure.
+                     * The controls can be formatted with the options below.
+                     * The panel part appears and disappears according to the use
+                     * of the controls. *)
+                  
+                    OpenCtl : transaction unit -> xbody,
+                    (* This should accept the transaction representing the opening of
+                     * the panel and produce an XML control having this as action. *)
 
-(* type formatCtl = {FormatPanel : xbody -> xbody -> xbody, *)
-(*                   (\* Allows for formatting the panel.  The first two parameters *)
-(*                    * represent "holes" for the control and panel respectively while *)
-(*                    * the result should be the desired xml laying out the whole structure. *)
-(*                    * The controls can be formatted with the options below. *)
-(*                    * The panel part appears and disappears according to the use  *)
-(*                    * of the controls. *\) *)
-                  
-(*                   OpenCtl : transaction unit -> xbody, *)
-(*                   (\* This should accept the transaction representing the opening of *)
-(*                    * the panel and produce an xml control having this as action. *\) *)
-
-(*                   CloseCtl : transaction unit -> xbody} *)
-(*                   (\* This should accept the transaction representing the closing of *)
-(*                    * the panel and produce an xml control having this as action. *\) *)
+                    CloseCtl : transaction unit -> xbody}
+                    (* This should accept the transaction representing the closing of
+                     * the panel and produce an xml control having this as action. *)
 
 (* Some reasonable default formats for the layout and controls. *)
-val defaultFormat :  other_ctx:::{Unit} -> [other_ctx ~ body] => formatCtl other_ctx
+val defaultFormat : formatCtl []
 
-val create : t ::: Type -> other_ctx:::{Unit} -> [other_ctx ~ body] => 
-    Gui.gui t (xml ([Body] ++ other_ctx) [] []) -> formatCtl other_ctx -> t -> bool -> transaction (togglePanel t other_ctx)
-(* Given instructions for formatting the display, some content and whether to start in
- * the open state get such a togglePanel. *)
+val create : t ::: Type -> ctx ::: {Unit} ->
+    formatCtl ctx (* Formatting instructions *)
+    -> t             (* Enclosed widget *)
+    -> bool          (* Start in open state? *)
+    -> transaction (togglePanel t ctx)
 
-val gui_togglePanel : t ::: Type ->  other_ctx:::{Unit} -> [other_ctx ~ body] => 
-    Gui.gui t (xml ([Body] ++ other_ctx) [] []) -> Gui.gui (togglePanel t other_ctx) (xml ([Body] ++ other_ctx) [] [])
+val gui_togglePanel : t ::: Type -> ctx ::: {Unit}
+                      -> Gui.gui t ctx
+                      -> Gui.gui (togglePanel t ctx) ctx
 (* The togglePanel is itself a widget.  It can be pretty printed to a piece
- * of xml with a use of toXml. *)
+ * of XML with a use of [toXml]. *)