home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / intuition / drawborder.c < prev    next >
C/C++ Source or Header  |  1997-01-27  |  4KB  |  159 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: drawborder.c,v 1.7 1997/01/27 00:36:37 ldp Exp $
  4.     $Log: drawborder.c,v $
  5.     Revision 1.7  1997/01/27 00:36:37  ldp
  6.     Polish
  7.  
  8.     Revision 1.6  1996/12/10 14:00:02  aros
  9.     Moved #include into first column to allow makedepend to see it.
  10.  
  11.     Revision 1.5  1996/11/08 11:28:01  aros
  12.     All OS function use now Amiga types
  13.  
  14.     Moved intuition-driver protos to intuition_intern.h
  15.  
  16.     Revision 1.4  1996/10/24 15:51:18  aros
  17.     Use the official AROS macros over the __AROS versions.
  18.  
  19.     Revision 1.3  1996/10/02 18:10:47  digulla
  20.     Fixed a bug (coordinates are relative to offset and not to last point)
  21.  
  22.     Revision 1.2  1996/08/29 13:33:30  digulla
  23.     Moved common code from driver to Intuition
  24.     More docs
  25.  
  26.     Revision 1.1  1996/08/23 17:28:18  digulla
  27.     Several new functions; some still empty.
  28.  
  29.  
  30.     Desc:
  31.     Lang: english
  32. */
  33. #include "intuition_intern.h"
  34. #include <proto/graphics.h>
  35.  
  36. /*****************************************************************************
  37.  
  38.     NAME */
  39. #include <graphics/rastport.h>
  40. #include <intuition/intuition.h>
  41. #include <proto/intuition.h>
  42.  
  43.     AROS_LH4(void, DrawBorder,
  44.  
  45. /*  SYNOPSIS */
  46.     AROS_LHA(struct RastPort *, rp, A0),
  47.     AROS_LHA(struct Border   *, border, A1),
  48.     AROS_LHA(LONG             , leftOffset, D0),
  49.     AROS_LHA(LONG             , topOffset, D1),
  50.  
  51. /*  LOCATION */
  52.     struct IntuitionBase *, IntuitionBase, 18, Intuition)
  53.  
  54. /*  FUNCTION
  55.     Draws one or more borders in the specified RastPort. Rendering
  56.     will start at the position which you get when you add the offsets
  57.     leftOffset and topOffset to the LeftEdge and TopEdge specified
  58.     in the Border structure. All coordinates are relative to that point.
  59.  
  60.     INPUTS
  61.     rp - The RastPort to render into
  62.     border - Information what and how to render
  63.     leftOffset, topOffset - Initial starting position
  64.  
  65.     RESULT
  66.     None.
  67.  
  68.     NOTES
  69.  
  70.     EXAMPLE
  71.     // Draw a house with one stroke
  72.     // The drawing starts at the lower left edge
  73.     WORD XY[] =
  74.     {
  75.         10, -10,
  76.         10,   0,
  77.          0, -10,
  78.         10, -10,
  79.          5, -15,
  80.          0, -10,
  81.          0,   0,
  82.         10,   0,
  83.     };
  84.     struct Border demo =
  85.     {
  86.         100, 100,    // Position
  87.         1, 2,    // Pens
  88.         JAM1,    // Drawmode
  89.         8,        // Number of pairs in XY
  90.         XY,     // Vector offsets
  91.         NULL    // No next border
  92.     };
  93.  
  94.     // Render the house with the bottom left edge at 150, 50
  95.     DrawBorder (rp, &demo, 50, -50);
  96.  
  97.     BUGS
  98.  
  99.     SEE ALSO
  100.  
  101.     INTERNALS
  102.  
  103.     HISTORY
  104.     29-10-95    digulla automatically created from
  105.                 intuition_lib.fd and clib/intuition_protos.h
  106.  
  107. *****************************************************************************/
  108. {
  109.     AROS_LIBFUNC_INIT
  110.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  111.     ULONG  apen;
  112.     ULONG  bpen;
  113.     ULONG  drmd;
  114.     WORD * ptr;
  115.     WORD   x, y;
  116.     WORD   xoff, yoff;
  117.     int    t;
  118.  
  119.     /* Store important variables of the RastPort */
  120.     apen = GetAPen (rp);
  121.     bpen = GetBPen (rp);
  122.     drmd = GetDrMd (rp);
  123.  
  124.     /* For all borders... */
  125.     for ( ; border; border=border->NextBorder)
  126.     {
  127.     /* Change RastPort to the colors/mode specified */
  128.     SetAPen (rp, border->FrontPen);
  129.     SetBPen (rp, border->BackPen);
  130.     SetDrMd (rp, border->DrawMode);
  131.  
  132.     /* Move to initial position */
  133.     Move (rp
  134.         , x = border->LeftEdge + leftOffset
  135.         , y = border->TopEdge + topOffset
  136.     );
  137.  
  138.     /* Start of vector offsets */
  139.     ptr = border->XY;
  140.  
  141.     for (t=0; t<border->Count; t++)
  142.     {
  143.         /* Add vector offset to current position */
  144.         xoff = *ptr ++;
  145.         yoff = *ptr ++;
  146.  
  147.         /* Stroke */
  148.         Draw (rp, x + xoff, y + yoff);
  149.     }
  150.     }
  151.  
  152.     /* Restore RastPort */
  153.     SetAPen (rp, apen);
  154.     SetBPen (rp, bpen);
  155.     SetDrMd (rp, drmd);
  156.  
  157.     AROS_LIBFUNC_EXIT
  158. } /* DrawBorder */
  159.