#include "DRW/drwwh.h"
#include "DRW/drwWwinit.h"
#include "DRW/drwWxdata.h"
#include "DRW/drwWopenW.h"
#include "DRW/drwUopenW.h"
#include "DRW/drwWstate.h"


extern wimp_w pane1, pane2, pane3;


void drw_u_openwindow(wimp_w whan, int x, int y, wimp_w stack)

{

int w, h;

/* If main window opened then... */
/* Decide required stacking order of panes in final display. Here, it is */
/* pane3% on top, then pane2%, then pane1%, then Main%. */
/* Use calls to 'PROCwimp_openwindowat' (normally) starting with eventual */
/* topmost first (here, pane3%) opening it at 'stack%'. */
/* Then open other panes in top-to-bottom order, using adjacent higher pane */
/* handle as stack position. */
/* Don't forget to add *top-most* pane (here, pane3%) to FNuse_pane */

if (whan == pwd->uwd->barwin)
 {
  /* open pane3 in the correct stack position */

  w = drw_wimp_getwindowvisiblesize(pane3, 0);
  drw_wimp_openwindowat(pane3,
                        x - w,
                        y,
                        0,
                        0,
                        stack);

  /* open pane2 below pane3 */

  h = drw_wimp_getwindowvisiblesize(whan, 1);
  drw_wimp_openwindowat(pane2,
                        x ,
                        y - h,
                        0,
                        0,
                        stack == (wimp_w) -3 ? stack: pane3);

  /* open pane1 below pane2 */

  drw_wimp_openwindowat(pane1,
                        x,
                        y,
                        0,
                        0,
                        stack == (wimp_w) -3 ? stack: pane2);
 }

}


wimp_w drw_u_pane(wimp_w window)

{

/* Make 'pane1' the *sole* assigned pane for the main window. */
/* Note pane1 is the bottom-most (and last) one to be opened in */
/* drw_u_openwindow (when main% is opened.) */

if (window == pwd->uwd->barwin)
 return pane1;

return (wimp_w) -1;

}


int drw_u_preclosewindow(wimp_w window)

{

return TRUE;

}


void drw_u_closewindow(wimp_w window)

{

if (window == pwd->uwd->barwin)
 {
  drw_wimp_closewindow(pane1);
  drw_wimp_closewindow(pane2);
  drw_wimp_closewindow(pane3);
 }

}


void drw_u_init_def_wdefn(byte *wblock)

{

return;

}


