home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Graphics / PPT / include / ppt.h < prev    next >
C/C++ Source or Header  |  1999-11-08  |  19KB  |  579 lines

  1. /*
  2.     PROJECT: ppt
  3.     MODULE : ppt.h
  4.  
  5.     $Revision: 6.0 $
  6.         $Date: 1999/09/05 02:19:28 $
  7.       $Author: jj $
  8.  
  9.     Main definitions for PPT.
  10.  
  11.     This file is (C) Janne Jalkanen 1994-1999.
  12.  
  13.     Please note that those fields marked PRIVATE in structures truly are
  14.     so. So keep your hands off them, because they will probably change between releases.
  15.  
  16.  */
  17.  
  18. #ifndef PPT_H
  19. #define PPT_H
  20.  
  21. #if defined(_POWERPC)
  22. #pragma options align=m68k
  23. #endif
  24.  
  25. #ifndef INTUITION_INTUITION_H
  26. #include <intuition/intuition.h>
  27. #endif
  28.  
  29. #ifndef EXEC_NODES_H
  30. #include <exec/nodes.h>
  31. #endif
  32.  
  33. #ifndef EXEC_EXECBASE_H
  34. #include <exec/execbase.h>
  35. #endif
  36.  
  37. #ifndef EXEC_TYPES_H
  38. #include <exec/types.h>
  39. #endif
  40.  
  41. #ifndef EXEC_LIBRARIES_H
  42. #include <exec/libraries.h>
  43. #endif
  44.  
  45. #ifndef DOS_DOS_H
  46. #include <dos/dos.h>
  47. #endif
  48.  
  49. #ifndef LIBRARIES_IFFPARSE_H
  50. #include <libraries/iffparse.h>
  51. #endif
  52.  
  53. #ifndef LIBRARIES_BGUI_H
  54. #include <libraries/bgui.h>
  55. #endif
  56.  
  57. #ifndef LIBRARIES_LOCALE_H
  58. #include <libraries/locale.h>
  59. #endif
  60.  
  61. #ifndef ASKREQ_H
  62. #include "askreq.h"
  63. #endif
  64.  
  65. /*------------------------------------------------------------------*/
  66. /* Types we will use everywhere */
  67.  
  68. typedef UBYTE *     ROWPTR;         /* Sample row pointer */
  69. typedef void *      FPTR;           /* Function pointer */
  70. typedef LONG        PERROR;         /* Error code */
  71. typedef ULONG       ID;             /* Identification code */
  72.  
  73. typedef struct RGBPixel_T {
  74.     UBYTE r,g,b;
  75. } RGBPixel;
  76.  
  77. typedef struct ARGBPixel_T {
  78.     UBYTE a,r,g,b;
  79. } ARGBPixel;
  80.  
  81. typedef struct GrayPixel_T {
  82.     UBYTE g;
  83. } GrayPixel;
  84.  
  85. typedef void Pixel;                 /* Use only as Pixel * */
  86.  
  87. /*
  88.  *  These macros can be used to extract an ULONG-cast
  89.  *  ARGB pixels components.
  90.  */
  91.  
  92. #define ARGB_A(x) (UBYTE)((x) >> 24)
  93. #define ARGB_R(x) (UBYTE)((x) >> 16)
  94. #define ARGB_G(x) (UBYTE)((x) >> 8)
  95. #define ARGB_B(x) (UBYTE)(x)
  96.  
  97. /* Useful macros and definitions */
  98.  
  99. #define NEGNUL      ((void *) ~0)
  100. #define POKE(s,v)   ( (*(s)) = (v) )
  101. #define PEEKL(x)    (*( (LONG *) (x) ))
  102. #define MIN(a,b)    ( ((a) < (b)) ? (a) : (b) )
  103. #define MAX(a,b)    ( ((a) > (b)) ? (a) : (b) )
  104. #define SYSBASE()   (struct Library *)(* ((ULONG *)4L))
  105. #define MULU16(x,y) ( (UWORD)(x) * (UWORD)(y) ) /* To get DCC compile fast code */
  106. #define MULS16(x,y) ( (WORD)(x) * (WORD)(y) )
  107. #define MULUW(x,y)  MULU16(x,y)
  108. #define MULSW(x,y)  MULS16(x,y)
  109.  
  110. /* Clamps x between a and b (inclusive) */
  111.  
  112. #define CLAMP(x,min,max)        if( (x) < (min) ) { (x) = (min); } \
  113.                                 else if( (x) > (max) ) { (x) = (max); }
  114.  
  115. /* This macro calculates picture size in bytes. Requires pointer to a  pixinfo
  116.    structure.*/
  117. #define PICSIZE(a) \
  118.     (ULONG)( (a)->height * (a)->bytes_per_row )
  119.  
  120. /* This macro gives the row length. OBSOLETE */
  121. #define ROWLEN(a) \
  122.     ( ((PIXINFO *)(a))->bytes_per_row )
  123.  
  124. /*------------------------------------------------------------------*/
  125. /* Definitions */
  126.  
  127. #define MAXPATHLEN          256     /* Std AmigaDOS path len */
  128. #define NAMELEN             40      /* Maximum length of frame name */
  129. #define MAXPATTERNLEN       80      /* The maximum length for PPTX_PostFixPattern */
  130.  
  131. /*
  132.  *  Maximum image dimensions - current internal limit.
  133.  *  Do not rely on these.  They may grow bigger, but not
  134.  *  smaller.
  135.  */
  136.  
  137. #define MAX_WIDTH           16383
  138. #define MAX_HEIGHT          16383
  139.  
  140.  
  141. /*------------------------------------------------------------------*/
  142.  
  143. /*
  144.     This must be in the beginning of each external module.
  145.  
  146.     NB:  Does not concern you!  Just make a shared library and be happy.
  147.  */
  148.  
  149. struct ModuleInfo {
  150.     ULONG           code[2];    /* moveq.l #-1,d0; rts */
  151.     ULONG           id;         /* Identification string. See below.*/
  152.     struct TagItem  *tagarray;
  153. };
  154.  
  155. /* The ID's for the id-field. */
  156.  
  157. #define ID_LOADER       MAKE_ID('P','P','T','L')
  158. #define ID_EFFECT       MAKE_ID('P','P','T','F')
  159.  
  160.  
  161.  
  162. /*------------------------------------------------------------------*/
  163.  
  164.  
  165. /*
  166.     This structure contains information on the picture data itself.
  167.     Your loader should fill out any necessary fields.
  168. */
  169.  
  170. typedef struct {
  171.     UWORD           height,     /* Picture height and width */
  172.                     width;
  173.  
  174.     UBYTE           colorspace; /* See below.  */
  175.     UBYTE           components; /* Amount of components: 4 for ARGB,
  176.                                    3 for fullcolor, 1 for grayscale */
  177.     UBYTE           origdepth;  /* Original depth information. */
  178.  
  179.     UBYTE           bits_per_component; /* Currently 8 */
  180.  
  181.     UWORD           DPIX, DPIY; /* Dots per inch.  Use these to signify the
  182.                                    aspect ratio of the image.  If you do not
  183.                                    know the DPI values, use 72 as the base value,
  184.                                    as this is a common guess for an image to
  185.                                    be shown on a computer screen.  It is safe
  186.                                    to put zero in either of the locations (which
  187.                                    signifies 1:1 aspect ratio.) */
  188.  
  189.     ULONG           private1;   /* Private data. */
  190.  
  191.     ULONG           bytes_per_row; /* Amount of bytes / pixel row. */
  192.  
  193.     ULONG           origmodeid; /* Original display mode id */
  194.  
  195.     /* The fields beyond this point are PRIVATE! */
  196.  
  197. } PIXINFO;
  198.  
  199. /* Possible color spaces. */
  200.  
  201. #define CS_UNKNOWN          0   /* Not known at this time */
  202. #define CS_GRAYLEVEL        1   /* 8bit graylevel data */
  203. #define CS_RGB              2   /* 24 bit RGB data */
  204. #define CS_LUT              3   /* Color lookup table.  DO NOT USE! */
  205. #define CS_ARGB             4   /* 32 bit ARGB data */
  206.  
  207. /* Flag definitions for PPTX_ColorSpaces.  Please note that CSF_LUT
  208.    is used ONLY on savers.  PPT processes only in real color, but a color-
  209.    reduced image can be saved. */
  210.  
  211. #define CSF_NONE            0x00   /* Use this to signify nothing is understood*/
  212. #define CSF_UNKNOWN         (1<<CS_UNKNOWN)   /* Dummy. Not used. */
  213. #define CSF_GRAYLEVEL       (1<<CS_GRAYLEVEL)
  214. #define CSF_RGB             (1<<CS_RGB)
  215. #define CSF_LUT             (1<<CS_LUT)
  216. #define CSF_ARGB            (1<<CS_ARGB)
  217.  
  218.  
  219. /*
  220.     The display structure contains the data about a rendered image or
  221.     an open display.
  222.  
  223.     This structure is READ ONLY!  And most of the time, nothing very
  224.     useful is in it, anyway...  Use only, if you really need the information,
  225.     for example in a saver module.
  226.  
  227.     The colortable contains up to ncolors ARGBPixel_T structures that
  228.     contain the RGB values as well as the Alpha channel value for an image.
  229.     An alpha value of 255 means that this color is fully transparent, a value
  230.     of zero means that it is not transparent at all.
  231.  
  232.     If the image format supports only one transparent color, then you should
  233.     use the first color (starting from color zero) with a transparency value of 255.
  234.  
  235.     More than 8 bits-per-gun colortables are not supported, as I really do not
  236.     see the value for using anything else.  In heavy-duty-image processing yes,
  237.     but colormapped images were originally used because the display hardware
  238.     could not cope with the bandwiths required for a full truecolor display and
  239.     are nowadays used just to keep the image size down.
  240.  
  241.     If you really need 16-bits per gun color, then tell me.
  242.  
  243.  */
  244.  
  245. typedef struct ARGBPixel_T      COLORMAP;
  246.  
  247. typedef struct {
  248.     struct Screen   *scr;       /* NULL, if not opened */
  249.     struct Window   *win;       /* Render to this windows rastport. */
  250.     COLORMAP        *colortable; /* The colormap. See above. */
  251.     UWORD           height,width;  /* Sizes. */
  252.     ULONG           dispid;     /* Standard display ID */
  253.     ULONG           ncolors;    /* Number of colors. May be somewhere between 2...depth */
  254.     UWORD           type;       /* PRIVATE */
  255.     UWORD           depth;      /* The depth the screen should use */
  256.  
  257.     UWORD           DPIX, DPIY; /* The DPI values of the display. */
  258.  
  259.     /* All fields below this point are PRIVATE */
  260. } DISPLAY;
  261.  
  262.  
  263.  
  264. /*
  265.     The main frame structure holds all necessary information to handle a
  266.     picture.
  267.  */
  268.  
  269.  
  270. typedef struct Frame_t {
  271.     struct Node     nd;             /* PRIVATE! */
  272.     char            path[MAXPATHLEN];/* Just the path-part.*/
  273.     char            name[NAMELEN];  /* The name of the frame, as seen in main display */
  274.     struct Process  *currproc;      /* Points to current owning process. */
  275.     PIXINFO         *pix;           /* Picture data.  See above. */
  276.     DISPLAY         *disp;          /* This is the display window. See above. */
  277.     struct Rectangle selbox;        /* This contains the bounding box of the area
  278.                                        currently selected. */
  279.  
  280.     /* All data beyond this point is PRIVATE! */
  281. } FRAME;
  282.  
  283.  
  284. /*
  285.     This structure contains info about user preferred values. sizeof(PREFS)
  286.     should be divisible by four. This structure is definately read-only,
  287.     but suggested reading if you open your own GUI. Please note especially
  288.     user font preferences.
  289.  */
  290.  
  291. typedef struct {
  292.     /*
  293.      *  NB:  The TextAttr pointers below may very well be NULL, in which
  294.      *       case the user has not set a preference and you should use the
  295.      *       default screen font.
  296.      */
  297.  
  298.     struct TextAttr *mainfont;
  299.     struct TextAttr *listfont;
  300.  
  301.     /*
  302.      *  The (recommended) preview height and preview width.  If you are
  303.      *  providing your own previews, then you should observe these.  Try not
  304.      *  to skew the aspect ratio of the image too much.
  305.      *
  306.      *  Do not cache these, as they may be set by the user (or PPT) at any time.
  307.      */
  308.  
  309.     WORD            previewheight,
  310.                     previewwidth;
  311.  
  312.     /*
  313.      *  If this is set to TRUE, then the user wants to confirm most of
  314.      *  his requesters.  If FALSE, he does not want to do that, so you
  315.      *  should only show the most important requesters and take the default
  316.      *  action for everything else.  This is really a power-user option.
  317.      */
  318.  
  319.     BOOL            confirm;
  320.  
  321.     /* PRIVATE data only beyond this point */
  322.  
  323. } PREFS;
  324.  
  325.  
  326. /*
  327.     Global variables structure. If you wish to read this structure, you must
  328.     ObtainSemaphoreShared(&phore) first. But don't hold it too long. Writing to
  329.     this structure is reserved for the main program ONLY! Use the support
  330.     functions, if you ever have to meddle with this structure.
  331.  */
  332.  
  333. typedef struct {
  334.     struct SignalSemaphore phore;   /* Must be locked if you read the struct! */
  335.     DISPLAY         *maindisp;      /* Main display data. */
  336.     PREFS           *userprefs;     /* Currently applicable preferences */
  337.     struct MsgPort  *mport;         /* Main message port for externals to call in. */
  338.  
  339.     /* PRIVATE data beyond this point*/
  340. } GLOBALS;
  341.  
  342.  
  343. /*
  344.     This structure is the library base for the PPT support functions library.
  345.     It has valid library bases if you wish to use them. These are guaranteed to be
  346.     unique to your task. A pointer to this structure is passed to your external
  347.     in A5. All support functions also expect a pointer to this structure to be
  348.     passed in A6 whenever you call them.
  349.  
  350.     You don't need to explicitly open this library.
  351.  
  352.     Thou shalt not modify any data in it!
  353.  
  354.     lib is a standard library node. Currently only lib.Version field is supported.
  355.     You may use this to check the PPT main version number.
  356. */
  357.  
  358. struct PPTBase {
  359.     struct Library  lib;            /* A standard library structure */
  360.  
  361. /* PPT public fields start here. Read, don't write. */
  362.  
  363.     GLOBALS         *g;             /* Pointer to PPT global variables */
  364.     struct MsgPort  *mport;         /* Your own message port */
  365.     struct ExecBase *lb_Sys;        /* Exec.library */
  366.     struct IntuitionBase *lb_Intuition;
  367.     struct Library  *lb_Utility;
  368.     struct GfxBase  *lb_Gfx;        /* Graphics.library */
  369.     struct DosLibrary *lb_DOS;
  370.     struct Library  *lb_BGUI;       /* bgui.library */
  371.     struct Library  *lb_GadTools;   /* gadtools.library */
  372.  
  373.     /*
  374.      *  The following fields are for the AmigaOS localization system,
  375.      *  available from OS 2.1 (V38) onwards. If your system does not
  376.      *  support localization, locales could not be opened or your
  377.      *  external module does not support localization at all, some or
  378.      *  all of these fields may be NULL. Always check before using!
  379.      *
  380.      *  For more information on how the PPT submodule localization works,
  381.      *  see the autodoc for pptsupp/GetStr().
  382.      */
  383.  
  384.     struct Library  *lb_Locale;     /* locale.library */
  385.     struct Locale   *locale;        /* The current locale. */
  386.     struct Catalog  *extcatalog;    /* This external's own catalog, opened by PPT */
  387.  
  388. /* PPT private fields start here. Don't even read. */
  389.  
  390.  
  391. /* PPT hyper-private experimental fields start here. Don't even think about reading.
  392.    See?  Now the system is in a completely unstable state and may crash any time.
  393.    Your fault! */
  394.  
  395. };
  396.  
  397. /*
  398.  *  Obsolete stuff
  399.  */
  400.  
  401. typedef struct PPTBase EXTBASE;
  402.  
  403. /*------------------------------------------------------------------------*/
  404. /*
  405.     The locale subsystem. See the autodoc on pptsupp/GetStr()
  406. */
  407.  
  408. struct LocaleString {
  409.     LONG    ID;
  410.     STRPTR  Str;
  411. };
  412.  
  413.  
  414. /*------------------------------------------------------------------*/
  415. /* Global tags for external programs. */
  416.  
  417.  
  418. #define GTAGBASE                ( TAG_USER + 10000 )
  419.  
  420. /*
  421.  *  External info tags. These tags can be found in the external's tagarray
  422.  *  that describes the external. These are common for both loaders and
  423.  *  filters.
  424.  *
  425.  *  More information about the different tags can be found in the
  426.  *  file 'tags.doc'
  427.  */
  428.  
  429. #define PPTX_Version            ( GTAGBASE + 1 ) /* UWORD. OBSOLETE */
  430. #define PPTX_Revision           ( GTAGBASE + 2 ) /* UWORD. OBSOLETE */
  431. #define PPTX_Name               ( GTAGBASE + 4 ) /* UBYTE * */
  432. #define PPTX_CPU                ( GTAGBASE + 5 ) /* UWORD, see execbase.h */
  433. #define PPTX_InfoTxt            ( GTAGBASE + 7 ) /* STRPTR */
  434. #define PPTX_Author             ( GTAGBASE + 8 ) /* STRPTR */
  435. #define PPTX_ReqKickVersion     ( GTAGBASE + 9 ) /* UWORD */
  436. #define PPTX_ReqPPTVersion      ( GTAGBASE + 10) /* UWORD */
  437. #define PPTX_ColorSpaces        ( GTAGBASE + 11) /* ULONG */
  438. #define PPTX_RexxTemplate       ( GTAGBASE + 12) /* STRPTR */
  439. #define PPTX_Priority           ( GTAGBASE + 13) /* BYTE */
  440. #define PPTX_SupportsGetArgs    ( GTAGBASE + 14) /* BOOL */
  441.  
  442.  
  443. /*
  444.  *  Loader specifig tags
  445.  */
  446.  
  447. #define PPTX_Load               ( GTAGBASE + 101 ) /* BOOL */
  448. #define PPTX_NoFile             ( GTAGBASE + 105 ) /* BOOL */
  449. #define PPTX_PreferredPostFix   ( GTAGBASE + 106 ) /* STRPTR */
  450. #define PPTX_PostFixPattern     ( GTAGBASE + 107 ) /* STRPTR */
  451.  
  452. /*
  453.  *  Effect specific tags
  454.  */
  455.  
  456. #define PPTX_EasyExec           ( GTAGBASE + 201 ) /* FPTR. OBSOLETE */
  457. #define PPTX_EasyTitle          ( GTAGBASE + 202 ) /* FPTR. OBSOLETE */
  458. #define PPTX_NoNewFrame         ( GTAGBASE + 203 ) /* BOOL */
  459. #define PPTX_NoChangeFrame      ( GTAGBASE + 204 ) /* BOOL (V5) */
  460.  
  461. /*
  462.  *  These tags can be passed to externals upon execution.
  463.  */
  464.  
  465. #define PPTX_RexxArgs           ( GTAGBASE + 1005 ) /* ULONG * */
  466. #define PPTX_FileName           ( GTAGBASE + 1006 ) /* STRPTR */
  467. #define PPTX_ArgBuffer          ( GTAGBASE + 1007 ) /* STRPTR (V6) */
  468.  
  469. /*
  470.  *  The following tags have been reserved for the ObtainPreviewFrame()
  471.  *  calls.
  472.  */
  473.  
  474. #define PREV_PreviewHook        ( GTAGBASE + 10000 ) /* struct Hook * */
  475.  
  476. /*------------------------------------------------------------------*/
  477. /* Error codes.  You should note that if you use these error
  478.    codes in SetErrorCode() you'll get a text box describing the
  479.    error in a vaguely general way.  For example, if you return
  480.    PERR_OUTOFMEMORY, PPT will display a requester stating that
  481.    your module just ran out of memory. */
  482.  
  483.  
  484. #define PERR_OK             0
  485. #define PERR_UNKNOWNTYPE    1 /* ie. Unknown filetype, etc. */
  486. #define PERR_OUTOFMEMORY    2 /* Pretty clear, eh? */
  487. #define PERR_WONTOPEN       3 /* if file refuses to open. OBSOLETE */
  488. #define PERR_INUSE          4 /* Someone is using the object */
  489. #define PERR_INITFAILED     5 /* Cannot initialize.  Could mean anything. */
  490. #define PERR_FAILED         6 /* A general failure */
  491. #define PERR_BREAK          7 /* A break signal (CTRL-C) was received */
  492. #define PERR_MISSINGCODE    8 /* If the loader/etc misses code. */
  493. #define PERR_CANCELED       9 /* If the user canceled */
  494. #define PERR_INVALIDARGS   10 /* If user gives invalid arguments to some
  495.                                  lone piece of code. */
  496. #define PERR_WINDOWOPEN    11
  497. #define PERR_FILEOPEN      12
  498. #define PERR_FILEREAD      13
  499. #define PERR_FILEWRITE     14
  500. #define PERR_FILECLOSE     15
  501.  
  502. #define PERR_WARNING       16 /* If something non-fatal happened */
  503.  
  504.  
  505. #define PERR_GENERAL       PERR_FAILED  /* Obsolete */
  506. #define PERR_ERROR         PERR_FAILED  /* Obsolete */
  507.  
  508. #define PERR_NOTINIMAGE    17 /* An out-of-bounds error happened when
  509.                                  indexing an image */
  510. #define PERR_UNKNOWNCOLORSPACE 18 /* An unsupported colorspace was met */
  511.  
  512.  
  513. /*------------------------------------------------------------------*/
  514. /* Flags.
  515.  
  516.    First, the DFF_* flags are for the DupFrame() function.  See
  517.    the autodoc for more information.
  518.  
  519. */
  520.  
  521. #define DFF_COPYDATA        (1<<0)
  522. #define DFF_MAKENEWNAME     (1<<1)
  523.  
  524. /*
  525.  *  Flags for the CopyFrameData() function.
  526.  */
  527.  
  528. #define CFDF_SHOWPROGRESS   (1<<0)
  529.  
  530. /* This is completely unofficial and should only be used within PPT */
  531. #define AFF_PPC             (1<<8)
  532.  
  533. /*------------------------------------------------------------------*/
  534. /* Extensions.  This also contains the pre-defined names for
  535.    AddExtension().  For more explanation, see the
  536.    AddExtension() autodoc. */
  537.  
  538. struct Extension {
  539.     struct Node         en_Node;    /* PRIVATE */
  540.     STRPTR              en_Name;
  541.     ULONG               en_Length;
  542.     ID                  en_FrameID;
  543.     ULONG               en_Flags;
  544.     APTR                en_Data;
  545.  
  546.     /* Nothing but private data down from here */
  547. };
  548.  
  549. /*
  550.    Pre-defined names.  Loaders may or may not understand these,
  551.    but these will be supported.  The meanings are as explained
  552.    in the AddExtension() autodoc.
  553. */
  554.  
  555. #define EXTNAME_AUTHOR      "Author"
  556. #define EXTNAME_ANNO        "Annotation"
  557. #define EXTNAME_DATE        "Date"
  558.  
  559. /* Flags for en_Flags.  As usual, all unused bits should be set
  560.    to 0.  Note that some of the flags are mutually exclusive,
  561.    as a datatype cannot be a text string or a value at the same
  562.    time. */
  563.  
  564. #define EXTF_PRIVATE        0x00 /* Private type. PPT will not attempt
  565.                                     to parse this. */
  566. #define EXTF_CSTRING        0x01 /* This extension is a standard C
  567.                                     string with ASCII codeset */
  568. #define EXTF_LONG           0x02 /* The value is a signed long */
  569. #define EXTF_FLOAT          0x03 /* The value is an IEEE floating point
  570.                                     number */
  571.  
  572. #ifndef PPTMESSAGE_H
  573. #include "pptmessage.h"
  574. #endif
  575.  
  576.  
  577. #endif /* PPT_H */
  578.  
  579.