#ifndef MESSAGES_H
#define MESSAGES_H

#include <exec/types.h>
#include <exec/ports.h>
#include <graphics/gfx.h>
#include <intuition/intuition.h>

/* Use FindPort(START_MENU_PORT_NAME) to get a pointer to the port */
#define STARTMENU_PORT_NAME     "Start_Menu_Port"

/* Commands */
#define ADD_TASKBAR_GADGET      0       /* Add a gadget to the main bar   */
#define REM_TASKBAR_GADGET      1       /* Remove a gadget you added      */
#define ADD_CLOCK_GADGET        2       /* Add a gadget to the clock area */
#define REM_CLOCK_GADGET        3       /* Remove a gadget you added      */
#define GADGET_STATUS           4       /* GADGETUP or GADGETDOWN         */
#define SCALE_BITMAP            5       /* Scale to fit in task bar       */
#define SCALE_IMAGE             6       /* Scale an Intuition Image       */
#define SCALE_IFF               7       /* Scale in IFF ILBM picture file */
#define FREE_BIT_MAP            8
#define REFRESH_TASKBAR_GADGET  9       /* Erase and redraw a gadget      */
#define REFRESH_CLOCK_GADGET    10      /* Erase and redraw a gadget      */
#define CREATE_NEW_BITMAP       11      /* Create a bitmap                */
#define GET_WINDOW_INFO         12      /* Returns info about StartMenu   */
/* These are private!!! */ 
#define RESET_WINDOW            13
#define HANDLE_MSG              14

/* Use this instead of the exec struct Message */
typedef struct {
    struct Message  sm_Msg;         /* Exec message struct */
    UBYTE           sm_Command;     /* See above           */
    APTR            sm_Data;        /* See below           */
} START_MSG;

#define START_MSG_SIZE     sizeof(START_MSG)

/*
 * Send this structure to add a gadget
 * Clock gadgets should not have text and are rendered without a border
 * DO NOT do anything with the returned Gadget (smg_Gadget) except set
 *   its selected state using SetGadgetAttrs().  This Gadget ptr
 *   to be used as a reference.  You can check it for NULL, which means the
 *   gadget was not created for some reason.  Use it when sending other
 *   messages like REM_TASKBAR_GADGET, etc.
 */
typedef struct {
    STRPTR           smg_Title;      /* Text inside gadget  - can be NULL    */
    struct BitMap   *smg_BitMap,     /* Image - can be NULL                  */
                    *smg_Mask;       /* Only NULL if smg_BitMap is NULL      */
    struct MsgPort  *smg_Port;       /* Where to send activation msg's       */
    BOOL             smg_PrivateBM;  /* So StartMenu doesn't delete BitMap   */
    struct Gadget   *smg_Gadget;     /* Will point to gadget or NULL if fail */
} START_MENU_GADGET;

/* 
 * Send this structure to scale a struct BitMap
 * If you change the bitmap's imagery, you will also need to change the
 *    mask's imagery to match.
 * DO NOT change the size or it will not fit properly.
 * Check the returned bms_ScaledBM for NULL. It it is NULL, the mask will be
 *    NULL, too.  This means the BitMap could not be created for some reason.
 * Also, use this for RESCALE_BITMAP.
 */
typedef struct {
    ULONG          bms_SBMWidth;      /* Width (in pixels) of source BitMap   */
    struct BitMap *bms_SourceBM,      /* The BitMap to be scaled              */
                  *bms_ScaledBM,      /* The newly created and scaled BitMap  */
                  *bms_Mask;          /* One bitplane mask for drawing        */
    ULONG          bms_Size;          /* Width and Height (in pixels)         */
} BIT_MAP_SCALED;

/*
 * Send this to scale an Intuition Image structure.
 * The same rules apply as to BIT_MAP_SCALED.
 */
typedef struct {
    struct Image  *ims_Image;         /* The Image to be scaled               */
    struct BitMap *ims_ScaledBM,      /* The newly created and scaled BitMap  */
                  *ims_Mask;          /* One bitplane mask for drawing        */
    ULONG          ims_Size;          /* Width and Height (in pixels)         */
} IMAGE_SCALED;

/*
 * Send this to scale an IFF ILBM picture file (no DataTypes support yet)
 * The same rules apply as to BIT_MAP_SCALED.
 */
typedef struct {
    STRPTR         iffs_FileName;     /* The file to be scaled - full path!   */
    struct BitMap *iffs_ScaledBM,     /* The newly created and scaled BitMap  */
                  *iffs_Mask;         /* One bitplane mask for drawing        */
    ULONG          iffs_Size;         /* Width and Height (in pixels)         */
} IFF_SCALED;

/*
 * Send this to free a BitMap and Mask created by StartMenu.
 * Normally you don't need this - if a BitMap is attatched to a gadget
 *   then that BitMap will be freed automatically when the gadget is freed.
 */
typedef struct {
    struct BitMap *fbm_BitMap,        /* The BitMap                          */
                  *fbm_Mask;          /* The Mask                            */
} FREE_BITMAP;

/*
 * Send this to remove a gadget.
 * This message can be sent to you if StartMenu needs to remove your
 *   gadget - i.e. when StartMenu quits.  If this happens, StartMenu will
 *   free the memory for the Gadget and BitMap!!!  DO NOT call REM_GADGET
 *   or FREE_BITMAP when this happens!!!!!!!!
 * Also, use this for REFRESH_GADGET.  i.e. To 
 */
typedef struct {
    struct Gadget *re_Gadget;         /* The gadget to be removed            */
} RE_GADGET;

/*
 * This message gets sent by StartMenu when the user selects the gadget.
 */
typedef struct {
    struct Gadget       *gs_Gadget;   /* The target gadget                    */
    struct IntuiMessage *gs_IMSG;     /* The message                          */
} GADGET_STATS;

/*
 * Send this and StartMenu returns a blank bitmap that you can draw to
 * i.e. attatch it to a RastPort.
 * Only to be used by clock gadgets!
 * Note, there is no mask.
 */
typedef struct {
    struct BitMap *nbm_BitMap;        /* The ready-to-use BitMap              */
    ULONG          nbm_Size,          /* Width and Height (in pixels)         */
                   nbm_FrontPen,      /* Use these pens for drawing, if you   */
                   nbm_BackPen;       /*  want, but don't change them!!       */
} NEW_BITMAP;

/*
 * Send this to get info about StartMenu's window.
 */
typedef struct {
    struct Rectangle  wi_WinXY;     /* You might need this??                */
    struct Window    *wi_Window;    /* Only to be used if you need to call  */
                                    /* SetGadgetAttrs(). DO NOT ALTER THIS  */
                                    /* STRUCTURE IN ANY WAY!!!!!            */
} WIN_INFO;

#endif      /* MESSAGES_H */
