(****************************************************************************

$RCSfile: GUIEnvD.def $

$Revision: 1.6 $
    $Date: 1994/11/24 10:35:37 $

    All type and const definition for GUIEnvironment

    M2Amiga Modula-2 Compiler V4.3

  Copyright © 1994, Carsten Ziegeler
                    Augustin-Wibbelt-Str.7, 33106 Paderborn, Germany


****************************************************************************)
DEFINITION MODULE GUIEnvD; (*$ Implementation:=FALSE *)

  FROM SYSTEM     IMPORT ADDRESS;
  FROM ExecD      IMPORT MsgPortPtr;
  FROM GraphicsD  IMPORT TextAttrPtr;
  FROM IntuitionD IMPORT IDCMPFlagSet, ScreenPtr, WindowPtr, GadgetPtr,
                         DrawInfoPtr, IntuiMessagePtr, MenuItemPtr;
  FROM LocaleD    IMPORT CatalogPtr, LocalePtr;
  FROM UtilityD   IMPORT HookPtr, TagItemPtr, tagUser;
IMPORT R;


(* ======================================================================= *)
(*                               Error codes                               *)
(* ======================================================================= *)

CONST

  geDone             =   0;   (* no error, everything done *)
  geMemoryErr        =   1;   (* not enough memory *)
  geWindowErr        =   2;   (* no window specified *)
  geVisualInfoErr    =   3;   (* couldn't get VisualInfo *)
  geDrawInfoErr      =   4;   (* couldn't get DrawInfo *)
  geGuideErr         =  50;   (* couldn't display AmigaGuide node *)

  geGadContextErr    = 100;   (* GadTools CreateContext failed *)
  geGadCreateErr     = 101;   (* error calling CreateGadget/NewObject *)
  geGadTooManyErr    = 102;   (* more than 256 gadgets *)
  geGadKeyTwiceErr   = 102;   (* same key equivalent for two gadgets *)
  geGadUnknownKind   = 104;   (* unknown gadget kind *)
  geGadChainErr      = 105;   (* ChainStart/ChainEnd missing *)
  geGadHookErr       = 106;   (* Hook function failed *)

  geMenuCreateErr    = 200;   (* error calling CreateMenu *)
  geMenuStripErr     = 201;   (* error calling SetMenuStrip *)
  geMenuLayoutErr    = 202;   (* error calling LayoutMenus *)
  geMenuTooManyErr   = 203;   (* more than 256 menu items *)


(* ======================================================================= *)
(*                         GE Hook functions                               *)
(* ======================================================================= *)

(* The GUIEnvironment hook functions:
   - The hook functions are implemented as amiga callback hooks as
     documented in the Utilities documentation
   - Before a hook functions is called, the A4 register is set
   - The A0 register points to Hook structure
   - The A1/A2 register are used as stated below

*)

(* ------------------------ return values -------------------------------- *)

  gehKeyShifted  = 512;
  gehKeyUnknown  = -1;

(* ------------------------ The hook functions --------------------------- *)

TYPE

         (* Hook function for key equivalents:

              A1      : Currently unused, set to NIL
              A2      : LONGINT : The ASCII character code
              RESULT  : LONGINT : gehKeyUnknown if the key is not a key
                                  equivalent or the number of the gadget,
                                  or the number of the gadget plus
                                  gehKeyShifted !


            Handle message hook

              A1, A2  : Currently unused, set to NIL
              RESULT  : LONGINT, handled as BOOLEAN
                        Return TRUE, if GUIEnv should not work on the
                        message anymore, otherwise FALSE


            Refresh hook

              A1, A2  : Currently unused, set to NIL
              RESULT  : Currently unused, set this always to 0 !


            Gadget event message hook

              A2      : Pointer to event gadget
              A1      : Currently unused, set to NIL
              RESULT  : LONGINT, handled as BOOLEAN
                        If you want to wait for further messages return
                        TRUE, otherwise FALSE to exit the message-loop.


            Menu event message hook

              A2      : Pointer to event menu item (if possible)
              A1      : Currently unused, set to NIL
              RESULT  : LONGINT, handled as BOOLEAN
                        If you want to wait for further messages return
                        TRUE, otherwise FALSE to exit the message-loop.


            Gadget creation hook

              A2      : Pointer to event gadget
              A1      : Currently unused, set to NIL
              RESULT  : LONGINT, handled as BOOLEAN
                        If your creation hook has done his work, return
                        TRUE, otherwise FALSE to stop creation !

*)

(* ======================================================================= *)
(*                               Gadgets                                   *)
(* ======================================================================= *)

CONST
(* ----------------------- gadget kinds ---------------------------------- *)

  gegKinds                 =  65535; (* GUIEnv gadgets *)
  gegProgressIndicatorKind =  65536;
  gegBevelboxKind          =  65537;
  gegBorderKind            =  65538;

  gegBOOPSIKinds           = 131071; (* BOOPSI gadgets *)
  gegBOOPSIPublicKind      = 131072;
  gegBOOPSIPrivateKind     = 131073;

(* ----------------------- gadget chain flags ---------------------------- *)

TYPE
  GEGChainFlags = (gegChainUpNext, gegChainUpPrev, gegChainDownNext,
                   gegChainDownPrev, gengcf4, gengcf5, gengcf6,
                   gengcf7, gengcf8);

  GEGChainFlagSet = SET OF GEGChainFlags;  (* 16 bits *)

(* ----------------------- gadget description flags ---------------------- *)

CONST
  gegDistNorm    =  0;  (* Normal distance *)
  gegDistAbs     =  1;  (* absolute distance from an object *)
  gegDistRel     =  2;  (* relative distance from an object *)
  gegDistPercent =  3;  (* percentual distance *)

  gegObjBorder   =  0;  (* window border *)
  gegObjGadget   =  4;  (* gadget (standard is previous gadget) *)

  gegObjRight    =  0;  (* distance from which part of the object *)
  gegObjBottom   =  0;
  gegObjLeft     = 32;
  gegObjTop      = 32;

(* ----------------------- gadget tag values ----------------------------- *)

  gegACTIVATIONUP  =  0;
  gegACTIVATIONDOWN=  1;


  gegALLGADGETS    = -1;

(* ----------------------- gadget tags ----------------------------------- *)

  gegBase = tagUser + 016000H;
  gegText            = gegBase +  1;
  gegFlags           = gegBase +  2;
  gegFont            = gegBase +  3;
  gegUserData        = gegBase +  4;
  gegDescription     = gegBase +  5;
  gegObjects         = gegBase +  6;
  gegGuideNode       = gegBase +  7;
  gegCatalogString   = gegBase + 10;
  gegClass           = gegBase + 11;
  gegVarAddress      = gegBase + 12;
  gegHandleInternal  = gegBase + 13;
  gegStartChain      = gegBase + 14;
  gegEndChain        = gegBase + 15;
  gegActivate        = gegBase + 16;
  gegChainActivation = gegBase + 17;
  gegStatus          = gegBase + 19;
  gegUpAHook         = gegBase + 20;
  gegDownAHook       = gegBase + 21;
  gegCreationAHook   = gegBase + 22;

  gegPIMaxValue      = gegBase + 50;
  gegPICurrentValue  = gegBase + 51;
  gegBBRecessed      = gegBase + 52;

  gegDisable         = gegBase + 100;
  gegEnable          = gegBase + 101;
  gegSetVar          = gegBase + 102;
  gegGetVar          = gegBase + 103;
  gegActivateUp      = gegBase + 104;
  gegActivateDown    = gegBase + 105;

  gegAddress         = gegBase + 200;
  gegLeftEdge        = gegBase + 201;
  gegTopEdge         = gegBase + 202;
  gegWidth           = gegBase + 203;
  gegHeight          = gegBase + 204;
  gegRedraw          = gegBase + 205;


(* ----------------------- GUIGadgetInfo structure ------------------------ *)

TYPE

  GUIGadgetInfoPtr = POINTER TO GUIGadgetInfo; (* gadget^.userData *)

  GUIGadgetInfo = RECORD  (* a pointer to this structure is stored in
                             gadget^.userData *)
    userData : ADDRESS;   (* use this for own user data *)
    kind     : LONGINT;   (* gadget kind *)

    gadgetClass : ADDRESS;(* The BOOPSI Gadget Class *)

    functionUp   : HookPtr;
    functionDown : HookPtr;

    guideNode: ADDRESS;   (* The AmigaGuide node for this gadget *)

  END;

(* ======================================================================= *)
(*                             Menu Items                                  *)
(* ======================================================================= *)

CONST
(* ---------------------- menu item tags --------------------------------- *)

  gemBase = tagUser + 018000H;
  gemUserData        = gemBase + 1;
  gemGuideNode       = gemBase + 3;
  gemCatalogString   = gemBase + 4;
  gemShortCut        = gemBase + 5;
  gemFlags           = gemBase + 6;
  gemMutualExclude   = gemBase + 7;
  gemAHook           = gemBase + 8;

(* ---------------------- GUIMenuInfo structure -------------------------- *)

TYPE

  GUIMenuInfoPtr = POINTER TO GUIMenuInfo; (* menu^.userData *)

  GUIMenuInfo = RECORD    (* a pointer to this structure is stored in
                              menuitem^.userData *)
    userData : ADDRESS;   (* use this for own user data *)

    function : HookPtr;

    guideNode: ADDRESS;   (* The AmigaGuide node for this menuitem *)

  END;



(* ======================================================================= *)
(*                            GUIInfo                                      *)
(* ======================================================================= *)

(* -------------------------- GUIInfo structure -------------------------- *)

  GUIInfoPtr = POINTER TO GUIInfo;
  GUIInfo = RECORD
    window     : WindowPtr;         (* pointer to the used Window *)
    screen     : ScreenPtr;         (* pointer to window's screen *)
    visualInfo : ADDRESS;           (* pointer to screen's VisualInfo *)
    drawInfo   : DrawInfoPtr;       (* pointer to a copy of DrawInfo *)
    localeInfo : LocalePtr;         (* pointer to locale environment *)

    menuFont : TextAttrPtr;         (* pointer to menu-font. Is set to
                                       screens font. *)

    creationWidth  : INTEGER;       (* window inner width *)
    creationHeight : INTEGER;       (* window inner height *)

    msgPort  : MsgPortPtr;          (* Pointer to IDCMP-Port *)

    intuiMsg : IntuiMessagePtr;     (* Points to a copy of the
                                       FULL IntuiMessage even if it
                                       is extended (OS3.0+) *)

 (* Additional information about the message: *)
    msgClass : IDCMPFlagSet;

    msgCode     : INTEGER;
    msgBoolCode : BOOLEAN;
    msgCharCode : CHAR;

    msgGadget  : GadgetPtr;

    msgItemAdr : MenuItemPtr;

    msgGadNbr  : INTEGER;

    msgMenuNum : INTEGER;
    msgItemNum : INTEGER;
    msgSubNum  : INTEGER;

 (* Some user stuff: *)
    userData      : ADDRESS;        (* for own data *)
    compilerReg   : ADDRESS;        (* for compiler data reg *)

    gadgetGuide   : ADDRESS;        (* name & path for the guide *)
    menuGuide     : ADDRESS;        (* name & path for the guide *)

    catalogInfo   : CatalogPtr;     (* points to the catalog given
                                       with the GUI_CatalogFile tag *)
    gadgetCatalogString : LONGINT;  (* The number of the next string *)
    menuCatalogString   : LONGINT;  (* in the catalog *)

    vanKeyHook    : HookPtr;        (* Hook functions *)
    handleMsgHook : HookPtr;
    refreshHook   : HookPtr;

    hookInterface : ADDRESS;

    creationFont  : TextAttrPtr;    (* GUIDefinition: text/gadget font *)
    textFont      : TextAttrPtr;    (* Font for gadgets and text *)
  END;

CONST

(* --------------------------- GUI Tags ------------------------------------ *)

  guiBase = tagUser + 015000H;
  guiTextFont            = guiBase +  1;
  guiMenuFont            = guiBase +  2;
  guiCreateError         = guiBase +  4;
  guiUserData            = guiBase +  5;
  guiCompilerReg         = guiBase +  6;
  guiGadgetGuide         = guiBase +  8;
  guiMenuGuide           = guiBase +  9;
  guiCatalogFile         = guiBase + 10;
  guiGadgetCatalogOffset = guiBase + 11;
  guiMenuCatalogOffset   = guiBase + 12;
  guiCreationWidth       = guiBase + 13;
  guiCreationHeight      = guiBase + 14;
  guiMsgPort             = guiBase + 16;
  guiRefreshAHook        = guiBase + 17;
  guiHandleMsgAHook      = guiBase + 18;
  guiVanKeyAHook         = guiBase + 19;
  guiHookInterface       = guiBase + 20;
  guiCreationFont        = guiBase + 21;
  guiPreserveWindow      = guiBase + 22;

  guiRemoveMenu          = guiBase + 100;
  guiRemoveGadgets       = guiBase + 101;
  guiClearWindow         = guiBase + 102;
  guiEmptyMsgPort        = guiBase + 103;
  guiDoBeep              = guiBase + 104;
  guiLock                = guiBase + 105;  (* Requires ReqTools *)
  guiUnLock              = guiBase + 106;  (* Requires ReqTools *)


(* -------------------- Preserve Window Flags ---------------------------- *)

  guiPWFull    = 0;   (* Preserve the window and the min and max values *)
  guiPWSize    = 1;   (* Preserve only the window *)
  guiPWMinMax  = 2;   (* Preserve only the min and max values *)


(* ======================================================================= *)
(*                             Requester                                   *)
(* ======================================================================= *)

(* -------------------- Requester kinds ---------------------------------- *)

  gerGeneralKind = 0;
  gerOKKind      = 1;
  gerDoItKind    = 2;
  gerYNCKind     = 3;
  gerFileKind    = 4;
  gerDirKind     = 5;

  gerRTKind      = 100;  (* Requires ReqTools *)
  gerRTOKKind    = 101;
  gerRTDoItKind  = 102;
  gerRTYNCKind   = 103;
  gerRTFileKind  = 104;
  gerRTDirKind   = 105;

(* --------------------- Return values ----------------------------------- *)

  gerCancel = 0;  (* gerYNCKind / gerDoItKind / gerOKKind /
                     gerFileKind / gerDirKind*)
  gerYes    = 1;  (* gerYNCKind / gerDoItKind / gerFileKind / gerDirKind *)
  gerNo     = 2;  (* gerYNCKind *)

(* --------------------- Requester tags ---------------------------------- *)

  gerBase = tagUser + 017000H;
  gerGadgets        = gerBase +  1;
  gerArgs           = gerBase +  2;
  gerFlags          = gerBase +  3;
  gerTitle          = gerBase +  4;
  gerIDCMP          = gerBase +  5;
  gerPattern        = gerBase +  6;
  gerNameBuffer     = gerBase +  7;
  gerFileBuffer     = gerBase +  8;
  gerDirBuffer      = gerBase +  9;
  gerSave           = gerBase + 10;
  gerLocaleID       = gerBase + 11;


(* ======================================================================= *)
(*                              Windows                                    *)
(* ======================================================================= *)

(* ---------------------- window tags ------------------------------------ *)

  gewBase = tagUser + 019000H;
  gewOuterSize = gewBase + 1;

END GUIEnvD.
