 
#ifndef __dl_wimp_h
#define __dl_wimp_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __dl_core_h
#include "Core.h"
#endif
#define wimp_MAXNAME 12
typedef struct
{
int x, y;
} wimp_point;
typedef wimp_point wimp_coord;
typedef struct
{
wimp_point min;
wimp_point max;
} wimp_rect;
typedef wimp_rect wimp_box;
typedef int window_handle;
typedef int icon_handle;
typedef int task_handle;
#define colour_WHITE 0
#define colour_GREY0 0
#define colour_GREY1 1
#define colour_GREY2 2
#define colour_GREY3 3
#define colour_GREY4 4
#define colour_GREY5 5
#define colour_GREY6 6
#define colour_GREY7 7
#define colour_BLACK 7
#define colour_DARK_BLUE 8
#define colour_YELLOW 9
#define colour_GREEN 10
#define colour_RED 11
#define colour_CREAM 12
#define colour_ARMY_GREEN 13
#define colour_ORANGE 14
#define colour_LIGHT_BLUE 15
#define colour_TRANSPARENT 255 
typedef union
{
int value;
struct
{
unsigned int wimpcolour : 4;
unsigned int gcolaction : 3;
unsigned int foreback : 1;
unsigned int padding : 24;
} data;
} wimp_colour;
typedef union
{
int value;
struct
{
char gcol;
char red;
char green;
char blue;
} data;
} palette_entry;
typedef struct
{
palette_entry colour[16];
palette_entry border;
palette_entry mouse1;
palette_entry mouse2;
palette_entry mouse3;
} palette_block;
#define iconbtype_NEVER 0
#define iconbtype_ALWAYS 1
#define iconbtype_AUTOREPEAT 2
#define iconbtype_CLICK 3
#define iconbtype_RELEASE 4
#define iconbtype_DOUBLECLICK 5
#define iconbtype_CLICKDRAG 6
#define iconbtype_RELEASEDRAG 7
#define iconbtype_DOUBLEDRAG 8
#define iconbtype_MENU 9
#define iconbtype_DOUBLECLICKDRAG 10
#define iconbtype_RADIO 11
#define iconbtype_RESERVED1 12
#define iconbtype_RESERVED2 13
#define iconbtype_WRITECLICKDRAG 14
#define iconbtype_WRITABLE 15
#define iconbar_RIGHT -1
#define iconbar_LEFT -2
#define window_ICONBAR -2
#define icon_TEXT 0x00000001 
#define icon_SPRITE 0x00000002 
#define icon_BORDER 0x00000004 
#define icon_HCENTRE 0x00000008 
#define icon_VCENTRE 0x00000010 
#define icon_FILLED 0x00000020 
#define icon_FONT 0x00000040 
#define icon_NEEDSHELP 0x00000080 
#define icon_INDIRECTED 0x00000100 
#define icon_RJUSTIFY 0x00000200 
#define icon_ALLOWADJUST 0x00000400 
#define icon_HALVESPRITE 0x00000800 
#define icon_BUTTONTYPE 0x00001000 
#define icon_SELECTED 0x00200000 
#define icon_SHADED 0x00400000 
#define icon_DELETED 0x00800000 
#define icon_FORECOLOUR 0x01000000 
#define icon_BACKCOLOUR 0x10000000 
#define iconvalid_ALLOW 'A'
#define iconvalid_BORDERTYPE 'R'
#define iconvalid_DISPLAY 'D'
#define iconvalid_FONTCOLOURS 'F'
#define iconvalid_LINESPACE 'L'
#define iconvalid_SPRITENAME 'S'
#define iconborder_PLINTH 0
#define iconborder_SURROUND 1
#define iconborder_OKBUTTON 2
#define iconborder_INDENT 3
typedef union
{
unsigned int value;
struct
{
unsigned int garbage1 : 6; 
unsigned int font : 1; 
unsigned int garbage2 : 17; 
unsigned int handle : 8; 
} font;
struct
{
unsigned int text : 1;
unsigned int sprite : 1;
unsigned int border : 1;
unsigned int hcentre : 1;
unsigned int vcentre : 1;
unsigned int filled : 1;
unsigned int font : 1;
unsigned int needshelp : 1;
unsigned int indirected : 1;
unsigned int rightjustify : 1;
unsigned int allowadjust : 1;
unsigned int halfsize : 1;
unsigned int buttontype : 4;
unsigned int esg : 5;
unsigned int selected : 1;
unsigned int shaded : 1;
unsigned int deleted : 1;
unsigned int foreground : 4;
unsigned int background : 4;
} data;
} icon_flags;
typedef struct
{
char *buffer;
char *validstring;
unsigned int bufflen;
} icon_indtext;
typedef struct
{
const char *name;
void *spritearea;
unsigned int nameisname;
} icon_indsprite;
typedef union
{
char text[wimp_MAXNAME];
icon_indtext indirecttext;
char spritename[wimp_MAXNAME];
icon_indsprite indirectsprite;
} icon_data;
typedef struct
{
wimp_box workarearect;
icon_flags flags;
icon_data data;
} icon_block;
typedef struct
{
window_handle window;
icon_block icondata;
} icon_createblock;
typedef union
{
struct
{
unsigned int hastitle : 1; 
unsigned int moveable : 1;
unsigned int hasvscroll : 1; 
unsigned int hashscroll : 1; 
unsigned int autoredraw : 1;
unsigned int pane : 1;
unsigned int nobounds : 1;
unsigned int nobackclose : 1; 
unsigned int scrollrq : 1;
unsigned int scrollrqdebounced : 1;
unsigned int realcolours : 1;
unsigned int backwindow : 1;
unsigned int hotkeys : 1;
unsigned int keeponscreen : 1;
unsigned int ignoreright : 1;
unsigned int ignorebottom : 1;
unsigned int open : 1;
unsigned int top : 1;
unsigned int fullsize : 1;
unsigned int istoggling : 1;
unsigned int focus : 1;
unsigned int forceonce : 1;
unsigned int dummy22 : 1;
unsigned int dummy23 : 1;
unsigned int backicon : 1;
unsigned int closeicon : 1;
unsigned int titlebar : 1;
unsigned int toggleicon : 1;
unsigned int vscroll : 1;
unsigned int adjusticon : 1;
unsigned int hscroll : 1;
unsigned int newflags : 1; 
} data;
int value;
} window_flags;
typedef struct 
{ 
int x : 16; 
int y : 16; 
} window_minsize;
typedef enum
{
windowcol_TITLEFORE = 0,
windowcol_TITLEBACK,
windowcol_WORKFORE,
windowcol_WORKBACK,
windowcol_SCROLLBACK,
windowcol_SCROLLFORE,
windowcol_TITLEHILITE
} window_colourindices;
typedef struct
{
wimp_box screenrect;
wimp_point scroll;
window_handle behind;
window_flags flags;
char colours[8];
wimp_box workarearect;
icon_flags titleflags;
icon_flags workflags;
void *spritearea;
window_minsize minsize;
icon_data title;
unsigned int numicons;
} window_block;
typedef struct
{
window_handle window;
wimp_box screenrect;
wimp_point scroll;
window_handle behind;
} window_openblock;
typedef struct
{
window_openblock openblock;
window_flags flags;
} window_state;
typedef struct
{
window_handle window;
window_block block;
} window_info;
typedef struct
{
window_handle window;
wimp_box rect;
wimp_point scroll;
wimp_box cliprect;
} window_redrawblock;
typedef struct
{
window_handle window;
wimp_box screenrect;
} window_outline;
#define button_ADJUST 0x00000001
#define button_MENU 0x00000002
#define button_SELECT 0x00000004
#define button_DRAGADJUST 0x00000010
#define button_DRAGSELECT 0x00000040
#define button_CLICKADJUST 0x00000100
#define button_CLICKSELECT 0x00000400
typedef union
{
unsigned int value;
struct
{
unsigned int adjust : 1;
unsigned int menu : 1;
unsigned int select : 1;
unsigned int dummy3 : 1;
unsigned int dragadjust : 1;
unsigned int dummy5 : 1;
unsigned int dragselect : 1;
unsigned int dummy7 : 1;
unsigned int clickadjust : 1;
unsigned int dummy9 : 1;
unsigned int clickselect : 1;
} data;
} button_state;
typedef struct
{
wimp_point pos;
button_state button;
window_handle window;
icon_handle icon;
} mouse_block;
typedef struct
{
int shapenumber;
char *shapedata;
unsigned int width;
unsigned int height;
wimp_point active;
} pointer_shapeblock;
typedef enum
{
drag_MOVEWINDOW = 1,
drag_RESIZEWINDOW,
drag_SCROLLX,
drag_SCROLLY,
drag_FIXEDBOX,
drag_RUBBERBOX,
drag_INVISIBLE,
drag_USERFIXEDBBOX,
drag_USERRUBBERBOX,
drag_USERFIXEDNC,
drag_USERRUBBERNC
} drag_type;
typedef struct
{
window_handle window;
drag_type type;
wimp_box screenrect;
wimp_box parent;
} drag_block;
typedef union
{
unsigned int value;
struct
{
unsigned int ok : 1;
unsigned int cancel : 1;
unsigned int highlightcancel : 1;
unsigned int noprompt : 1;
unsigned int noprefix : 1;
unsigned int nowait : 1;
unsigned int closebox : 1;
} data;
} error_flags;
typedef struct menu_block *menu_ptr;
typedef union
{
unsigned int value;
struct
{
unsigned int ticked : 1;
unsigned int dotted : 1;
unsigned int writable : 1;
unsigned int notifysub : 1;
unsigned int openshaded : 1;
unsigned int dummy2 : 2;
unsigned int last : 1;
unsigned int indtitle : 1;
unsigned int dummy13 : 13;
unsigned int shaded : 1;
unsigned int dummy1 : 1;
unsigned int foreground : 4;
unsigned int background : 4;
} data;
} menu_flags;
typedef union
{
menu_ptr menu;
window_handle window;
int value;
} menu_submenu;
typedef struct
{
menu_flags menuflags;
menu_submenu submenu;
icon_flags iconflags;
icon_data icondata;
} menu_item;
typedef struct menu_block
{
char title [wimp_MAXNAME];
char titlefore, titleback, workfore, workback;
unsigned int width;
unsigned int height;
unsigned int gap;
} menu_block;
typedef int key_press;
typedef struct
{
window_handle window;
icon_handle icon;
wimp_point offset;
int height;
int index;
} caret_block;
typedef struct
{
caret_block caret;
key_press code;
} key_block;
typedef struct
{
int address;
int contents;
} pollword_block;
typedef enum
{
message_QUIT = 0,
message_CLOSEDOWN = 0,
message_DATASAVE = 1,
message_DATASAVEACK = 2,
message_DATASAVEOK = 2,
message_DATALOAD = 3,
message_DATALOADACK = 4,
message_DATALOADOK = 4,
message_DATAOPEN,
message_RAMFETCH,
message_RAMTRANSMIT,
message_PREQUIT,
message_PALETTECHANGE,
message_SAVEDESK,
message_DEVICECLAIM,
message_DEVICEINUSE,
message_DATASAVED,
message_FILEROPENDIR = 0x400,
message_FILERCLOSEDIR,
message_FILEROPENDIRAT,
message_FILERSELECTIONDIRECTORY,
message_FILERADDSELECTION,
message_FILERACTION,
message_FILERCONTROLACTION,
message_FILERSELECTION,
message_HELPREQUEST = 0x502,
message_HELPREPLY,
message_NOTIFY = 0x40040,
message_MENUWARNING = 0x400C0,
message_MENUWARN = 0x400C0,
message_MODECHANGE,
message_TASKINITIALISE = 0x400C2,
message_INITTASK = 0x400C2,
message_TASKCLOSEDOWN = 0x400C3,
message_CLOSETASK = 0x400C3,
message_SLOTSIZE = 0x400C4,
message_SLOTCHANGE = 0x400C4,
message_SETSLOT = 0x400C5,
message_TASKNAMERQ,
message_TASKNAMEIS,
message_TASKSTARTED,
message_MENUSDELETED, 
message_WINDOWINFO = 0x400CC, 
message_POPUPRQ = 0x46D40, 
message_POPUPREQUEST = 0x46D40,
message_POPUPSTATE,
message_POPUPCLOSED,
message_PRINTFILE = 0x80140,
message_WILLPRINT,
message_PRINTSAVE,
message_PRINTINIT,
message_PRINTERROR,
message_PRINTTYPEODD,
message_PRINTTYPEKNOWN,
message_SETPRINTER,
message_PSPRINTERQUERY = 0x8014c,
message_PSPRINTERACK,
message_PSPRINTERMODIFIED,
message_PSPRINTERDEFAULTS,
message_PSPRINTERDEFAULTED,
message_PSPRINTERNOTPS,
message_RESETPRINTER,
message_PSISFONTPRINTRUNNING,
message_TASKWINDOW_INPUT = 0x808c0,
message_TASKWINDOW_OUTPUT,
message_TASKWINDOW_EGO,
message_TASKWINDOW_MORIO,
message_TASKWINDOW_MORITE,
message_TASKWINDOW_NEWTASK,
message_TASKWINDOW_SUSPEND,
message_TASKWINDOW_RESUME
} message_action;
typedef int message_destinee; 
typedef struct
{
unsigned int size;
task_handle sender;
unsigned int myref;
unsigned int yourref;
message_action action;
} message_header;
typedef struct
{
window_handle window;
icon_handle icon;
wimp_point pos;
int estsize;
int filetype;
char leafname[12];
} message_datasave;
typedef struct
{
window_handle window; 
icon_handle icon; 
wimp_point pos;
int estsize;
int filetype;
char filename[212];
} message_datasaveack;
typedef struct
{
window_handle window;
icon_handle icon;
wimp_point pos;
int size;
int filetype;
char filename[212];
} message_dataload;
typedef struct 
{
window_handle window;
icon_handle icon;
wimp_point pos;
int size;
int filetype;
char filename[212];
} message_dataloadack;
typedef message_dataload message_dataopen;
typedef struct
{
char *buffer;
int buffsize;
} message_ramfetch;
typedef struct
{
char *buffer; 
int byteswritten;
} message_ramtransmit;
typedef struct
{
mouse_block where; 
} message_helprequest;
typedef struct
{
char text[200];
} message_helpreply;
typedef struct
{
int filler[5];
int filetype;
char filename[212];
} message_print;
typedef struct
{
int id; 
wimp_point openpos; 
int selection[10]; 
} message_menuwarn;
typedef struct
{
window_handle window;
task_handle task;
char title[20];
} message_iconize;
typedef struct
{
window_handle window;
int dummy;
char spritename[8];
char title[20];
} message_windowinfo;
typedef struct
{
message_header header;
union
{
char bytes [236];
int words [59];
message_datasave datasave;
message_datasaveack datasaveack;
message_dataload dataload;
message_dataopen dataopen;
message_ramfetch ramfetch;
message_ramtransmit ramtransmit;
message_helprequest helprequest;
message_helpreply helpreply;
message_print print;
message_menuwarn menuwarn;
message_iconize iconize;
message_windowinfo windowinfo;
#if FALSE
message_popuprequest popuprequest; 
message_popupstate popupstate; 
#endif
} data;
} message_block;
#define wimp_NUMBEROFEVENTS 20
typedef enum
{
event_ANY = -99, 
event_NULL = 0,
event_REDRAW,
event_OPEN,
event_CLOSE,
event_PTRLEAVE,
event_PTRENTER,
event_CLICK = 6,
event_BUTTON = 6,
event_USERDRAG,
event_KEY,
event_MENU,
event_SCROLL,
event_LOSECARET,
event_GAINCARET,
event_NONZEROPOLLWORD,
event_USERMESSAGE = 17,
event_SEND = 17,
event_USERMESSAGERECORDED = 18,
event_SENDWANTACK = 18,
event_USERMESSAGEACK = 19,
event_ACK = 19
} event_type;
typedef union
{
unsigned int value;
struct
{
unsigned int null : 1;
unsigned int redraw : 1;
unsigned int open : 1;
unsigned int close : 1;
unsigned int ptrleave : 1;
unsigned int ptrenter : 1;
unsigned int click : 1;
unsigned int userdrag : 1;
unsigned int key : 1;
unsigned int menu : 1;
unsigned int scroll : 1;
unsigned int losecaret : 1;
unsigned int gaincaret : 1;
unsigned int nonzeropollword : 1;
unsigned int dummy14 : 1;
unsigned int dummy15 : 1;
unsigned int dummy16 : 1;
unsigned int usermessage : 1;
unsigned int usermessagerecorded : 1;
unsigned int usermessageack : 1;
unsigned int dummy20 : 1;
unsigned int dummy21 : 1;
unsigned int r3ispollwordptr : 1;
unsigned int highprioritypoll : 1;
unsigned int keepfpregisters : 1;
} data;
} event_pollmask;
typedef struct
{
window_openblock openblock;
wimp_point direction;
} scroll_rq;
typedef union
{
caret_block caret;
key_block key;
pollword_block pollword;
window_openblock openblock;
message_block message;
mouse_block mouse;
wimp_box screenrect;
int selection[10];
scroll_rq scroll;
char bytes [256];
int words [64];
} event_data;
typedef struct
{
event_type type;
event_data data;
} event_pollblock;
typedef struct
{
char fonts[256];
} font_array;
typedef struct
{
window_block *buffer;
char *workfree;
char *workend;
font_array *font;
char *name;
unsigned int index;
} template_block;
typedef struct
{
wimp_point mul;
wimp_point div;
} scale_block;
#ifdef __cplusplus
}
#endif
#endif
