(****************************************************************)
(*                                                              *)
(*         Gardens Point Modula-2 Library Definition            *)
(*                                                              *)
(*                                                              *)
(*     (c) Copyright 1996 Faculty of Information Technology     *)
(*              Queensland University of Technology             *)
(*                                                              *)
(*     Permission is granted to use, copy and change this       *)
(*     program as long as the copyright message is left intact  *)
(*                                                              *)
(****************************************************************)

(****************************************************************)
(*                                                              *)
(*            Sample OS/2 API interface definitions		*)
(*                                                              *)
(*      original module : jl Feb 1995				*)
(*      modifications   :					*)
(*                                                              *)
(****************************************************************)

INTERFACE DEFINITION MODULE OS2;

FROM SYSTEM IMPORT ADDRESS, WORD, BYTE;
FROM Types  IMPORT SHORTINT, SHORTCARD;


  CONST
    NULL = NIL;

    WM_CREATE        = 00001H;
    WM_DESTROY       = 00002H;
    WM_SIZE          = 00007H;
    WM_COMMAND       = 00020H;
    WM_PAINT         = 00023H;
    WM_TIMER         = 00024H;
    WM_INITDLG       = 0003BH;
    WM_BUTTON1DBLCLK = 00073H;
    WM_BUTTON2DBLCLK = 00076H;

    FID_SYSMENU      = 08002H;
    FID_TITLEBAR     = 08003H;
    FID_MINMAX       = 08004H;
    FID_MENU         = 08005H;
    FID_VERTSCROLL   = 08006H;
    FID_HORZSCROLL   = 08007H;
    FID_CLIENT       = 08008H;

    SC_SIZE          = 08000H;
    SC_MOVE          = 08001H;
    SC_MINIMIZE      = 08002H;
    SC_MAXIMIZE      = 08003H;
    SC_CLOSE         = 08004H;
    SC_NEXT          = 08005H;
    SC_APPMENU       = 08006H;
    SC_SYSMENU       = 08007H;
    SC_RESTORE       = 08008H;
    SC_NEXTFRAME     = 08009H;
    SC_NEXTWINDOW    = 08010H;

    MM_DELETEITEM    = 00181H;

    WS_VISIBLE       = 80000000H;
    WS_DISABLED      = 40000000H;
    WS_CLIPCHILDREN  = 20000000H;
    WS_CLIPSIBLINGS  = 10000000H;
    WS_PARENTCLIP    = 08000000H;
    WS_SAVEBITS      = 04000000H;
    WS_SYNCPAINT     = 02000000H;
    WS_MINIMIZED     = 01000000H;
    WS_MAXIMIZED     = 00800000H;
    WS_ANIMATE       = 00400000H;

    CS_MOVENOTIFY    = 00000001H;
    CS_SIZEREDRAW    = 00000004H;
    CS_HITTEST       = 00000008H;
    CS_PUBLIC        = 00000010H;
    CS_FRAME         = 00000020H;
    CS_CLIPCHILDREN  = 20000000H;
    CS_CLIPSIBLINGS  = 10000000H;
    CS_PARENTCLIP    = 08000000H;
    CS_SAVEBITS      = 04000000H;
    CS_SYNCPAINT     = 02000000H;

    DID_OK           =  1;
    DID_CANCEL       =  2;
    DID_ERROR        =  0FFFFH;

    SWP_SIZE            = 00001H;
    SWP_MOVE            = 00002H;
    SWP_ZORDER          = 00004H;
    SWP_SHOW            = 00008H;
    SWP_HIDE            = 00010H;
    SWP_NOREDRAW        = 00020H;
    SWP_NOADJUST        = 00040H;
    SWP_ACTIVATE        = 00080H;
    SWP_DEACTIVATE      = 00100H;
    SWP_EXTSTATECHANGE  = 00200H;
    SWP_MINIMIZE        = 00400H;
    SWP_MAXIMIZE        = 00800H;
    SWP_RESTORE         = 01000H;
    SWP_FOCUSACTIVATE   = 02000H;
    SWP_FOCUSDEACTIVATE = 04000H;
    SWP_NOAUTOCLOSE     = 08000H;

    FCF_TITLEBAR        = 00000001H;
    FCF_SYSMENU         = 00000002H;
    FCF_MENU            = 00000004H;
    FCF_SIZEBORDER      = 00000008H;
    FCF_MINBUTTON       = 00000010H;
    FCF_MAXBUTTON       = 00000020H;
    FCF_MINMAX          = 00000030H;
    FCF_VERTSCROLL      = 00000040H;
    FCF_HORZSCROLL      = 00000080H;
    FCF_DLGBORDER       = 00000100H;
    FCF_BORDER          = 00000200H;
    FCF_SHELLPOSITION   = 00000400H;
    FCF_TASKLIST        = 00000800H;
    FCF_NOBYTEALIGN     = 00001000H;
    FCF_NOMOVEWITHOWNER = 00002000H;
    FCF_ICON            = 00004000H;
    FCF_ACCELTABLE      = 00008000H;
    FCF_SYSMODAL        = 00010000H;
    FCF_SCREENALIGN     = 00020000H;
    FCF_MOUSEALIGN      = 00040000H;
    FCF_HIDEBUTTON      = 01000000H;
    FCF_HIDEMAX         = 01000020H;
    FCF_AUTOICON        = 40000000H;
    FCF_STANDARD        = 0000CC3FH;

    QWL_USER         =  0;
    QWL_STYLE        = -2;

    PU_ARBITRARY     = 00004H;
    PU_PELS          = 00008H;
    PU_LOMETRIC      = 0000CH;
    PU_HIMETRIC      = 00010H;
    PU_LOENGLISH     = 00014H;
    PU_HIENGLISH     = 00018H;
    PU_TWIPS         = 0001CH;
    GPIF_DEFAULT     = 0;
    GPIF_SHORT       = 00100H;
    GPIF_LONG        = 00200H;
    GPIT_NORMAL      = 0;
    GPIT_MICRO       = 01000H;
    GPIA_NOASSOC     = 0;
    GPIA_ASSOC       = 04000H;

    CLR_WHITE        = -2;
    CLR_BLACK        = -1;
    CLR_BACKGROUND   =  0;
    CLR_BLUE         =  1;
    CLR_RED          =  2;
    CLR_PINK         =  3;
    CLR_GREEN        =  4;
    CLR_CYAN         =  5;
    CLR_YELLOW       =  6;
    CLR_NEUTRAL      =  7;
    CLR_DARKGRAY     =  8;
    CLR_DARKBLUE     =  9;
    CLR_DARKRED      = 10;
    CLR_DARKPINK     = 11;
    CLR_DARKGREEN    = 12;
    CLR_DARKCYAN     = 13;
    CLR_BROWN        = 14;
    CLR_PALEGRAY     = 15;

    SYSCLR_WINDOW    = -20;


  TYPE
    LHANDLE   = CARDINAL;

    HWND      = LHANDLE;
    HBITMAP   = LHANDLE;
    HMQ       = LHANDLE;
    HRGN      = LHANDLE;
    HDC       = LHANDLE;
    HPS       = LHANDLE;
    HAB       = LHANDLE;
    HMODULE   = LHANDLE;
    HLIB      = LHANDLE;
    HMF       = LHANDLE;

    LONG      = INTEGER;
    SHORT     = SHORTINT;
    ULONG     = CARDINAL;
    USHORT    = SHORTCARD;

    BOOL      = BOOLEAN;  (* Be careful with alignment *)

    MPARAM    = ADDRESS;
    MRESULT   = ADDRESS;
    APIRET    = CARDINAL;
    PSZ       = ADDRESS;

    PFNWP     = PROCEDURE(HWND, ULONG, MPARAM, MPARAM) : MRESULT;


    POINTL  = RECORD
      x        : LONG;
      y        : LONG;
    END;
    PPOINTL = POINTER TO POINTL;

    POLYGON = RECORD
      ulPoints : ULONG;
      aPointl  : PPOINTL;
    END;
   
    RECTL   = RECORD
      xLeft    : LONG;
      yBottom  : LONG;
      xRight   : LONG;
      yTop     : LONG;
    END;

    QMSG    = RECORD
      hwnd     : HWND;
      msg      : ULONG;
      mp1      : MPARAM;
      mp2      : MPARAM;
      time     : ULONG;
      ptl      : POINTL;
      reserved : ULONG;
    END;

    SIZEL   = RECORD
      cx       : LONG;
      cy       : LONG;
    END;

    CREATESTRUCT  = RECORD
      pPresParams        : ADDRESS;
      pCtlData           : ADDRESS;
      id                 : ULONG;
      hwndInsertBehind   : HWND;
      hwndOwner          : HWND;
      cy                 : LONG;
      cx                 : LONG;
      y                  : LONG;
      x                  : LONG;
      flStyle            : ULONG;
      pszText            : PSZ;
      pszClass           : PSZ;
      hwndParent         : HWND;
    END;
    PCREATESTRUCT = POINTER TO CREATESTRUCT;

    BITMAPINFOHEADER = RECORD
      cbFix      : ULONG;
      cx         : USHORT;
      cy         : USHORT;
      cPlanes    : USHORT;
      cBitCount  : USHORT;
    END;

    RGB = RECORD
      bBlue  : BYTE;
      bGreen : BYTE;
      bRed   : BYTE;
    END;
    PRGB = POINTER TO RGB;

    BITMAPINFO = RECORD
      cbFix     : ULONG;
      cx        : USHORT;
      cy        : USHORT;
      cPlanes   : USHORT;
      cBitCount : USHORT;
      argbColor : PRGB
    END;
   PBITMAPINFO = POINTER TO BITMAPINFO;

  CONST
    HWND_DESKTOP  = VAL(HWND, 1);
    HWND_OBJECT   = VAL(HWND, 2);
    HWND_TOP      = VAL(HWND, 3);
    HWND_BOTTOM   = VAL(HWND, 4);

    NULLHANDLE    = VAL(LHANDLE,0);


           (* These are defined in gprts.c *)
  PROCEDURE MPFROM2SHORT ["MakeMPARAM"](a : WORD; b : WORD) : MPARAM;
  PROCEDURE MakePSTR                   (a : ARRAY OF CHAR)  : ADDRESS;
  PROCEDURE SHORT1FROMMP ["MakeSHORT1"](a : WORD)           : USHORT;
  PROCEDURE SHORT2FROMMP ["MakeSHORT2"](a : WORD)           : USHORT;


  TYPE SWP = RECORD
    fl : ULONG;
    cy : LONG;
    cx : LONG;
    y  : LONG;
    x  : LONG;
    hwndInsertBehind : HWND;
    hwnd             : HWND;
    ulReserved1      : ULONG;
    ulReserved2      : ULONG;
  END;

  PROCEDURE WinQueryWindowPos (hwnd : HWND; VAR pswp : SWP) : BOOL;

  PROCEDURE WinSetWindowPos (hwnd : HWND;
                             hwndInsertBehind : HWND;
                             x    : LONG;
                             y    : LONG;
                             cx   : LONG;
                             cy   : LONG;
                             fl   : ULONG) : BOOL;

  PROCEDURE WinIsWindow     (hab : HAB; hwnd : HWND) : BOOL;

  PROCEDURE WinWindowFromID (hwndParent : HWND; id : ULONG) : HWND;


  PROCEDURE WinRegisterClass(hab          : HAB;
                             pszClassName : PSZ;
                             pfnWndProc   : PFNWP;
                             flStyle      : ULONG;
                             cbWindowData : ULONG) : BOOL;

  PROCEDURE WinDefWindowProc(hwnd : HWND;
                             msg  : ULONG;
                             mp1  : MPARAM;
                             mp2  : MPARAM) : MRESULT;

  PROCEDURE WinDestroyWindow(hwnd : HWND) : BOOL;

  PROCEDURE WinShowWindow   (hwnd : HWND; fShow : BOOL) : BOOL;

  PROCEDURE WinQueryWindowRect(hwnd : HWND; VAR prclDest : RECTL) : BOOL;

  PROCEDURE WinQuerySysValue(hwndDesktop : HWND; iSysValue : LONG) : LONG;
  CONST
    SV_CXSCREEN  = 20;
    SV_CYSCREEN  = 21;


  PROCEDURE WinGetPS        (hwnd : HWND) : HPS;

  PROCEDURE WinReleasePS    (hps : HPS) : BOOL;

  PROCEDURE WinBeginPaint   (hwnd      : HWND;
                             hps       : HPS;
                         VAR prclPaint : RECTL) : HPS;

  PROCEDURE WinEndPaint     (hps : HPS) : BOOL;

  PROCEDURE WinMessageBox   (hwndParent    : HWND;
                             hwndOwner     : HWND;
                             pszText       : PSZ;
                             pszCaption    : PSZ;
                             idWindow      : ULONG;
                             flStyle       : ULONG) : ULONG;
   (* Message box types *)
  CONST
    MB_OK                = 0000H;
    MB_OKCANCEL          = 0001H;
    MB_RETRYCANCEL       = 0002H;
    MB_ABORTRETRYIGNORE  = 0003H;
    MB_YESNO             = 0004H;
    MB_YESNOCANCEL       = 0005H;
    MB_CANCEL            = 0006H;
    MB_ENTER             = 0007H;
    MB_ENTERCANCEL       = 0008H;

    MB_NOICON            = 0000H;
    MB_ICONQUESTION      = 0010H;
    MB_ICONEXCLAMATION   = 0020H;
    MB_ICONASTERISK      = 0030H;
    MB_ICONHAND          = 0040H;


  PROCEDURE WinDlgBox       (hwndParent    : HWND;
                             hwndOwner     : HWND;
                             pfnDlgProc    : PFNWP;
                             hmod          : HMODULE;
                             idDlg         : ULONG;
                             pCreateParams : ADDRESS) : ULONG;

  PROCEDURE WinDismissDlg   (hwndDlg : HWND; usResult : ULONG) : BOOL;

  PROCEDURE WinQueryDlgItemShort
			    (hwndDlg : HWND;
                             idItem  : ULONG;
                         VAR pResult : SHORT;
                             fSigned : BOOL) : BOOL;

  PROCEDURE WinSetDlgItemShort
			    (hwndDlg : HWND;
                             idItem  : ULONG;
                             usValue : USHORT;
                             fSigned : BOOL) : BOOL;

  PROCEDURE WinDefDlgProc   (hwndDlg : HWND;
                             msg     : ULONG;
                             mp1     : MPARAM;
                             mp2     : MPARAM) : MRESULT;

  PROCEDURE WinInitialize   (flOptions : ULONG) : HAB;

  PROCEDURE WinTerminate    (hab : HAB) : BOOL;

  PROCEDURE WinQueryAnchorBlock(hwnd : HWND) : HAB;

  PROCEDURE WinGetLastError (hab : HAB) : ULONG;

  PROCEDURE WinSendMsg      (hwnd  : HWND;
                             msg   : ULONG;
                             mp1   : MPARAM;
                             mp2   : MPARAM) : MRESULT;

  PROCEDURE WinCreateMsgQueue(hab : HAB; cmsg : LONG) : HMQ;

  PROCEDURE WinDestroyMsgQueue(hmq : HMQ) : BOOL;

  PROCEDURE WinGetMsg       (hab        : HAB;
                         VAR pqmsg      : QMSG;
                             hwndFilter : HWND;
                         msgFilterFirst : ULONG;
                         msgFilterLast  : ULONG) : BOOL;

  PROCEDURE WinDispatchMsg  (hab : HAB; VAR pqmsg : QMSG) : MRESULT;

  PROCEDURE WinCreateStdWindow
			    (hwndParent     : HWND;
                             flStyle        : ULONG;
                         VAR pflCreateFlags : ULONG;
                             pszClientClass : PSZ;
                             pszTitle       : PSZ;
                             styleClient    : ULONG;
                             hmod           : HMODULE;
                             idResources    : ULONG;
                         VAR phwndClient    : HWND) : HWND;

  PROCEDURE WinCreateWindow  (hwndParent        : HWND;
                              pszClass          : PSZ;
                              pszName           : PSZ;
                              flStyle           : ULONG;
                              x                 : LONG;
                              y                 : LONG;
                              cx                : LONG;
                              cy                : LONG;
                              hwndOwner         : HWND;
                              hwndInsertBehind  : HWND;
                              id                : ULONG;
                              pCtlData          : ADDRESS;
                              pPresParams       : ADDRESS) : HWND;
 
  PROCEDURE WinLoadLibrary  (hab : HAB; libname : PSZ) : HLIB;

  PROCEDURE WinLoadProcedure(hab       : HAB;
                             libhandle : HLIB;
                             procname  : PSZ) : PFNWP;

  PROCEDURE WinQueryWindowULong(hwnd : HWND; index : LONG) : ULONG;

  PROCEDURE WinSetWindowULong(hwnd : HWND; index : LONG; ul : ULONG) : BOOL;

  PROCEDURE WinUpdateWindow  (hwnd : HWND) : BOOL;

  PROCEDURE WinInvalidateRect
			    (hwnd : HWND;
                         VAR pwrc : RECTL;
                 fIncludeChildren : BOOL) : BOOL;

  PROCEDURE WinEqualRect    (hab   : HAB;
                         VAR prcl1 : RECTL;
                         VAR prcl2 : RECTL) : BOOL;

  PROCEDURE WinFillRect     (hps    : HPS;
                         VAR prcl   : RECTL;
                             lColor : LONG) : BOOL;

  PROCEDURE WinStartTimer   (hab       : HAB;
                             hwnd      : HWND;
                             idTimer   : ULONG;
                             dtTimeout : ULONG) : ULONG;

  PROCEDURE WinStopTimer    (hab     : HAB;
                             hwnd    : HWND;
                             idTimer : ULONG) : BOOL;

  PROCEDURE GpiCreatePS     (hab       : HAB;
                             hdc       : HDC;
                         VAR psizlSize : SIZEL;
                             flOptions : ULONG) : HPS;

  PROCEDURE GpiDestroyPS    (hps : HPS) : BOOL;

  PROCEDURE GpiCreateBitmap (hps           : HPS;
                         VAR pbmpNew       : BITMAPINFOHEADER;
                             flOptions     : ULONG;
                             pbInitData    : ADDRESS;
                             pbmiInfoTable : PBITMAPINFO) : HBITMAP;

  PROCEDURE GpiQueryDeviceBitmapFormats 
                            (hps     : HPS;
                             lCount  : LONG;
                             alArray : ARRAY OF LONG) : BOOL;

  PROCEDURE GpiSetBitmap    (hps : HPS;
                             hbm : HBITMAP) : HBITMAP;

  PROCEDURE GpiDeleteBitmap (hbm : HBITMAP) : BOOL;

  PROCEDURE GpiCreateRegion (hps    : HPS;
                             lCount : LONG;
                     arclRectangles : ARRAY OF RECTL) : HRGN;

  PROCEDURE GpiDestroyRegion(hps  : HPS; hrgn : HRGN) : BOOL;

  PROCEDURE GpiSetClipRegion(hps  : HPS;
                             hrgn : HRGN;
                     VAR phrgnOld : HRGN) : LONG;

  PROCEDURE GpiMove         (hps  : HPS;
                    VAR pptlPoint : POINTL) : BOOL;

  PROCEDURE GpiLine         (hps  : HPS;
                 VAR pptlEndPoint : POINTL) : LONG;

  PROCEDURE GpiSetColor     (hps : HPS; lColor : LONG) : BOOL;

  PROCEDURE GpiSetBackColor (hps : HPS; lColor : LONG) : BOOL;

  PROCEDURE GpiSetMix       (hps : HPS; lMixMode : LONG) : BOOL;

  PROCEDURE GpiSetBackMix   (hps : HPS; lMixMode : LONG) : BOOL;
  CONST
    FM_DEFAULT    = 0;
    FM_OR         = 1;
    FM_OVERPAINT  = 2;
    FM_LEAVEALONE = 5;

    BM_DEFAULT    = 0;
    BM_OR         = 1;
    BM_OVERPAINT  = 2;
    BM_LEAVEALONE = 5;


  PROCEDURE GpiPolygons     (hps       : HPS;
                             ulCount   : ULONG;
                             paplgn    : ARRAY OF POLYGON;
                             flOptions : ULONG;
                             flModel   : ULONG) : LONG;

  PROCEDURE GpiPolyLine     (hps       : HPS;
                             lCount    : LONG;
                             aptlPoints: ARRAY OF POINTL) : LONG;

  PROCEDURE GpiBox          (hps       : HPS;
                             lControl  : LONG;
                         VAR pptlPoint : POINTL;
                             lHRound   : LONG;
                             lVRound   : LONG) : LONG;
  CONST
    DRO_FILL        = 1;
    DRO_OUTLINE     = 2;
    DRO_OUTLINEFILL = 3;

    BA_NOBOUNDARY   = 0;
    BA_BOUNDARY     = 1;
    BA_ALTERNATE    = 0;
    BA_WINDING      = 2;
    BA_EXCL         = 0;
    BA_INCL         = 8;

  PROCEDURE GpiBeginArea    (hps : HPS; flOptions : ULONG) : BOOL;

  PROCEDURE GpiEndArea      (hps : HPS) : LONG;

  PROCEDURE GpiBitBlt       (hpsTarget  : HPS;
                             hpsSource  : HPS;
                             lCount     : LONG;
                             aptlPoints : ARRAY OF POINTL;
                             lRop       : LONG;
                             flOptions  : ULONG) : LONG;
  CONST
    ROP_SRCCOPY  = 000CCH;
    BBO_IGNORE   = 2;


  TYPE
    PFNEXITLIST  = PROCEDURE(ULONG);

  CONST
    EXLST_ADD    =  1;
    EXLST_REMOVE =  2;
    EXLST_EXIT   =  3;

  PROCEDURE DosExitList     (ordercode : ULONG; pfn : PFNEXITLIST) : APIRET;


  TYPE
    DRIVDATA = RECORD
      cb            : LONG;
      lVersion      : LONG;
      szDeviceName  : ARRAY [0 .. 31] OF CHAR;
      abGeneralData : PSZ;
    END;
    PDRIVDATA = POINTER TO DRIVDATA;

    DEVOPENSTRUC = RECORD
      pszLogAddress      : PSZ;
      pszDriverName      : PSZ;
      pdriv              : PDRIVDATA;
      pszDataType        : PSZ;
      pszComment         : PSZ;
      pszQueueProcName   : PSZ;
      pszQueueProcParams : PSZ;
      pszSpoolerParams   : PSZ;
      pszNetworkParams   : PSZ;
    END;

  CONST
    OD_MEMORY    = 8;

  PROCEDURE DevOpenDC       (hab      : HAB;
                             lType    : LONG;
                             pszToken : PSZ;
                             lCount   : LONG;
                         VAR pdopData : DEVOPENSTRUC;
                             hdcComp  : HDC) : HDC;

  PROCEDURE DevCloseDC      (hdc : HDC) : HMF;

END OS2.
