Don't get OOPBase in this ugly way.
[tangerine.git] / rom / graphics / getrpattrsa.c
bloba5d63f57a835d9225735af0543355d8d0e5e3575
1 /*
2 Copyright © 1995-2001, 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 Available tags:
39 RPTAG_Font Font for Text()
40 RPTAG_APen Primary rendering pen
41 RPTAG_BPen Secondary rendering pen
42 RPTAG_DrMd Drawing mode (graphics/rastport.h)
43 RPTAG_OutlinePen Area Outline pen
44 RPTAG_WriteMask Bit Mask for writing
45 RPTAG_MaxPen Maximum oen to render (see SetMaxPen())
46 RPTAG_DrawBounds Determine the area that will be redered
47 into by rendering commands. Can be used
48 to optimize window refresh. Pass a pointer
49 to a rectangle in the ti_Data field. On
50 return the rectangle's MinX will be
51 greater than its MaxX if there are no
52 active cliprects.
53 RPTAG_FgColor Primary rendering color in A8R8G8B8 format.
54 Only working on hicolor/truecolor bitmaps/
55 screens. (MorphOS extension)
56 RPTAG_BgColor Secondary rendering color in A8R8G8B8 format.
57 Only working on hicolor/truecolor bitmaps/
58 screens. (MorphOS extension)
59 RPTAG_PatternOriginX X Origin of fill pattern. (AROS extension)
60 RPTAG_PatternOriginY Y Origin of fill pattern. (AROS extension)
61 RPTAG_ClipRectangle Rectangle to clip rendering to. Rectangle will
62 be cloned. (AROS extension)
63 RPTAG_ClipRectangleFlags See <graphics/rpattr.h> (AROS extension)
64 RPTAG_RemapColorFonts Automatically remap colorfonts to their color
65 on hicolor/truecolor screens.
68 INPUTS
69 rp = pointer to a RastPort structure
70 tags = pointer to a taglist specifying the attributes to read and
71 the addresses to store the results
73 RESULT
75 NOTES
76 RPTAG_ClipRectangle and RPTAG_ClipRectangleFlags must not be
77 used on manually inited or cloned rastports. Instead the rastport
78 must have been created with CreateRastPort() or CloneRastPort().
80 EXAMPLE
82 BUGS
83 RPTAG_SoftStyle not supported, yet.
85 SEE ALSO
86 SetRPAttrsA() GetAPen() GetBPen() GetOutLinePen() GetWriteMask()
87 graphics/rpattr.h
89 INTERNALS
91 HISTORY
93 *****************************************************************************/
95 AROS_LIBFUNC_INIT
96 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
98 struct TagItem *tag, *tstate = tags;
99 ULONG MaxPen, z;
100 BOOL havedriverdata = FALSE;
102 while ((tag = NextTagItem ((const struct Tagitem **)&tstate)))
104 switch(tag->ti_Tag)
106 case RPTAG_Font :
107 *((IPTR *)tag->ti_Data) = (IPTR)rp->Font;
108 break;
110 case RPTAG_APen :
111 *((IPTR *)tag->ti_Data) = (IPTR)GetAPen(rp);
112 break;
114 case RPTAG_BPen :
115 *((IPTR *)tag->ti_Data) = (IPTR)GetBPen(rp);
116 break;
118 case RPTAG_DrMd :
119 *((IPTR *)tag->ti_Data) = (IPTR)GetDrMd(rp);
120 break;
122 case RPTAG_OutlinePen :
123 *((IPTR *)tag->ti_Data) = (IPTR)GetOutlinePen(rp);
124 break;
126 case RPTAG_WriteMask :
127 *((IPTR *)tag->ti_Data) = (IPTR)rp->Mask;
128 break;
130 case RPTAG_MaxPen :
131 MaxPen = 0x01;
132 z = (LONG)rp->Mask;
133 if (0 == z)
134 MaxPen = 0x100;
135 else
136 while (z != 0)
138 z >>= 1;
139 MaxPen <<= 1;
141 *((IPTR *)tag->ti_Data) = MaxPen;
142 break;
144 case RPTAG_DrawBounds :
145 ((struct Rectangle *)tag->ti_Data)->MinX = 0;
146 ((struct Rectangle *)tag->ti_Data)->MinY = 0;
147 ((struct Rectangle *)tag->ti_Data)->MaxX = 0;
148 ((struct Rectangle *)tag->ti_Data)->MaxY = 0;
149 break;
151 case RPTAG_FgColor:
152 *((IPTR *)tag->ti_Data) = RP_FGCOLOR(rp);
153 break;
155 case RPTAG_BgColor:
156 *((IPTR *)tag->ti_Data) = RP_BGCOLOR(rp);
157 break;
159 case RPTAG_PatternOriginX:
160 *((IPTR *)tag->ti_Data) = RP_PATORIGINX(rp);
161 break;
163 case RPTAG_PatternOriginY:
164 *((IPTR *)tag->ti_Data) = RP_PATORIGINY(rp);
165 break;
167 case RPTAG_ClipRectangle:
168 if (!havedriverdata)
170 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
173 if (havedriverdata)
175 if (RP_DRIVERDATA(rp)->dd_ClipRectangleFlags & RPCRF_VALID)
177 *((struct Rectangle **)tag->ti_Data) = &(RP_DRIVERDATA(rp)->dd_ClipRectangle);
179 else
181 *((struct Rectangle **)tag->ti_Data) = NULL;
184 else
186 *((IPTR *)tag->ti_Data) = 0;
188 break;
190 case RPTAG_ClipRectangleFlags:
191 if (!havedriverdata)
193 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
196 if (havedriverdata)
198 *((IPTR *)tag->ti_Data) = RP_DRIVERDATA(rp)->dd_ClipRectangleFlags;
200 else
202 *((IPTR *)tag->ti_Data) = 0;
204 break;
206 case RPTAG_RemapColorFonts:
207 *((IPTR *)tag->ti_Data) = (rp->Flags & RPF_REMAP_COLORFONTS) ? TRUE : FALSE;
208 break;
210 } /* switch(tag->ti_Tag) */
212 } /* while ((tag = NextTagItem ((const struct TagItem **)&tstate))) */
214 if (havedriverdata)
216 RELEASE_DRIVERDATA(rp, GfxBase);
219 AROS_LIBFUNC_EXIT
220 } /* GetRPAttrsA */