comparison togglePanel.ur @ 18:16447dc6a68c

Introduction of multi-parameter type class for gui components
author Ron de Bruijn <rmbruijn@gmail.com>
date Thu, 22 Sep 2011 19:24:01 +0200
parents 90be8b8917d5
children 3a303df9ae92
comparison
equal deleted inserted replaced
17:2947170fcfd6 18:16447dc6a68c
12 FormatCtl : formatCtl, 12 FormatCtl : formatCtl,
13 Content : t} 13 Content : t}
14 14
15 open Gui 15 open Gui
16 16
17 fun create [t ::: Type] (toXml : gui t) (f : formatCtl) (content : t) (startOpen : bool) : transaction (togglePanel t) = 17 fun create [t ::: Type] (toXml : gui t xbody) (f : formatCtl) (content : t) (startOpen : bool) : transaction (togglePanel t) =
18 state <- source (if startOpen then Open else Closed); 18 state <- source (if startOpen then Open else Closed);
19 19
20 return {PanelState = state, 20 return {PanelState = state,
21 FormatCtl = f, 21 FormatCtl = f,
22 Content = content} 22 Content = content}
23 23
24 fun render [t ::: Type] (_ : gui t) (panel : togglePanel t) = 24 fun render [t ::: Type] (_ : gui t xbody) (panel : togglePanel t) =
25 let 25 let
26 val openCtl = panel.FormatCtl.CloseCtl (set panel.PanelState Closed) 26 val openCtl = panel.FormatCtl.CloseCtl (set panel.PanelState Closed)
27 val closeCtl = panel.FormatCtl.OpenCtl (set panel.PanelState Open) 27 val closeCtl = panel.FormatCtl.OpenCtl (set panel.PanelState Open)
28 28
29 val content = toXml panel.Content 29 val content = toXml panel.Content
46 | Closed => <xml/>) 46 | Closed => <xml/>)
47 }/> 47 }/>
48 </xml> 48 </xml>
49 end 49 end
50 50
51 fun gui_togglePanel [t ::: Type] (_ : gui t) = mkGui render 51 fun gui_togglePanel [t ::: Type] (_ : gui t xbody) = mkGui render