/****************************************************************************************/
/*                                                                                      */
/*              Fichier objstr.h                                                        */
/*              Structure de données des différents objets affichables                  */
/*                                                                                      */
/*              Fred Manisse                                                            */
/*                                                                                      */
/****************************************************************************************/



//
// Modifications History
//
//$ LB (13/06/2002) : changed the objbitmap struct to manage the GDI problem.
//
//$LB (20/12/2002) : 16 bits to 24 bits
//
//$LB (16/12/2003) : add a background bitmap to the ObjWindow struct, in order to simulate
//                   the windows transparency (Win95, 98, Me). (WinXp, win2k : doesn't have to be
//                   simulated). 




#ifndef OBJSTR_H
#define OBJSTR_H

#include <windows.h>




#define OBJ_TYPE_NULL                   0
#define OBJ_TYPE_WINDOW                 1
#define OBJ_TYPE_TEXT                   2
#define OBJ_TYPE_EDIT_LINE              3
#define OBJ_TYPE_EDIT_TEXT              4
#define OBJ_TYPE_PUSHBUTTON             5
#define OBJ_TYPE_MENU                   6
#define OBJ_TYPE_CHECK_BOX              7
#define OBJ_TYPE_COMBO_BOX              8
#define OBJ_TYPE_FONT                   9
#define OBJ_TYPE_RICH_TEXT              10
#define OBJ_TYPE_BITMAP                 11
#define OBJ_TYPE_PUSH_BUTTON_BITMAP     12
#define OBJ_TYPE_LIST_BOX               14
#define OBJ_TYPE_MENU_ITEM              15
#define OBJ_TYPE_CURSOR                 16
#define OBJ_TYPE_TREE                   17
#define OBJ_TYPE_LISTBITMAP             18
#define OBJ_TYPE_LISTTAB                19
#define OBJ_TYPE_HEADER                 20

/* definition des constantes d'etat de la fenetre */
#define WINDOW_MINIMIZED                1
#define WINDOW_MAXIMIZED                2
#define WINDOW_RESTORED                 3
#define WINDOW_HIDDEN                   4
#define WINDOW_UNHIDDEN                 5

/* definition des constantes de creation des 'fenetres 2d' */
#define WN_MINIMIZE                     (1<<0)
#define WN_NOBORDER                     (1<<1)
#define WN_NOCAPTION                    (1<<2)
#define WN_NOCLIPCHILDREN               (1<<3)
#define WN_CHILD                        (1<<4)
#define WN_ACTIVEX                      (1<<5)
#define WN_MINBOX                       (1<<6)
#define WN_SIZEBOX                      (1<<7)
#define WN_MENU                         (1<<8)
#define WN_NOCURSOR                     (1<<9)
#define WN_NOFOCUS                      (1<<10)
#define WN_DRAGDROP                     (1<<11)
#define WN_CHILDMENU                    (1<<12)
#define WN_HIDE                         (1<<13)
#define WN_DIALOG                       (1<<14)
#define WN_DOWN                         (1<<15)
#define WN_GROUP                        (1<<16)
#define WN_MAXBOX                       (1<<17)
#define WN_MODAL                        (1<<18)
#define WN_HSCROLL                      (1<<19)
#define WN_VSCROLL                      (1<<20)
#define WN_CHILDSCROLL                  (1<<21)
#define WN_NOBACKGROUND					(1<<22)

/****************************************************************************************/
/*                                                                                      */
/*              Structure ObjVoid : structure de base, commune a tout les objets        */
/*                                                                                      */
/****************************************************************************************/

struct ObjVoid {

        int     Type            ; /* le type d'objet , voir plus bas                    */       
        int     Father          ; /* le pointeur magma sur le pere                      */
        int     Buffer          ; /* donnee de type TYPEBUF                             */
        int     Tab             ; /* donnee de type TYPETAB                             */
} ;


typedef struct ObjVoid *PtrObjVoid ;




/****************************************************************************************/
/*                                                                                      */
/*     Structure for bitmap type                                                         */
/*                                                                                      */
/****************************************************************************************/

//$ LB (13/06/2002) : changed the objbitmap struct to manage the GDI problem.
//$ LB (12/07/2003) : 16 bits to 24 bits


typedef unsigned char* OBJBITMAP_BUFFER;

struct ObjBitmap {

        int PosX ;
        int PosY ;
        int TailleW ;
        int TailleH ;
        int BPP , BytesPP, BPL ;
        int Flags ;
        HWND WHandler ;        
        int Couleurs ; /* nombre de couleur */

		int handler;           // new global handler
		OBJBITMAP_BUFFER bits; // bitmap buffer
		PALETTEENTRY *table;   // table of colors
        HBITMAP DIBhandler;    // handler of the DIBSection
};

typedef struct ObjBitmap * PtrObjBitmap ;




//$LB (16/12/2003)
extern PtrObjBitmap LIB2DtransBkg; /* background bitmap for simulated window transparency */


struct Palette {
    unsigned char R [ 256 ] ;
    unsigned char G [ 256 ] ;
    unsigned char B [ 256 ] ;
} ;

typedef struct Palette * PtrPalette ;
#define GET_RED(pal,num)  ((pal)->R[num]) 
#define GET_GREEN(pal,num) ((pal)->G[num])
#define GET_BLUE(pal,num) ((pal)->B[num])









/****************************************************************************************/ 
/*                                                                                      */ 
/*              Structure ObjWindow : structure de donnees buffer d'un objet window     */ 
/*                                                                                      */ 
/****************************************************************************************/ 

//$LB (16/12/2003) : add a background bitmap to the ObjWindow struct, in order to simulate
//                   the windows transparency (Win95, 98, Me). (WinXp, win2k : doesn't have to be
//                   simulated). 
struct ObjWindow {

        int     PosX            ; /* position X a l'ecran                               */ 
        int     PosY            ; /* position Y a l'ecran                               */ 
        int     TailleW         ; /* taille horizontale de la fenetre                   */ 
        int     TailleH         ; /* tailel verticale de la fenetre                     */ 
        int     Flags           ; /* flags de la fenetre                                */ 
        HWND    WHandler        ; /* Handler Windows                                    */ 
        int     MinW            ; /* taille minimale horizontale de la fenetre          */ 
        int     MinH            ; /* taille minimale verticale de la fenetre            */ 
        int     MaxW            ; /* taille maximale horizontale de la fenetre          */ 
        int     MaxH            ; /* taille maximale verticale de la fenetre            */ 
        HWND    Child           ; /* fenetre fille pour le scrolling                    */ 
        HCURSOR Cursor           ; /* fenetre fille pour le scrolling                    */ 

		//$LB(16/12/2003)
		unsigned char tSimulated; /* 1 if simulated (Win95,98,ME,NT),                    */
		PtrObjBitmap  tBuf      ; /* bitmap buffer for simulated transpary               */
		PtrObjBitmap  tBkg      ; /* point to LIB2DtransBkg                              */
		int           tX, tY    ; /* <=> window coordinates <=> coordinates of the LIB2DtransBkg area to draw */
		unsigned char tColorB   ; /* transparency color R G B                            */
		unsigned char tColorG   ;
		unsigned char tColorR   ; 
		unsigned char tfactor   ; /* alpha blending factor                                    */
		int           tflags    ; /* transparency flags : transparency color | alpha blending */

        };        

typedef struct ObjWindow *PtrObjWindow ;


/****************************************************************************************/
/*                                                                                      */
/*            Structure pour le type Font                                               */
/*                                                                                      */
/****************************************************************************************/

struct ObjFont {

        int Height ;
        int Direction ;
        int Flags ;
        HFONT WHandler ;
} ;

typedef struct ObjFont * PtrObjFont ;
                





//$LB (11/11/2003)
/****************************************************************************************/
/*                                                                                      */
/*      Structure pour le type cursor                                                   */
/*                                                                                      */
/****************************************************************************************/

struct ObjCursor {

    HCURSOR HCursor ;
    int X ;
    int Y ;  
} ;

typedef struct ObjCursor * PtrObjCursor ;
//////////////////////////


#endif