#ifndef IR_IRBASE_H
#define IR_IRBASE_H 1
/*
**  $VER: irbase.h 34.4
**
*/

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef EXEC_LIBRARIES_H
#include <exec/libraries.h>
#endif

#ifndef INTUITION_INTUITION_H
#include <intuition/intuition.h>
#endif

/*
 *  The Base for InfraRed.library
 */

struct IRBase
{
    struct Library LibNode;
};

struct TextBlock {
    struct IntuiText    tb_intuitext;
    struct TextAttr     tb_textattr;
    UBYTE               tb_fontname[32];
    UWORD               tb_width,tb_height;
};    
union renderinfo {
    struct  Image       ri_image;
    struct  TextBlock   ri_textblock;
};    

struct GNode {
    struct  Node        gn_node;            // for list handling (contains also some data - see defines)
    union   renderinfo  gn_renderinfo;      // either struct Image or struct TextBlock
    UWORD               gn_rendersize;      // sizeof( )
    APTR                gn_renderdata;      // pointer to ImageData or Text
    BOOL                gn_learned;         // boolean for the learned-status (only ir-nodes can be learned)
    UBYTE               gn_irdata[800];     // data for ir-signal (or lcontrol-command/shell command or for further use)
    UBYTE               gn_type;            // see defines below
    BOOL                gn_wobbel;          // is it a wobbel code (so send irdata and next time send &irdata[400]
    UBYTE               gn_multisend;       // how often to send
    WORD                gn_left,gn_top,gn_width,gn_height;  // the nodes position
    struct  Gadget      *gn_gadget;         // pointer to Gadget corresponding to this gnode
};

// some defines
#define gn_channel      gn_node.ln_Pri      // for parallel hw
#define gn_dmatyp       gn_channel          // for audio-hw
#define gn_gnrender     gn_node.ln_Type     // render type of gadget
#define gn_name         gn_node.ln_Name     // obsolete! used for dmachannel now!!!

// rendertypes of GNodes
#define GNRENDER_GFX1       0       // it is one grafic (highlight)
#define GNRENDER_GFX2       1       // two graphics (not yet supported)
#define GNRENDER_TEXT       2       // Text (centered)


// macros for better list handling
#define GetGNodeNum( x,y )  getnodenum( x , (struct Node *)y )
#define GetGNodeAddr( x,y ) ((struct GNode *)getnodeaddr( x , y ))
#define GetGSucc( x )       ((struct GNode *)getsucc( (struct Node *) x ))
#define GetGPred( x )       ((struct GNode *)getpred( (struct Node *) x ))
#define GetGHead( x )       ((struct GNode *)gethead( x ))
#define GetGTail( x )       ((struct GNode *)gettail( x ))
#define RemoveG( x )        Remove( (struct Node *) x )
#define AddGTail( x,y)      AddTail( x , (struct Node *)y)

// other macros
#define GNWidthA( gn )   ( &gn->gn_gadget->Width )
#define GNHeightA( gn )  ( &gn->gn_gadget->Height )
#define GNTopA( gn )     ( &gn->gn_gadget->TopEdge )
#define GNLeftA( gn )    ( &gn->gn_gadget->LeftEdge )

#define GNWidth( gn )                  ( gn->gn_gadget->Width     )
#define GNHeight( gn )                 ( gn->gn_gadget->Height    )
#define GNTop( gn )                    ( gn->gn_gadget->TopEdge   )
#define GNLeft( gn )                   ( gn->gn_gadget->LeftEdge  )
#define GNDmaChannel( gn )             ( (int)gn->gn_node.ln_Name )
#define Set_DmaChannel( gn , channel ) (gn->gn_node.ln_Name = (char *)channel )


// the different types of GNodes
#define TYP_DMASEND     8       // audio output
#define TYP_CONRAD      7       // relaicard
#define TYP_COMMAND     6       // shell command
#define TYP_RAPID_CODE  5       // send msg to Rapid
#define TYP_CONTROL_L   4       // send msg to LControl
#define TYP_KHZ66       3       // output frq 66kHz
#define TYP_NOPULSE     2       //  ...
#define TYP_KHZ45       1
#define TYP_KHZ37       0


#define PREFS_CODE      "IRMP1.3"   // the file identifier
struct ProjectHeader {              // leading struct of a file
    UBYTE   pr_name[31];            // ignored (better use the filename)
    UBYTE   pr_fontheight;
    WORD    pr_width;               // width of window
    WORD    pr_height;              // height of window
};    

