Updates to includes for scsi & usbhardware.
[cake.git] / rom / graphics / getrpattrsa.c
blobd61d537fb6a9b62296607f45fb359b01bbe9d6dd
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function GetRPAttrsA()
6 Lang: english
7 */
8 #include <graphics/rpattr.h>
9 #include <graphics/rastport.h>
10 #include <graphics/gfx.h>
11 #include "graphics_intern.h"
12 #include <proto/utility.h>
14 #include "gfxfuncsupport.h"
16 /*****************************************************************************
18 NAME */
19 #include <proto/graphics.h>
21 AROS_LH2(void, GetRPAttrsA,
23 /* SYNOPSIS */
24 AROS_LHA(struct RastPort *, rp , A0),
25 AROS_LHA(struct TagItem *, tags, A1),
27 /* LOCATION */
28 struct GfxBase *, GfxBase, 174, Graphics)
30 /* FUNCTION
32 Read the current settings of a RastPort into variables.
33 The ti_Tag field specifies the attribute to read and the
34 ti_Data field points to an address where to store the result.
35 All results are stored as IPTRs!
37 INPUTS
38 rp = pointer to a RastPort structure
39 tags = pointer to a taglist specifying the attributes to read and
40 the addresses to store the results
42 TAGS
43 RPTAG_Font (UBYTE) - Font for Text()
44 RPTAG_APen (UBYTE) - Primary rendering pen
45 RPTAG_BPen (UBYTE) - Secondary rendering pen
46 RPTAG_DrMd (UBYTE) - Drawing mode (graphics/rastport.h)
47 RPTAG_OutlinePen (UBYTE) - Area Outline pen
48 RPTAG_WriteMask (ULONG) - Bit Mask for writing
49 RPTAG_MaxPen (ULONG) - Maximum pen to render (see SetMaxPen())
51 AROS extensions
52 RPTAG_FgColor (ULONG) - Primary rendering color in A8R8G8B8 format.
53 Only working on hicolor/truecolor bitmaps/screens.
54 RPTAG_BgColor (ULONG) - Secondary rendering color in A8R8G8B8 format.
55 Only working on hicolor/truecolor bitmaps/screens.
56 RPTAG_PatternOriginX (WORD) - X Origin of fill pattern.
57 RPTAG_PatternOriginY (WORD) - Y Origin of fill pattern.
58 RPTAG_ClipRectangle (struct Rectangle *) - Rectangle to clip rendering to. Rectangle will
59 be cloned.
60 RPTAG_ClipRectangleFlags (LONG) - RPCRF_RELRIGHT | RPCRF_RELBOTTOM (see <graphics/rpattr.h>)
61 RPTAG_RemapColorFonts (BOOL) - Automatically remap colorfonts to their color
62 on hicolor/truecolor screens.
64 RESULT
66 NOTES
67 RPTAG_ClipRectangle and RPTAG_ClipRectangleFlags must not be
68 used on manually inited or cloned rastports. Instead the rastport
69 must have been created with CreateRastPort() or CloneRastPort().
71 EXAMPLE
73 BUGS
74 RPTAG_SoftStyle not supported, yet.
76 SEE ALSO
77 SetRPAttrsA(), GetAPen(), GetBPen(), GetOutLinePen(), graphics/rpattr.h
79 INTERNALS
81 HISTORY
83 *****************************************************************************/
85 AROS_LIBFUNC_INIT
87 struct TagItem *tag, *tstate = tags;
88 ULONG MaxPen, z;
89 BOOL havedriverdata = FALSE;
91 while ((tag = NextTagItem ((const struct Tagitem **)&tstate)))
93 switch(tag->ti_Tag)
95 case RPTAG_Font :
96 *((IPTR *)tag->ti_Data) = (IPTR)rp->Font;
97 break;
99 case RPTAG_APen :
100 *((IPTR *)tag->ti_Data) = (IPTR)GetAPen(rp);
101 break;
103 case RPTAG_BPen :
104 *((IPTR *)tag->ti_Data) = (IPTR)GetBPen(rp);
105 break;
107 case RPTAG_DrMd :
108 *((IPTR *)tag->ti_Data) = (IPTR)GetDrMd(rp);
109 break;
111 case RPTAG_OutlinePen :
112 *((IPTR *)tag->ti_Data) = (IPTR)GetOutlinePen(rp);
113 break;
115 case RPTAG_WriteMask :
116 *((IPTR *)tag->ti_Data) = (IPTR)rp->Mask;
117 break;
119 case RPTAG_MaxPen :
120 MaxPen = 0x01;
121 z = (LONG)rp->Mask;
122 if (0 == z)
123 MaxPen = 0x100;
124 else
125 while (z != 0)
127 z >>= 1;
128 MaxPen <<= 1;
130 *((IPTR *)tag->ti_Data) = MaxPen;
131 break;
133 case RPTAG_DrawBounds :
134 ((struct Rectangle *)tag->ti_Data)->MinX = 0;
135 ((struct Rectangle *)tag->ti_Data)->MinY = 0;
136 ((struct Rectangle *)tag->ti_Data)->MaxX = 0;
137 ((struct Rectangle *)tag->ti_Data)->MaxY = 0;
138 break;
140 case RPTAG_FgColor:
141 *((IPTR *)tag->ti_Data) = RP_FGCOLOR(rp);
142 break;
144 case RPTAG_BgColor:
145 *((IPTR *)tag->ti_Data) = RP_BGCOLOR(rp);
146 break;
148 case RPTAG_PatternOriginX:
149 *((IPTR *)tag->ti_Data) = RP_PATORIGINX(rp);
150 break;
152 case RPTAG_PatternOriginY:
153 *((IPTR *)tag->ti_Data) = RP_PATORIGINY(rp);
154 break;
156 case RPTAG_ClipRectangle:
157 if (!havedriverdata)
159 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
162 if (havedriverdata)
164 if (RP_DRIVERDATA(rp)->dd_ClipRectangleFlags & RPCRF_VALID)
166 *((struct Rectangle **)tag->ti_Data) = &(RP_DRIVERDATA(rp)->dd_ClipRectangle);
168 else
170 *((struct Rectangle **)tag->ti_Data) = NULL;
173 else
175 *((IPTR *)tag->ti_Data) = 0;
177 break;
179 case RPTAG_ClipRectangleFlags:
180 if (!havedriverdata)
182 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
185 if (havedriverdata)
187 *((IPTR *)tag->ti_Data) = RP_DRIVERDATA(rp)->dd_ClipRectangleFlags;
189 else
191 *((IPTR *)tag->ti_Data) = 0;
193 break;
195 case RPTAG_RemapColorFonts:
196 *((IPTR *)tag->ti_Data) = (rp->Flags & RPF_REMAP_COLORFONTS) ? TRUE : FALSE;
197 break;
199 } /* switch(tag->ti_Tag) */
201 } /* while ((tag = NextTagItem ((const struct TagItem **)&tstate))) */
203 if (havedriverdata)
205 RELEASE_DRIVERDATA(rp, GfxBase);
208 AROS_LIBFUNC_EXIT
209 } /* GetRPAttrsA */