/*
 *  WICONSETTER     A companion utility to wIconify.  wIconSetter allows
 *                  you to specify custom icons for windows ans screens
 *                  that normally use the default icons.
 *
 *  wIconSetup.h    Information shared by the handler and loader.
 *
 *  Copyright 1990 by Davide P. Cervone, all rights reserved.
 *  You may use this code, provided this copyright notice is kept intact.
 */

#define PORTNAME        "wIconSetter-Port"      /* Name of the system port */
#define ICONPROCNAME    " wIconify-Handler "    /* the wIconify process */

#define WI_AUTOICONIFY      BIT(7)              /* wIconSetter flag only */ 

#define MAXNAME         64                      /* longest name allowed */
#define NAME_ANY        ((char *)-1)            /* name is '[ANY]' */
#define NAME_NULL       NULL                    /* name is '[NULL]' */
#define SCREENICON      ((char *)-2)            /* this is a screen icon */


typedef struct IconWindow ICONDEFINE;
typedef struct IconWindow ICONWINDOW;
typedef struct IconScreen ICONSCREEN;
typedef struct IconProgram ICONPROGRAM;


#define IconDefine  IconWindow


/*
 *  The following structures form the linked list of programs, screens,
 *  windows and definititions that determine what windows should get icons.
 */

struct IconWindow
{
   ICONWINDOW *Next;                /* Pointer to next window */
   char *Name;                      /* Window's expected title */
   struct Image *Mask;              /* Image structure used to hold the mask */
   WICON Icon;                      /* The icon to apply to this window */
   ULONG Flags;                     /* Flag bits */
     #define IW_IMAGE       BIT(0)      /* An Image was allocated */
     #define IW_SELECT      BIT(1)      /* A Select Image was allocated */
     #define IW_MASK        BIT(2)      /* A Mask Image was allocated */
     #define IW_NAME        BIT(3)      /* An Icon Name was allocated */
     #define IW_ALLOCED     (IW_IMAGE| IW_SELECT| IW_MASK| IW_NAME);
};

struct IconScreen
{
   ICONSCREEN *Next;        /* Pointer to next screen */
   char *Name;              /* The screen's expected name */
   ICONWINDOW *Window;      /* The window's on this screen that get icons */
};

struct IconProgram
{
   ICONPROGRAM *Next,*Prev;     /* Linked-list and binary-tree pointers */
   char *Name;                  /* The name of the program */
   ICONSCREEN *Screen;          /* The first screen with icons specified */
};


struct IconHandlerInfo
{
   struct MsgPort IconPort;                 /* port used to store this info */
   short MajVers,MinVers, MinLoadVers;      /* version of handler and loader */
   long Segment;                            /* SegList loaded by loader */
   struct IntuitionBase **IntuitionBase;
   struct SysBase **SysBase;
   
   /*
    *  These are the routines replaced by SetFunction()
    */
   
   void (*aOpenWindow)();
   long *OldOpenWindow;
   void (*aSetWindowTitles)();
   long *OldSetWindowTitles;
   void (*aOpenScreen)();
   long *OldOpenScreen;

   /*
    *  These are the structures used for set-up and clean-up
    */
    
   void (*GetProgramName)();
   int  (*PrefixMatch)();
   ICONWINDOW *(*FindIcon)();
   ICONDEFINE  **FirstDefine;
   ICONPROGRAM **FirstProgram;
   ICONPROGRAM **ProgramAny;
};


/*
 *  Macros to make using IconHandlerInfo easy
 */

#define VAR(x)      (*(IconHandlerData->x))
#define var(x)      (IconHandlerData->x)
