/*********************************************************************************
 
    STRUCT.h : Definition of basic structures
    Last update : 26 july 96
    Last modification : I don't remember
 
*********************************************************************************/
 
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You must do : 
#define TDE_GLOBALS 
in one (and only one) .c file of your Module.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
 
/* To avoid unnecessary includes :  */
#ifndef  __TDE_STRUCT_H
#define __TDE_STRUCT_H
 
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
 
 
/* For DLLs who are using this module : */ 
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
 #define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
 #define CPA_EXPORT __declspec(dllexport)
#else
 #define CPA_EXPORT
#endif
 
 
/* For Global declaration in C files : */
#ifndef TDE_GLOBALS
 #define __TDE_EXTERN extern
#else /* !TDE_GLOBALS */
 #define __TDE_EXTERN
#endif /* !TDE_GLOBALS */
 
/*
-----------------------------------------------------------------------------
TYPES DEFINITION : 
-----------------------------------------------------------------------------
*/
 
#ifdef NOTUSE_GLD
/* Substitution viewport structure if we do not use GLD*/
typedef struct GLD_stViewportAttributes
{
    DWORD   dwInitialHeight;    /* Initial height of viewport in pixels */
    DWORD   dwInitialWidth;     /* Initial width of viewport in pixels  */
    DWORD   dwHeight;           /* Current height of viewport in pixels */
    DWORD   dwWidth;            /* Current width of viewport in pixels  */
 
    DWORD   dwBytesPerPixel;
 
    DWORD   dwTopInPix;     /* Y of Left up corner    */
    DWORD   dwBottomInPix;  /* Y of right down corner */
    DWORD   dwLeftInPix;    /* X of left up corner    */
    DWORD   dwRightInPix;   /* X of right down corner */
 
    DWORD   dwTopInPixForClip;      /* Y of Left up corner    */
    DWORD   dwBottomInPixForClip;   /* Y of right down corner */
    DWORD   dwLeftInPixForClip;     /* X of left up corner    */
    DWORD   dwRightInPixForClip;    /* X of right down corner */
    
    DWORD   dwTopInPercent;     /* Y of Left up corner      */
    DWORD   dwBottomInPercent;  /* Y of right down corner   */
    DWORD   dwLeftInPercent;    /* X of left up corner      */
    DWORD   dwRightInPercent;   /* X of right bottom corner */
 
    char    *p_cVirtualScreen;  /* Pointer to back memory associated with the viewport */
    LONG    lPitch;             /* Distance to the start of the next line              */
    void    *p_vReserved;       /* Reserved                                            */    
    void    *p_vSpecificToXD; /* Additionnal Attributes specific to 2D or 3D */
} GLD_tdstViewportAttributes, *GLD_tdpstViewportAttributes;
 
 
/* Structures for Pictures */
typedef struct GLD_stPictureAttributes
{
    char            *p_szBitmap;        /* Bitmap loaded in surface    */
    DWORD           dwHeight;           /* Height of picture in pixels */
    DWORD           dwWidth;            /* Width of picture in pixels  */
    char            *p_cVirtualScreen;  /* Pointer to picture                     */
    LONG            lPitch;             /* Distance to the start of the next line */
    void            *p_vReserved;       /* Reserved                               */
} GLD_tdstPictureAttributes, *GLD_tdpstPictureAttributes;
#endif
 
/**************************************************************************
        TDE_tdsVertex : 2D point structure
***************************************************************************/
typedef struct _TDE_tdsVertex
{
    TDE_tdxValue    xX;
    TDE_tdxValue    xY;
}TDE_tdsVertex;
 
 
typedef struct
{
    TDE_tdsVertex  Point;
    TDE_tdsVertex  TexPoint;
} TDE_tdsClippedVertex;
 
 
/****************************************************************************
        TDE_tdsVertex1616 : 16:16 format 2D point structure
*****************************************************************************/
 
typedef struct _TDE_tdsVertex1616
{
    TDE_tdl1616 lX;
    TDE_tdl1616 lY;
}TDE_tdsVertex1616;
 
 
 
typedef struct _TDE_tdsClippedVertex1616
{
    TDE_tdsVertex1616  Point;
    TDE_tdsVertex1616  TexPoint;
}TDE_tdsClippedVertex1616;
 
 
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
 NAME : TDE_tdsRect
 VERSION : 2.0 / Valérie
           1.0 / Franck
 
 Rectangle structure. This rectangle is linked with a DDraw
 surface, so it contains info about it -> pith & pointer
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
typedef struct _TDE_tdsRect
{
    TDE_tdsVertex   tdsSommet[4];
    long            lPitch;
    TDE_tdxPixel    *p_usPointer;
}TDE_tdsRect;
 
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
 NAME : TDE_tdsLRect
 VERSION : 2.0 / Valérie
           1.0 / Franck
 
 Light Rectangle structure. Without DD surface.
 Used for Memory sprites
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
typedef struct _TDE_tdsLRect
{
    TDE_tdsVertex   tdsSommet[4];
}TDE_tdsLRect;
 
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
 NAME : TDE_tdsMemZone
 VERSION : 2.0 / Valérie
           1.0 / Franck
 Contains memory zone informations for memory sprites 
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
typedef struct _TDE_tdsMemZone
{    
    TDE_tdxPixel   *p_usPointer;
    TDE_tdsVertex  stDim;
    TDE_tdxPixel   xMagicColor;
}TDE_tdsMemZone;
 
/********************************************************************************
        TDE_tdsSpriteMatrix : Matrix structure
*********************************************************************************/
typedef struct _TDE_tdsMatrix
{
    TDE_tdxValue    a4_xM[2][2];
}TDE_tdsMatrix;
 
 
typedef struct _TDE_tdsSuperObjectMatrix
{
    TDE_tdxAngle    xAngle;             /* angle in radians*/
    TDE_tdsVertex   stScale;            /* zoom vertex*/
    TDE_tdsMatrix   a4_xS;              /* Scale matrix*/
    TDE_tdsMatrix   a4_xRxS;            /* Product matrix*/
    TDE_tdsVertex   stTranslateVertex;  /* Center coodinates*/
}TDE_tdsSuperObjectMatrix;
 
/*********************************************************************************
        TDE_tdsPictureAttributes : source attributes
**********************************************************************************/
 
typedef struct _TDE_tdsPictureAttributes
{
    TDE_tdxValue    xWidth;
    TDE_tdxValue    xHeight;
    TDE_tdxValue    xSrcPitch;      /* Source pitch */
    TDE_tdLP_SOURCE lp_Data;        /* Source type*/
    TDE_tdLP_SURF   lp_DDS;
}TDE_tdsPictureAttributes;
 
 
/********************************************************************************
        TDE_tdsSprite : sprite structure
*********************************************************************************/
typedef struct _TDE_tdsSprite
{
    TDE_tdsVertex            stDim;            /* Dimensions of the sprite    */
    TDE_tdxPixel             xMagicColor;
    TDE_tdxPixel             *v_pData;         /* pointer on memory data      */
    CHAR                     c_NZ;             /* Is there a non-zero color ?*/
    TDE_tdsVertex            stSourceOrigin;
    CHAR                     cFlip;
    TDE_tdsPictureAttributes stPicture;        /* Picture attributes*/
    CHAR                     cSemiTransparent; /* 1 -> semi-transparent (50-50)*/
    TDE_tdxValue             alpha;
}TDE_tdsSprite;
 
/********************************************************************************
        TDE_tdsLine : line structure
*********************************************************************************/
typedef struct _TDE_tdsLine
{
    LONG            lColor;         /* color of the line*/
    TDE_tdxValue    xLength;
}TDE_tdsLine;
 
/********************************************************************************
        TDE_tdsSuperObject : super object structure
*********************************************************************************/
 
typedef enum {
    TDE_eOT_EMPTY   = 0,
    TDE_eOT_SPRITE  = 1,
    TDE_eOT_TEXTBOX = 2,
    TDE_eOT_LINE    = 3
} TDE_tdeType;
 
typedef struct _TDE_tdsSuperObject  *TDE_p_stSuperObject;
 
typedef struct _TDE_tdsTextBox TDE_tdsTextBox;
 
typedef struct _TDE_tdsSuperObject
{
    SHORT                       sPriority;
    TDE_tdsSuperObjectMatrix    stMatrix;         /* Rotation & translation matrix*/
    TDE_tdsSuperObjectMatrix    stModifiedMatrix;       
    TDE_p_stSuperObject         p_stChild;            
    TDE_p_stSuperObject         p_stLeftBrother;
    TDE_p_stSuperObject         p_stRightBrother;
    TDE_p_stSuperObject         p_stFather;
    TDE_p_stSuperObject         p_stNextZList;
    TDE_tdeType                 eType;            /* Type of the object (sprite, line)*/
    union {
        TDE_tdsSprite           *p_stSprite;
        TDE_tdsTextBox          *p_stTextBox;
        TDE_tdsLine             *p_stLine;
        void                    *p_vPointer;
    };
    TDE_tdsRect                *p_stSOClipRect;
    long                        lArea;            /* ID to menu_object*/
    long                        lObject;          /* First dependance ! Maybe temporary    */
}TDE_tdsSuperObject;
 
 
/*/////////////////////////////////////////////////////////////////////////////*/
/* TDE_tdsAnimatedCursor : */
/* Sprite list of an animated cursor.*/
/**/
/* stActiveCoordinates are coordinates of the acive point of the mouse cursor.*/
/* they are given in absolute coordinates but relatively to sprite center*/
/**/
/*                         ------------*/
/*                         |          |*/
/*                         |   (0,0)  |*/
/*                         |     --------> X*/
/*                         |     |    |*/
/*                         |     |    |*/
/*                         |     |    |  */
/*                         ------|-----*/
/*                            Y  v*/
/**/
/*/////////////////////////////////////////////////////////////////////////////*/
typedef struct _TDE_tdsAnimatedCursor  *TDE_p_stAnimatedCursor;
 
typedef struct _TDE_tdsAnimatedCursor
{
    TDE_tdsVertex               stActiveCoordinates;
    TDE_tdsSprite               Step;
    TDE_p_stAnimatedCursor      Next;
}TDE_tdsAnimatedCursor;
 
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
 NAME : TDE_tdsBitmapFont
 VERSION : 2.0 / Valérie
           1.0 / Franck
 
 MBF Font structure
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
typedef struct _TDE_tdsBitmapLetter
{
    TDE_tdsSuperObject  stBLetter;
    unsigned short    usVAlign;
}TDE_tdsBitmapLetter;
 
typedef struct _TDE_tdsBitmapFont
{
    TDE_tdsBitmapLetter      *p_stMBLetter[TDE_kNBLETTERS];
    unsigned short           usHMax;
    unsigned short           usVAMax;
    unsigned short           usHorzSep;
    unsigned short           usVertSep;
}TDE_tdsBitmapFont;
 
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
 NAME : TDE_tdsTrueTypeFont
 VERSION : 2.0 / Valérie
           1.0 / Franck
 
 MTF Font structure
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
typedef struct _TDE_tdsTrueTypeFont
{
    HFONT       hFont;
    COLORREF    lColor;
}TDE_tdsTrueTypeFont;
 
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
 NAME : TDE_tdsTextBox
 VERSION : 2.0 / Valérie
           1.0 / Franck
 
 Third SO type after sprites & lines
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
typedef enum _TDE_tdeFontType
{
    TDE_eFT_BITMAP,
    TDE_eFT_TRUETYPE,
    TDE_eFT_UNDEFINED
} TDE_tdeFontType;
 
typedef enum _TDE_tdeCursorType
{
    TDE_eCT_NOCURSOR    = 0,
    TDE_eCT_INSERT      = 1,
    TDE_eCT_OVERWRITE   = 2
} TDE_tdeCursorType;
 
typedef struct _TDE_tdsTextBox
{
/*  Formatting rectangle*/
    TDE_tdsRect            *p_stFormatRect;
/*  Clipping rectangle*/
    TDE_tdsRect            *p_stClipRect;
/*  Font*/
    TDE_tdeFontType         eFontType;
    union {
    TDE_tdsBitmapFont       *p_stBFont;
    TDE_tdsTrueTypeFont     *p_stTFont;
    };
/*  Format of the text (like in Windows DrawText function)*/
    unsigned long           ulStyle;
/*  Text*/
    char                    *p_cText;
/*  Normal colors (0) or negative colors (1)*/
    char                    cColorMode;
/*  Index of flicking cursor in text*/
    long                    lCursorPosition;
/*  Cursor type*/
    TDE_tdeCursorType       eCursorType;
}TDE_tdsTextBox;
 
/********************************************************************************
        TDE_tdsCamera : camera structure
*********************************************************************************/
typedef TDE_tdsSuperObjectMatrix TDE_tdsCamera;
 
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
 NAME : TDE_tdstPickInfo
 VERSION : 2.0 / Valérie
           1.0 / Franck
 
 Structure used for picking
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
typedef struct TDE_tdstSprObjPickInfo_
{
    TDE_tdsSuperObject  *p_stSprObj;
    TDE_tdxPixel        xColor;
} TDE_tdstSprObjPickInfo;
 
 
typedef struct TDE_tdstPickInfo_
{
    int                     iNbSprPick;
    TDE_tdstSprObjPickInfo  aDEF_stInfo[TDE_kMAXPICK];    
} TDE_tdstPickInfo;
 
#ifdef __cplusplus
};
#endif /* __cplusplus */
 
 
#endif /* __TDE_STRUCT_H  */
 
 
 
 
 
 
 
