New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / intuition / drawborder.c
blobcbfcaa87a241fcfb743339a947e7ac64f2e4ab66
1 /*
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <proto/graphics.h>
8 #include <proto/layers.h>
9 #include <graphics/rpattr.h>
10 #include "intuition_intern.h"
12 /*****************************************************************************
14 NAME */
15 #include <graphics/rastport.h>
16 #include <intuition/intuition.h>
17 #include <proto/intuition.h>
19 AROS_LH4(void, DrawBorder,
21 /* SYNOPSIS */
22 AROS_LHA(struct RastPort *, rp, A0),
23 AROS_LHA(struct Border *, border, A1),
24 AROS_LHA(LONG , leftOffset, D0),
25 AROS_LHA(LONG , topOffset, D1),
27 /* LOCATION */
28 struct IntuitionBase *, IntuitionBase, 18, Intuition)
30 /* FUNCTION
31 Draws one or more borders in the specified RastPort. Rendering
32 will start at the position which you get when you add the offsets
33 leftOffset and topOffset to the LeftEdge and TopEdge specified
34 in the Border structure. All coordinates are relative to that point.
36 INPUTS
37 rp - The RastPort to render into
38 border - Information what and how to render
39 leftOffset, topOffset - Initial starting position
41 RESULT
42 None.
44 NOTES
46 EXAMPLE
47 // Draw a house with one stroke
48 // The drawing starts at the lower left edge
49 WORD XY[] =
51 10, -10,
52 10, 0,
53 0, -10,
54 10, -10,
55 5, -15,
56 0, -10,
57 0, 0,
58 10, 0,
60 struct Border demo =
62 100, 100, // Position
63 1, 2, // Pens
64 JAM1, // Drawmode
65 8, // Number of pairs in XY
66 XY, // Vector offsets
67 NULL // No next border
70 // Render the house with the bottom left edge at 150, 50
71 DrawBorder (rp, &demo, 50, -50);
73 BUGS
75 SEE ALSO
77 INTERNALS
79 HISTORY
80 29-10-95 digulla automatically created from
81 intuition_lib.fd and clib/intuition_protos.h
83 *****************************************************************************/
85 AROS_LIBFUNC_INIT
86 AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
88 ULONG apen;
89 ULONG bpen;
90 ULONG drmd;
91 ULONG penmode;
92 WORD *ptr;
93 WORD x, y;
94 WORD xoff, yoff;
95 int t;
97 EXTENDWORD(leftOffset);EXTENDWORD(topOffset);
99 DEBUG_DRAWBORDER(dprintf("DrawBorder: rp %p border %p Left %ld Top %ld\n",
100 rp, border, leftOffset, topOffset));
102 SANITY_CHECK(rp)
103 SANITY_CHECK(border)
105 if (rp->Layer) LockLayer(0,rp->Layer);
107 /* Store important variables of the RastPort */
108 #ifdef __MORPHOS__
109 GetRPAttrs(rp,RPTAG_PenMode,(ULONG)&penmode,RPTAG_APen,(ULONG)&apen,
110 RPTAG_BPen,(ULONG)&bpen,RPTAG_DrMd,(ULONG)&drmd,TAG_DONE);
111 #else
112 GetRPAttrs(rp,RPTAG_APen,(ULONG)&apen,
113 RPTAG_BPen,(ULONG)&bpen,RPTAG_DrMd,(ULONG)&drmd,TAG_DONE);
114 #endif
116 /* For all borders... */
117 for ( ; border; border = border->NextBorder)
119 /* Change RastPort to the colors/mode specified */
120 SetAPen (rp, border->FrontPen);
121 SetBPen (rp, border->BackPen);
122 SetDrMd (rp, border->DrawMode);
124 /* Get base coords */
126 x = border->LeftEdge + leftOffset;
127 y = border->TopEdge + topOffset;
129 /* Start of vector offsets */
130 ptr = border->XY;
132 for (t = 0; t < border->Count; t++)
134 /* Add vector offset to current position */
135 xoff = *ptr ++;
136 yoff = *ptr ++;
138 if (t == 0)
140 Move (rp, x + xoff, y + yoff);
142 else
144 /* Stroke */
145 Draw (rp, x + xoff, y + yoff);
149 } /* for ( ; border; border = border->NextBorder) */
151 /* Restore RastPort */
152 #ifdef __MORPHOS__
153 SetRPAttrs(rp,RPTAG_APen,apen,RPTAG_BPen,bpen,RPTAG_DrMd,drmd,RPTAG_PenMode,penmode,TAG_DONE);
154 #else
155 SetRPAttrs(rp,RPTAG_APen,apen,RPTAG_BPen,bpen,RPTAG_DrMd,drmd,TAG_DONE);
156 #endif
158 if (rp->Layer) UnlockLayer(rp->Layer);
160 AROS_LIBFUNC_EXIT
161 } /* DrawBorder */