Go to the first, previous, next, last section, table of contents.

TopLevel abstraction

To embed a user interface component inside a window, two methods are possible:

* wopen style component
As used in the initial Hello, World example, wopen puts a component up inside a toplevel window:

wopen :: [String] -> Component (a, DisplayHandle) -> IO (a, Window)

The first argument contain the customisation options (See section Creating and customising a component for more info) to apply to the user interface component being realised in the new window. The component returns the toplevel DisplayHandle together with an arbitrary application value.
* mkDC style
create a DisplayContext, i.e., the environment all component creating functions take. The first argument is the same as for wopen, the customisation options to initially put into the DisplayContext environment.

* realiseDH env component

realiseDH :: DC -> DisplayHandle -> IO ()

The other half of mkDC, taking the DisplayContext environment and the DisplayHandle put up inside the window. The DisplayHandle will normally be the root of the hierarchy of DisplayHandles.

The use of wopen vs. the use of the mkDC/realiseDH pair is largely a question of taste, although wopen can cause some excessive plumbing as all values of interest produced within the second argument of wopen has to be passed out at the end, i.e.,


 ...
 wopen [] 
  (\ env ->
      foo env >>= \ a ->
      bar env >>= \ b ->
      ...
      return ((a,b),...)) >>= \ ((a,b),...) ->
 return ()

tedious, and slightly error prone.


Go to the first, previous, next, last section, table of contents.