2 Copyright © 1998, The AROS Development Team. All rights reserved.
5 Desc: Test for graphics.hidd
9 /*****************************************************************************
17 GCNewDispose HIDD/K,FG/N/K,BG/N/K
25 Creates a gc, prints the attributes of the gc and dispose
29 HIDD - name of the hidd to use e.g. "graphics-X11.hidd"
30 (default: graphics.hdd)
31 FG - Set foreground color to this value (default: 1)
32 BG - Set background color to this value (default: 2)
35 RETURN_OK - hidd works
36 RETURN_ERROR - hidd produce errors
37 RETURN_FAIL - could not test hidd i.e. OpenLibrary() fails
51 ******************************************************************************/
58 #include <aros/config.h>
60 #include <exec/types.h>
62 #include <proto/exec.h>
63 #include <proto/dos.h>
64 #include <proto/oop.h>
65 #include <proto/utility.h>
67 #include <utility/tagitem.h>
70 #include <hidd/graphics.h>
72 #include "gfxhiddtool.h"
77 #include <aros/debug.h>
79 struct DosLibrary
*DOSBase
;
80 struct Library
*OOPBase
;
81 struct Library
*HIDDGraphicsBase
;
83 struct ght_OpenLibs LibsArray
[] =
85 GHT_LIB("dos.library" , 37, &DOSBase
),
86 GHT_LIB(AROSOOP_NAME
, 0, &OOPBase
),
87 GHT_LIB(NULL
, 0, NULL
)
89 /***************************************************************/
91 int main(int argc
, char **argv
)
93 ULONG ret
= RETURN_FAIL
;
95 OOP_AttrBase HiddGfxAttrBase
= 0;
96 OOP_AttrBase HiddGCAttrBase
= 0;
97 OOP_AttrBase HiddBitMapAttrBase
= 0;
103 STRPTR hiddName
= "graphics.hidd";
107 /* ReadArgs() declarations */
108 /* each entry must have a size of 4 bytes */
116 struct Args args
= {hiddName
, &fg
, &bg
};
120 if(ght_OpenLibs(LibsArray
))
122 rda
= ReadArgs("HIDD/K,FG/N/K,BG/N/K", (IPTR
*)&args
, NULL
);
125 HIDDGraphicsBase
= OpenLibrary(args
.hiddName
, 0);
130 HiddGfxAttrBase
= OOP_ObtainAttrBase(IID_Hidd_Gfx
);
131 HiddBitMapAttrBase
= OOP_ObtainAttrBase(IID_Hidd_BitMap
);
132 HiddGCAttrBase
= OOP_ObtainAttrBase(IID_Hidd_GC
);
133 if(HiddGfxAttrBase
&& HiddBitMapAttrBase
&& HiddGCAttrBase
)
135 gfxHidd
= OOP_NewObject(NULL
, args
.hiddName
, NULL
);
138 bitMap
= HIDD_Gfx_NewBitMap(gfxHidd
, NULL
);
141 struct TagItem gc_tags
[] =
143 {aHidd_GC_BitMap
, (IPTR
) bitMap
},
144 {aHidd_GC_Foreground
, (IPTR
) *args
.fg
},
145 {aHidd_GC_Background
, (IPTR
) *args
.bg
},
149 gc
= HIDD_Gfx_NewGC(gfxHidd
, gc_tags
);
152 printf("GC created:\n");
153 printf(" fg : %li\n", ght_GetAttr(gc
, aHidd_GC_Foreground
));
154 printf(" bg : %li\n", ght_GetAttr(gc
, aHidd_GC_Background
));
155 printf(" drMode: %li\n", ght_GetAttr(gc
, aHidd_GC_DrawMode
));
156 printf(" bitMap: %li\n", ght_GetAttr(gc
, aHidd_GC_BitMap
));
158 HIDD_Gfx_DisposeGC(gfxHidd
, gc
);
163 HIDD_Gfx_DisposeBitMap(gfxHidd
, bitMap
);
166 if(gfxHidd
) OOP_DisposeObject(gfxHidd
);
168 } /* if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase) */
170 if(HiddGCAttrBase
) OOP_ReleaseAttrBase(IID_Hidd_GC
);
171 if(HiddBitMapAttrBase
) OOP_ReleaseAttrBase(IID_Hidd_BitMap
);
172 if(HiddGfxAttrBase
) OOP_ReleaseAttrBase(IID_Hidd_Gfx
);
174 CloseLibrary(HIDDGraphicsBase
);
175 } /* if(HIDDGraphicsBase) */
181 PrintFault(IoErr(), "");
182 } /* if (rda != NULL) */
184 } /* if OpenLibs() */
186 ght_CloseLibs(LibsArray
);