kkallio@8
|
1 (* TogglePanel provides a panel or section of xml which appears and
|
kkallio@8
|
2 * disappears when the user activates an associated control. The
|
kkallio@8
|
3 * panel may contain another gui widget as content. *)
|
kkallio@8
|
4
|
rmbruijn@19
|
5 con togglePanel :: Type -> {Unit} -> Type
|
adam@20
|
6 (* The type of appearing and disappearing panels. The arguments
|
adam@20
|
7 * are as for [Gui.gui]. *)
|
kkallio@8
|
8
|
adam@20
|
9 con formatCtl = fn ctx :: {Unit} => [body ~ ctx] =>
|
adam@20
|
10 {FormatPanel : xbody -> xbody -> xml (body ++ ctx) [] [],
|
adam@20
|
11 (* Allows for formatting the panel. The first two parameters
|
adam@20
|
12 * represent "holes" for the control and panel respectively while
|
adam@20
|
13 * the result should be the desired XML laying out the whole structure.
|
adam@20
|
14 * The controls can be formatted with the options below.
|
adam@20
|
15 * The panel part appears and disappears according to the use
|
adam@20
|
16 * of the controls. *)
|
adam@20
|
17
|
adam@20
|
18 OpenCtl : transaction unit -> xbody,
|
adam@20
|
19 (* This should accept the transaction representing the opening of
|
adam@20
|
20 * the panel and produce an XML control having this as action. *)
|
rmbruijn@19
|
21
|
adam@20
|
22 CloseCtl : transaction unit -> xbody}
|
adam@20
|
23 (* This should accept the transaction representing the closing of
|
adam@20
|
24 * the panel and produce an xml control having this as action. *)
|
kkallio@8
|
25
|
kkallio@8
|
26 (* Some reasonable default formats for the layout and controls. *)
|
adam@20
|
27 val defaultFormat : formatCtl []
|
kkallio@8
|
28
|
adam@20
|
29 val create : t ::: Type -> ctx ::: {Unit} ->
|
adam@20
|
30 formatCtl ctx (* Formatting instructions *)
|
adam@20
|
31 -> t (* Enclosed widget *)
|
adam@20
|
32 -> bool (* Start in open state? *)
|
adam@20
|
33 -> transaction (togglePanel t ctx)
|
kkallio@8
|
34
|
adam@20
|
35 val gui_togglePanel : t ::: Type -> ctx ::: {Unit}
|
adam@20
|
36 -> Gui.gui t ctx
|
adam@20
|
37 -> Gui.gui (togglePanel t ctx) ctx
|
kkallio@8
|
38 (* The togglePanel is itself a widget. It can be pretty printed to a piece
|
adam@20
|
39 * of XML with a use of [toXml]. *)
|