2 Copyright © 2013, The AROS Development Team. All rights reserved.
6 #include <intuition/diattr.h>
7 #include <proto/graphics.h>
9 #include "intuition_intern.h"
11 #define ARG_MASK 0x0000000F
13 #define SetResult(x) if (resultPtr) *resultPtr = x;
15 /*****************************************************************************
18 #include <proto/intuition.h>
20 AROS_LH3(ULONG
, GetDrawInfoAttr
,
23 AROS_LHA(struct DrawInfo
*, drawInfo
, A0
),
24 AROS_LHA(ULONG
, attrID
, D0
),
25 AROS_LHA(IPTR
* , resultPtr
, A1
),
28 struct IntuitionBase
*, IntuitionBase
, 156, Intuition
)
31 Gets value of the specified attribute from DrawInfo object, or
32 system default value (for some attributes).
35 drawInfo - an object pointer to query. It is possible to set this
36 argument to NULL when querying GDIA_Color or GDIA_Pen
37 attributes. In this case values will be retrieved from
39 attrID - ID of the attribute you want. The following IDs are
42 GDIA_Color - 0RGB value of the color corresponding to a given pen.
43 It is possible to retrieve these values only from
44 DrawInfos belonging to direct-color screens. Pen ID
45 should be ORed with attribute ID.
46 GDIA_Pen - LUT color number corresponding to a given pen.
47 GDIA_Version - Version number of the DrawInfo object.
48 GDIA_DirectColor - TRUE if the DrawInfo belongs to direct-color screen. Note
49 that in case of failure it also sets success indicator to
51 GDIA_NumPens - Number of pens or colors defined in this DrawInfo object.
52 GDIA_Font - Font specified in this DrawInfo.
53 GDIA_Depth - Depth of this DrawInfo. Note that this attribute will
54 return real depth of DrawInfo's screen, however dri_Depth
55 member will contain 8 for AmigaOS(tm) compatibility.
56 GDIA_ResolutionX - X resolution in ticks
57 GDIA_ResolutionY - Y resolution in ticks
58 GDIA_CheckMark - A pointer to CheckMark image object for the menu.
59 GDIA_MenuKey - A pointer to Menu (Amiga) key image object for the menu.
61 resultPtr - an optional storage area for success indicator. You
62 can set this parameter to NULL.
65 A value of the specified attribute. resultPtr, if supplied, gets
66 TRUE for success and FALSE for failure.
69 This function is compatible with MorphOS
79 *****************************************************************************/
82 * MorphOS (as of v2.6) quirks which are intentionally not reproduced in this
85 * 1. MorphOS implementation does not accept struct DrawInfo with version
86 different from OS own number.
87 * 2. MorphOS implementation does not check dri_NumPens when reading dri_Pens,
88 * this is clearly a bug.
89 * 3. In MorphOS GDIA_DirectColor and GDIA_Depth work only if DrawInfo has
90 * attached screen, consequently returning failure with handmade DrawInfos.
96 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
103 /* Most of IDs make sense only with nonzero DrawInfo */
107 return drawInfo
->dri_Version
;
109 case GDIA_DirectColor
:
110 return (drawInfo
->dri_Flags
& DRIF_DIRECTCOLOR
) ? TRUE
: FALSE
;
113 return drawInfo
->dri_NumPens
;
116 return (IPTR
)drawInfo
->dri_Font
;
119 return (drawInfo
->dri_Version
< 3) ? drawInfo
->dri_Depth
:
120 GetPrivScreen(drawInfo
->dri_Screen
)->realdepth
;
123 if (drawInfo
->dri_Version
< 2)
128 return (IPTR
)drawInfo
->dri_CheckMark
;
131 if (drawInfo
->dri_Version
< 2)
136 return (IPTR
)drawInfo
->dri_AmigaKey
;
138 case GDIA_ResolutionX
:
139 return drawInfo
->dri_Resolution
.X
;
141 case GDIA_ResolutionY
:
142 return drawInfo
->dri_Resolution
.Y
;
146 * If we are here, this should be GDIA_Color or GDIA_Pen.
147 * First we need to extract pen ID.
149 pen
= attrID
& ARG_MASK
;
150 if (pen
< drawInfo
->dri_NumPens
)
152 switch (attrID
& ~ARG_MASK
)
156 * According to original MorphOS semantics we return RGB colors
157 * only for direct-color screens.
159 if (drawInfo
->dri_Flags
& DRIF_DIRECTCOLOR
)
163 GetRGB32(drawInfo
->dri_Screen
->ViewPort
.ColorMap
, drawInfo
->dri_Pens
[pen
], 1, col
);
164 return ((col
[0] & 0xFF000000) >> 8) |
165 ((col
[1] & 0xFF000000) >> 16) |
171 return drawInfo
->dri_Pens
[pen
];
178 * No DrawInfo supplied.
179 * In this case we return only default colors/pens from our preferences.
181 pen
= attrID
& ARG_MASK
;
182 if (pen
< NUMDRIPENS
)
186 /* Extract color number corresponding to the pen */
187 pen
= GetPrivIBase(IntuitionBase
)->DriPens8
[pen
];
189 switch (attrID
& ~ARG_MASK
)
193 * In AROS we don't have separate preferences for direct-color
194 * screens. So we now decode color number into its RGB representation
195 * according to system palette.
200 col
= &GetPrivIBase(IntuitionBase
)->Colors
[pen
];
202 else if ((pen
> 16) && (pen
< 20))
204 /* These are pointer colors, indexes 8...10 in system palette */
205 col
= &GetPrivIBase(IntuitionBase
)->Colors
[pen
- 17 + 8];
210 * There's no known color value for other pens.
211 * We also have 4 last colors defined, however we don't know which
212 * pens correspond to them, because this depends on screen depth.
213 * Well, after all, we are not MOS. :)
218 return ((col
->red
& 0xFF000000) >> 8) |
219 ((col
->green
& 0xFF000000) >> 16) |
229 * Unknown IDs as well as failed conditions end up here.
230 * Report error and return zero.