added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / rom / graphics / getrpattrsa.c
blob2f3d41e8096f3c17d4b65c881cd9a8409dee0aba
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 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 pen to render (see SetMaxPen())
46 RPTAG_DrawBounds Determine the area that will be rendered
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
97 struct TagItem *tag, *tstate = tags;
98 ULONG MaxPen, z;
99 BOOL havedriverdata = FALSE;
101 while ((tag = NextTagItem ((const struct Tagitem **)&tstate)))
103 switch(tag->ti_Tag)
105 case RPTAG_Font :
106 *((IPTR *)tag->ti_Data) = (IPTR)rp->Font;
107 break;
109 case RPTAG_APen :
110 *((IPTR *)tag->ti_Data) = (IPTR)GetAPen(rp);
111 break;
113 case RPTAG_BPen :
114 *((IPTR *)tag->ti_Data) = (IPTR)GetBPen(rp);
115 break;
117 case RPTAG_DrMd :
118 *((IPTR *)tag->ti_Data) = (IPTR)GetDrMd(rp);
119 break;
121 case RPTAG_OutlinePen :
122 *((IPTR *)tag->ti_Data) = (IPTR)GetOutlinePen(rp);
123 break;
125 case RPTAG_WriteMask :
126 *((IPTR *)tag->ti_Data) = (IPTR)rp->Mask;
127 break;
129 case RPTAG_MaxPen :
130 MaxPen = 0x01;
131 z = (LONG)rp->Mask;
132 if (0 == z)
133 MaxPen = 0x100;
134 else
135 while (z != 0)
137 z >>= 1;
138 MaxPen <<= 1;
140 *((IPTR *)tag->ti_Data) = MaxPen;
141 break;
143 case RPTAG_DrawBounds :
144 ((struct Rectangle *)tag->ti_Data)->MinX = 0;
145 ((struct Rectangle *)tag->ti_Data)->MinY = 0;
146 ((struct Rectangle *)tag->ti_Data)->MaxX = 0;
147 ((struct Rectangle *)tag->ti_Data)->MaxY = 0;
148 break;
150 case RPTAG_FgColor:
151 *((IPTR *)tag->ti_Data) = RP_FGCOLOR(rp);
152 break;
154 case RPTAG_BgColor:
155 *((IPTR *)tag->ti_Data) = RP_BGCOLOR(rp);
156 break;
158 case RPTAG_PatternOriginX:
159 *((IPTR *)tag->ti_Data) = RP_PATORIGINX(rp);
160 break;
162 case RPTAG_PatternOriginY:
163 *((IPTR *)tag->ti_Data) = RP_PATORIGINY(rp);
164 break;
166 case RPTAG_ClipRectangle:
167 if (!havedriverdata)
169 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
172 if (havedriverdata)
174 if (RP_DRIVERDATA(rp)->dd_ClipRectangleFlags & RPCRF_VALID)
176 *((struct Rectangle **)tag->ti_Data) = &(RP_DRIVERDATA(rp)->dd_ClipRectangle);
178 else
180 *((struct Rectangle **)tag->ti_Data) = NULL;
183 else
185 *((IPTR *)tag->ti_Data) = 0;
187 break;
189 case RPTAG_ClipRectangleFlags:
190 if (!havedriverdata)
192 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
195 if (havedriverdata)
197 *((IPTR *)tag->ti_Data) = RP_DRIVERDATA(rp)->dd_ClipRectangleFlags;
199 else
201 *((IPTR *)tag->ti_Data) = 0;
203 break;
205 case RPTAG_RemapColorFonts:
206 *((IPTR *)tag->ti_Data) = (rp->Flags & RPF_REMAP_COLORFONTS) ? TRUE : FALSE;
207 break;
209 } /* switch(tag->ti_Tag) */
211 } /* while ((tag = NextTagItem ((const struct TagItem **)&tstate))) */
213 if (havedriverdata)
215 RELEASE_DRIVERDATA(rp, GfxBase);
218 AROS_LIBFUNC_EXIT
219 } /* GetRPAttrsA */