home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 199.lha / GimmeLib / DOCS < prev    next >
Encoding:
Text File  |  1988-12-28  |  120.6 KB  |  3,488 lines

  1. /*
  2.  * NAME:    gimmeBitMap
  3.  *
  4.  * SYNOPSIS:    bm = gimmeBitMap( depth, width, height );
  5.  *        struct BitMap *bm;
  6.  *
  7.  * INPUTS:    SHORT    depth;        number of required bitplanes
  8.  *        SHORT    width;        number of columns wide in pixels
  9.  *        SHORT    height;     number of rows high in pixels
  10.  *
  11.  * DESCRIPTION: Allocate and initialize/clear a BitMap struct.
  12.  *        If the depth, width and height parameters are strictly positive,
  13.  *        the required bit-planesare allocated as well, and the BitMap
  14.  *        is properly initialized,
  15.  *        otherwise the BitMap is cleared.
  16.  *
  17.  * RESULTS:    Returns pointer to a BitMap, or NULL if anything went wrong.
  18.  *
  19.  * SEE ALSO:    getRidOfBitMap
  20.  */
  21.  
  22. /*
  23.  * NAME:    getRidOfBitMap
  24.  *
  25.  * SYNOPSIS:    err = getRidOfBitMap( bitmap );
  26.  *        short err;
  27.  *
  28.  * INPUTS:    struct BitMap    *bitmap;    pointer to initialized bitmap
  29.  *
  30.  * DESCRIPTION: Deallocate memory for a bitmap, including bitplanes.
  31.  *        Number of bitplanes determined from bitmap.
  32.  *
  33.  * RESULTS:    Returns non-zero on error.
  34.  *
  35.  * SEE ALSO:    gimmeBitMap
  36.  */
  37.  
  38. /*
  39.  * NAME:    gimmeBitPlanes
  40.  *
  41.  * SYNOPSIS:    flags = gimmeBitPlanes( bm, myflags );
  42.  *        ULONG flags;
  43.  *
  44.  * INPUTS:    struct BitMap    *bm;        ptr to initialized BitMap
  45.  *        ULONG        myflags;    flags for routine
  46.  *
  47.  * DESCRIPTION: Allocate bit-plane(s) given an initialized BitMap struct,
  48.  *        according to the flags:
  49.  *          - contiguous    - all planes allocated contiguously,
  50.  *                    as required for Image data
  51.  *          - separate    - all planes allocated individually
  52.  *          - default    - try contiguous first, then separate
  53.  *
  54.  *        Note: the "initialized" BitMap struct should not have any
  55.  *        planes allocated for it prior to this call, as the plane
  56.  *        pointers are stored in the BitMap's Planes[] field.
  57.  *
  58.  * RESULTS:    Returns actual flags used.
  59.  *        Check if bm->Planes[0] is non-NULL to see if successfull,
  60.  *        or if the returned flags equals the error flag defined in
  61.  *        bitplane.h
  62.  *
  63.  * SEE ALSO:    getRidOfBitPlanes
  64.  */
  65.  
  66. /*
  67.  * NAME:    getRidOfBitPlanes
  68.  *
  69.  * SYNOPSIS:    err = getRidOfBitPlanes( bitmap, myflags );
  70.  *        short err;
  71.  *
  72.  * INPUTS:    struct BitMap    *bitmap;    pointer to initialized bitmap
  73.  *        ULONG        myflags;    flags for routine
  74.  *
  75.  * DESCRIPTION: Deallocate memory for a bitmap's bitplanes.
  76.  *        Number of bitplanes determined from bitmap.
  77.  *
  78.  * RESULTS:    Returns non-zero on error.
  79.  *
  80.  * SEE ALSO:    gimmeBitPlanes
  81.  */
  82.  
  83. /*
  84.  * NAME:    getDefaultColors
  85.  *
  86.  * SYNOPSIS:    colortable = getDefaultColors();
  87.  *        USHORT *colortable;
  88.  *
  89.  * DESCRIPTION: Get pointer to the default color table.
  90.  *
  91.  * RESULTS:    Returns pointer to the default color table,
  92.  *        or NULL if there is none.
  93.  */
  94.  
  95. /*
  96.  * NAME:    setColors
  97.  *
  98.  * SYNOPSIS:    error = setColors( screen, colortable, colors );
  99.  *        short error;
  100.  *
  101.  * INPUTS:    struct Screen    *screen;    pointer to Intuition screen
  102.  *        USHORT    *colortable;        or use NULL for default color table
  103.  *        SHORT    colors;         number of colors to set
  104.  *
  105.  * DESCRIPTION: Set the colors of an Intuition screen.
  106.  *
  107.  * RESULTS:    Returns non-zero on error (eg. if default color table
  108.  *        requested but not large enough).
  109.  */
  110.  
  111. /*
  112.  * NAME:    checkColors
  113.  *
  114.  * SYNOPSIS:    err = checkColors( screen, colors );
  115.  *        short err;
  116.  *
  117.  * INPUTS:    struct Screen    *screen;    pointer to Intuition screen
  118.  *        SHORT    colors;         number of colors to check
  119.  *
  120.  * DESCRIPTION: Check colors of an Intuition screen by writing "hi!" in
  121.  *        every color on the screen.
  122.  *
  123.  *        Note: This is intended for "debug" purposes, as it will
  124.  *        overwrite the screen's display.
  125.  *
  126.  * RESULTS:    Returns non-zero on error.
  127.  */
  128.  
  129. /*
  130.  * NAME:    c_init
  131.  *
  132.  * SYNOPSIS:    err = c_init();
  133.  *        short err;
  134.  *
  135.  * DESCRIPTION: Initialize the communication interface software.
  136.  *
  137.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  138.  *
  139.  * SEE ALSO:    c_open
  140.  */
  141.  
  142. /*
  143.  * NAME:    c_open
  144.  *
  145.  * SYNOPSIS:    err = c_open( parms );
  146.  *        short err;
  147.  *
  148.  * INPUTS:    struct c_parameters *parms;    serial setup parameters
  149.  *
  150.  * DESCRIPTION: Open the communications channel to the serial device.
  151.  *
  152.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  153.  *
  154.  * SEE ALSO:    c_setup, c_init
  155.  */
  156.  
  157. /*
  158.  * NAME:    c_setup
  159.  *
  160.  * SYNOPSIS:    err = c_setup( parms );
  161.  *        short err;
  162.  *
  163.  * INPUTS:    struct c_parameters *parms;    serial setup parameters
  164.  *
  165.  * DESCRIPTION: Set the parameters that configure the serial port for
  166.  *        communication.
  167.  *        The different modes for serial configuration are not set in
  168.  *        this function. They are only done in c_open.
  169.  *
  170.  *        NOTE: the serial port must already be successfully opened by
  171.  *        c_open and there should be no pending commands on the port.
  172.  *
  173.  * RESULTS:    Returns a non-zero error code (see shandler.h) upon error.
  174.  *
  175.  * SEE ALSO:    c_open
  176.  */
  177.  
  178. /*
  179.  * NAME:    c_getc
  180.  *
  181.  * SYNOPSIS:    err = c_getc( charptr );
  182.  *        short err;
  183.  *
  184.  * INPUTS:    char    *charptr;    pointer to location to put character
  185.  *
  186.  * DESCRIPTION: Get a single character from the serial channel, with a
  187.  *        "large" timeout.
  188.  *
  189.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  190.  *
  191.  * SEE ALSO:    c_gets, c_getline, c_emptyc
  192.  */
  193.  
  194. /*
  195.  * NAME:    c_emptyc
  196.  *
  197.  * SYNOPSIS:    err = c_emptyc();
  198.  *        short err;
  199.  *
  200.  * DESCRIPTION: Flush the buffer, with a "small" timeout.
  201.  *
  202.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  203.  *
  204.  * SEE ALSO:    c_getc, c_gets, c_getline
  205.  */
  206.  
  207. /*
  208.  * NAME:    c_putc
  209.  *
  210.  * SYNOPSIS:    err = c_putc( character );
  211.  *        short err;
  212.  *
  213.  * INPUTS:    char    character;        character to send
  214.  *
  215.  * DESCRIPTION: Send one character to the serial channel.
  216.  *
  217.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  218.  *
  219.  * SEE ALSO:    c_puts
  220.  */
  221.  
  222. /*
  223.  * NAME:    c_gets
  224.  *
  225.  * SYNOPSIS:    err = c_gets( buffer, num_to_get );
  226.  *        short err;
  227.  *
  228.  * INPUTS:    char    *buffer;    buffer to store characters
  229.  *        SHORT    num_to_get;    number of characters to get
  230.  *
  231.  * DESCRIPTION: Get the specified number of characters from
  232.  *        the input channel and places them in the buffer.
  233.  *        Note: does NOT stop reading on a '\0', nor is a '\0' appended.
  234.  *
  235.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  236.  *
  237.  * SEE ALSO:    c_getc, c_getline
  238.  */
  239.  
  240. /*
  241.  * NAME:    c_getline
  242.  *
  243.  * SYNOPSIS:    err = c_getline( buffer, num_to_get );
  244.  *        short err;
  245.  *
  246.  * INPUTS:    char    *buffer;    buffer to store characters
  247.  *        SHORT    num_to_get;    number of characters to get
  248.  *
  249.  * DESCRIPTION: Get up to the specified number of characters,
  250.  *        or until the end-of-line character is found,
  251.  *        from the input channel and place them in the buffer.
  252.  *        The default end-of-line character is 0x0d (CR) (check
  253.  *        gimmelib/shandler.h to be sure), but this can be changed
  254.  *        using the c_setEOL() routine.
  255.  *        Note: the end-of-line character is kept in the buffer
  256.  *        and NO '\0' is appended.
  257.  *
  258.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  259.  *
  260.  * SEE ALSO:    c_setEOL, c_getc, c_gets
  261.  */
  262.  
  263. /*
  264.  * NAME:    c_setEOL
  265.  *
  266.  * SYNOPSIS:    err = c_setEOL( eol_character )
  267.  *        short err;
  268.  *
  269.  * INPUTS:    char    eol_character;        new end-of-line character
  270.  *
  271.  * DESCRIPTION: Set the end-of-line character for use with c_getline().
  272.  *        Note: the end-of-line character must be changed (if desired)
  273.  *        after each c_open().
  274.  *
  275.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  276.  *
  277.  * SEE ALSO:    c_getline, c_open
  278.  */
  279.  
  280. /*
  281.  * NAME:    c_puts
  282.  *
  283.  * SYNOPSIS:    err = c_puts( buffer, num_to_put );
  284.  *        short err;
  285.  *
  286.  * INPUTS:    char    *buffer;
  287.  *        SHORT    num_to_put;
  288.  *
  289.  * DESCRIPTION: Send the specified number of characters to the serial port
  290.  *        starting at the location pointed to by buffer.
  291.  *
  292.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  293.  *
  294.  * SEE ALSO:    c_putc
  295.  */
  296.  
  297. /*
  298.  * NAME:    c_close
  299.  *
  300.  * SYNOPSIS:    err = c_close();
  301.  *        short err;
  302.  *
  303.  * DESCRIPTION: Close the communications channel.
  304.  *
  305.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  306.  *
  307.  * SEE ALSO:    c_init, c_open
  308.  */
  309.  
  310. /*
  311.  * NAME:    c_done
  312.  *
  313.  * SYNOPSIS:    err = c_done();
  314.  *        short err;
  315.  *
  316.  * DESCRIPTION: De-initialize the communication interface software,
  317.  *        i.e. tell it you are completely done with it.
  318.  *
  319.  * RESULTS:    Returns a non-zero code on error (see gimmelib/shandler.h).
  320.  *
  321.  * SEE ALSO:    c_init, c_open, c_close
  322.  */
  323.  
  324. /*
  325.  * NAME:    copyDataImage
  326.  *
  327.  * SYNOPSIS:    err = copyDataImage( data, image );
  328.  *        short err;
  329.  *
  330.  * INPUTS:    USHORT        *data;        pointer to start of data to copy
  331.  *        struct Image    *image;     image to receive data
  332.  *
  333.  * DESCRIPTION: Copy the data into the image's data buffer (in chip memory).
  334.  *        Note: the image must already have a data buffer.
  335.  *
  336.  * RESULTS:    Returns non-zero on error.
  337.  *
  338.  * SEE ALSO:    gimmeImage, copyImageData
  339.  */
  340.  
  341. /*
  342.  * NAME:    copyImageData
  343.  *
  344.  * SYNOPSIS:    err = copyImageData( image, data );
  345.  *        short err;
  346.  *
  347.  * INPUTS:    struct Image    *image;     image to receive data
  348.  *        USHORT        *data;        pointer to start of data to copy
  349.  *
  350.  * DESCRIPTION: Copy the image's actual data into a supplied buffer.
  351.  *
  352.  * RESULTS:    Returns non-zero on error.
  353.  *
  354.  * SEE ALSO:    gimmeImage, copyDataImage
  355.  */
  356.  
  357. /*
  358.  * NAME:    copyBorder
  359.  *
  360.  * SYNOPSIS:    border = copyBorder( memheadptr, oldborder, numbord, myflags );
  361.  *        struct Border *border;
  362.  *
  363.  * INPUTS:    void        **memheadptr;    pointer to chained-memory head
  364.  *        struct Border    *oldborder;    border to copy (first of list)
  365.  *        SHORT        numbord;    # of borders to copy, -1 for all
  366.  *        ULONG        myflags;    flags for this routine
  367.  *
  368.  * DESCRIPTION: Copy numbord Border structs beginning with oldborder.
  369.  *        A numbord of -1 means all the borders in the list.
  370.  *
  371.  *        The flags define how much detail should be copied.
  372.  *
  373.  *        NOTE: chainAllocMem is used and you
  374.  *        should use chainFreeMem eventually to free the memory;
  375.  *
  376.  * RESULTS:    Returns pointer to Border, or NULL.
  377.  *
  378.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeBorder
  379.  */
  380.  
  381. /*
  382.  * NAME:    copyImage
  383.  *
  384.  * SYNOPSIS:    image = copyImage( memheadptr, oldimage, numimage, myflags );
  385.  *        struct Image *image;
  386.  *
  387.  * INPUTS:    void        **memheadptr;    pointer to chained-memory head
  388.  *        struct Image   *oldimage;     image to copy (first of list)
  389.  *        SHORT        numimage;     # of images to copy, -1 for all
  390.  *        ULONG        myflags;    flags for this routine
  391.  *
  392.  * DESCRIPTION: Copy numimage Image structs beginning with oldimage.
  393.  *        A numimage of -1 means all the images in the list.
  394.  *
  395.  *        The flags define how much detail should be copied.
  396.  *
  397.  *        NOTE: chainAllocMem is used and you
  398.  *        should use chainFreeMem eventually to free the memory;
  399.  *
  400.  * RESULTS:    Returns pointer to Image, or NULL.
  401.  *
  402.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeImage
  403.  */
  404.  
  405. /*
  406.  * NAME:    copyIntuiText
  407.  *
  408.  * SYNOPSIS:    it = copyIntuiText( memheadptr, olditext, numitext, myflags );
  409.  *        struct IntuiText *it;
  410.  *
  411.  * INPUTS:    void         **memheadptr;     pointer to chained-memory head
  412.  *        struct IntuiText *olditext;     itext to copy (first of list)
  413.  *        SHORT         numitext;     # of itexts to copy, -1 for all
  414.  *        ULONG         myflags;     flags for this routine
  415.  *
  416.  * DESCRIPTION: Copy numitext IntuiText structs beginning with olditext.
  417.  *        A numitext of -1 means all the IntuiTexts in the list.
  418.  *
  419.  *        The flags define how much detail should be copied.
  420.  *
  421.  *        NOTE: chainAllocMem is used and you
  422.  *        should use chainFreeMem eventually to free the memory;
  423.  *
  424.  * RESULTS:    Returns pointer to IntuiText, or NULL.
  425.  *
  426.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeIntuiText
  427.  */
  428.  
  429. /*
  430.  * NAME:    copyMenuItem
  431.  *
  432.  * SYNOPSIS:    item = copyMenuItem( memheadptr, olditem, numitem, numsub,
  433.  *                        myflags );
  434.  *        struct MenuItem *item;
  435.  *
  436.  * INPUTS:    void        **memheadptr;    pointer to chained-memory head
  437.  *        struct MenuItem *olditem;    item to copy (first of list)
  438.  *        SHORT        numitem;    #items to copy, -1 for all
  439.  *        SHORT        numsub;     #subitems to copy, -1 for all
  440.  *        ULONG        myflags;    flags for this routine
  441.  *
  442.  * DESCRIPTION: Copy numitem MenuItem structs beginning with olditem.
  443.  *        A numitem of -1 means all the items in the list.
  444.  *        For each MenuItem copied, numsub subitems will be copied as
  445.  *        well (a numsub of -1 means all subitems).
  446.  *
  447.  *        The flags define how much detail should be copied.
  448.  *
  449.  *        NOTE: chainAllocMem is used and you
  450.  *        should use chainFreeMem eventually to free the memory;
  451.  *
  452.  * RESULTS:    Returns pointer to MenuItem, or NULL.
  453.  *
  454.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeMenuItem
  455.  */
  456.  
  457. /*
  458.  * NAME:    copyMenu
  459.  *
  460.  * SYNOPSIS:    menu = copyMenu( memheadptr, oldmenu, nummenu, numitem,
  461.  *                    numsub, myflags );
  462.  *        struct Menu *menu;
  463.  *
  464.  * INPUTS:    void        **memheadptr;    pointer to chained-memory head
  465.  *        struct Menu    *oldmenu;    menu to copy (first of list)
  466.  *        SHORT        nummenu;    #menus to copy, -1 for all
  467.  *        SHORT        numitem;    #menus to copy, -1 for all
  468.  *        SHORT        numsub;     #submenus to copy, -1 for all
  469.  *        ULONG        myflags;    flags for this routine
  470.  *
  471.  * DESCRIPTION: Copy nummenu Menu structs beginning with oldmenu.
  472.  *        A nummenu of -1 means all the menus in the list.
  473.  *        For each Menu copied, numitem menuitems will be copied as
  474.  *        well (a numitem of -1 means all menuitems) via copyMenuItem
  475.  *        using numsub for the number of subitems to copy.
  476.  *
  477.  *        The flags define how much detail should be copied.
  478.  *
  479.  *        NOTE: chainAllocMem is used and you
  480.  *        should use chainFreeMem eventually to free the memory;
  481.  *
  482.  * RESULTS:    Returns pointer to Menu, or NULL.
  483.  *
  484.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeMenu, copyMenuItem
  485.  */
  486.  
  487. /*
  488.  * NAME:    makeDBuf
  489.  *
  490.  * SYNOPSIS:    err = makeDBuf( screen, bmptr );
  491.  *        short err;
  492.  *
  493.  * INPUTS:    struct Screen    *screen;    ptr to single-buffered screen
  494.  *        struct BitMap    **bmptr;    ptr to bitmap ptr for second buffer
  495.  *
  496.  * DESCRIPTION: Change a single-buffered Intuition screen into a
  497.  *        double-buffered screen.
  498.  *        If you already have your own bitmap for the secondary buffer,
  499.  *        bmptr should point to the bitmap pointer;
  500.  *        otherwise bmptr should point to a NULL pointer, in which case
  501.  *        a bitmap of the same depth/width/height as the screen is
  502.  *        dynamically created, and the pointer to this bitmap is
  503.  *        returned in *bmptr.
  504.  *
  505.  *        Note: you must not alter the bitmap pointer placed in *bmptr.
  506.  *
  507.  * RESULTS:    Returns non-zero on error.
  508.  *
  509.  * SEE ALSO:    unmakeDBuf, swapDBuf
  510.  */
  511.  
  512. /*
  513.  * NAME:    unmakeDBuf
  514.  *
  515.  * SYNOPSIS:    err = unmakeDBuf( screen, bmptr, bm );
  516.  *        short err;
  517.  *
  518.  * INPUTS:    struct Screen    *screen;    ptr to double-buffered screen
  519.  *        struct BitMap    **bmptr;    ptr to bitmap ptr for second buffer
  520.  *        struct BitMap    *bm;        ptr to bitmap to be freed
  521.  *
  522.  * DESCRIPTION: Changes a double-buffered screen [as made by makeDBuf]
  523.  *        back into a single-buffered screen.
  524.  *        The screen's buffers are swapped if necessary to ensure that
  525.  *        a CloseScreen() will work properly.
  526.  *        If bm is non-NULL, the bitmap will be freed (de-allocated);
  527.  *        this is intended primarily to be used to free the bitmap that
  528.  *        was created by makeDBuf if you did not previously have
  529.  *        a bitmap for the secondary buffer.
  530.  *
  531.  *        Note: the screen and bmptr parameters should be exactly the
  532.  *        same as those given to makeDBuf.
  533.  *
  534.  * RESULTS:    Returns non-zero on error.
  535.  *
  536.  * SEE ALSO:    makeDBuf, swapDBuf
  537.  */
  538.  
  539. /*
  540.  * NAME:    swapDBuf
  541.  *
  542.  * SYNOPSIS:    err = swapDBuf( screen, minterm );
  543.  *        short err;
  544.  *
  545.  * INPUTS:    struct Screen    *screen;    ptr to double-buffered screen
  546.  *        SHORT        minterm;    minterm for the copy
  547.  *
  548.  * DESCRIPTION: Switch the display and draw buffers for the screen.
  549.  *        The minterm is used to specify the type of blit used to copy
  550.  *        the new displayed buffer (source) to the new hidden/drawing
  551.  *        buffer (dest).
  552.  *        Some common minterms are:
  553.  *            0x000    - clear destination
  554.  *            0x0c0    - vanilla copy (result: source only)
  555.  *            0x0a0    - no copy (result: dest only)
  556.  *
  557.  *        Note: this routine hums along fine if the screen is not
  558.  *        actually double-buffered, doing no swap and no copy.
  559.  *
  560.  * RESULTS:    Returns non-zero on error.
  561.  *
  562.  * SEE ALSO:    makeDBuf, unmakeDBuf
  563.  */
  564.  
  565. /*
  566.  * NAME:    makeDBufQuick
  567.  *
  568.  * SYNOPSIS:    err = makeDBufQuick( screen, bmptr, lcprptr, scprptr );
  569.  *        short err;
  570.  *
  571.  * INPUTS:    struct Screen    *screen;    ptr to single-buffered screen
  572.  *        struct BitMap    **bmptr;    ptr to bitmap ptr for second buffer
  573.  *        struct cprlist    **lcprptr;  ptr to (long) copper list pointer
  574.  *        struct cprlist    **scprptr;  ptr to (short) copper list pointer
  575.  *
  576.  * DESCRIPTION: Change a single-buffered Intuition screen into a
  577.  *        double-buffered screen.
  578.  *        If you already have your own bitmap for the secondary buffer,
  579.  *        bmptr should point to the bitmap pointer;
  580.  *        otherwise bmptr should point to a NULL pointer, in which case
  581.  *        a bitmap of the same depth/width/height as the screen is
  582.  *        dynamically created, and the pointer to this bitmap is
  583.  *        returned in *bmptr.
  584.  *
  585.  *        Note: you must not alter the bitmap pointer placed in *bmptr.
  586.  *
  587.  * RESULTS:    Returns non-zero on error.
  588.  *
  589.  * SEE ALSO:    unmakeDBufQuick, swapDBufQuick
  590.  */
  591.  
  592. /*
  593.  * NAME:    unmakeDBufQuick
  594.  *
  595.  * SYNOPSIS:    err = unmakeDBufQuick( screen, bmptr, bm,
  596.  *                        lcprptr, scprptr );
  597.  *        short err;
  598.  *
  599.  * INPUTS:    struct Screen    *screen;    ptr to double-buffered screen
  600.  *        struct BitMap    **bmptr;    ptr to bitmap ptr for second buffer
  601.  *        struct BitMap    *bm;        ptr to bitmap to be freed
  602.  *        struct cprlist    **lcprptr;  ptr to (long) copper list pointer
  603.  *        struct cprlist    **scprptr;  ptr to (short) copper list pointer
  604.  *
  605.  * DESCRIPTION: Changes a double-buffered screen [as made by makeDBufQuick]
  606.  *        back into a single-buffered screen.
  607.  *        The screen's buffers are swapped if necessary to ensure that
  608.  *        a CloseScreen() will work properly.
  609.  *        If bm is non-NULL, the bitmap will be freed (de-allocated);
  610.  *        this is intended primarily to be used to free the bitmap that
  611.  *        was created by makeDBufQuick if you did not previously have
  612.  *        a bitmap for the secondary buffer.
  613.  *
  614.  *        Note: the screen and bmptr parameters should be exactly the
  615.  *        same as those given to makeDBufQuick.
  616.  *
  617.  * RESULTS:    Returns non-zero on error.
  618.  *
  619.  * SEE ALSO:    makeDBufQuick, swapDBufQuick
  620.  */
  621.  
  622. /*
  623.  * NAME:    swapDBufQuick
  624.  *
  625.  * SYNOPSIS:    err = swapDBufQuick( screen, minterm, lcprptr, scprptr );
  626.  *        short err;
  627.  *
  628.  * INPUTS:    struct Screen    *screen;    ptr to double-buffered screen
  629.  *        SHORT        minterm;    minterm for the copy
  630.  *        struct cprlist    **lcprptr;  ptr to (long) copper list pointer
  631.  *        struct cprlist    **scprptr;  ptr to (short) copper list pointer
  632.  *
  633.  * DESCRIPTION: Switch the display and draw buffers for the screen.
  634.  *        The minterm is used to specify the type of blit used to copy
  635.  *        the new displayed buffer (source) to the new hidden/drawing
  636.  *        buffer (dest).
  637.  *        Some common minterms are:
  638.  *            0x000    - clear destination
  639.  *            0x0c0    - vanilla copy (result: source only)
  640.  *            0x0a0    - no copy (result: dest only)
  641.  *
  642.  *        Note: this routine hums along fine if the screen is not
  643.  *        actually double-buffered, doing no swap and no copy.
  644.  *
  645.  * RESULTS:    Returns non-zero on error.
  646.  *
  647.  * SEE ALSO:    makeDBufQuick, unmakeDBufQuick
  648.  */
  649.  
  650. /*
  651.  * NAME:    makeDBufVQuick
  652.  *
  653.  * SYNOPSIS:    err = makeDBufVQuick( screen, bmptr );
  654.  *        short err;
  655.  *
  656.  * INPUTS:    struct Screen    *screen;    ptr to single-buffered screen
  657.  *        struct BitMap    **bmptr;    ptr to bitmap ptr for second buffer
  658.  *
  659.  * DESCRIPTION: Change a single-buffered Intuition screen into a
  660.  *        double-buffered screen.
  661.  *        If you already have your own bitmap for the secondary buffer,
  662.  *        bmptr should point to the bitmap pointer;
  663.  *        otherwise bmptr should point to a NULL pointer, in which case
  664.  *        a bitmap of the same depth/width/height as the screen is
  665.  *        dynamically created, and the pointer to this bitmap is
  666.  *        returned in *bmptr.
  667.  *
  668.  *        Note: you must not alter the bitmap pointer placed in *bmptr.
  669.  *
  670.  * RESULTS:    Returns non-zero on error.
  671.  *
  672.  * SEE ALSO:    unmakeDBufVQuick, swapDBufVQuick
  673.  */
  674.  
  675. /*
  676.  * NAME:    unmakeDBufVQuick
  677.  *
  678.  * SYNOPSIS:    err = unmakeDBufVQuick( screen, bmptr, bm );
  679.  *        short err;
  680.  *
  681.  * INPUTS:    struct Screen    *screen;    ptr to double-buffered screen
  682.  *        struct BitMap    **bmptr;    ptr to bitmap ptr for second buffer
  683.  *        struct BitMap    *bm;        ptr to bitmap to be freed
  684.  *
  685.  * DESCRIPTION: Changes a double-buffered screen [as made by makeDBufVQuick]
  686.  *        back into a single-buffered screen.
  687.  *        The screen's buffers are swapped if necessary to ensure that
  688.  *        a CloseScreen() will work properly.
  689.  *        If bm is non-NULL, the bitmap will be freed (de-allocated);
  690.  *        this is intended primarily to be used to free the bitmap that
  691.  *        was created by makeDBufVQuick if you did not previously have
  692.  *        a bitmap for the secondary buffer.
  693.  *
  694.  *        Note: the screen and bmptr parameters should be exactly the
  695.  *        same as those given to makeDBufVQuick.
  696.  *
  697.  * RESULTS:    Returns non-zero on error.
  698.  *
  699.  * SEE ALSO:    makeDBufVQuick, swapDBufVQuick
  700.  */
  701.  
  702. /*
  703.  * NAME:    swapDBufVQuick
  704.  *
  705.  * SYNOPSIS:    err = swapDBufVQuick( screen, minterm );
  706.  *        short err;
  707.  *
  708.  * INPUTS:    struct Screen    *screen;    ptr to double-buffered screen
  709.  *        SHORT        minterm;    minterm for the copy
  710.  *
  711.  * DESCRIPTION: Switch the display and draw buffers for the screen.
  712.  *        The minterm is used to specify the type of blit used to copy
  713.  *        the new displayed buffer (source) to the new hidden/drawing
  714.  *        buffer (dest).
  715.  *        Some common minterms are:
  716.  *            0x000    - clear destination
  717.  *            0x0c0    - vanilla copy (result: source only)
  718.  *            0x0a0    - no copy (result: dest only)
  719.  *
  720.  *        Note: this routine hums along fine if the screen is not
  721.  *        actually double-buffered, doing no swap and no copy.
  722.  *
  723.  * RESULTS:    Returns non-zero on error.
  724.  *
  725.  * SEE ALSO:    makeDBufVQuick, unmakeDBufVQuick
  726.  */
  727.  
  728. /*
  729.  * NAME:    makeDualPlayfield
  730.  *
  731.  * SYNOPSIS:    err = makeDualPlayfield( screen, ri, reldepth );
  732.  *        short err;
  733.  *
  734.  * INPUTS:    struct Screen    *screen;    ptr to single-playfield screen
  735.  *        struct RasInfo    *ri;        ptr to RasInfo for second playfield
  736.  *        SHORT    reldepth;        depth of second playfield relative
  737.  *                          to first playfield (0 or -1)
  738.  *
  739.  * DESCRIPTION: Change a single-playfield Intuition screen into a
  740.  *        dual-playfield screen.
  741.  *        Fully initializes the RasInfo struct pointed at by ri,
  742.  *        and links it into the screen's RasInfo.
  743.  *        A bitmap of the appropriate depth and same width/height will
  744.  *        be dynamically created - the pointer is returned in ri->BitMap
  745.  *        The possible depth combinations are limited (see RKM), but
  746.  *        essentially:
  747.  *        - the first playfield can be at most depth 3
  748.  *        - the second playfield must have same depth or 1 less.
  749.  *        Therefore "reldepth" must be 0 or -1.
  750.  *        NOTE: present default: the first playfield is given video
  751.  *        priority over the second playfield (though you can set the
  752.  *        PFBA flag yourself if you do it right - CAUTION!).
  753.  *
  754.  *        Note: you must have opened the screen using OpenScreen()
  755.  *        without specifying DUALPF in the NewScreen's Flags field before
  756.  *        calling this routine to keep things consistent (1.2 Intuition
  757.  *        does not support opening/closing DUALPF screens properly).
  758.  *
  759.  * RESULTS:    Returns non-zero on error.
  760.  *
  761.  * SEE ALSO:    unmakeDualPlayfield
  762.  */
  763.  
  764. /*
  765.  * NAME:    unmakeDualPlayfield
  766.  *
  767.  * SYNOPSIS:    err = unmakeDualPlayfield( screen );
  768.  *        short err;
  769.  *
  770.  * INPUTS:    struct Screen    *screen;    pointer to dual-playfield screen
  771.  *
  772.  * DESCRIPTION: Changes a dual-playfield screen [as made by makeDualPlayfield]
  773.  *        back into a single-playfield screen.
  774.  *
  775.  *        NOTE: The bitmap *currently* used for the second-playfield is
  776.  *        de-allocated, making the second playfield's RasInfo's BitMap
  777.  *        pointer invalid. This will be the same bitmap that was
  778.  *        allocated by makeDualPlayfield ONLY if you don't play
  779.  *        around with the second-playfield's RasInfo's BitMap pointer.
  780.  *
  781.  *        Note: you must call this routine before you do a CloseScreen()
  782.  *        to keep things consistent (1.2 Intuition does not fully support
  783.  *        opening/closing DUALPF screens properly).
  784.  *
  785.  * RESULTS:    Returns non-zero on error (eg screen is NULL or screen is not
  786.  *        dual-playfield).
  787.  *
  788.  * SEE ALSO:    makeDualPlayfield
  789.  */
  790.  
  791. /*
  792.  * NAME:    gimmeFont
  793.  *
  794.  * REQUISITES:    struct DiskfontBase *DiskfontBase;    properly initialized
  795.  *
  796.  * SYNOPSIS:    textfont = gimmeFont( textattr );
  797.  *        struct TextFont *textfont;
  798.  *
  799.  * INPUTS:    struct TextAttr *textattr;        ptr to font description
  800.  *
  801.  * DESCRIPTION: Load specified font from disk (check in memory first).
  802.  *        NOTE: the textattr may be altered to reflect actual font found.
  803.  *
  804.  *        NOTE: you must have a global variable named DiskfontBase,
  805.  *        declared as a "struct DiskfontBase *", already initialized by
  806.  *        by opening the diskfont.library with code similar to the
  807.  *        following:
  808.  *            struct DiskfontBase *DiskfontBase;
  809.  *            DiskfontBase = (struct DiskfontBase *)
  810.  *                    OpenLibrary("diskfont.library", 0L);
  811.  *            { check for NULL pointer returned on error }
  812.  *
  813.  * RESULTS:    Returns TextFont or NULL on error.
  814.  *        The TextAttr's ta_YSize and ta_Style fields are altered to
  815.  *        reflect those of the actual font found if successful.
  816.  *
  817.  * SEE ALSO:    gimmeFontLazy, getRidOfFont
  818.  */
  819.  
  820. /*
  821.  * NAME:    gimmeFontLazy
  822.  *
  823.  * REQUISITES:    struct DiskfontBase *DiskfontBase;    properly initialized
  824.  *
  825.  * SYNOPSIS:    textfont = gimmeFontLazy( name, size );
  826.  *        struct TextFont *textfont;
  827.  *
  828.  * INPUTS:    UBYTE    *name;        name of desired font
  829.  *        UWORD    size;        y-size of desired font
  830.  *
  831.  * DESCRIPTION: Load specified font from disk (check in memory first).
  832.  *        NOTE: a similar font may be used if the exact font is not found.
  833.  *
  834.  *        NOTE: you must have a global variable named DiskfontBase --
  835.  *        see gimmeFont for information on how to initialize it.
  836.  *
  837.  * RESULTS:    Returns TextFont or NULL on error.
  838.  *
  839.  * SEE ALSO:    gimmeFont, getRidOfFont
  840.  */
  841.  
  842. /*
  843.  * NAME:    getRidOfFont
  844.  *
  845.  * SYNOPSIS:    err = getRidOfFont( textfont );
  846.  *        short err;
  847.  *
  848.  * INPUTS:    struct TextFont *textfont;    pointer to TextFont
  849.  *
  850.  * DESCRIPTION: Releases access to a disk font obtained via gimmeFont(Quick).
  851.  *
  852.  * RESULTS:    Returns non-zero on error.
  853.  *
  854.  * SEE ALSO:    gimmeFont, gimmeFontLazy
  855.  */
  856.  
  857. /*
  858.  * NAME:    getRidOfGadgets
  859.  *
  860.  * SYNOPSIS:    err = getRidOfGadgets( firstgadget );
  861.  *        short err;
  862.  *
  863.  * INPUTS:    struct Gadget    *firstgadget;        pointer to first Gadget
  864.  *
  865.  * DESCRIPTION: Frees memory allocated for each gadget in chain, starting
  866.  *        with firstgadget, using chainFreeMem.
  867.  *
  868.  *        NOTE: uses a gadget's UserData field as pointer to head of
  869.  *        memory-chain, as returned by chainAllocMem and set by the
  870.  *        other gimme-gadget routines.
  871.  *
  872.  * RESULTS:    Returns non-zero on error.
  873.  *
  874.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeXXXGadget
  875.  */
  876.  
  877. /*
  878.  * NAME:    gimmeBoolGadget
  879.  *
  880.  * REQUISITES:    struct GfxBase *GfxBase;    properly initialized - but only if
  881.  *                          ysize == -1, !window && !textattr
  882.  *
  883.  * SYNOPSIS:    gp = gimmeBoolGadget( window, id, left, top, xsize, ysize,
  884.  *                    s, s2, textattr, myflags );
  885.  *        struct Gadget *gp;
  886.  *
  887.  * INPUTS:    struct Window    *window;    window for gadget, or NULL
  888.  *        USHORT    id;            non-zero id for gadget
  889.  *        SHORT    left;            left offset in pixels
  890.  *        SHORT    top;            top offset in pixels
  891.  *        SHORT    xsize;            total width in pixels, or -1
  892.  *        SHORT    ysize;            total height in pixels, or -1
  893.  *        UBYTE    *s;            main text string
  894.  *        UBYTE    *s2;            auxiliary text string, or NULL
  895.  *        struct TextAttr *textattr;  pointer to font, or NULL
  896.  *        ULONG    myflags;        flags for the routine
  897.  *
  898.  * DESCRIPTION: Allocate and initialize a boolean Gadget structure,
  899.  *        including a border.
  900.  *        The border is created appropriately enough to enclose
  901.  *        the string nicely. Note: this routine succeeds even if no
  902.  *        border was allocated (check gp->GadgetRender for a non-NULL
  903.  *        value if you want to be sure that a border was allocated).
  904.  *
  905.  *        NOTE: For text (with a border), not an image.
  906.  *
  907.  *        If the window is non-NULL, some further customization of the
  908.  *        gadget is done; notably the FgPen, BgPen and DrawMode of the
  909.  *        window's rastport are used.
  910.  *        If xsize or ysize are non-positive (use -1), appropriate
  911.  *        value(s) are calculated to enclose the string nicely.
  912.  *        If the auxiliary string s2 is NULL, a *hit select* boolean
  913.  *        gadget is constructed, otherwise a *toggle select* boolean
  914.  *        gadget is constructed -- NOTE: due to the odd nature of the
  915.  *        toggle-selected text, you must use toggleBoolGadget upon
  916.  *        receiving the GADGETDOWN message to effect the toggle visibly
  917.  *        in the window.
  918.  *
  919.  *        If xsize is non-positive and s2 is non-NULL,
  920.  *        the border is constructed to enclose the longer string nicely
  921.  *        and the shorter string is centred in the box accordingly,
  922.  *        without residue of the longer string when displayed (toggled).
  923.  *        The textattr can be NULL to use the default font.
  924.  *        The flags (see gimmelib/postext.h) allow special effects for
  925.  *        positioning the gadget:
  926.  *            - if xsize is "real" (positive):
  927.  *            - x-flags cause the final gadget box to be placed
  928.  *              accordingly within the region from left to left+xsize
  929.  *              (eg. x-centre means the gadget is centred within
  930.  *                xsize bits, offset by the left parm)
  931.  *            - if xsize is -1 (non-postive):
  932.  *            - the left parameter is taken to be the coordinate
  933.  *              as specified by the x-flags
  934.  *              (eg. x-centre means the left parm is actually the
  935.  *                centre of the gadget in the x-direction)
  936.  *            - the y-flags always modify the meaning of the top parm
  937.  *              (eg. y-centre means the top parm is actually the
  938.  *                centre of the gadget in the y-direction)
  939.  *
  940.  *        NOTE: The auxiliary string's IntuiText is stored in
  941.  *        the gadget's SelectRender field. You must leave this field
  942.  *        alone, which also means do not use the GADGHIMAGE flag.
  943.  *        The two strings can be switched and displayed by using
  944.  *        toggleBoolGadget.
  945.  *
  946.  *        NOTE: To remove the border permanently, do something similar
  947.  *        to the following (with appropriate error checking):
  948.  *            gp = gimmeBoolGadget(...);
  949.  *            pluckChainMem( &gp->UserData, gp->GadgetRender );
  950.  *            gp->GadgetRender = NULL;
  951.  *        (the pluckChainMem is not absolutely necessary, since the
  952.  *        border's memory would be freed when getRidOfGadgets is called)
  953.  *
  954.  *        If all goes well, the head pointer to chained memory for the
  955.  *        gadget and its other required structures is stored in the
  956.  *        gp->UserData field. You must preserve this pointer!!
  957.  *        If you need to use the UserData yourself, be sure to save
  958.  *        gp->UserData somewhere safe after calling this routine.
  959.  *        When you are done with the gadget you must ensure that the
  960.  *        chained memory head pointer is restored into gp->UserData
  961.  *        before you call getRidOfGadgets.
  962.  *
  963.  *        NOTE: if you supply an auxiliary string s2 to create a toggle
  964.  *        gadget, and window is non-NULL, then the window's rastport's
  965.  *        drawmode should be JAM2 otherwise visual confusion may occur
  966.  *        upon toggling and/or clearing.
  967.  *
  968.  * RESULTS:    Returns pointer to boolean gadget, or NULL.
  969.  *        Note: The gadget is NOT added to the window.
  970.  *
  971.  * SEE ALSO:    toggleBoolGadget, getRidOfGadgets, gimmeBoolImageGadget
  972.  */
  973.  
  974. /*
  975.  * NAME:    gimmeBoolImageGadget
  976.  *
  977.  * SYNOPSIS:    gp = gimmeBoolImageGadget( window, id, left, top, depth, width,
  978.  *                        height, myflags, dep2, wid2, ht2 );
  979.  *        struct Gadget *gp;
  980.  *
  981.  * INPUTS:    struct Window    *window;    window for gadget, or NULL
  982.  *        USHORT    id;            non-zero id for gadget
  983.  *        SHORT    left;            left offset in pixels
  984.  *        SHORT    top;            top offset in pixels
  985.  *        SHORT    depth;            depth of primary image
  986.  *        SHORT    width;            width of primary image, in pixels
  987.  *        SHORT    height;         height of primary image, in pixels
  988.  *        ULONG    myflags;        flags for the routine
  989.  *        SHORT    dep2;            depth of secondary image, or <= 0
  990.  *        SHORT    wid2;            width of secondary image, or <= 0
  991.  *        SHORT    ht2;            height of secondary image, or <= 0
  992.  *
  993.  * DESCRIPTION: Allocate and initialize a boolean Gadget structure,
  994.  *        including Image structure(s) and data memory (via gimmeImage)
  995.  *        for the primary image, and for the secondary image if the
  996.  *        3 size specifications for it are strictly positive.
  997.  *        Note that for the primary image, you can specify zero for any
  998.  *        of its dimensions so that an Image structure but no data memory
  999.  *        is allocated.
  1000.  *
  1001.  *        NOTE: For images, not text.
  1002.  *
  1003.  *        If the secondary image's dimensions are improper, a *hit select*
  1004.  *        boolean gadget is constructed, otherwise a *toggle select*
  1005.  *        boolean gadget is constructed.
  1006.  *        NOTE: if you wish the secondary image to merely be highlighting
  1007.  *        imagery for a *hit select* boolean gadget, you should do this:
  1008.  *            gp->Activation = RELVERIFY;
  1009.  *        after this function call (note your two images should overlap
  1010.  *        exactly to keep things clean on the screen).
  1011.  *        NOTE: if you wish to toggle manually, do the following:
  1012.  *            gp->Flags = GADGIMAGE | GADGHNONE;
  1013.  *            gp->Activation = GADGIMMEDIATE;
  1014.  *        after this function call. Then, when you receive a GADGETDOWN
  1015.  *        message, call toggleBoolGadget to switch the imagery. This is
  1016.  *        similar to the system toggle select except that toggleBoolGadget
  1017.  *        erases the current image before drawing the "alternate" image
  1018.  *        and redefines the gadget's select box for the new image.
  1019.  *
  1020.  *        The flags (see gimmelib/postext.h) alter the meaning of the
  1021.  *        top and left parameters, with respect to the size of the
  1022.  *        primary image.
  1023.  *
  1024.  *        If all goes well, the head pointer to chained memory for the
  1025.  *        gadget and its other required structures is stored in the
  1026.  *        gp->UserData field. You must preserve this pointer!!
  1027.  *        If you need to use the UserData yourself, be sure to save
  1028.  *        gp->UserData somewhere safe after calling this routine.
  1029.  *        When you are done with the gadget you must ensure that the
  1030.  *        chained memory head pointer is restored into gp->UserData
  1031.  *        before you call getRidOfGadgets.
  1032.  *
  1033.  * RESULTS:    Returns pointer to boolean gadget, or NULL.
  1034.  *        Note: The gadget is NOT added to the window.
  1035.  *
  1036.  * SEE ALSO:    toggleBoolGadget, getRidOfGadgets, gimmeBoolGadget
  1037.  */
  1038.  
  1039. /*
  1040.  * NAME:    gimmePropGadget
  1041.  *
  1042.  * SYNOPSIS:    gp = gimmePropGadget( window, id, left, top, xsize, ysize,
  1043.  *                       label, textattr, activflags, propflags );
  1044.  *        struct Gadget *gp;
  1045.  *
  1046.  * INPUTS:    struct Window    *window;    window for gadget, or NULL
  1047.  *        USHORT    id;            non-zero id for gadget
  1048.  *        SHORT    left;            left offset in pixels
  1049.  *        SHORT    top;            top offset in pixels
  1050.  *        SHORT    xsize;            total width in pixels
  1051.  *        SHORT    ysize;            total height in pixels
  1052.  *        UBYTE    *label;         gadget label, or NULL
  1053.  *        struct TextAttr *textattr;  pointer to font, or NULL
  1054.  *        ULONG    activflags;        gadget Activation flags
  1055.  *        ULONG    propflags;        flags for PropInfo
  1056.  *
  1057.  * DESCRIPTION: Allocate and initialize a string Gadget structure,
  1058.  *        including PropInfo and optional label.
  1059.  *        If the window is non-NULL, some further customization of the
  1060.  *        gadget is done; notably the FgPen, BgPen and DrawMode of the
  1061.  *        window's rastport are used for the label.
  1062.  *        The xsize and ysize parms define the size of the actual,
  1063.  *        gadget, NOT including the (optional) label.
  1064.  *        Note: if xsize and/or ysize are non-positive, you must set
  1065.  *        the appropriate flags (such as GRELWIDTH, GRELHEIGHT) in the
  1066.  *        gadget's Flags field after this routine returns.
  1067.  *        If label is non-NULL, a label is set up with the actual prop
  1068.  *        gadget to the right of the label.
  1069.  *        The textattr can be NULL to use the default font.
  1070.  *        The activflags are set in the gadget's Activation field.
  1071.  *        The propflags are set in the gadget's PropInfo structure - see
  1072.  *        gimmePropInfo for details on how these flags are used.
  1073.  *        Note: if you wish to change the knob imagery to your own, do
  1074.  *        something similar to the following after this routine:
  1075.  *            gp->GadgetRender = (APTR) <your image or border>;
  1076.  *            ((struct PropInfo *)gp->SpecialInfo)->Flags &= ~AUTOKNOB;
  1077.  *            gp->Flags &= ~GADGIMAGE;    ;; ONLY if you want a BORDER
  1078.  *
  1079.  *        If all goes well, the head pointer to chained memory for the
  1080.  *        gadget and its other required structures is stored in the
  1081.  *        gp->UserData field. You must preserve this pointer!!
  1082.  *        If you need to use the UserData yourself, be sure to save
  1083.  *        gp->UserData somewhere safe after calling routine.
  1084.  *        When you are done with the gadget you must ensure that the
  1085.  *        chained memory head pointer is restored into gp->UserData
  1086.  *        before you call getRidOfGadgets.
  1087.  *
  1088.  * RESULTS:    Returns pointer to prop gadget, or NULL.
  1089.  *        Note: The gadget is NOT added to the window.
  1090.  *
  1091.  * SEE ALSO:    getRidOfGadgets, gimmePropInfo
  1092.  */
  1093.  
  1094. /*
  1095.  * NAME:    gimmePropInfo
  1096.  *
  1097.  * SYNOPSIS:    pi = gimmePropInfo( memheadptr, flags );
  1098.  *        struct PropInfo *pi;
  1099.  *
  1100.  * INPUTS:    void    **memheadptr;    pointer to chained-memory head
  1101.  *        ULONG    flags;        flags for PropInfo
  1102.  *
  1103.  * DESCRIPTION: Allocate and initialize a PropInfo structure.
  1104.  *
  1105.  *        The PropInfo's flags are set to "AUTOKNOB | flags"
  1106.  *        which you can change after this function returns.
  1107.  *
  1108.  *        The allocated memory is chained to the memory chain pointed
  1109.  *        at by memheadptr using chainAllocMem.
  1110.  *        Eventually chainFreeMem should be called on the memhead.
  1111.  *
  1112.  * RESULTS:    Returns pointer to PropInfo, or NULL.
  1113.  *
  1114.  * SEE ALSO:    chainAllocMem, chainFreeMem
  1115.  */
  1116.  
  1117. /*
  1118.  * NAME:    gimmeStringGadget
  1119.  *
  1120.  * REQUISITES:    struct GfxBase *GfxBase;    properly initialized - but only
  1121.  *                          needed if !window && !textattr
  1122.  *
  1123.  * SYNOPSIS:    gp = gimmeStringGadget( window, id, left, top, width, maxbuf,
  1124.  *                    s, label, textattr, activflags );
  1125.  *        struct Gadget *gp;
  1126.  *
  1127.  * INPUTS:    struct Window    *window;    window for gadget, or NULL
  1128.  *        USHORT    id;            non-zero id for gadget
  1129.  *        SHORT    left;            left offset in pixels
  1130.  *        SHORT    top;            top offset in pixels
  1131.  *        SHORT    width;            total width in pixels
  1132.  *        SHORT    maxbuf;         maximum buffer size including '\0'
  1133.  *        UBYTE    *s;            initial text string
  1134.  *        UBYTE    *label;         gadget label, or NULL
  1135.  *        struct TextAttr *textattr;  pointer to font, or NULL
  1136.  *        ULONG    activflags;        gadget Activation flags
  1137.  *
  1138.  * DESCRIPTION: Allocate and initialize a string Gadget structure,
  1139.  *        including border, StringInfo, buffers and optional label.
  1140.  *        If the window is non-NULL, some further customization of the
  1141.  *        gadget is done; notably the FgPen, BgPen and DrawMode of the
  1142.  *        window's rastport are used for the label and border.
  1143.  *        The border is width pixels wide and high enough to enclose
  1144.  *        the string nicely. Note: this routine succeeds even if no
  1145.  *        border was allocated (check gp->GadgetRender for a non-NULL
  1146.  *        value if you want to be sure that a border was allocated).
  1147.  *        If you want to remove the border, do something similar to this:
  1148.  *            pluckChainMem( &gp->UserData, gp->GadgetRender );
  1149.  *            gp->GadgetRender = NULL;
  1150.  *        If label is non-NULL, a label is set up with the actual string
  1151.  *        gadget to the right of the label.
  1152.  *        NOTE: the width includes space taken by the label (if any).
  1153.  *        The textattr can be NULL to use the default font.
  1154.  *        The activflags are set in the gadget's Activation field.
  1155.  *
  1156.  *        Note: the actual string is rendered in the screen's font.
  1157.  *        This is normally the font specified when the screen is opened.
  1158.  *        However, doing a SetFont() on the screen's rastport to alter the
  1159.  *        font (and even if you change the screen's Font field as well)
  1160.  *        will cause the string gadget to be handled a little awkwardly:
  1161.  *        the initial rendering will occur in the screen's original font,
  1162.  *        and once the gadget is selected, the "new" font will be used for
  1163.  *        rendering; however, the "old" font's character width is used to
  1164.  *        determine which character in the string gadget is clicked on,
  1165.  *        which may result in some visual confusion.
  1166.  *
  1167.  *        If all goes well, the head pointer to chained memory for the
  1168.  *        gadget and its other required structures is stored in the
  1169.  *        gp->UserData field. You must preserve this pointer!!
  1170.  *        If you need to use the UserData yourself, be sure to save
  1171.  *        gp->UserData somewhere safe after calling routine.
  1172.  *        When you are done with the gadget you must ensure that the
  1173.  *        chained memory head pointer is restored into gp->UserData
  1174.  *        before you call getRidOfGadgets.
  1175.  *
  1176.  * RESULTS:    Returns pointer to string gadget, or NULL.
  1177.  *        Note: The gadget is NOT added to the window.
  1178.  *
  1179.  * SEE ALSO:    getRidOfGadgets, gimmeStringInfo
  1180.  */
  1181.  
  1182. /*
  1183.  * NAME:    gimmeStringInfo
  1184.  *
  1185.  * SYNOPSIS:    si = gimmeStringInfo( memheadptr, bufsize, s, flags );
  1186.  *        struct StringInfo *si;
  1187.  *
  1188.  * INPUTS:    void **memheadptr;  pointer to chained memory head
  1189.  *        SHORT bufsize;        maximum size including nullchar
  1190.  *        UBYTE *s;        initial string
  1191.  *        ULONG flags;        flags for StringInfo: only LONGINT checked
  1192.  *
  1193.  * DESCRIPTION: Allocate and initialize a StringInfo structure,
  1194.  *        including space for the main and undo buffers.
  1195.  *        If the LONGINT flag is set in flags, the initial string s
  1196.  *        should consist of a valid long integer in ascii format.
  1197.  *
  1198.  *        The allocated memory is chained to the memory chain pointed
  1199.  *        at by memheadptr using chainAllocMem.
  1200.  *        Eventually chainFreeMem should be called on the memhead.
  1201.  *
  1202.  * RESULTS:    Returns pointer to StringInfo, or NULL.
  1203.  *
  1204.  * SEE ALSO:    chainAllocMem, chainFreeMem
  1205.  */
  1206.  
  1207. /*
  1208.  * NAME:    clearGadgets
  1209.  *
  1210.  * SYNOPSIS:    err = clearGadgets( firstgadget, window, req, numgad );
  1211.  *        short err;
  1212.  *
  1213.  * INPUTS:    struct Gadget        *firstgadget;   first gadget to clear
  1214.  *        struct Window        *window;        gadget's window
  1215.  *        struct Requester    *req;        gadget's requester, or NULL
  1216.  *        SHORT            numgad;        # of gadgets to clear, or -1
  1217.  *
  1218.  * DESCRIPTION: Clear the imagery of numgad gadgets in a window, starting with
  1219.  *        firstgadget.
  1220.  *        If numgad is negative, the whole list starting with firstgadget
  1221.  *        is cleared. If numgad is zero, no gadgets are cleared.
  1222.  *        NOTE: the gadget cannot be in a requester, so if the req
  1223.  *        parameter is non-NULL, the gadget(s) will not be cleared and
  1224.  *        an error returned.
  1225.  *        NOTE: The requester is ignored unless the first gadget has the
  1226.  *        REQGADGET gadget type flag set; you should ensure that this flag
  1227.  *        is consistently set or clear in each gadget in the list.
  1228.  *        It is assumed that all gadgets are in the requester if the first
  1229.  *        one is.
  1230.  *        NOTE: the gadget(s) will be cleared regardless of whether it
  1231.  *        actually exists in the window or requester.
  1232.  *
  1233.  *        If RefreshGadgets() is called after this routine, the gadget(s)
  1234.  *        will be displayed normally.
  1235.  *
  1236.  *        NOTE: active "invisible" gadgets may look odd; especially a
  1237.  *        previously activated string gadget and when you click somewhere
  1238.  *        else, the cursor in the string gadget is redrawn by Intuition.
  1239.  *        The cause of this may be the following: if a string gadget has
  1240.  *        the GADGHCOMP flag set, then the cursor is drawn when a
  1241.  *        RefreshGadgets() is done (possibly only if the gadget is in a
  1242.  *        requester).
  1243.  *
  1244.  * RESULTS:    Returns non-zero on error.
  1245.  *        Note that the Gadget's display on screen is cleared to the
  1246.  *        background colour of the window's rastport immediately.
  1247.  *
  1248.  * SEE ALSO:    RefreshGList, RemoveGList, AddGList
  1249.  */
  1250.  
  1251. /*
  1252.  * NAME:    toggleBoolGadget
  1253.  *
  1254.  * SYNOPSIS:    error = toggleBoolGadget( window, gadget, req );
  1255.  *        short error;
  1256.  *
  1257.  * INPUTS:    struct Window    *window;    gadget's window
  1258.  *        struct Gadget    *gadget;    boolean gadget to toggle
  1259.  *        struct Requester *req;        gadget's requester, or NULL
  1260.  *
  1261.  * DESCRIPTION: Toggle a boolean gadget's text OR image, by switching it
  1262.  *        with the alternative text or image respectively.
  1263.  *
  1264.  *        If it is a text gadget:
  1265.  *            NOTE: the alternative text pointer is originally stored in
  1266.  *            the gadget's SelectRender field by gimmeBoolGadget.
  1267.  *            You must leave this field alone, which also means do not use
  1268.  *            the GADGHIMAGE flag.
  1269.  *        If it is an image gadget:
  1270.  *            the current ("old") image is erased before the new image is
  1271.  *            drawn, and the select box of the gadget is altered to the
  1272.  *            dimensions of the new image (this works perfectly only if
  1273.  *            the image's top left corner is the same as the gadget's).
  1274.  *
  1275.  * RESULTS:    Returns non-zero on error.
  1276.  *        Note: this routine only refreshes this gadget.
  1277.  *
  1278.  * SEE ALSO:    gimmeBoolGadget, clearGadgets
  1279.  */
  1280.  
  1281. /*
  1282.  * NAME:    findGadget
  1283.  *
  1284.  * SYNOPSIS:    gp = findGadget( firstgadget, id );
  1285.  *        struct Gadget *gp;
  1286.  *
  1287.  * INPUTS:    struct Gadget    *firstgadget;        pointer to Gadget list
  1288.  *        USHORT        id;            id of Gadget being sought
  1289.  *
  1290.  * DESCRIPTION: Search linked list of Gadgets, starting with firstgadget,
  1291.  *        for the first Gadget with GadgetID equal to id.
  1292.  *
  1293.  * RESULTS:    Returns pointer to Gadget matching the id, or NULL if none.
  1294.  */
  1295.  
  1296. /*
  1297.  * NAME:    findMyFirstGadget
  1298.  *
  1299.  * SYNOPSIS:    gp = findMyFirstGadget( window, id );
  1300.  *        struct Gadget *gp;
  1301.  *
  1302.  * INPUTS:    struct Gadget    *firstgadget;        pointer to Gadget list
  1303.  *        USHORT        id;            threshold id to skip over
  1304.  *
  1305.  * DESCRIPTION: Search linked list of Gadgets, starting with firstgadget,
  1306.  *        for the first Gadget with GadgetID strictly greater than id.
  1307.  *
  1308.  * RESULTS:    Returns pointer to first Gadget with a greater id,
  1309.  *        or NULL if none.
  1310.  */
  1311.  
  1312. /*
  1313.  * NAME:    gimmeGraph
  1314.  *
  1315.  * SYNOPSIS:    gr = gimmeGraph( newgraph, bitmap, areainfo, tmpras );
  1316.  *        GRAPH *gr;
  1317.  *
  1318.  * INPUTS:    struct NEWGRAPH *newgraph;    ptr to initialized NEWGRAPH
  1319.  *        struct BitMap    *bitmap;    bitmap pointer, or NULL
  1320.  *        struct AreaInfo *areainfo;    areainfo pointer, or NULL
  1321.  *        struct TmpRas    *tmpras;    tmpras pointer, or NULL
  1322.  *
  1323.  * DESCRIPTION: Create and initialize a GRAPH structure,
  1324.  *        according to the specifications in the newgraph.
  1325.  *        The axes and title will be rendered immediately unless the
  1326.  *        appropriate flag is set, in which case you can modify the GRAPH
  1327.  *        structure, then call drawGraphAxes yourself after this routine.
  1328.  *
  1329.  *        NOTE: currently the graph routines only properly support 1st
  1330.  *        quadrant graphing with a right-handed coordinate system
  1331.  *        (ie the axes should increase in value up and to the right).
  1332.  *        If you use scrolling (via DELTA flags), you should avoid
  1333.  *        values that fall exactly on an axis.
  1334.  *
  1335.  *        If the newgraph's rastport pointer is non-NULL, the actual
  1336.  *        rastport is copied into the graph structure, leaving the
  1337.  *        rastport pointed at by the newgraph forever untouched;
  1338.  *        otherwise the graph's rastport is initialized by InitRastPort().
  1339.  *        If bitmap is non-NULL, the bitmap pointer is copied into the
  1340.  *        graph's rastport's bitmap pointer.
  1341.  *        NOTE: if you specified a rastport in the newgraph and no bitmap
  1342.  *        parameter, the bitmap in that rastport will be used; otherwise
  1343.  *        you MUST specify a valid bitmap pointer as a parameter.
  1344.  *
  1345.  *        The areainfo and tmpras parameters go together, and are used
  1346.  *        only if either or both FILLTO flags are set.
  1347.  *        If areainfo (or tmpras) is non-NULL, the pointer will be set
  1348.  *        in the graph's rastport. If areainfo (or tmpras) is NULL, then
  1349.  *        an AreaInfo struct and vector buffer (or TmpRas struct and a
  1350.  *        raster the same size as the bitmap) are allocated for you.
  1351.  *        NOTE: if you specify the same areainfo and/or tmpras for two
  1352.  *        or more graphs, you must ensure that any addToGraph using FILLTO
  1353.  *        is not done concurrently, since technically the areainfo/tmpras
  1354.  *        structs should be unique for each graph.
  1355.  *
  1356.  *        The graphing routines are intended to be reasonably flexible;
  1357.  *        you can alter the fonts and colours for the various titles and
  1358.  *        labvels (title refers to words; label refers to the numbers on
  1359.  *        an axis) after this routine -- currently, the labels default to
  1360.  *        use the same font as their respective titles; the axes' title
  1361.  *        colours default to the same as the title colour; and the axes'
  1362.  *        label colours default to the axes colour.
  1363.  *        NOTE: if you wish to use different fonts for the labels, you
  1364.  *        can set the appropriate graph's textfont pointer, for example
  1365.  *        by assigning the title-textfont to the x-label-textfont, or
  1366.  *        setting it to NULL to use the "default" font;
  1367.  *        however, it is recommended that you do not introduce new fonts
  1368.  *        unless you know how to handle fonts properly (in particular
  1369.  *        do not play around with the three title font pointers).
  1370.  *
  1371.  *        Points are added to the graph dynamically using addToGraph.
  1372.  *
  1373.  *        See gimmelib/graph.h for descriptions of the various graphing
  1374.  *        structures and flags; note that some of the newgraph flags
  1375.  *        apply to how axis information is used.
  1376.  *
  1377.  *        Note: all allocated memory, including the GRAPH struct itself,
  1378.  *        is chained and the header is stored in the GRAPH's memhead
  1379.  *        field, which is used by getRidOfGraph to deallocate memory.
  1380.  *        You should use getRidOfGraph to free all the memory allocated
  1381.  *        by this routine.
  1382.  *
  1383.  * RESULTS:    Returns a pointer to a GRAPH, or NULL if anything went wrong.
  1384.  *
  1385.  * SEE ALSO:    addToGraph, getRidOfGraph, gimmeFont, drawGraphAxes,
  1386.  *        chainAllocMem
  1387.  */
  1388.  
  1389. /*
  1390.  * NAME:    getRidOfGraph
  1391.  *
  1392.  * SYNOPSIS:    err = getRidOfGraph( graph );
  1393.  *        short err;
  1394.  *
  1395.  * INPUTS:    GRAPH    *graph;     pointer to a GRAPH structure
  1396.  *
  1397.  * DESCRIPTION: Close a graph, freeing any allocated memory and releasing
  1398.  *        access to fonts accessed by gimmeGraph.
  1399.  *        May clear the graph first if the flags dictate it.
  1400.  *
  1401.  * RESULTS:    Returns non-zero on error.
  1402.  *
  1403.  * SEE ALSO:    gimmeGraph, clearGraph, getRidOfFont, chainFreeMem
  1404.  */
  1405.  
  1406. /*
  1407.  * NAME:    clearGraph
  1408.  *
  1409.  * SYNOPSIS:    clearGraph( graph );
  1410.  *
  1411.  * INPUTS:    GRAPH    *graph;     pointer to a GRAPH structure
  1412.  *
  1413.  * DESCRIPTION: Clear a graph.
  1414.  *        Effectively this means drawing the axes, labels and titles
  1415.  *        in the background colour and then clearing the rectangular
  1416.  *        region of the graph (bounded by the axes).
  1417.  *        Note: the graph struct is otherwise unchanged after this call.
  1418.  *
  1419.  * SEE ALSO:    gimmeGraph, getRidOfGraph
  1420.  */
  1421.  
  1422. /*
  1423.  * NAME:    resetGraph
  1424.  *
  1425.  * SYNOPSIS:    resetGraph( graph );
  1426.  *
  1427.  * INPUTS:    GRAPH    *graph;     pointer to a GRAPH structure
  1428.  *
  1429.  * DESCRIPTION: Resets a graph to the beginning.
  1430.  *        Effectively this means clearing the graph, re-initializing
  1431.  *        appropriate variables such as first and last point, undoing
  1432.  *        the effects of any scrolling, etc. and redrawing the "empty"
  1433.  *        graph if the graph's flags dictate it.
  1434.  *
  1435.  * SEE ALSO:    gimmeGraph, clearGraph, drawGraphAxes, getRidOfGraph
  1436.  */
  1437.  
  1438. /*
  1439.  * NAME:    drawGraphAxesOnly
  1440.  *
  1441.  * SYNOPSIS:    drawGraphAxesOnly( graph );
  1442.  *
  1443.  * INPUTS:    GRAPH    *graph;     pointer to a GRAPH structure
  1444.  *
  1445.  * DESCRIPTION: Draw the axes (lines only -- not labels) of a graph.
  1446.  *        Existing axes (if any) are NOT cleared first.
  1447.  *
  1448.  * SEE ALSO:    drawGraphAxes, gimmeGraph, clearGraph
  1449.  */
  1450.  
  1451. /*
  1452.  * NAME:    drawGraphAxes
  1453.  *
  1454.  * SYNOPSIS:    drawGraphAxes( graph );
  1455.  *
  1456.  * INPUTS:    GRAPH    *graph;     pointer to a GRAPH structure
  1457.  *
  1458.  * DESCRIPTION: Draw the axes including labels, titles and graph title
  1459.  *        of a graph in appropriate fonts, colours and positions.
  1460.  *        This means main title centred over the graph quad, the x-title
  1461.  *        centred under the x-axis (and labels), and the y-axis vertical
  1462.  *        and centred left of the y-axis (and labels).
  1463.  *
  1464.  *        Existing axes, labels and titles (if any) are NOT cleared first.
  1465.  *
  1466.  * RESULTS:    Returns the maximum width required for the labels (not titles).
  1467.  *
  1468.  * SEE ALSO:    drawGraphAxes, gimmeGraph, clearGraph, drawGraphTitle,
  1469.  *            drawGraphXtitle, drawGraphYtitle
  1470.  */
  1471.  
  1472. /*
  1473.  * NAME:    drawGraphTitle
  1474.  *
  1475.  * SYNOPSIS:    drawGraphTitle( graph, xoff, yoff, myflags );
  1476.  *
  1477.  * INPUTS:    GRAPH    *graph;     pointer to a GRAPH structure
  1478.  *        SHORT    xoff;        offset from y-axis in pixels
  1479.  *        SHORT    yoff;        offset from x-axis in pixels
  1480.  *        ULONG    myflags;    flags ala positionText
  1481.  *
  1482.  * DESCRIPTION: Draw the main title for a graph in the appropriate font
  1483.  *        and colour at (xoff, yoff) relative to the graph origin
  1484.  *        as modified by myflags via positionText.
  1485.  *        NOTE: yoff is positive upwards from the x-axis, and negative
  1486.  *        downwards (opposite to the normal rastport offsets).
  1487.  *
  1488.  *        Existing title (if any) is NOT cleared first.
  1489.  *
  1490.  * SEE ALSO:    drawGraphAxes, gimmeGraph, clearGraph, positionText
  1491.  */
  1492.  
  1493. /*
  1494.  * NAME:    drawGraphXtitle
  1495.  *
  1496.  * SYNOPSIS:    drawGraphXtitle( graph, xoff, yoff, myflags );
  1497.  *
  1498.  * INPUTS:    GRAPH    *graph;     pointer to a GRAPH structure
  1499.  *        SHORT    xoff;        offset from y-axis in pixels
  1500.  *        SHORT    yoff;        offset from x-axis in pixels
  1501.  *        ULONG    myflags;    flags ala positionText
  1502.  *
  1503.  * DESCRIPTION: Draw the title for a graph's x-axis in the appropriate font
  1504.  *        and colour at (xoff, yoff) relative to the graph origin
  1505.  *        as modified by myflags via positionText.
  1506.  *        NOTE: yoff is positive upwards from the x-axis, and negative
  1507.  *        downwards (opposite to the normal rastport offsets).
  1508.  *
  1509.  *        Existing title (if any) is NOT cleared first.
  1510.  *
  1511.  * SEE ALSO:    drawGraphAxes, gimmeGraph, clearGraph, positionText
  1512.  */
  1513.  
  1514. /*
  1515.  * NAME:    drawGraphYtitle
  1516.  *
  1517.  * SYNOPSIS:    drawGraphYtitle( graph, xoff, yoff, myflags );
  1518.  *
  1519.  * INPUTS:    GRAPH    *graph;     pointer to a GRAPH structure
  1520.  *        SHORT    xoff;        offset from y-axis in pixels
  1521.  *        SHORT    yoff;        offset from x-axis in pixels
  1522.  *        ULONG    myflags;    flags ala positionText
  1523.  *
  1524.  * DESCRIPTION: Draw the title for a graph's y-axis in the appropriate font
  1525.  *        and colour at (xoff, yoff) relative to the graph origin
  1526.  *        as modified by myflags via positionText.
  1527.  *        NOTE: yoff is positive upwards from the x-axis, and negative
  1528.  *        downwards (opposite to the normal rastport offsets).
  1529.  *
  1530.  *        Existing y-title (if any) is NOT cleared first.
  1531.  *
  1532.  * SEE ALSO:    drawGraphAxes, gimmeGraph, clearGraph, positionText
  1533.  */
  1534.  
  1535. /*
  1536.  * NAME:    graphWriteLabel
  1537.  *
  1538.  * SYNOPSIS:    graphWriteLabel( graph, myflags, first, last, step )
  1539.  *
  1540.  * INPUTS:    GRAPH    *graph;     pointer to a GRAPH structure
  1541.  *        ULONG    myflags;    flags for this routine
  1542.  *        SHORT    first;        low coordinate to start at
  1543.  *        SHORT    last;        high coordinate to end at
  1544.  *        SHORT    step;        fixed step size, 0 for automagic size
  1545.  *
  1546.  * DESCRIPTION: Draw the labels for one axis of a graph in the appropriate font
  1547.  *        and colour (note: does not draw axis title).
  1548.  *
  1549.  *        Automagically labels an axis between the coords first and last
  1550.  *        inclusive (the first and last parms should be reasonable -- not
  1551.  *        checked).
  1552.  *        If step is zero (0) then labels for first and last are rendered,
  1553.  *        and as many labels as reasonably possible are placed starting
  1554.  *        next to first and going towards just before last, leaving a
  1555.  *        reasonable amount of space between labels.
  1556.  *        If step is strictly positive, then a label is written for the
  1557.  *        coords: first, first+step, first+step+step,...,last
  1558.  *        (note that if last is not n-steps away from first then a label
  1559.  *        for last itself will not be drawn).
  1560.  *        Note: the step size should not be too small (not checked).
  1561.  *
  1562.  *        NOTE: exact label "wording" depend on the axis scale and certain
  1563.  *        graph flags.
  1564.  *
  1565.  *        Warning: this is a very recursive routine (unless you give
  1566.  *        a fixed step size).
  1567.  *
  1568.  * RESULTS:    Returns the maximum width of the labels for this axis.
  1569.  *
  1570.  * SEE ALSO:    drawGraphAxes, gimmeGraph, clearGraph
  1571.  */
  1572.  
  1573. /*
  1574.  * NAME:    addToGraph
  1575.  *
  1576.  * SYNOPSIS:    addToGraph( graph, x, y );
  1577.  *
  1578.  * INPUTS:    GRAPH    *graph;     pointer to a GRAPH structure
  1579.  *        SHORT    x;        x coordinate of new point to add
  1580.  *        SHORT    y;        y coordinate of new point to add
  1581.  *
  1582.  * DESCRIPTION: Add a point to the graph, rendered according to the flags
  1583.  *        in the graph structure.
  1584.  *        This includes lines, block fills etc. as well as scrolling
  1585.  *        if necessary.
  1586.  *        Note: the point is moved to the boundary of the rectangular
  1587.  *        region defined by the origin and the size of the axes
  1588.  *        if the point would fall outside of this boundary.
  1589.  *
  1590.  *        NOTE: if either FILLTO flag is set in the graph, the proper
  1591.  *        initialized AreaInfo and TmpRas structures must exist
  1592.  *        (gimmeGraph takes care of this if either FILLTO flag was set
  1593.  *        when it was called) otherwise crashes will occur.
  1594.  *
  1595.  * SEE ALSO:    gimmeGraph, getRidOfGraph, drawGraphAxes
  1596.  */
  1597.  
  1598. /*
  1599.  * NAME:    addInputHandler
  1600.  *
  1601.  * SYNOPSIS:    ioreq = addInputHandler( handler, data, pri, name );
  1602.  *        struct IOStdReq *ioreq;
  1603.  *
  1604.  * INPUTS:    void    (*handler)();       address of handler routine
  1605.  *        APTR    data;            pointer to data area for handler
  1606.  *        BYTE    pri;            priority for the handler
  1607.  *        UBYTE    *name;            name for input handler, or NULL
  1608.  *
  1609.  * DESCRIPTION: Add an input handler to the system.
  1610.  *        The priority indicates the priority level of the input handler;
  1611.  *        note that Intuition operates at priority fifty (50).
  1612.  *        The name is optional.
  1613.  *
  1614.  *        Your "real" input handler routine should be written as if called
  1615.  *        from the following C-language statement (see manuals):
  1616.  *            newEventChain = handler( oldEventChain, data );
  1617.  *        This isn't entirely true... the routine "handler" should
  1618.  *        actually expect the oldEventChain and data parameters
  1619.  *        in A0 and A1 respectively (see manuals).
  1620.  *        IF your real input handler is written in C, make your real
  1621.  *        input handler act like the above C-language call and also
  1622.  *        you must set up an interface routine similar to the following:
  1623.  *          #asm
  1624.  *          _handler:
  1625.  *            MOVEM.L    D2/D3/A4/A6,-(sp)       ; save some registers
  1626.  *            MOVEM.L    A0/A1,-(sp)             ; set up parms for C
  1627.  *            JSR     _myrealhandler
  1628.  *            LEA     8(sp),sp                ; pop parms
  1629.  *            MOVEM.L    (sp)+,D2/D3/A4/A6       ; restore registers
  1630.  *            RTS                 ; return in D0
  1631.  *          #endasm
  1632.  *        then call this routine using "handler", NOT "myrealhandler",
  1633.  *        as the handler parameter.
  1634.  *
  1635.  *        NOTE: your "real" input handler may have to do a geta4() as
  1636.  *        the first thing (or the Lattice equivalent) to set up a special
  1637.  *        pointer for small code/data models.
  1638.  *
  1639.  *        NOTE: do not fiddle with the iorequest; in particular, you
  1640.  *        must not alter the ioreq->io_Data pointer.
  1641.  *
  1642.  * RESULTS:    Returns a pointer to a IOStdReq, or NULL if unsuccessful.
  1643.  *
  1644.  * SEE ALSO:    removeInputHandler
  1645.  */
  1646.  
  1647. /*
  1648.  * NAME:    removeInputHandler
  1649.  *
  1650.  * SYNOPSIS:    err = removeInputHandler( ioreq );
  1651.  *        short err;
  1652.  *
  1653.  * INPUTS:    struct IOStdReq *ioreq;     ioreq returned by addInputHandler
  1654.  *
  1655.  * DESCRIPTION: Remove an input handler to the system (previously added by
  1656.  *        addInputHandler).
  1657.  *
  1658.  *        Note: the contents of the ioreq must be unchanged since the
  1659.  *        preceding addInputHandler call.
  1660.  *
  1661.  * RESULTS:    Returns non-zero on error.
  1662.  *
  1663.  * SEE ALSO:    addInputHandler
  1664.  */
  1665.  
  1666. /*
  1667.  * NAME:    gimmeBorder
  1668.  *
  1669.  * SYNOPSIS:    border = gimmeBorder( memheadptr, xsize, ysize );
  1670.  *        struct Border *border;
  1671.  *
  1672.  * INPUTS:    void    **memheadptr;    pointer to chained-memory head
  1673.  *        SHORT    xsize;        total width in pixels
  1674.  *        SHORT    ysize;        total height in pixels
  1675.  *
  1676.  * DESCRIPTION: Allocate and initialize a Border structure.
  1677.  *        If xsize and ysize are both strictly positive, the five
  1678.  *        coordinates for the border are set up as well.
  1679.  *
  1680.  *        Note: the draw mode and colours are set to JAM1 and 1, 0.
  1681.  *
  1682.  *        If memheadptr is non-NULL, chainAllocMem is used and you
  1683.  *        should use chainFreeMem eventually to free the memory;
  1684.  *        otherwise AllocMem is used and you must FreeMem on each
  1685.  *        separately allocated component.
  1686.  *
  1687.  * RESULTS:    Returns pointer to Border, or NULL.
  1688.  *
  1689.  * SEE ALSO:    chainAllocMem, chainFreeMem
  1690.  */
  1691.  
  1692. /*
  1693.  * NAME:    gimmeImage
  1694.  *
  1695.  * SYNOPSIS:    image = gimmeImage( memheadptr, depth, width, height );
  1696.  *        struct Image *image;
  1697.  *
  1698.  * INPUTS:    void    **memheadptr;        pointer to chained-memory head
  1699.  *        SHORT    depth;            number of bit-planes for image
  1700.  *        SHORT    width;            width of image in pixels
  1701.  *        SHORT    height;         height of image in pixels
  1702.  *
  1703.  * DESCRIPTION: Allocate and initialize an Image structure.
  1704.  *        If depth, width and height are all non-zero, sufficient
  1705.  *        contiguous chip memory is allocated for the image data;
  1706.  *        the pointer is stored in the image's ImageData field.
  1707.  *
  1708.  *        If memheadptr is non-NULL, chainAllocMem is used and you
  1709.  *        should use chainFreeMem eventually to free the memory;
  1710.  *        otherwise AllocMem is used and you must FreeMem on each
  1711.  *        separately allocated component.
  1712.  *
  1713.  * RESULTS:    Returns pointer to Image, or NULL.
  1714.  *
  1715.  * SEE ALSO:    chainAllocMem, chainFreeMem
  1716.  */
  1717.  
  1718. /*
  1719.  * NAME:    gimmeIntuiText
  1720.  *
  1721.  * SYNOPSIS:    itext = gimmeIntuiText( memheadptr, s, textattr, width );
  1722.  *        struct IntuiText *itext;
  1723.  *
  1724.  * INPUTS:    void    **memheadptr;        pointer to chained-memory head
  1725.  *        UBYTE    *s;            text string
  1726.  *        struct TextAttr *textattr;  pointer to font, or NULL
  1727.  *        SHORT    width;            total width; for optional centering
  1728.  *
  1729.  * DESCRIPTION: Allocate and initialize a IntuiText structure.
  1730.  *        The textattr can be NULL to use the default font.
  1731.  *
  1732.  *        NOTE: width is "optional":
  1733.  *        if width is positive, then the string is centered in the
  1734.  *        field that is width pixels wide.
  1735.  *
  1736.  *        Note: the draw mode and colours are set to JAM2 and 1, 0.
  1737.  *
  1738.  *        If memheadptr is non-NULL, chainAllocMem is used and you
  1739.  *        should use chainFreeMem eventually to free the memory;
  1740.  *        otherwise AllocMem is used and you must FreeMem on each
  1741.  *        separately allocated component.
  1742.  *
  1743.  * RESULTS:    Returns pointer to IntuiText, or NULL.
  1744.  *
  1745.  * SEE ALSO:    chainAllocMem, chainFreeMem
  1746.  */
  1747.  
  1748. /*
  1749.  * NAME:    deadKeyConvert
  1750.  *
  1751.  * REQUISITES:    struct ConsoleDevice *ConsoleDevice;    properly initialized
  1752.  *
  1753.  * SYNOPSIS:    len = deadKeyConvert( imsg, buf, bufsize, keymap );
  1754.  *        SHORT len;
  1755.  *
  1756.  * INPUTS:    struct IntuiMessage *imsg;    pointer to Intuition message
  1757.  *        UBYTE    *buf;            address of a buffer
  1758.  *        USHORT    bufsize;        size of the buffer "buf"
  1759.  *        struct KeyMap    *keymap;    pointer to a KeyMap, or NULL
  1760.  *
  1761.  * DESCRIPTION: Takes an Intuition RAWKEY message and processes it.
  1762.  *        The result will be "cooked" keys and key conversions placed
  1763.  *        in the buffer "buf".
  1764.  *
  1765.  *        NOTE: you must have a global variable named ConsoleDevice,
  1766.  *        declared as a "struct ConsoleDevice *", already initialized by
  1767.  *        extracting the "library" pointer from the console.device
  1768.  *        with code similar to the following:
  1769.  *            struct IOStdReq ioreq;
  1770.  *            err = OpenDevice("console.device", <unit-no>, &ioreq, 0L);
  1771.  *            { check for error }
  1772.  *            ConsoleDevice = (struct ConsoleDevice *) ioreq.io_Device;
  1773.  *
  1774.  *        Also, some versions of the Axtec C "functions.h" file have
  1775.  *        a bug: it declares the function "ConsoleDevice()" which
  1776.  *        is non-existant and that line should be deleted.
  1777.  *        Note: this is *very* similar to the DeadKeyConvert() function
  1778.  *        from the Amiga Enhancer Manual.
  1779.  *
  1780.  * RESULTS:    Returns the actual number of characters put into the buffer
  1781.  *        or -1 if the buffer overflowed
  1782.  *        or -2 if the IntuiMessage is not of class RAWKEY
  1783.  *        or -3 if parameters are invalid (if checking is done)
  1784.  */
  1785.  
  1786. /*
  1787.  * NAME:    chainAllocMem
  1788.  *
  1789.  * SYNOPSIS:    memptr = chainAllocMem( headptr, size, type );
  1790.  *        void *memptr;
  1791.  *
  1792.  * INPUTS:    void    **headptr;    ptr to the memory-chain head
  1793.  *        ULONG    size;        size of desired memory
  1794.  *        ULONG    flags;        type of memory ala AllocMem()
  1795.  *
  1796.  * DESCRIPTION: Allocate requested memory and possibly chain it to *headptr.
  1797.  *
  1798.  *        NOTE: if headptr is non-NULL, the chain head pointer MUST be
  1799.  *        initialized to NULL before its first use, and
  1800.  *        the memory returned must be freed by chainFreeMem only!!
  1801.  *
  1802.  *        NOTE: if headptr is NULL, then a normal AllocMem() is done
  1803.  *        and absolutely no chaining occurs and you are responsible
  1804.  *        for freeing the memory with a FreeMem(),
  1805.  *
  1806.  * RESULTS:    Returns pointer to requested chunk of memory, or NULL.
  1807.  *        Note that *headptr is updated if headptr is a valid pointer.
  1808.  *
  1809.  * SEE ALSO:    chainFreeMem, AllocMem, linkChainMem
  1810.  */
  1811.  
  1812. /*
  1813.  * NAME:    chainFreeMem
  1814.  *
  1815.  * SYNOPSIS:    chainFreeMem( head );
  1816.  *
  1817.  * INPUTS:    void    *head;            head of memory-chain to be freed
  1818.  *
  1819.  * DESCRIPTION: Free all memory chained to this head (including the head)
  1820.  *
  1821.  *        NOTE: head must be NULL or altered by chainAllocMem only!
  1822.  *
  1823.  * SEE ALSO:    chainAllocMem, pluckChainMem
  1824.  */
  1825.  
  1826. /*
  1827.  * NAME:    linkChainMem
  1828.  *
  1829.  * SYNOPSIS:    err = linkChainMem( headptr, head );
  1830.  *        short err;
  1831.  *
  1832.  * INPUTS:    void    **headptr;        ptr to memory-chain head
  1833.  *        void    *head;            secondary chain head
  1834.  *
  1835.  * DESCRIPTION: Link secondary chain (pointed at by head) to the front of the
  1836.  *        memory-chain (pointed at by *headptr), updating *headptr.
  1837.  *
  1838.  *        NOTE: head and the head pointed at by headptr must be NULL or
  1839.  *        altered by chainAllocMem only!
  1840.  *
  1841.  * RESULTS:    Non-zero on error. Note that *headptr may be updated.
  1842.  *
  1843.  * SEE ALSO:    chainAllocMem
  1844.  */
  1845.  
  1846. /*
  1847.  * NAME:    pluckChainMem
  1848.  *
  1849.  * SYNOPSIS:    err = pluckChainMem( headptr, mem );
  1850.  *        short err;
  1851.  *
  1852.  * INPUTS:    void    **headptr;        ptr to memory-chain head
  1853.  *        void    *mem;            actual pointer to memory chunk
  1854.  *
  1855.  * DESCRIPTION: Search for the "mem" entry in the memory-chain list pointed at
  1856.  *        by headptr; if it is in the list, unlink it and free the memory,
  1857.  *        otherwise it will not be freed so that memory lists are not
  1858.  *        corrupted.
  1859.  *        NOTE: mem must be a "real" pointer returned by chainAllocMem.
  1860.  *
  1861.  *        NOTE: the head pointed at by headptr must be NULL or
  1862.  *        altered by chainAllocMem only!
  1863.  *
  1864.  * RESULTS:    Non-zero on error, eg. headptr is NULL.
  1865.  *        Note that *headptr may be updated.
  1866.  *        If successful, the memory "mem" is freed and therefore unusable.
  1867.  *
  1868.  * SEE ALSO:    chainAllocMem, chainFreeMem
  1869.  */
  1870.  
  1871. /*
  1872.  * NAME:    gimmeMenu
  1873.  *
  1874.  * SYNOPSIS:    menu = gimmeMenu( memheadptr, left, width, name, flags );
  1875.  *        struct Menu *menu;
  1876.  *
  1877.  * INPUTS:    void    **memheadptr;    pointer to chained-memory head
  1878.  *        SHORT    left;        left offset in pixels
  1879.  *        SHORT    width;        total width in pixels, or -1
  1880.  *        UBYTE    *name;        name for menu
  1881.  *        ULONG    flags;        Menu flags
  1882.  *
  1883.  * DESCRIPTION: Allocate and initialize a Menu structure.
  1884.  *        Width should include room for a checkmark if necessary.
  1885.  *        If width is -1 (negative), a feeble attempt at calculating
  1886.  *        a width is made (9 pixels per character).
  1887.  *
  1888.  *        If memheadptr is non-NULL, chainAllocMem is used and you
  1889.  *        should use chainFreeMem eventually to free the memory;
  1890.  *        otherwise AllocMem is used and you must FreeMem on each
  1891.  *        separately allocated component.
  1892.  *
  1893.  * RESULTS:    Returns pointer to Menu, or NULL.
  1894.  *
  1895.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeMenuItem
  1896.  */
  1897.  
  1898. /*
  1899.  * NAME:    gimmeMenuItem
  1900.  *
  1901.  * REQUISITES:    struct GfxBase *GfxBase;    properly initialized - but only if
  1902.  *                          text && height == -1  && !textattr
  1903.  *
  1904.  * SYNOPSIS:    item = gimmeMenuItem( memheadptr, left, width, height,
  1905.  *                    command, name, textattr, flags );
  1906.  *        struct MenuItem *item;
  1907.  *
  1908.  * INPUTS:    void    **memheadptr;        pointer to chained-memory head
  1909.  *        SHORT    left;            left offset in pixels
  1910.  *        SHORT    width;            total width in pixels, or -1
  1911.  *        SHORT    height;         total height in pixels, or -1
  1912.  *        BYTE    command;        Command byte, if COMMSEQ flag set
  1913.  *        UBYTE    *name;            name for menu item
  1914.  *        struct TextAttr *textattr;  pointer to font, or NULL
  1915.  *        ULONG    flags;            MenuItem flags
  1916.  *
  1917.  * DESCRIPTION: Allocate and initialize a MenuItem structure.
  1918.  *        If ITEMTEXT flag set, then an IntuiText structure is created
  1919.  *        using the name and textattr (using INVERSVID drawing mode);
  1920.  *        otherwise:
  1921.  *            treat "(struct Image *)name" as primary image
  1922.  *            if HIGHIMAGE set, then treat
  1923.  *            "(struct Image *)textattr" as secondary image
  1924.  *        In either case, if width (and/or height) is -1 (negative)
  1925.  *        a suitable width (and/or height) is calculated. Further,
  1926.  *        if the CHECKIT or COMMSEQ flags are set, then CHECKWIDTH or
  1927.  *        COMMWIDTH respectively is added in to the calculated width
  1928.  *        (not LOWCHECKWIDTH nor LOWCOMMWIDTH since I can't tell the
  1929.  *        resolution and besides, no one really uses lo-res do they? :-)
  1930.  *
  1931.  *        NOTE: chainAllocMem is used and you
  1932.  *        should use chainFreeMem eventually to free the memory;
  1933.  *
  1934.  * RESULTS:    Returns pointer to MenuItem, or NULL.
  1935.  *
  1936.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeMenu
  1937.  */
  1938.  
  1939. /*
  1940.  * NAME:    addMenuItem
  1941.  *
  1942.  * SYNOPSIS:    menucode = addMenuItem( menu, item, positem, possub,
  1943.  *                        numitem, myflags );
  1944.  *        ULONG menucode;
  1945.  *
  1946.  * INPUTS:    struct Menu    *menu;        menu to which to add MenuItem
  1947.  *        struct MenuItem *item;        item (or subitem) to add
  1948.  *        SHORT        positem;    position of item, or -1
  1949.  *        SHORT        possub;     position of subitem, or -1
  1950.  *        SHORT        numitem;    number of (sub)items to add, or -1
  1951.  *        ULONG        myflags;    flags for this routine
  1952.  *
  1953.  * DESCRIPTION: Add a (list of) MenuItem to a Menu as an item or a subitem,
  1954.  *        depending on the flags.
  1955.  *        If the subitem-flag is set in myflags, then positem is used to
  1956.  *        locate a MenuItem to which "item" is to be added as a subitem;
  1957.  *         NOTE: in this case a MenuItem must already exist in the menu.
  1958.  *
  1959.  *        Actually add numitem MenuItems from a list starting with "item",
  1960.  *        where a numitem of -1 means all the MenuItems in the list.
  1961.  *        Either positem or possub may be -1 (ie. negative) which means
  1962.  *        the end of the list; otherwise use normal menu(item) position
  1963.  *        numbers, ie. 0 means the first one, 1 means the second, etc.
  1964.  *
  1965.  *        The flags (see gimmelib/menustuff.h) dictate other options,
  1966.  *        such as automatic adjusting of top edges to compensate visually
  1967.  *        for the insertion of the menuitems (visually) in the middle or
  1968.  *        at the end of the menu.
  1969.  *        Note: the Intuition menucode depends on the physical position
  1970.  *        of the menuitem in the menu's chain (not the visual position).
  1971.  *
  1972.  *        NOTE: this routine should only be used on a menustrip that is
  1973.  *        not attached to a window or guaranteed not to be actively used
  1974.  *        by Intuition (eg. by using the MENUVERIFY flag).
  1975.  *
  1976.  * RESULTS:    Returns menucode corresponding to position of (sub)item,
  1977.  *        or MENUNULL on error.
  1978.  *
  1979.  * SEE ALSO:    gimmeMenuItem, gimmeMenu, addMenu
  1980.  */
  1981.  
  1982. /*
  1983.  * NAME:    addMenu
  1984.  *
  1985.  * SYNOPSIS:    menucode = addMenu( menuptr, menu, posmenu, nummenu, myflags );
  1986.  *        ULONG menucode;
  1987.  *
  1988.  * INPUTS:    struct Menu    **menuptr;  pointer to menu ptr on which to add
  1989.  *        struct Menu    *menu;        menu to add
  1990.  *        SHORT        posmenu;    position of menu, or -1
  1991.  *        SHORT        nummenu;    number of menus to add, or -1
  1992.  *        ULONG        myflags;    flags for this routine
  1993.  *
  1994.  * DESCRIPTION: Add nummenu Menus to a menustrip starting with "menu",
  1995.  *        where a nummenu of -1 means all the Menus in the list.
  1996.  *
  1997.  *        A posmenu of -1 (ie. negative) means the end of the list;
  1998.  *        otherwise use normal menu position numbers, ie. 0 means the
  1999.  *        first one, 1 means the second, etc.
  2000.  *
  2001.  *        NOTE: menuptr can point at a NULL pointer (ie *menuptr == NULL)
  2002.  *        which means that a "new" menu is begun with "menu".
  2003.  *
  2004.  *        The flags (see gimmelib/menustuff.h) dictate other options,
  2005.  *        such as automatic adjusting of left edges to compensate for
  2006.  *        the insertion of the menus (visually) in the middle or at the
  2007.  *        end of the menustrip.
  2008.  *        Note: the Intuition menucode depends on the physical position
  2009.  *        of the menu in the menustrip's chain (not the visual position).
  2010.  *
  2011.  *        NOTE: this routine should only be used on a menustrip that is
  2012.  *        not attached to a window or guaranteed not to be actively used
  2013.  *        by Intuition (eg. by using the MENUVERIFY flag).
  2014.  *
  2015.  * RESULTS:    Returns menucode corresponding to position of menu,
  2016.  *        or MENUNULL on error.
  2017.  *
  2018.  * SEE ALSO:    gimmeMenu, gimmeMenuItem, addMenuItem
  2019.  */
  2020.  
  2021. /*
  2022.  * NAME:    removeMenuItem
  2023.  *
  2024.  * SYNOPSIS:    item = removeMenuItem( menu, item, positem, possub,
  2025.  *                        numitem, myflags );
  2026.  *        strut MenuItem *item;
  2027.  *
  2028.  * INPUTS:    struct Menu    *menu;        menu from which to remove MenuItem
  2029.  *        struct MenuItem *item;        item (or subitem) to remove, or NULL
  2030.  *        SHORT        positem;    position of item, or -1
  2031.  *        SHORT        possub;     position of subitem, or -1
  2032.  *        SHORT        numitem;    #(sub)items to remove, or -1
  2033.  *        ULONG        myflags;    flags for this routine
  2034.  *
  2035.  * DESCRIPTION: Remove a (list of) MenuItem to a Menu as an item or a subitem,
  2036.  *        depending on the flags.
  2037.  *        If the subitem-flag is set in myflags, then positem is used to
  2038.  *        locate a MenuItem from which "item" is to be removed as a
  2039.  *        subitem; NOTE: in this case a MenuItem must already exist in
  2040.  *        the menu.
  2041.  *
  2042.  *        If item is non-NULL (ie. you have an actual MenuItem address):
  2043.  *        actually remove numitem MenuItems from a list starting with
  2044.  *        "item", where numitem of -1 means all the MenuItems in the list;
  2045.  *        in this case, positem and possub are ignored.
  2046.  *
  2047.  *        Otherwise (if item is NULL):
  2048.  *        find the appropriate item [as specified by positem, and possub
  2049.  *        if the subitem-flag is set] and then actually remove numitem
  2050.  *        MenuItems starting with the found item, where numitem of -1
  2051.  *        means all the MenuItems in the list.
  2052.  *        Either positem or possub may be -1 (ie. negative) which means
  2053.  *        the end of the list; otherwise use normal menu(item) position
  2054.  *        numbers, ie. 0 means the first one, 1 means the second, etc.
  2055.  *
  2056.  *        The flags (see gimmelib/menustuff.h) dictate other options,
  2057.  *        such as automatic adjusting of top edges to compensate for the
  2058.  *        removal of the menuitems (effects visual offsets in the menu).
  2059.  *
  2060.  *        NOTE: this routine should only be used on a menustrip that is
  2061.  *        not attached to a window or guaranteed not to be actively used
  2062.  *        by Intuition (eg. by using the MENUVERIFY flag).
  2063.  *
  2064.  * RESULTS:    Returns pointer to the (list of) MenuItem removed,
  2065.  *        or NULL on error.
  2066.  *
  2067.  * SEE ALSO:    addMenuItem, addMenu, removeMenu
  2068.  */
  2069.  
  2070. /*
  2071.  * NAME:    removeMenu
  2072.  *
  2073.  * SYNOPSIS:    menu = removeMenu( menuptr, menu, posmenu, nummenu, myflags );
  2074.  *        struct Menu *menu;
  2075.  *
  2076.  * INPUTS:    struct Menu    **menuptr;  pointer to menu ptr on which to add
  2077.  *        struct Menu    *menu;        menu to remove, or NULL
  2078.  *        SHORT        posmenu;    position of menu, or -1
  2079.  *        SHORT        nummenu;    number of menus to remove, or -1
  2080.  *        ULONG        myflags;    flags for this routine
  2081.  *
  2082.  * DESCRIPTION: Remove a (list of) Menu from a menustrip.
  2083.  *
  2084.  *        If menu is non-NULL (ie. you have an actual Menu address):
  2085.  *        actually remove nummenu Menus from a list starting with
  2086.  *        "menu", where nummenu of -1 means all the Menus in the list;
  2087.  *        in this case, posmenu is ignored.
  2088.  *
  2089.  *        Otherwise (if menu is NULL):
  2090.  *        find the appropriate menu [as specified by posmenu], and then
  2091.  *        actually remove nummenu Menus starting with the found menu,
  2092.  *        where nummenu of -1 means all the Menus in the list.
  2093.  *        A posmenu of -1 (ie. negative) means the end of the list;
  2094.  *        otherwise use normal menu(item) position numbers,
  2095.  *        ie. 0 means the first one, 1 means the second, etc.
  2096.  *
  2097.  *        The flags (see gimmelib/menustuff.h) dictate other options,
  2098.  *        such as automatic adjusting of left edges to compensate for
  2099.  *        the removal of the menus (visually) in the middle or at the
  2100.  *        end of the menustrip.
  2101.  *
  2102.  *        NOTE: this routine should only be used on a menustrip that is
  2103.  *        not attached to a window or guaranteed not to be actively used
  2104.  *        by Intuition (eg. by using the MENUVERIFY flag).
  2105.  *
  2106.  * RESULTS:    Returns pointer to the (list of) MenuItem removed,
  2107.  *        or NULL on error.
  2108.  *
  2109.  * SEE ALSO:    addMenu, addMenuItem, removeMenuItem
  2110.  */
  2111.  
  2112. /*
  2113.  * NAME:    adjustMenuItems
  2114.  *
  2115.  * SYNOPSIS:    err = adjustMenuItems( item, stop, topedge, mepos, myflags );
  2116.  *        short err;
  2117.  *
  2118.  * INPUTS:    struct MenuItem *item;        item at which to start
  2119.  *        struct MenuItem *stop;        first item not to alter, or NULL
  2120.  *        SHORT        topedge;    topedge for first menu item
  2121.  *        SHORT        mepos;        pos of 1st item (for MutualExclude)
  2122.  *        ULONG        myflags;    flags for this routine
  2123.  *
  2124.  * DESCRIPTION: Adjust the TopEdge and/or MutualExclude fields of a list of
  2125.  *        MenuItems, depending on the flags.
  2126.  *
  2127.  *        Starting with "item" the adjustment is done for the entire list,
  2128.  *        OR until (but not including) "stop" is reached,
  2129.  *        OR only from "stop" until the end of the list
  2130.  *        -- all according to the flags (see gimmelib/menustuff.h).
  2131.  *
  2132.  *        The topedge and mutualexlude options are independant (and have
  2133.  *        separate flags), so you can mix and match when either one is
  2134.  *        done in a single call [eg. adjust topedges until "past" and
  2135.  *        mutualexcludes only from "past" onwards].
  2136.  *
  2137.  *        NOTE: this routine should only be used on a menustrip that is
  2138.  *        not attached to a window or guaranteed not to be actively used
  2139.  *        by Intuition (eg. by using the MENUVERIFY flag).
  2140.  *
  2141.  * RESULTS:    Returns non-zero on error.
  2142.  *
  2143.  * SEE ALSO:    gimmeMenuItem, addMenuItem, gimmeMenu, addMenu
  2144.  */
  2145.  
  2146. /*
  2147.  * NAME:    adjustMenuLefts
  2148.  *
  2149.  * SYNOPSIS:    err = adjustMenuLefts( menu, stop, leftedge, myflags );
  2150.  *        short err;
  2151.  *
  2152.  * INPUTS:    struct Menu *menu;    menu at which to start
  2153.  *        struct Menu *stop;    first menu not to alter, or NULL
  2154.  *        SHORT        leftedge;    leftedge for first menu given
  2155.  *        ULONG        myflags;    flags for this routine
  2156.  *
  2157.  * DESCRIPTION: Adjust the LeftEdge field of a list of Menus, starting with
  2158.  *        leftedge and incremented using the widths of the menus.
  2159.  *
  2160.  *        Starting with "menu" the adjustment is done for the entire list,
  2161.  *        OR until (but not including) "stop" is reached -- according to
  2162.  *        the flags (see gimmelib/menustuff.h).
  2163.  *
  2164.  *        NOTE: this routine should only be used on a menustrip that is
  2165.  *        not attached to a window or guaranteed not to be actively used
  2166.  *        by Intuition (eg. by using the MENUVERIFY flag).
  2167.  *
  2168.  * RESULTS:    Returns non-zero on error.
  2169.  *
  2170.  * SEE ALSO:    gimmeMenuItem, addMenuItem, gimmeMenu, addMenu
  2171.  */
  2172.  
  2173. /*
  2174.  * NAME:    gimmeMessage
  2175.  *
  2176.  * SYNOPSIS:    msg = gimmeMessage( size, replyport );
  2177.  *        struct Message *msg;
  2178.  *
  2179.  * INPUTS:    ULONG        size;        size of your message struct
  2180.  *        struct MsgPort    *replyport;    ptr to a reply port, or NULL
  2181.  *
  2182.  * DESCRIPTION: Allocate memory for an [extended] message struct,
  2183.  *        initializing the Node, Length and ReplyPort [enough to
  2184.  *        do a PutMsg() immediately].
  2185.  *        Node type set to NT_FREEMSG for consistency.
  2186.  *
  2187.  *        NOTE: size must be passed as a ULONG, *not* a short.
  2188.  *
  2189.  * RESULTS:    Returns pointer to an [extended] message struct of the
  2190.  *        specified size, or NULL on failure.
  2191.  *
  2192.  * SEE ALSO:    getRidOfMessage
  2193.  */
  2194.  
  2195. /*
  2196.  * NAME:    getRidOfMessage
  2197.  *
  2198.  * SYNOPSIS:    err = getRidOfMessage( msg );
  2199.  *        short err;
  2200.  *
  2201.  * INPUTS:    struct Message    *msg;        pointer to initialized Message
  2202.  *
  2203.  * DESCRIPTION: Free the [extended] message struct, using its Length field.
  2204.  *
  2205.  * RESULTS:    Returns non-zero on error.
  2206.  *
  2207.  * SEE ALSO:    gimmeMessage
  2208.  */
  2209.  
  2210. /*
  2211.  * NAME:    gimmePicture
  2212.  *
  2213.  *        #include <gimmelib/picture.h>
  2214.  *
  2215.  * SYNOPSIS:    pic = gimmePicture( filename, myflags );
  2216.  *        PICTURE *pic;
  2217.  *
  2218.  * INPUTS:    UBYTE    *filename;        name of iff ilbm file
  2219.  *        ULONG    myflags;        flags for the routine
  2220.  *
  2221.  * DESCRIPTION: Read a picture (IFF/ILBM) from the specified file.
  2222.  *        Create and initialize a PICTURE structure for the picture.
  2223.  *        The flags specify whether chip memory for the bitplanes
  2224.  *        should be allocated contiguously or sequentially or either;
  2225.  *        these flags are the same as those used by gimmeBitPlanes,
  2226.  *        and are defined in <gimmelib/bitplane.h>.
  2227.  *        If possible, an error message is printed if anything goes
  2228.  *        wrong -- it is safe to call this function from a (sub)task
  2229.  *        that has no CLI window.
  2230.  *
  2231.  *        Note: all allocated memory, including the PICTURE struct itself,
  2232.  *        is chained and the header is stored in the PICTURE's memhead
  2233.  *        field, which is used by getRidOfPicture to deallocate memory.
  2234.  *        You should use getRidOfPicture to free all the memory allocated
  2235.  *        by this routine.
  2236.  *
  2237.  * RESULTS:    Returns pointer to an initialized PICTURE, or NULL on error.
  2238.  *
  2239.  * SEE ALSO:    getRidOfPicture
  2240.  */
  2241.  
  2242. /*
  2243.  * NAME:    getRidOfPicture
  2244.  *
  2245.  * SYNOPSIS:    err = getRidOfPicture( picture );
  2246.  *        short err;
  2247.  *
  2248.  * INPUTS:    PICTURE   *picture;        pointer to PICTURE
  2249.  *
  2250.  * DESCRIPTION: De-allocate a PICTURE structure that was dynamically
  2251.  *        allocated by gimmePicture.
  2252.  *
  2253.  * RESULTS:    Returns non-zero on error.
  2254.  *
  2255.  * SEE ALSO:    gimmePicture
  2256.  */
  2257.  
  2258. /*
  2259.  * NAME:    positionPicture
  2260.  *
  2261.  * SYNOPSIS:    err = positionPicture( rp, myflags, pic, minterm, x, y );
  2262.  *        short err;
  2263.  *
  2264.  * INPUTS:    struct RastPort *rp;        rastport in which to place it
  2265.  *        ULONG        myflags;    flags for the routine
  2266.  *        PICTURE     *pic;        picture to be placed/removed
  2267.  *        SHORT        minterm;    how to blit the picture
  2268.  *        SHORT        x, y;        offsets for placing picture
  2269.  *
  2270.  * DESCRIPTION: Position a picture's image into a rastport using the blitter.
  2271.  *        The rastport should NOT be a window's rastport, because of
  2272.  *        layers associated with windows that are bypassed here.
  2273.  *        The flags modify the interpretation of the x and y coordinates
  2274.  *        so that the x and y values can specify the centre or any corner
  2275.  *        pixel positions; see gimmelib/postext.h for the actual flags.
  2276.  *        The minterm determines how the picture's image (bitmap) will
  2277.  *        be blitted into the screen's rastport; see gimmelib/minterm.h
  2278.  *        for some common minterms.
  2279.  *
  2280.  *        NOTE: clipping is done so that you can safely position part or
  2281.  *        all of the picture outside of the rastport's boundaries so that
  2282.  *        the remaining portion (if any) is visible.
  2283.  *
  2284.  * RESULTS:    Returns non-zero on error.
  2285.  *
  2286.  * SEE ALSO:    gimmePicture, getRidOfPicture
  2287.  */
  2288.  
  2289. /*
  2290.  * NAME:    usePictureColors
  2291.  *
  2292.  * SYNOPSIS:    err = usePictureColors( pic, screen );
  2293.  *        short err;
  2294.  *
  2295.  * INPUTS:    PICTURE     *pic;        use this picture's colors
  2296.  *        struct Screen    *screen;    screen to be affected
  2297.  *
  2298.  * DESCRIPTION: Set a screen's colors to those of a picture.
  2299.  *
  2300.  * RESULTS:    Returns non-zero on error.
  2301.  *
  2302.  * SEE ALSO:    gimmePicture, getRidOfPicture
  2303.  */
  2304.  
  2305. /*
  2306.  * NAME:    positionText
  2307.  *
  2308.  * SYNOPSIS:    maxrastlen = positionText( rp, myflags, s, num, x, y );;
  2309.  *        SHORT maxrastlen;
  2310.  *
  2311.  * INPUTS:    struct RastPort *rp;    pointer to rastport to draw into
  2312.  *        ULONG    myflags;    routine flags controlling position
  2313.  *        UBYTE    *s;        pointer to string to display, or NULL
  2314.  *        LONG    num;        number to display (or 0L if not used)
  2315.  *        SHORT    x, y;        coordinates used in displaying text,
  2316.  *                      interpreted according to flags
  2317.  *
  2318.  * DESCRIPTION: Displays a string using the coordinates (x, y).
  2319.  *        The string displayed is: if s is NULL, "num" is converted
  2320.  *        to a string, otherwise the string "s" is used.
  2321.  *        The current font, pen colours and draw-mode of the rastport
  2322.  *        are used.
  2323.  *        The type of coordinates can be specified in the <flags>
  2324.  *        individually for x/y (see gimmelib/postext.h for flag names):
  2325.  *        - flags for x: left, right and centre.
  2326.  *        - flags for y: top, bottom, centre, baseline, centrebase.
  2327.  *        For example, specifying the centre-x flag will cause the
  2328.  *        x coordinate to be used as the centre of the text to be
  2329.  *        displayed.
  2330.  *        NOTE: centre-y means the centre of the character's height,
  2331.  *        whereas centrebase-y means the centre of the top of the
  2332.  *        character to its baseline. Since most of a character
  2333.  *        appears above the baseline, this may be more desirable than
  2334.  *        centre-y on certain fonts.
  2335.  *
  2336.  *        Note: normally when text is displayed using the system's
  2337.  *        Text() function, the coordinates specified are the LEFT-x
  2338.  *        and BASELINE-y.
  2339.  *
  2340.  *        If the y-upwards or y-downwards control flags are specified,
  2341.  *        then the text is written vertically (eg. a label for a y-axis).
  2342.  *        Note "upwards" means rotated 90 degrees counter-clockwise,
  2343.  *        similarly "downwards" is clockwise (as viewed from your seat).
  2344.  *        In these 2 cases, the meaning of the flags are changed slightly:
  2345.  *        the x-flags are applied to the y-coordinate, and the y-flags are
  2346.  *        applied to the x-coordinate. The way to picture this is like so:
  2347.  *        if you look at your vertical text so that is horizontal (normal)
  2348.  *        then how would you apply the flags? But since the vertical text
  2349.  *        does get rotated 90 degrees, the x and y coordinates really
  2350.  *        apply to the y and x coordinates relative to the normal text.
  2351.  *        eg. the baseline of the text is now an offset in the x-direction
  2352.  *        because the text is sideways.
  2353.  *        NOTE: currently any portion of vertical text (JAM2 or otherwise)
  2354.  *        that is colour 0 does NOT get rendered in the rastport.
  2355.  *        Note: the x-thicken control flag only works in conjunction with
  2356.  *        vertical text.
  2357.  *        Note: vertical text does NOT take layers into account.
  2358.  *
  2359.  * RESULTS:    Returns the maximum possible length in pixels that the
  2360.  *        number/string could occupy in the current given rastport,
  2361.  *        or a negative number on error (eg. incorrect parameters).
  2362.  */
  2363.  
  2364. /*
  2365.  * NAME:    gimmeAutoRequest
  2366.  *
  2367.  * SYNOPSIS:    result = gimmeAutoRequest( window, s, textattr );
  2368.  *        SHORT result;
  2369.  *
  2370.  * INPUTS:    struct Window    *window;    window, or NULL for default screen
  2371.  *        UBYTE        *s;        main text string for requester
  2372.  *        struct TextAttr *textattr;  pointer to font type, or NULL
  2373.  *
  2374.  * DESCRIPTION: Put up an auto requester in the window (or screen if window
  2375.  *        is NULL).
  2376.  *        Use default font if textattr is NULL.
  2377.  *
  2378.  *        Note: If you wish to change the default positive/negative
  2379.  *        gadgets' text, you can alter the pointers which are extern'd in
  2380.  *        gimmelib/requester.h, to which you are referred.
  2381.  *        The defaults can be restored by assigning GAR_POSTEXT and
  2382.  *        GAR_NEGTEXT to the respective pointers.
  2383.  *        Caution: if you play around with these pointers in your program,
  2384.  *        you must not have more than one task within the same process
  2385.  *        space manipulating these pointers simultaneously.
  2386.  *
  2387.  * RESULTS:    Returns TRUE or FALSE, ala AutoRequest(), according to the
  2388.  *        user's selection.
  2389.  */
  2390.  
  2391. /*
  2392.  * NAME:    gimmeRequester
  2393.  *
  2394.  * SYNOPSIS:    req = gimmeRequester( memheadptr, left, top, width, height,
  2395.  *                    backfill, gplist, s, textattr, flags );
  2396.  *        struct Requester *req;
  2397.  *
  2398.  * INPUTS:    void    **memheadptr;        pointer to chained-memory head
  2399.  *        SHORT    left;            left offset in pixels
  2400.  *        SHORT    top;            top offset in pixels
  2401.  *        SHORT    width;            total width in pixels, or -1
  2402.  *        SHORT    height;         total height in pixels, or -1
  2403.  *        UBYTE    backfill;        color to fill in back of requester
  2404.  *        struct Gadget    *gplist;    first of a list of gadgets
  2405.  *        UBYTE    *s;            main text string, or NULL
  2406.  *        struct TextAttr *textattr;  pointer to font, or NULL
  2407.  *        ULONG    flags;            Requester flags
  2408.  *
  2409.  * DESCRIPTION: Allocate and initialize a Requester structure,
  2410.  *        including a border just inside the edge of the requester
  2411.  *        in the complement of the backfill colour.
  2412.  *        Note: this routine succeeds even if no border was allocated
  2413.  *        (check gp->GadgetRender for a non-NULL value if you want to
  2414.  *        be sure that a border was allocated).
  2415.  *        If you want to remove the border, do something similar to this:
  2416.  *            pluckChainMem( memheadptr, req->ReqBorder );
  2417.  *            req->ReqBorder = NULL;
  2418.  *
  2419.  *        The requester background is filled with the backfill color.
  2420.  *        The main text string pointed at by "s" is put in its own
  2421.  *        (allocated) IntuiText struct.
  2422.  *        If width is non-positive, then a suitable width is calculated
  2423.  *        based on the given text, font and gadgets.
  2424.  *        If height is non-positive, then a suitable height is calculated
  2425.  *        based on the given text, font and gadgets.
  2426.  *        Note: in either of these cases, gadget Borders or alternate
  2427.  *        images are not checked in calculating sufficient sizes.
  2428.  *
  2429.  *        The textattr can be NULL to use the default font.
  2430.  *        The linked list of gadget(s) is attached to the requester;
  2431.  *        remember that at least one gadget must have the ENDGADGET flag
  2432.  *        set so that the requester can be made to go away.
  2433.  *        Note that you might have to adjust the gadgets' back colours
  2434.  *        to match the backfill colour yourself if JAM2 modes are used.
  2435.  *        The flags are set in the requester's Flags field.
  2436.  *
  2437.  *        The allocated memory is chained to the memory chain pointed
  2438.  *        at by memheadptr using chainAllocMem.
  2439.  *        Eventually chainFreeMem should be called on the memhead.
  2440.  *
  2441.  * RESULTS:    Returns pointer to requester, or NULL.
  2442.  *        Note: the requester is NOT added to a window.
  2443.  *
  2444.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeStringInfo
  2445.  */
  2446.  
  2447. /*
  2448.  * NAME:    gimmeNewScreen
  2449.  *
  2450.  * SYNOPSIS:    ns = gimmeNewScreen( modes, type, depth, title, textattr );
  2451.  *        struct NewScreen *ns;
  2452.  *
  2453.  * INPUTS:    ULONG    modes;            new screen ViewMode flags
  2454.  *        ULONG    type;            new screen Type (eg CUSTOMSCREEN)
  2455.  *        SHORT    depth;            depth to make screen
  2456.  *        UBYTE    *title;         title string
  2457.  *        struct TextAttr *textattr;  pointer to font, or NULL
  2458.  *
  2459.  * DESCRIPTION: Allocate and initialize a NewScreen structure.
  2460.  *        Width and height taken from WorkBench screen (however, if
  2461.  *        you want to find out the height, eg for windows, you must
  2462.  *        wait until you open the screen and then check the Height
  2463.  *        field in the Screen structure).
  2464.  *        Note: this routine assumes an upper width limit of 350 for
  2465.  *        lo-res screens, and adjusts the width taken from GfxBase
  2466.  *        accordingly.
  2467.  *
  2468.  *        You can customize the NewScreen structure before opening
  2469.  *        the screen.
  2470.  *
  2471.  * RESULTS:    Returns pointer to NewScreen structure, or NULL on error.
  2472.  *
  2473.  * SEE ALSO:    getRidOfNewScreen, gimmeScreen, getRidOfScreen
  2474.  */
  2475.  
  2476. /*
  2477.  * NAME:    getRidOfNewScreen
  2478.  *
  2479.  * SYNOPSIS:    err = getRidOfNewScreen( ns );
  2480.  *        short err;
  2481.  *
  2482.  * INPUTS:    struct NewScreen    *ns;    pointer to NewScreen structure
  2483.  *
  2484.  * DESCRIPTION: De-allocates a NewScreen structure that was dynamically
  2485.  *        allocated by gimmeNewScreen.
  2486.  *
  2487.  * RESULTS:    Returns non-zero on error.
  2488.  *
  2489.  * SEE ALSO:    gimmeNewScreen, gimmeScreen, gimmeScreenLazy, getRidOfScreen
  2490.  */
  2491.  
  2492. /*
  2493.  * NAME:    gimmeScreen
  2494.  *
  2495.  * SYNOPSIS:    screen = gimmeScreen( ns, windowptr, depth, IDCMPflags,
  2496.  *                    winflags );
  2497.  *        struct Screen *screen;
  2498.  *
  2499.  * INPUTS:    struct NewScreen    *ns;        ptr to initialized NewScreen
  2500.  *        struct Window        **windowptr;    ptr to window ptr
  2501.  *        SHORT            depth;        depth for window
  2502.  *        ULONG            IDCMPflags;     IDCMP flags for window
  2503.  *        ULONG            winflags;        flags for window
  2504.  *
  2505.  * DESCRIPTION: Open an Intuition screen.
  2506.  *        If the NewScreen pointer "ns" in NULL, then a default NewScreen
  2507.  *        structure is temporarily created, used and deleted.
  2508.  *        If windowptr is non-NULL, a window with the given IDCMP and
  2509.  *        window flags is opened on the screen; the pointer to this window
  2510.  *        is placed where windowptr points to. The screen's titlebar will
  2511.  *        be hidden behind the window if it is a backdrop window.
  2512.  *        The window, if opened, will be the same width as the screen,
  2513.  *        but one pixel shorter and placed down one pixel so that the
  2514.  *        screen's titlebar is still accessible.
  2515.  *        Note that the screen's titlebar may be partially visible.
  2516.  *
  2517.  *        Note: the depth parameter is only used if no NewScreen is
  2518.  *        given, ie. if "ns" is NULL.
  2519.  *
  2520.  *        Note: when you close the screen with getRidOfScreen, you must
  2521.  *        either close the window using getRidOfWindow on the window ptr
  2522.  *        placed in *windowptr, OR pass this window ptr along to the
  2523.  *        getRidOfScreen routine.
  2524.  *
  2525.  *        Note: this routine will fail if a window is asked for but
  2526.  *        cannot be opened even though the screen opened (any allocated
  2527.  *        memory will be freed and the screen closed before returning).
  2528.  *
  2529.  * RESULTS:    Returns a pointer to an open Intuition screen, or NULL if
  2530.  *        anything went wrong. If windowptr is non-NULL, *windowptr will
  2531.  *        be updated to contain a pointer to a window.
  2532.  *
  2533.  * SEE ALSO:    getRidOfNewScreen, gimmeScreenLazy, getRidOfScreen
  2534.  */
  2535.  
  2536. /*
  2537.  * NAME:    gimmeScreenLazy
  2538.  *
  2539.  * SYNOPSIS:    screen = gimmeScreenLazy( ns, windowptr, depth );
  2540.  *        struct Screen *screen;
  2541.  *
  2542.  * INPUTS:    struct NewScreen    *ns;        ptr to initialized NewScreen
  2543.  *        struct Window        **windowptr;    ptr to window ptr
  2544.  *        SHORT            depth;        depth for window
  2545.  *
  2546.  * DESCRIPTION: Open an Intuition screen, and possibly a window.
  2547.  *        This routine is a shortcut for using gimmeScreen, using
  2548.  *        default IDCMP and window flags (see gimmelib/window.h) for
  2549.  *        a backdrop window if windowptr in non-NULL.
  2550.  *        Note that the screen titlebar may be partially visible.
  2551.  *
  2552.  *        Note: this routine will fail if a window is asked for but
  2553.  *        cannot be opened even though the screen opened (any allocated
  2554.  *        memory will be freed and the screen closed before returning).
  2555.  *
  2556.  * RESULTS:    Returns a pointer to an open Intuition screen, or NULL if
  2557.  *        anything went wrong. If windowptr is non-NULL, *windowptr will
  2558.  *        be updated to contain a pointer to a window.
  2559.  *
  2560.  * SEE ALSO:    gimmeNewScreen, gimmeScreen, getRidOfScreen
  2561.  */
  2562.  
  2563. /*
  2564.  * NAME:    getRidOfScreen
  2565.  *
  2566.  * SYNOPSIS:    err = getRidOfScreen( screen, window );
  2567.  *        short err;
  2568.  *
  2569.  * INPUTS:    struct Screen    *screen;    pointer to Intuition screen
  2570.  *        struct Window    *window;    pointer to window -- see note
  2571.  *
  2572.  * DESCRIPTION: Close a screen.
  2573.  *        If window is non-NULL, close the window first.
  2574.  *        NOTE: if window is specified, it SHOULD be the window ptr
  2575.  *        returned by gimmeScreen where the window-ptr parameter
  2576.  *        pointed to.
  2577.  *
  2578.  *        Note: does NOT call ClearMenuStrip() on the window.
  2579.  *
  2580.  * RESULTS:    Returns non-zero on error.
  2581.  *
  2582.  * SEE ALSO:    gimmeNewScreen, getRidOfNewScreen, gimmeScreen
  2583.  */
  2584.  
  2585. /*
  2586.  * NAME:    lowerScreen
  2587.  *
  2588.  * SYNOPSIS:    err = lowerScreen( screen, toheight );
  2589.  *        short err;
  2590.  *
  2591.  * INPUTS:    struct Screen    *screen;    pointer to Intuition screen
  2592.  *        SHORT    toheight;        height in pixels from top of view
  2593.  *
  2594.  * DESCRIPTION: Slide the screen down until top of screen is at the
  2595.  *        desired height from the top of the viewing area.
  2596.  *
  2597.  * RESULTS:    Returns non-zero on error.
  2598.  *
  2599.  * SEE ALSO:    raiseScreen
  2600.  */
  2601.  
  2602. /*
  2603.  * NAME:    raiseScreen
  2604.  *
  2605.  * SYNOPSIS:    err = raiseScreen( screen, toheight );
  2606.  *        short err;
  2607.  *
  2608.  * INPUTS:    struct Screen    *screen;    pointer to Intuition screen
  2609.  *        SHORT    toheight;        height in pixels from top of view
  2610.  *
  2611.  * DESCRIPTION: Slides the screen up until top of screen is at the
  2612.  *        desired height from the top of the viewing area.
  2613.  *
  2614.  * RESULTS:    Returns non-zero on error.
  2615.  *
  2616.  * SEE ALSO:    lowerScreen
  2617.  */
  2618.  
  2619. /*
  2620.  * NAME:    gimmeOneScroll
  2621.  *
  2622.  * SYNOPSIS:    gp = gimmeOneScroll( window, id, dirflags, myflags );
  2623.  *        struct Gadget *gp;
  2624.  *
  2625.  * INPUTS:    struct Window    *window;    window for gadget, or NULL
  2626.  *        USHORT        id;        non-zero id for gadget
  2627.  *        ULONG        dirflags;   direction flags as per PropInfo
  2628.  *                          can be FREEVERT or FREEHORIZ
  2629.  *        ULONG        myflags;    flags for routine
  2630.  *
  2631.  * DESCRIPTION: Creates an initialized scroll-button (vertical or horizontal)
  2632.  *        placed near the corners of a window,
  2633.  *        leaving room for the sizing gadget (whether or not it is there).
  2634.  *        These are often used at the top/left and bottom/right ends
  2635.  *        of a scroll-bar to be used for incremental scrolling.
  2636.  *        If window is non-NULL, the gadget is further customized for
  2637.  *        the window (eg checks for GIMMEZEROZERO).
  2638.  *
  2639.  *        If all goes well, the head pointer to chained memory for the
  2640.  *        gadget and its other required structures is stored in the
  2641.  *        gp->UserData field. You must preserve this pointer!!
  2642.  *        If you need to use the UserData yourself, be sure to save
  2643.  *        gp->UserData somewhere safe after calling gimmeOneScroll.
  2644.  *        When you are done with the gadget you must ensure that the
  2645.  *        chained memory head pointer is restored into gp->UserData
  2646.  *        before you call getRidOfGadget.
  2647.  *
  2648.  * RESULTS:    Returns pointer to requested type of Gadget, or NULL.
  2649.  *        Note: The gadget is NOT added to the window.
  2650.  *
  2651.  * SEE ALSO:    getRidOfGadgets, gimmeScrollBar, gimmeFullScrollBar
  2652.  */
  2653.  
  2654. /*
  2655.  * NAME:    gimmeScrollBar
  2656.  *
  2657.  * SYNOPSIS:    gp = gimmeScrollBar( window, id, dirflags, propflags );
  2658.  *        struct Gadget *gp;
  2659.  *
  2660.  * INPUTS:    struct Window    *window;    window for gadget, or NULL
  2661.  *        USHORT        id;        non-zero id for gadget
  2662.  *        ULONG        propflags;  flags for PropInfo
  2663.  *        ULONG        myflags;    flags for routine
  2664.  *
  2665.  * DESCRIPTION: Creates an initialized scroll-bar (vertical or horizontal only),
  2666.  *        leaving room for the sizing gadget (whether or not it is there)
  2667.  *        to be placed in a window.
  2668.  *        If window is non-NULL, the gadget is further customized for
  2669.  *        the window (eg checks for GIMMEZEROZERO and calculates
  2670.  *        the PropInfo's HorizBody and VertBody), also the FgPen and BgPen
  2671.  *        colours of the window's rastport are used (see gimmePropGadget).
  2672.  *        The propflags are used by gimmePropInfo to set up the PropInfo
  2673.  *        structure for the scrollbar.
  2674.  *        Note: if you wish to change the knob imagery to your own, do
  2675.  *        something similar to the following after this routine:
  2676.  *            gp->GadgetRender = (APTR) <your image or border>;
  2677.  *            ((struct PropInfo *)gp->SpecialInfo)->Flags &= ~AUTOKNOB;
  2678.  *            gp->Flags &= ~GADGIMAGE;    ;; ONLY if you want a BORDER
  2679.  *
  2680.  *
  2681.  *        If all goes well, the head pointer to chained memory for the
  2682.  *        gadget and its other required structures is stored in the
  2683.  *        gp->UserData field. You must preserve this pointer!!
  2684.  *        If you need to use the UserData yourself, be sure to save
  2685.  *        gp->UserData somewhere safe after calling gimmeScrollBar.
  2686.  *        When you are done with the gadget you must ensure that the
  2687.  *        chained memory head pointer is restored into gp->UserData
  2688.  *        before you call getRidOfGadget.
  2689.  *
  2690.  * RESULTS:    Returns pointer to requested type of Gadget, or NULL.
  2691.  *        Note: The gadget is NOT added to the window.
  2692.  *
  2693.  * SEE ALSO:    getRidOfGadgets, gimmeFullScrollBar, gimmeOneScroll
  2694.  */
  2695.  
  2696. /*
  2697.  * NAME:    gimmeFullScrollBar
  2698.  *
  2699.  * SYNOPSIS:    gp = gimmeFullScrollBar( window, id, propflags, myflags,
  2700.  *                        id1, id2 );
  2701.  *        struct Gadget *gp;
  2702.  *
  2703.  * INPUTS:    struct Window    *window;    window for gadget, or NULL
  2704.  *        USHORT        id;        non-zero id for gadget
  2705.  *        ULONG        propflags;  flags for PropInfo
  2706.  *        ULONG        myflags;    flags for routine
  2707.  *        USHORT        id1;        id for left/up one-scroll gadget
  2708.  *        USHORT        id2;        id for right/down one-scroll gadget
  2709.  *
  2710.  * DESCRIPTION: Creates an initialized scroll-bar (vertical or horizontal)
  2711.  *        along with two one-scroll button gadgets at the ends of the
  2712.  *        scroll bar (hence the "full" designation),
  2713.  *        leaving room for the sizing gadget (whether or not it is there).
  2714.  *        If window is non-NULL, the gadget is further customized for
  2715.  *        the window (eg checks for GIMMEZEROZERO and calculates
  2716.  *        the PropInfo's HorizBody and VertBody).
  2717.  *        The propflags are used by gimmePropInfo to set up the PropInfo
  2718.  *        structure for the scrollbar.
  2719.  *
  2720.  *        Note: since the gadgets are linked together (with the scrollbar
  2721.  *        gadget first), be careful when using the gadget pointer returned
  2722.  *        by this function -- use addGadgets to add the list of gadgets,
  2723.  *        or follow the NextGadget pointers before chaining other gadgets
  2724.  *        to the end of these gadgets.
  2725.  *
  2726.  *        If all goes well, the head pointer to chained memory for the
  2727.  *        gadget and its other required structures is stored in the
  2728.  *        gp->UserData field. You must preserve this pointer!!
  2729.  *        If you need to use the UserData yourself, be sure to save
  2730.  *        gp->UserData somewhere safe after calling gimmeScrollBar.
  2731.  *        When you are done with the gadget you must ensure that the
  2732.  *        chained memory head pointer is restored into gp->UserData
  2733.  *        before you call getRidOfGadget.
  2734.  *
  2735.  * RESULTS:    Returns pointer to scroll-bar Gadget, to which the two
  2736.  *        one-scroll gadgets are linked, or NULL.
  2737.  *        Note: The gadgets are NOT added to the window.
  2738.  *
  2739.  * SEE ALSO:    getRidOfGadgets, gimmeScrollBar, gimmeOneScroll, addGadgets
  2740.  */
  2741.  
  2742. /*
  2743.  * NAME:    gimmeSound
  2744.  *
  2745.  *        #include <gimmelib/sound.h>
  2746.  *
  2747.  * SYNOPSIS:    snd = gimmeSound( filename );
  2748.  *        SOUND *snd;
  2749.  *
  2750.  * INPUTS:    UBYTE    *filename;        name of iff sound file
  2751.  *
  2752.  * DESCRIPTION: Read a sound sample from the specified file.
  2753.  *        Create and initialize a SOUND structure for the sound sample.
  2754.  *        If possible, an error message is printed if anything goes
  2755.  *        wrong -- it is safe to call this function from a (sub)task
  2756.  *        that has no CLI window.
  2757.  *
  2758.  *        Note: all allocated memory, including the SOUND struct itself,
  2759.  *        is chained and the header is stored in the SOUND's memhead
  2760.  *        field, which is used by getRidOfSound to deallocate memory.
  2761.  *
  2762.  * RESULTS:    Returns pointer to an initialized SOUND, or NULL on error.
  2763.  *
  2764.  * SEE ALSO:    getRidOfSound
  2765.  */
  2766.  
  2767. /*
  2768.  * NAME:    getRidOfSound
  2769.  *
  2770.  * SYNOPSIS:    err = getRidOfSound( sound );
  2771.  *        short err;
  2772.  *
  2773.  * INPUTS:    SOUND    *sound;     pointer to SOUND
  2774.  *
  2775.  * DESCRIPTION: De-allocate a SOUND structure that was dynamically
  2776.  *        allocated by gimmeSound.
  2777.  *
  2778.  * RESULTS:    Returns non-zero on error.
  2779.  *
  2780.  * SEE ALSO:    gimmeSound
  2781.  */
  2782.  
  2783. /*
  2784.  * NAME:    gimmeStdStuff
  2785.  *
  2786.  * SYNOPSIS:    error = gimmeStdStuff( myflags, revision );
  2787.  *        ULONG error;
  2788.  *
  2789.  * INPUTS:    ULONG    myflags;    flags for libraries/devices to open
  2790.  *        SHORT    revision;    revision number to use for OpenDevice()
  2791.  *
  2792.  * DESCRIPTION: Open standard libraries and devices and other things
  2793.  *        specified by the given myflags, using the given revision number.
  2794.  *        Pointers are stored in global variables in gimme.lib
  2795.  *        See gimmelib/stdstuff.h for the flags and variable names
  2796.  *        in order to find out what you can open with this routine.
  2797.  *
  2798.  *        Things are opened or initialized in the same order as the flags
  2799.  *        are listed (ie. in order of increasing importance!)
  2800.  *        except the special things (indicated by special bits).
  2801.  *
  2802.  *        NOTE: this routine is NOT reentrant; it can only be safely used
  2803.  *        by one task.
  2804.  *
  2805.  *        NOTE: it is not recommended to use any of the global variables
  2806.  *        associated with this routine for use without this routine and
  2807.  *        getRidOfStdStuff.
  2808.  *
  2809.  * RESULTS:    Returns zero if ok, otherwise flag corresponding to library
  2810.  *        or device that could not be opened.
  2811.  *        NOTE: returns on the first failure to open something.
  2812.  *
  2813.  * SEE ALSO:    getRidOfStdStuff
  2814.  */
  2815.  
  2816. /*
  2817.  * NAME:    getRidOfStdStuff
  2818.  *
  2819.  * SYNOPSIS:    error = getRidOfStdStuff( myflags );
  2820.  *        ULONG error;
  2821.  *
  2822.  * INPUTS:    ULONG    myflags;    special flags for closing devices
  2823.  *
  2824.  * DESCRIPTION: Close the standard libraries/devices/things opened by
  2825.  *        gimmeStdStuff.
  2826.  *        See gimmelib/stdstuff.h for the global variable names used.
  2827.  *        The myflags specify control flags, esp. with regard to handling
  2828.  *        errors encountered when closing devices.
  2829.  *
  2830.  *        Things are closed or reset in the *reverse* order as the flags
  2831.  *        are listed (ie. in order of decreasing importance!)
  2832.  *        except the special things (corresponding to the special bits).
  2833.  *
  2834.  *        NOTE: this routine is NOT reentrant; it can only be safely used
  2835.  *        by one task.
  2836.  *
  2837.  * RESULTS:    Returns zero if ok, otherwise flag corresponding to library
  2838.  *        or device that could not be closed.
  2839.  *        NOTE: returns on the first failure to close something.
  2840.  *
  2841.  * SEE ALSO:    getRidOfStdStuff
  2842.  */
  2843.  
  2844. /*
  2845.  * NAME:    gimmeSubTask
  2846.  *
  2847.  * SYNOPSIS:    task = gimmeSubTask( countptr, portptr, stacksize, datasize,
  2848.  *                                myportptr );
  2849.  *        struct Task *task;
  2850.  *
  2851.  * INPUTS:    SHORT        *countptr;  pointer to counter variable, or NULL
  2852.  *        struct MsgPort    **portptr;  pointer to a MsgPort ptr, or NULL
  2853.  *        LONG        stacksize;  size of stack for subtask
  2854.  *        LONG        datasize;   size of a startup data area for
  2855.  *                          the subtask, or 0L if none needed
  2856.  *        struct MsgPort **myportptr; pointer to a pointer where subtask
  2857.  *                          is to put its MsgPort ptr, or NULL
  2858.  *
  2859.  * DESCRIPTION: Set everything up to launch a subtask via startSubTask.
  2860.  *        It creates (and allocates memory) for the following:
  2861.  *        - a Task struct
  2862.  *        - a <stacksize>-byte stack
  2863.  *            - minimum approx 90 bytes used if <stacksize> is smaller
  2864.  *        - a <datasize>-byte data area
  2865.  *            - ONLY IF <datasize> is strictly positive
  2866.  *            - pointer to this data area stored in task->tc_UserData
  2867.  *            - pointer to this area will be passed as the single
  2868.  *              parameter to the subtask by startSubTask.
  2869.  *        - a special Message struct
  2870.  *            ONLY IF portptr and myportptr are non-NULL
  2871.  *            NOTE: when your subtask returns "normally" (ie you don't
  2872.  *            kill it), the default auto-clean-up routine will send
  2873.  *            a special "I'm dying" message to your task-monitoring port
  2874.  *            (indirectly pointed at by portptr) and *wait* for a reply
  2875.  *            (on the port it created for itself; see myportptr)
  2876.  *            before decrementing the subtask counter and removing
  2877.  *            itself from the system.
  2878.  *            Before your subtask exits, it should empty its message
  2879.  *            port and then (safely) NULL its port pointer (since a
  2880.  *            copy is kept by the subtasking "library") before it exits,
  2881.  *            so that (hopefully) other tasks will no longer put messages
  2882.  *            on its port (this will also help the auto-cleanup-routine).
  2883.  *        - a message port
  2884.  *            - ONLY IF myportptr is non-NULL
  2885.  *            - NOTE: the message port isn't actually created until
  2886.  *              the subtask starts running after you call startSubTask.
  2887.  *            - see note below.
  2888.  *
  2889.  *        Note: if myportptr is non-NULL, a non-public message port
  2890.  *        will be automagically created when the subtask starts
  2891.  *        *running* [after it has been started via startSubTask]
  2892.  *        and the pointer to this message port will be stored in what
  2893.  *        myportptr points to. Thus the port will exist and the pointer
  2894.  *        pointed at by myportptr will be valid when the actual code
  2895.  *        of the subtask starts (called by the subtask startup code).
  2896.  *        If at that time the message port cannot be created, the
  2897.  *        subtask will exit gracefully without ever entering your
  2898.  *        initial subtask code.
  2899.  *
  2900.  *        This function should be followed by initialization of the data
  2901.  *        area (if any) for the child task, then startSubTask
  2902.  *        OR use undoGimmeSubTask if you change your mind and don't
  2903.  *        want to start the subtask to free any allocated memory.
  2904.  *
  2905.  *        Use getRidOfTask to cleanly kill a subtask, or allow the
  2906.  *        default task-completion code for the subtask to clean up
  2907.  *        everything.
  2908.  *
  2909.  *        Note: countptr should be the same as was passed to
  2910.  *        initSubTasker, and portptr should be NULL or the same as
  2911.  *        passed to initSubTasker.
  2912.  *
  2913.  * RESULTS:    Returns a pointer to the Task struct,
  2914.  *        with task->tc_UserData pointing to the data area (if any)
  2915.  *        which is automatically passed as the only parameter to your
  2916.  *        subtask by startSubTask.
  2917.  *
  2918.  * SEE ALSO:    startSubTask, undoGimmeSubTask, getRidOfTask
  2919.  */
  2920.  
  2921. /*
  2922.  * NAME:    undoGimmeSubTask
  2923.  *
  2924.  * SYNOPSIS:    undoGimmeSubTask( task );
  2925.  *
  2926.  * INPUTS:    struct Task *task;        pointer to task struct
  2927.  *
  2928.  * DESCRIPTION: Free memory allocated for this subtask-in-the-making
  2929.  *        by gimmeSubTask.
  2930.  *
  2931.  *        NOTE: this is a "cancel!" function to be used after
  2932.  *        gimmeSubTask but before the task is actually
  2933.  *        started by startSubTask if you no longer want to submit
  2934.  *        the subtask.
  2935.  *
  2936.  * RESULTS:    The task pointer becomes invalid.
  2937.  *
  2938.  * SEE ALSO:    gimmeSubTask, killSubTask, startSubTask
  2939.  */
  2940.  
  2941. /*
  2942.  * NAME:    killSubTask
  2943.  *
  2944.  * SYNOPSIS:    killSubTask( countptr, portptr, task )
  2945.  *
  2946.  * INPUTS:    SHORT        *countptr;    ptr to counter variable, or NULL
  2947.  *        struct MsgPort    **portptr;    ptr to a MsgPort ptr, or NULL
  2948.  *        struct Task    *task;        ptr to an existing task
  2949.  *
  2950.  * DESCRIPTION: Remove the specified subtask from the system.
  2951.  *        Delete the port (if any) pointed at by what portptr points to.
  2952.  *        Note that the countptr and portptr parameters should be
  2953.  *        the same as was passed to initSubTasker.
  2954.  *
  2955.  * SEE ALSO:    gimmeSubTask, undoGimmeSubTask, startSubTask
  2956.  */
  2957.  
  2958. /*
  2959.  * NAME:    startSubTask
  2960.  *
  2961.  * SYNOPSIS:    error =  startSubTask( task, name, pri, initialpc, finalpc );
  2962.  *        short error;
  2963.  *
  2964.  *        struct Task *task;        pointer to task struct
  2965.  *        char        *name;        name for subtask
  2966.  *        BYTE        pri;        priority of subtask
  2967.  *        void        (*initialpc)();     address of routine for subtask
  2968.  *        void        (*finalpc)();       NULL - see note below
  2969.  *
  2970.  * DESCRIPTION: Start a subtask, ie. add it to the system.
  2971.  *        The task pointer must be the result of gimmeSubTask.
  2972.  *        Initialization of the data (if any) for the new task should
  2973.  *        already have been done before this routine.
  2974.  *        Note: regarding finalpc:
  2975.  *        - a value of NULL will cause the default cleanup
  2976.  *          routine getRidOfMyself to be used, which will
  2977.  *          handle things very nicely and cleanly.
  2978.  *        - Use your own finalpc routine AT YOUR OWN RISK!!!
  2979.  *        NOTE: the subtask counter [see countptr parameter for
  2980.  *        initSubTasker] gets incremented by the subtask itself
  2981.  *        once the subtask starts *running*!!!
  2982.  *
  2983.  *        WARNING: do NOT try to write to stdout or stderr
  2984.  *        (unless they are a file ??)
  2985.  *        or do a Write() to Output() from the subtask
  2986.  *        since it can be very bad for your health!!
  2987.  *
  2988.  * RESULTS:    Returns non-zero on error.
  2989.  *
  2990.  * SEE ALSO:    gimmeSubTask, undoGimmeSubTask, killSubTask
  2991.  */
  2992.  
  2993. /*
  2994.  * NAME:    initSubTasker
  2995.  *
  2996.  * SYNOPSIS:    error = initSubTasker( countptr, portptr );
  2997.  *        short error;
  2998.  *
  2999.  * INPUTS:    SHORT        *countptr;    ptr to counter variable, or NULL
  3000.  *        struct MsgPort    **portptr;    ptr to a MsgPort ptr, or NULL
  3001.  *
  3002.  * DESCRIPTION: Initialize the sub-tasking "library" mechanism by:
  3003.  *        - setting the counter to zero (pointed at by countptr).
  3004.  *        - if portptr is non-NULL, a message port is created, pointed
  3005.  *          at by what portptr points to.
  3006.  *        Note that the countptr and portptr parameters should be
  3007.  *        passed to certain other sub-tasking routines, such as:
  3008.  *        doneSubTasker, getRidOfSubTask and
  3009.  *        handleSpecialSubTaskMsg.
  3010.  *        A message port is only necessary if you use the dying-task-
  3011.  *        messages-its-parent or printf'ing from a subtask features;
  3012.  *        if you do not need these, portptr can be NULL and a message
  3013.  *        port will *not* be created.
  3014.  *
  3015.  * RESULTS:    Returns non-zero on error.
  3016.  *
  3017.  * SEE ALSO:    doneSubTasker, gimmeSubTask
  3018.  */
  3019.  
  3020. /*
  3021.  * NAME:    doneSubTasker
  3022.  *
  3023.  * SYNOPSIS:    error = doneSubTasker( countptr, portptr )
  3024.  *        short error;
  3025.  *
  3026.  * INPUTS:    SHORT        *countptr;    ptr to counter variable, or NULL
  3027.  *        struct MsgPort    **portptr;    ptr to a MsgPort ptr, or NULL
  3028.  *
  3029.  * DESCRIPTION: Finish access to the sub-tasking "library" mechanism by:
  3030.  *        - checking for outstanding subtasks via the counter variable
  3031.  *          pointed at by countptr (returns error if there are)
  3032.  *        - deletes message port (if any) created by initSubTasker and
  3033.  *          pointed at by what portptr points to.
  3034.  *        Note: the message port (if any) is *not* deleted if an error
  3035.  *        occurred.
  3036.  *        Note that the countptr and portptr parameters should be
  3037.  *        the same as was passed to initSubTasker.
  3038.  *
  3039.  * RESULTS:    Returns non-zero on error.
  3040.  *
  3041.  * SEE ALSO:    initSubTasker
  3042.  */
  3043.  
  3044. /*
  3045.  * NAME:    doPrintf
  3046.  *
  3047.  * SYNOPSIS:    error = doPrintf( port, replyport, s, p1, p2, p3, p4 )
  3048.  *        short error;
  3049.  *
  3050.  * INPUTS:    struct MsgPort    *port;        ptr to a Dos process' port
  3051.  *        struct MsgPort    *replyport;    your replyport or NULL
  3052.  *        UBYTE        *s;        a format string ala printf
  3053.  *        LONG        p1, p2;     4 parms for printf
  3054.  *        double        p3, p4;     see note below
  3055.  *
  3056.  * DESCRIPTION: Sends a message to a DOS process to print something.
  3057.  *        The DOS process in question must use handleSpecialSubTaskMsg
  3058.  *        to receive the print message.
  3059.  *        If replyport is NULL, doPrintf will not Wait() for a reply
  3060.  *        and the messaged process must do the FreeMem().
  3061.  *
  3062.  *        NOTE: The final string to be printed (ie. after processing
  3063.  *        by printf) should be no longer than 163 characters (which is
  3064.  *        approximately 2 full lines plus newlines) not including the
  3065.  *        final null character.
  3066.  *
  3067.  *        NOTE: the 4 printf parms (p1, p2, p3 and p4) do NOT have
  3068.  *        to match the long and double types exactly. This routine
  3069.  *        passes 4 parameters [ total size PARMS_SIZE calculated as:
  3070.  *          2 * sizeof(LONG) + 2 * sizeof(double)  ] to printf,
  3071.  *        which will only use what is required by the format
  3072.  *        string "s". This makes it possible to pass as printf parms
  3073.  *        the equivalent in size to 6 longwords. If this space isn't
  3074.  *        sufficient, several doPrintf's will be required.
  3075.  *        ==> This means that you can pass as many parameters as you
  3076.  *        want to doPrintf, but only up to the first PARMS_SIZE bytes
  3077.  *        will be used. This isn't exactly ANSI standard, but then
  3078.  *        again neither is the compiler.
  3079.  *
  3080.  *        NOTE: use synchronous printing VERY cautiously:
  3081.  *        the DOS process must be able to accept the message right
  3082.  *        away so you do not wait forever for a reply, and the first
  3083.  *        message on your replyport must be the reply to your print
  3084.  *        message (otherwise you screw up what arrives on your port).
  3085.  *
  3086.  * RESULTS:    Returns non-zero on error.
  3087.  *
  3088.  * SEE ALSO:    handleSpecialSubTaskMsg
  3089.  */
  3090.  
  3091. /*
  3092.  * NAME:    handleSpecialSubTaskMsg
  3093.  *
  3094.  * SYNOPSIS:    numdied = handleSpecialSubTaskMsg( countptr, portptr )
  3095.  *        SHORT numdied;
  3096.  *
  3097.  * INPUTS:    SHORT        *countptr;    ptr to counter variable, or NULL
  3098.  *        struct MsgPort    **portptr;    ptr to a MsgPort ptr
  3099.  *
  3100.  * DESCRIPTION: Handles special messages from subtasks, in particular
  3101.  *        "print" and "done" messages.
  3102.  *        If printing messages (say, from subtasks),
  3103.  *        this routine must be called from a DOS process, not a subtask
  3104.  *        otherwise nothing will get printed.
  3105.  *
  3106.  * RESULTS:    The number of "I'm dying" messages received from subtasks.
  3107.  *
  3108.  * SEE ALSO:    initSubTasker, doneSubTasker, doPrintf
  3109.  */
  3110.  
  3111. /*
  3112.  * NAME:    accessTimer
  3113.  *
  3114.  * REQUISITES:    struct Device *TimerBase;
  3115.  *
  3116.  * SYNOPSIS:    tr = accessTimer( unit, portptr );
  3117.  *        struct timerequest *tr;
  3118.  *
  3119.  * INPUTS:    ULONG    unit;            timer device unit
  3120.  *        struct MsgPort    **portptr;    pointer to a MsgPort ptr
  3121.  *
  3122.  * DESCRIPTION: Open the timer device.
  3123.  *        Allocates memory for a "master" time-request and initializes
  3124.  *        it for use with the timer device.
  3125.  *        The "unit" must be either UNIT_VBLANK or UNIT_MICROHZ.
  3126.  *        If portptr is non-NULL:
  3127.  *        - if the pointer that portptr points to is non-NULL,
  3128.  *          the time-request will use that port as a reply port.
  3129.  *        - otherwise a reply port is created and a pointer to it is
  3130.  *          stuffed into what portptr points at.
  3131.  *        If portptr is NULL, a message port will be created but you
  3132.  *        would have to snoop around the time-request struct to find
  3133.  *        a pointer to it.
  3134.  *        NOTE: make sure what portptr points to is NULL if it is not
  3135.  *        a valid pointer (ie initialize it).
  3136.  *
  3137.  *        NOTE: you must end any and all "slave" time-requests
  3138.  *        you create [via gimmeTimeRequest] by using
  3139.  *        getRidOfTimeRequest on each "slave" before releasing access
  3140.  *        to the timer via releaseTimer on the "master" time-request.
  3141.  *
  3142.  *        Note: you must have declared a global variable as follows:
  3143.  *            struct Device *TimerBase = NULL;
  3144.  *        The actual pointer will be stored in the TimerBase variable
  3145.  *        by this routine [after opening the timer device].
  3146.  *
  3147.  * RESULTS:    Returns a pointer to a "master" time-request, or NULL.
  3148.  *
  3149.  * SEE ALSO:    releaseTimer, gimmeTimeRequest, getRidOfTimeRequest
  3150.  */
  3151.  
  3152. /*
  3153.  * NAME:    releaseTimer
  3154.  *
  3155.  * SYNOPSIS:    error = releaseTimer( tr, saveport );
  3156.  *        LONG error;
  3157.  *
  3158.  * INPUTS:    struct timerequest  *tr;    ptr to "master" time-request
  3159.  *        struct MsgPort        *saveport;    ptr to msgport to save, or NULL
  3160.  *
  3161.  * DESCRIPTION: Close the timer device and free the memory of the "master"
  3162.  *        time-request.
  3163.  *        If saveport is NULL, the port associated with the given
  3164.  *        "master" time-request will be deleted (not necessarily the
  3165.  *        same one as the saveport specified in the parameters).
  3166.  *        If saveport is non-NULL, no message port will be deleted.
  3167.  *
  3168.  *        NOTE: you must have ended any and all "slave" time-requests
  3169.  *        you created [via gimmeTimeRequest] by using
  3170.  *        getRidOfTimeRequest on each "slave" BEFORE calling this
  3171.  *        function.
  3172.  *
  3173.  * RESULTS:    Returns non-zero ala AbortIO() on error.
  3174.  *
  3175.  * SEE ALSO:    accessTimer, gimmeTimeRequest, getRidOfTimeRequest
  3176.  */
  3177.  
  3178. /*
  3179.  * NAME:    gimmeTimeRequest
  3180.  *
  3181.  * SYNOPSIS:    tr = gimmeTimeRequest( trmaster );
  3182.  *        struct timerequest *tr;
  3183.  *
  3184.  * INPUTS:    struct timerequest  *trmaster;        ptr to "master" time-request
  3185.  *
  3186.  * DESCRIPTION: Allocate memory for a "slave" time-request and initializes
  3187.  *        it from the "master" time-request.
  3188.  *        This "slave" timerequest will use the same timer unit
  3189.  *        (either UNIT_VBLANK or UNIT_MICROHZ) and reply port
  3190.  *        as the "master" time-request.
  3191.  *        NOTE: you must end all "slave" time-requests
  3192.  *        via getRidOfTimeRequest before releasing access to the
  3193.  *        timer via releaseTimer using the "master" time-request.
  3194.  *
  3195.  * RESULTS:    Returns a pointer to a "slave" time-request, or NULL.
  3196.  *
  3197.  * SEE ALSO:    accessTimer, getRidOfTimeRequest, releaseTimer
  3198.  */
  3199.  
  3200. /*
  3201.  * NAME:    getRidOfTimeRequest
  3202.  *
  3203.  * SYNOPSIS:    error = getRidOfTimeRequest( tr );
  3204.  *        LONG error;
  3205.  *
  3206.  * INPUTS:    struct timerequest  *tr;    pointer to "slave" time-request,
  3207.  *                          as returned by gimmeTimeRequest
  3208.  *
  3209.  * DESCRIPTION: Free memory taken by the "slave" time-request, rendering
  3210.  *        the pointer <tr> invalid.
  3211.  *        The time-request will be aborted if it is currently in
  3212.  *        progress.
  3213.  *
  3214.  * RESULTS:    Returns zero if ok, or non-zero ala AbortIO() on error.
  3215.  *        Either way, the time-request gets freed and <tr> becomes
  3216.  *        an invalid pointer.
  3217.  *
  3218.  * SEE ALSO:    gimmeTimeRequest, accessTimer, releaseTimer
  3219.  */
  3220.  
  3221. /*
  3222.  * NAME:    timeDelay
  3223.  *
  3224.  * SYNOPSIS:    error = timeDelay( secs, micros, unit, mytr );
  3225.  *        LONG error;
  3226.  *
  3227.  * INPUTS:    ULONG            secs;    number of seconds to delay
  3228.  *        ULONG            micros;    number of microseconds to delay
  3229.  *        ULONG            unit;    timer device unit
  3230.  *        struct timerequest  *mytr;    ptr to a time-request, or NULL
  3231.  *
  3232.  * DESCRIPTION: Delay a specified amount of time using Synchronous IO.
  3233.  *        If mytr is non-NULL, that time-request is used, otherwise a
  3234.  *        "master" timerequest" is created via accessTimer.
  3235.  *        The unit must be either UNIT_VBLANK or UNIT_MICROHZ,
  3236.  *        but is ignored if myptr is non-NULL.
  3237.  *        The "tv" parameter should point to a timeval struct which
  3238.  *        contains the number of seconds and microseconds to wait.
  3239.  *
  3240.  *        Note: this function can be used completely stand-alone if
  3241.  *        the "mytr" parameter is NULL, or in conjunction with other
  3242.  *        timer routines such as accessTimer and gimmeTimeRequest.
  3243.  *
  3244.  * RESULTS:    Returns non-zero on error.
  3245.  *
  3246.  * SEE ALSO:    accessTimer, releaseTimer
  3247.  */
  3248.  
  3249. /*
  3250.  * NAME:    timeDelayAsync
  3251.  *
  3252.  * SYNOPSIS:    tr = timeDelayAsync( secs, micros, unit, mytr );
  3253.  *        struct timerequest *tr;
  3254.  *
  3255.  * INPUTS:    ULONG            secs;    number of seconds to delay
  3256.  *        ULONG            micros;    number of microseconds to delay
  3257.  *        ULONG            unit;    timer device unit
  3258.  *        struct timerequest  *mytr;    ptr to a time-request, or NULL
  3259.  *
  3260.  * DESCRIPTION: Send a delay request using Asynchronous IO.
  3261.  *        If mytr is non-NULL, that time-request is used, otherwise
  3262.  *        a "master" time request with no reply port is created via
  3263.  *        accessTimer.
  3264.  *        The unit must be either UNIT_VBLANK or UNIT_MICROHZ,
  3265.  *        but is ignored if myptr is non-NULL.
  3266.  *        The "tv" parameter should point to a timeval struct which
  3267.  *        contains the number of seconds and microseconds to wait.
  3268.  *
  3269.  *        Note: if mytr is NULL, you must remove the time-request via
  3270.  *        releaseTimer when you are signalled that it is done.
  3271.  *
  3272.  * RESULTS:    Returns a pointer to a time-request (either the same one
  3273.  *        passed as a parameter or a new "master" time-request),
  3274.  *        or NULL on error.
  3275.  *
  3276.  * SEE ALSO:    accessTimer, releaseTimer
  3277.  */
  3278.  
  3279. /*
  3280.  * NAME:    waitTimer
  3281.  *
  3282.  * SYNOPSIS:    error = waitTimer( tr );
  3283.  *        LONG error;
  3284.  *
  3285.  * INPUTS:    struct timerequest  *tr;    time-request to wait for
  3286.  *
  3287.  * DESCRIPTION: Wait for the specified time-request to complete.
  3288.  *        Usually used after an Asynchronous time delay,
  3289.  *        eg. using timeDelayAsync.
  3290.  *
  3291.  * RESULTS:    Returns non-zero on error, ala WaitIO().
  3292.  *
  3293.  * SEE ALSO:    accessTimer, releaseTimer, gimmeTimeRequest, timeDelayAsync
  3294.  */
  3295.  
  3296. /*
  3297.  * NAME:    killTimeDelay
  3298.  *
  3299.  * SYNOPSIS:    error = killTimeDelay( tr );
  3300.  *        LONG error;
  3301.  *
  3302.  * INPUTS:    struct timerequest  *tr;    pointer to a time-request
  3303.  *
  3304.  * DESCRIPTION: Stop (abort) a "master" or "slave" time-request.
  3305.  *
  3306.  * RESULTS:    Returns zero if ok, or non-zero ala AbortIO() on error.
  3307.  *
  3308.  * SEE ALSO:    gimmeTimeRequest, getRidOfTimeRequest, accessTimer, releaseTimer
  3309.  */
  3310.  
  3311. /*
  3312.  * NAME:    getSysTime
  3313.  *
  3314.  * REQUISITES:    struct Device *TimerBase;        properly initialized
  3315.  *
  3316.  * SYNOPSIS:    err = getSysTime( secs, micros, mytr );
  3317.  *        short err;
  3318.  *
  3319.  * INPUTS:    ULONG            *secs;    ptr for storing #seconds
  3320.  *        ULONG            *micros;    ptr for storing #microseconds
  3321.  *        struct timerequest  *mytr;    ptr to a time-request, or NULL
  3322.  *
  3323.  * DESCRIPTION: Get the system time, placing it into the timeval struct
  3324.  *        pointed at by "tv".
  3325.  *        If mytr is non-NULL, that time-request is used, otherwise
  3326.  *        a "master" time request is created and destroyed internally.
  3327.  *
  3328.  *        NOTE: you must have a global variable named TimerBase,
  3329.  *        declared as a "struct Device *", which should be properly
  3330.  *        initialized if you supply a valid non-NULL mytr. Otherwise
  3331.  *        the TimerBase will be initialized when a temporary timerequest
  3332.  *        is created by this routine.
  3333.  *        If you supply a non-NULL mytr parameter, you should have done
  3334.  *        one of the following to initialize the TimerBase,
  3335.  *        by extracting the "library" pointer from the timer.device
  3336.  *        with code similar to the following:
  3337.  *        either 1)   struct timerequest *tr;
  3338.  *                tr = accessTimer(<appropriate parms>);
  3339.  *
  3340.  *            or 2)   struct timerequest tr;
  3341.  *                err = OpenDevice(TIMERNAME, <unit-no>, &tr, 0L);
  3342.  *                { check for error }
  3343.  *                TimerBase = tr.tr_node.io_Device;
  3344.  *
  3345.  * RESULTS:    Returns non-zero on error.
  3346.  *        Note that the seconds and microseconds are stored where the
  3347.  *        respective parameters point to.
  3348.  *
  3349.  * SEE ALSO:    accessTimer, releaseTimer
  3350.  */
  3351.  
  3352. /*
  3353.  * NAME:    setSysTime
  3354.  *
  3355.  * REQUISITES:    struct Device *TimerBase;        properly initialized
  3356.  *
  3357.  * SYNOPSIS:    err = setSysTime( secs, micros, mytr );
  3358.  *        short err;
  3359.  *
  3360.  * INPUTS:    ULONG            secs;    seconds since Jan 1, 1978
  3361.  *        ULONG            micros;    microseconds to set
  3362.  *        struct timerequest  *mytr;    ptr to a time-request, or NULL
  3363.  *
  3364.  * DESCRIPTION: Set the system time according to the number of seconds
  3365.  *        since (previous midnight) of January 1st, 1978.
  3366.  *        If mytr is non-NULL, that time-request is used, otherwise
  3367.  *        a "master" time request is created and destroyed internally.
  3368.  *
  3369.  *        NOTE: you must have a global variable named TimerBase,
  3370.  *        declared as a "struct Device *", which should be properly
  3371.  *        initialized if you supply a valid non-NULL mytr. Otherwise
  3372.  *        the TimerBase will be initialized when a temporary timerequest
  3373.  *        is created by this routine.
  3374.  *        If you supply a non-NULL mytr parameter, you should have done
  3375.  *        one of the following to initialize the TimerBase,
  3376.  *        by extracting the "library" pointer from the timer.device
  3377.  *        with code similar to the following:
  3378.  *        either 1)   struct timerequest *tr;
  3379.  *                tr = accessTimer(<appropriate parms>);
  3380.  *
  3381.  *            or 2)   struct timerequest tr;
  3382.  *                err = OpenDevice(TIMERNAME, <unit-no>, &tr, 0L);
  3383.  *                { check for error }
  3384.  *                TimerBase = tr.tr_node.io_Device;
  3385.  *
  3386.  * RESULTS:    Returns non-zero on error.
  3387.  *
  3388.  * SEE ALSO:    accessTimer, releaseTimer
  3389.  */
  3390.  
  3391. /*
  3392.  * NAME:    gimmeNewWindow
  3393.  *
  3394.  * SYNOPSIS:    nw = gimmeNewWindow( title, screen, leftedge, topedge,
  3395.  *                        IDCMPflags, flags );
  3396.  *        struct NewWindow *nw;
  3397.  *
  3398.  * INPUTS:    UBYTE    *title;         title string
  3399.  *        struct Screen    *screen;    ptr to Intuition screen, or NULL
  3400.  *        SHORT    leftedge;        offset of left edge in pixels
  3401.  *        SHORT    topedge;        offset of right edge in pixels
  3402.  *        ULONG    IDCMPflags;        IDCMP flags ala nw->IDCMPFlags field
  3403.  *        ULONG    flags;            window flags ala nw->Flags field
  3404.  *
  3405.  * DESCRIPTION: Allocate and initialize a NewWindow structure.
  3406.  *        Max width and height is taken from screen or WorkBench screen.
  3407.  *        Initial width and height is set to largest possible with
  3408.  *        regards to leftedge and topedge.
  3409.  *
  3410.  *        Note: if SUPER_BITMAP is specified, a BitMap will NOT be
  3411.  *        allocated here -- gimmeWindow will do that.
  3412.  *        You can customize the NewWindow structure before opening
  3413.  *        the window.
  3414.  *
  3415.  * RESULTS:    Returns pointer to NewWindow structure, or NULL on error.
  3416.  *
  3417.  * SEE ALSO:    getRidOfNewWindow, gimmeWindow, getRidOfWindow
  3418.  */
  3419.  
  3420. /*
  3421.  * NAME:    getRidOfNewWindow
  3422.  *
  3423.  * SYNOPSIS:    err = getRidOfNewWindow( nw );
  3424.  *        short err;
  3425.  *
  3426.  * INPUTS:    struct NewWindow    *nw;    pointer to NewWindow structure
  3427.  *
  3428.  * DESCRIPTION: De-allocate a NewWindow structure that was dynamically
  3429.  *        allocated by gimmeNewWindow.
  3430.  *
  3431.  * RESULTS:    Returns non-zero on error.
  3432.  *
  3433.  * SEE ALSO:    gimmeNewWindow, gimmeWindow, getRidOfWindow
  3434.  */
  3435.  
  3436. /*
  3437.  * NAME:    gimmeWindow
  3438.  *
  3439.  * SYNOPSIS:    window = gimmeWindow( nw, depth, width, height );
  3440.  *        struct Window *window;
  3441.  *
  3442.  * INPUTS:    struct NewWindow    *nw;        ptr to initialized NewWindow
  3443.  *        SHORT    depth, width, height;        dimensions for bitmap
  3444.  *
  3445.  * DESCRIPTION: Open an Intuition window.
  3446.  *        If the NewWindow pointer "nw" in NULL, then a default NewWindow
  3447.  *        structure is temporarily created, used and deleted
  3448.  *        (see gimmelib/window.h for the default flags used).
  3449.  *        If SUPER_BITMAP is NOT specified in the nw->Flags field,
  3450.  *        depth, width and height are ignored (however, set them to 0
  3451.  *        for future compatability).
  3452.  *
  3453.  *        Otherwise: a bitmap is allocated and linked into nw.
  3454.  *        If the bitmap allocation fails, no window will be opened.
  3455.  *        If all goes well, the pointer to the BitMap is stored in the
  3456.  *        window->UserData field. You must preserve this pointer!!
  3457.  *        If you need to use the UserData yourself, be sure to save
  3458.  *        window->UserData somewhere safe after calling gimmeWindow.
  3459.  *        When you are done with the window you must ensure that the
  3460.  *        bitmap pointer is restored into window->UserData and then
  3461.  *        call getRidOfWindow.
  3462.  *
  3463.  * RESULTS:    Returns a pointer to an open Intuition window, or NULL if
  3464.  *        anything went wrong.
  3465.  *
  3466.  * SEE ALSO:    getRidOfNewWindow, gimmeWindow, getRidOfWindow, gimmeBitMap
  3467.  */
  3468.  
  3469. /*
  3470.  * NAME:    getRidOfWindow
  3471.  *
  3472.  * SYNOPSIS:    err = getRidOfWindow( window );
  3473.  *        short err;
  3474.  *
  3475.  * INPUTS:    struct Window    *window;    pointer to Intuition window
  3476.  *
  3477.  * DESCRIPTION: Close a window, clearing the menustrip and replying to any
  3478.  *        outstanding messages on its UserPort first.
  3479.  *        If it is a SUPER_BITMAP window, also calls getRidOfBitMap
  3480.  *        using the bitmap pointer in window->UserData -- see details
  3481.  *        in description of gimmeWindow.
  3482.  *
  3483.  * RESULTS:    Returns non-zero on error.
  3484.  *
  3485.  * SEE ALSO:    gimmeNewWindow, getRidOfNewWindow, gimmeWindow, getRidOfBitMap
  3486.  */
  3487.  
  3488.